diff options
author | awk <[email protected]> | 2007-07-04 02:14:42 +0000 |
---|---|---|
committer | awk <[email protected]> | 2007-07-04 02:14:42 +0000 |
commit | 2e0106d686bb69faa1182dabbceb58969a93956f (patch) | |
tree | e00e2090e8a526e8e2baf205cdc4bbcda8825df4 /libhb/decmpeg2.c | |
parent | 5ceeadd648a9952506bd3e166d9fdba1ae2b4da4 (diff) |
Implement transport and program stream support. With these changes it's now possible to open a .ts or .mpg files and transcode to standard Handbrake Output files. This fixes Ticket #21.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@648 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decmpeg2.c')
-rw-r--r-- | libhb/decmpeg2.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c index 4fb6ad76b..65293c681 100644 --- a/libhb/decmpeg2.c +++ b/libhb/decmpeg2.c @@ -20,6 +20,7 @@ struct hb_libmpeg2_s int width; int height; int rate; + int aspect_ratio; int got_iframe; int look_for_break; int64_t last_pts; @@ -88,6 +89,28 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es, m->rate = 1126125; } } + if ( m->aspect_ratio <= 0 ) + { + // We can parse out the aspect ratio from the Sequence Start Header data in buf_es->data + + // Make sure we have the correct data in the buffer + if ((buf_es->data[0] == 0x00) && (buf_es->data[1] == 0x00) && (buf_es->data[2] == 0x01) && (buf_es->data[3] == 0xb3)) + { + unsigned char ar_fr = buf_es->data[7]; // Top 4 bits == aspect ratio flag - bottom 4 bits == rate flags + switch ((ar_fr & 0xf0) >> 4) + { + case 2: + m->aspect_ratio = HB_ASPECT_BASE * 4 / 3; // 4:3 + break; + case 3: + m->aspect_ratio = HB_ASPECT_BASE * 16 / 9; // 16:9 + break; + default: + hb_log("hb_libmpeg2_decode - STATE_SEQUENCE unexpected aspect ratio/frame rate 0x%x\n", ar_fr); + break; + } + } + } } else if( state == STATE_GOP && m->look_for_break == 2) { @@ -170,11 +193,12 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es, * *********************************************************************/ void hb_libmpeg2_info( hb_libmpeg2_t * m, int * width, int * height, - int * rate ) + int * rate, int *aspect_ratio ) { *width = m->width; *height = m->height; *rate = m->rate; + *aspect_ratio = m->aspect_ratio; } /********************************************************************** |