~ubuntu-branches/ubuntu/intrepid/gpac/intrepid-proposed

« back to all changes in this revision

Viewing changes to src/media_tools/mpeg2_ps.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2007-01-24 23:34:57 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070124233457-zzlls8afkt0nyakj
Tags: 0.4.2~rc2-0ubuntu1
* New upstream release
  * Most notably MP4 tagging support via MP4Box -itags
* debian/patches/01_64bits.dpatch: dropped; included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
  u32 samples_per_frame;
146
146
  u32 layer;
147
147
  // video stuff
148
 
  u32 h, w;
 
148
  u32 h, w, par;
149
149
  Double frame_rate;
150
150
  s32 have_mpeg2;
151
151
  Double bit_rate;
290
290
 
291
291
#define SEQ_ID 1
292
292
int MPEG12_ParseSeqHdr(u8 *pbuffer, u32 buflen, s32 *have_mpeg2, u32 *height, u32 *width, 
293
 
                                                                  Double *frame_rate, Double *bitrate, Double *aspect_ratio)
 
293
                                                                  Double *frame_rate, Double *bitrate, u32 *aspect_ratio)
294
294
{
295
295
  u32 aspect_code;
296
296
  u32 framerate_code;
315
315
      *height |= pbuffer[2];
316
316
      aspect_code = (pbuffer[3] >> 4) & 0xf;
317
317
      if (aspect_ratio != NULL) {
318
 
        switch (aspect_code) {
319
 
        default: *aspect_ratio = 1.0; break;
320
 
        case 2: *aspect_ratio = 4.0 / 3.0; break;
321
 
        case 3: *aspect_ratio = 16.0 / 9.0; break;
322
 
        case 4: *aspect_ratio = 2.21; break;
323
 
        }
 
318
                  u32 par = 0;
 
319
                        switch (aspect_code) {
 
320
                        default: *aspect_ratio = 0; break;
 
321
                        case 2: par = 4; par<<=16; par |= 3; break;
 
322
                        case 3: par = 16; par<<=16; par |= 9; break;
 
323
                        case 4: par = 2; par<<=16; par |= 21; break;
 
324
                        }
 
325
                        *aspect_ratio = par;
324
326
      }
325
327
          
326
328
        
1036
1038
                               &sptr->w,
1037
1039
                               &sptr->frame_rate,
1038
1040
                               &sptr->bit_rate,
1039
 
                               NULL) < 0) {
 
1041
                               &sptr->par) < 0) {
1040
1042
      sptr->m_stream_id = 0;
1041
1043
      sptr->m_fd = FDNULL;
1042
1044
    }
1046
1048
 
1047
1049
  if (sptr->m_stream_id >= 0xc0) {
1048
1050
    // mpeg audio
1049
 
    u32 hdr = GF_FOUR_CHAR_INT(buffer[0],buffer[1],buffer[2],buffer[3]);
 
1051
    u32 hdr = GF_4CC(buffer[0],buffer[1],buffer[2],buffer[3]);
1050
1052
 
1051
1053
    sptr->channels = gf_mp3_num_channels(hdr);
1052
1054
    sptr->freq = gf_mp3_sampling_rate(hdr);
1535
1537
  return ps->video_streams[streamno]->h;
1536
1538
}
1537
1539
 
 
1540
u32 mpeg2ps_get_video_stream_aspect_ratio (mpeg2ps_t *ps, u32 streamno)
 
1541
{
 
1542
  if (invalid_video_streamno(ps, streamno)) {
 
1543
    return 0;
 
1544
  }
 
1545
  return ps->video_streams[streamno]->par;
 
1546
}
 
1547
 
1538
1548
Double mpeg2ps_get_video_stream_bitrate (mpeg2ps_t *ps, u32 streamno)
1539
1549
{
1540
1550
  if (invalid_video_streamno(ps, streamno)) {