1 /* $Id: decmpeg2.c,v 1.12 2005/03/03 16:30:42 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.fr/>.
5 It may be used under the terms of the GNU General Public License. */
9 #include "mpeg2dec/mpeg2.h"
11 /* Cadence tracking */
12 #ifndef PIC_FLAG_REPEAT_FIRST_FIELD
13 #define PIC_FLAG_REPEAT_FIRST_FIELD 256
15 #define TOP_FIRST PIC_FLAG_TOP_FIELD_FIRST
16 #define PROGRESSIVE PIC_FLAG_PROGRESSIVE_FRAME
17 #define COMPOSITE PIC_FLAG_COMPOSITE_DISPLAY
18 #define SKIP PIC_FLAG_SKIP
19 #define TAGS PIC_FLAG_TAGS
20 #define REPEAT_FIRST PIC_FLAG_REPEAT_FIRST_FIELD
21 #define COMPOSITE_MASK PIC_MASK_COMPOSITE_DISPLAY
31 /**********************************************************************
33 *********************************************************************/
34 typedef struct hb_libmpeg2_s
36 mpeg2dec_t * libmpeg2;
37 const mpeg2_info_t * info;
44 int got_iframe; /* set when we get our first iframe */
45 int look_for_iframe; /* need an iframe to add chap break */
46 int look_for_break; /* need gop start to add chap break */
47 int cur_tag; /* index of current tag */
48 uint32_t nframes; /* number of frames we've decoded */
53 hb_list_t * list_subtitle;
54 hb_buffer_t * last_cc1_buf;
56 int64_t start; // start time of this frame
57 hb_buffer_t * cc_buf; // captions for this frame
61 /**********************************************************************
63 **********************************************************************
65 *********************************************************************/
66 static hb_libmpeg2_t * hb_libmpeg2_init()
68 hb_libmpeg2_t * m = calloc( sizeof( hb_libmpeg2_t ), 1 );
70 m->libmpeg2 = mpeg2_init();
71 m->info = mpeg2_info( m->libmpeg2 );
76 for ( i = 0; i < NTAGS; ++i )
78 m->tags[i].start = -1;
84 // send cc_buf to the CC decoder(s)
85 static void cc_send_to_decoder( hb_libmpeg2_t *m, hb_buffer_t *cc_buf )
87 hb_subtitle_t *subtitle;
89 // if there's more than one decoder for the captions send a copy
90 // of the buffer to all but the last. Then send the buffer to
91 // the last one (usually there's just one decoder so the 'while' is skipped).
92 int i = 0, n = hb_list_count( m->list_subtitle );
95 // make a copy of the buf then forward it to the decoder
96 hb_buffer_t *cpy = hb_buffer_init( cc_buf->size );
97 hb_buffer_copy_settings( cpy, cc_buf );
98 memcpy( cpy->data, cc_buf->data, cc_buf->size );
100 subtitle = hb_list_item( m->list_subtitle, i++ );
101 hb_fifo_push( subtitle->fifo_in, cpy );
103 subtitle = hb_list_item( m->list_subtitle, i );
104 hb_fifo_push( subtitle->fifo_in, cc_buf );
107 static void hb_mpeg2_cc( hb_libmpeg2_t *m, const uint8_t *cc_block )
109 uint8_t cc_hdr = *cc_block;
111 if ( ( cc_hdr & 0x4 ) == 0 )
112 // not valid - ignore
119 if ( ( cc_block[1] & 0x7f ) == 0 && ( cc_block[2] & 0x7f ) == 0 )
120 // just padding - ignore
123 if ( m->last_cc1_buf )
125 // new data from the same time as last call - add to buffer
126 int len = m->last_cc1_buf->size;
127 hb_buffer_realloc( m->last_cc1_buf, len + 2 );
128 memcpy( m->last_cc1_buf->data + len, cc_block+1, 2 );
129 m->last_cc1_buf->size = len + 2;
133 // allocate a new buffer and copy the caption data into it.
134 // (we don't send it yet because we don't know what timestamp to use).
135 hb_buffer_t *cc_buf = hb_buffer_init( 2 );
139 memcpy( cc_buf->data, cc_block+1, 2 );
140 m->last_cc1_buf = cc_buf;
145 //process608( cc_block+1, 2, &m->cc608 );
157 do_708 ((const unsigned char *) temp, 4);
166 static inline int have_captions( const uint8_t *user_data, uint32_t len )
169 ( ( user_data[0] == 0x43 && user_data[1] == 0x43 ) ||
170 ( user_data[0] == 0x47 && user_data[1] == 0x41 &&
171 user_data[2] == 0x39 && user_data[3] == 0x34 &&
172 user_data[4] == 3 && (user_data[5] & 0x40) ) );
175 static void do_one_dvd_cc( hb_libmpeg2_t *m, const uint8_t *header, int field1 )
179 data[0] = ( header[0] == 0xff && 0 == field1 )? 0x04 : 0x05;
182 hb_mpeg2_cc( m, data );
184 data[0] = ( header[3] == 0xff && 1 == field1 )? 0x04 : 0x05;
187 hb_mpeg2_cc( m, data );
190 // extract all the captions in the current frame and send them downstream
193 // (this routine should only be called if there are captions in the current
194 // frame. I.e., only if a call to 'have_captions' returns true.)
195 static void extract_mpeg2_captions( hb_libmpeg2_t *m )
197 const uint8_t *user_data = m->info->user_data;
198 int dvd_captions = user_data[0] == 0x43;
199 int capcount, field1packet = 0;
200 const uint8_t *header = &user_data[4];
203 // ATSC encapsulated captions - header starts one byte later
204 // and has an extra unused byte following it.
205 capcount = header[1] & 0x1f;
211 if ( ( header[0] & 0x80 ) == 0x00 )
212 field1packet=1; /* expect Field 1 second */
213 capcount=(header[0] & 0x1e) / 2;
218 for( i=0; i<capcount; i++ )
222 hb_mpeg2_cc( m, header );
227 do_one_dvd_cc( m, header, field1packet );
233 // Deal with extra closed captions some DVDs have.
234 while( header[0]==0xfe || header[0]==0xff )
236 do_one_dvd_cc( m, header, field1packet );
242 static void next_tag( hb_libmpeg2_t *m, hb_buffer_t *buf_es )
244 m->cur_tag = ( m->cur_tag + 1 ) & (NTAGS-1);
245 if ( m->tags[m->cur_tag].start >= 0 || m->tags[m->cur_tag].cc_buf )
247 if ( m->tags[m->cur_tag].start < 0 ||
248 ( m->got_iframe && m->tags[m->cur_tag].start >= m->first_pts ) )
249 hb_log("mpeg2 tag botch: pts %lld, tag pts %lld buf 0x%p",
250 buf_es->start, m->tags[m->cur_tag].start, m->tags[m->cur_tag].cc_buf);
251 if ( m->tags[m->cur_tag].cc_buf )
252 hb_buffer_close( &m->tags[m->cur_tag].cc_buf );
254 m->tags[m->cur_tag].start = buf_es->start;
255 mpeg2_tag_picture( m->libmpeg2, m->cur_tag, 0 );
258 static hb_buffer_t *hb_copy_frame( hb_job_t *job, int width, int height,
259 uint8_t* y, uint8_t *u, uint8_t *v )
261 int dst_w = width, dst_h = height;
264 dst_w = job->title->width;
265 dst_h = job->title->height;
267 int dst_wh = dst_w * dst_h;
268 hb_buffer_t *buf = hb_video_buffer_init( dst_w, dst_h );
271 if ( dst_w != width || dst_h != height )
273 // we're encoding and the frame dimensions don't match the title dimensions -
274 // rescale & matte Y, U, V into our output buf.
276 avpicture_alloc(&in, PIX_FMT_YUV420P, width, height );
277 avpicture_alloc(&out, PIX_FMT_YUV420P, dst_w, dst_h );
279 int src_wh = width * height;
280 memcpy( in.data[0], y, src_wh );
281 memcpy( in.data[1], u, src_wh >> 2 );
282 memcpy( in.data[2], v, src_wh >> 2 );
283 struct SwsContext *context = sws_getContext( width, height, PIX_FMT_YUV420P,
284 dst_w, dst_h, PIX_FMT_YUV420P,
285 SWS_LANCZOS|SWS_ACCURATE_RND,
287 sws_scale( context, in.data, in.linesize, 0, height, out.data, out.linesize );
288 sws_freeContext( context );
290 uint8_t *data = buf->data;
291 memcpy( data, out.data[0], dst_wh );
293 // U & V planes are 1/4 the size of Y plane.
295 memcpy( data, out.data[1], dst_wh );
297 memcpy( data, out.data[2], dst_wh );
299 avpicture_free( &out );
300 avpicture_free( &in );
304 // we're scanning or the frame dimensions match the title's dimensions
305 // so we can do a straight copy.
306 uint8_t *data = buf->data;
307 memcpy( data, y, dst_wh );
309 // U & V planes are 1/4 the size of Y plane.
311 memcpy( data, u, dst_wh );
313 memcpy( data, v, dst_wh );
318 /**********************************************************************
320 **********************************************************************
322 *********************************************************************/
323 static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
324 hb_list_t * list_raw )
332 if( buf_es->start >= 0 )
334 next_tag( m, buf_es );
336 mpeg2_buffer( m->libmpeg2, buf_es->data, buf_es->data + buf_es->size );
341 state = mpeg2_parse( m->libmpeg2 );
342 if( state == STATE_BUFFER )
344 /* Require some more data */
348 // if the user requested captions, process
349 // any captions found in the current frame.
350 if ( m->list_subtitle && m->last_pts >= 0 &&
351 have_captions( m->info->user_data, m->info->user_data_len ) )
353 extract_mpeg2_captions( m );
354 // if we don't have a tag for the captions, make one
355 if ( m->last_cc1_buf && m->tags[m->cur_tag].cc_buf != m->last_cc1_buf )
357 if (m->tags[m->cur_tag].cc_buf)
359 hb_log("mpeg2 tag botch2: pts %lld, tag pts %lld buf 0x%p",
360 buf_es->start, m->tags[m->cur_tag].start, m->tags[m->cur_tag].cc_buf);
361 hb_buffer_close( &m->tags[m->cur_tag].cc_buf );
363 // see if we already made a tag for the timestamp. If so we
364 // can just use it, otherwise make a new tag.
365 if (m->tags[m->cur_tag].start < 0)
367 next_tag( m, buf_es );
369 m->tags[m->cur_tag].cc_buf = m->last_cc1_buf;
372 if( state == STATE_SEQUENCE )
374 if( !( m->width && m->height && m->rate ) )
376 m->width = m->info->sequence->width;
377 m->height = m->info->sequence->height;
378 m->rate = m->info->sequence->frame_period;
379 if ( m->aspect_ratio <= 0 && m->height &&
380 m->info->sequence->pixel_height )
382 /* mpeg2_parse doesn't store the aspect ratio. Instead
383 * it keeps the pixel width & height that would cause
384 * the storage width & height to come out in the correct
385 * aspect ratio. Convert these back to aspect ratio.
387 double ar_numer = m->width * m->info->sequence->pixel_width;
388 double ar_denom = m->height * m->info->sequence->pixel_height;
389 m->aspect_ratio = ar_numer / ar_denom;
393 else if( state == STATE_GOP && m->look_for_break)
395 // we were looking for a gop to add a chapter break - we found it
396 // so now start looking for an iframe.
397 m->look_for_iframe = m->look_for_break;
398 m->look_for_break = 0;
400 else if( ( state == STATE_SLICE || state == STATE_END ) &&
401 m->info->display_fbuf )
403 m->last_cc1_buf = NULL;
405 if( !m->got_iframe && ( m->info->display_picture->flags &
406 PIC_MASK_CODING_TYPE ) == PIC_FLAG_CODING_TYPE_I )
408 // we got an iframe so we can start decoding video now
414 buf = hb_copy_frame( m->job, m->info->sequence->width,
415 m->info->sequence->height,
416 m->info->display_fbuf->buf[0],
417 m->info->display_fbuf->buf[1],
418 m->info->display_fbuf->buf[2] );
419 buf->sequence = buf_es->sequence;
421 hb_buffer_t *cc_buf = NULL;
422 if( m->info->display_picture->flags & PIC_FLAG_TAGS )
424 int t = m->info->display_picture->tag;
425 buf->start = m->tags[t].start;
426 cc_buf = m->tags[t].cc_buf;
427 m->tags[t].start = -1;
428 m->tags[t].cc_buf = NULL;
430 if( buf->start < 0 && m->last_pts >= 0 )
432 /* For some reason nb_fields is sometimes 1 while it
434 buf->start = m->last_pts +
435 MAX( 2, m->info->display_picture->nb_fields ) *
436 m->info->sequence->frame_period / 600;
438 if ( buf->start >= 0 )
440 m->last_pts = buf->start;
443 // if we were accumulating captions we now know the timestamp
444 // so ship them to the decoder.
447 cc_buf->start = m->last_pts;
448 cc_send_to_decoder( m, cc_buf );
451 if( m->look_for_iframe && ( m->info->display_picture->flags &
452 PIC_MASK_CODING_TYPE ) == PIC_FLAG_CODING_TYPE_I )
454 // we were waiting for an iframe to insert a chapter mark
456 buf->new_chap = m->look_for_iframe;
457 m->look_for_iframe = 0;
458 const char *chap_name = "";
459 if ( m->job && buf->new_chap > 0 &&
460 hb_list_item( m->job->title->list_chapter,
461 buf->new_chap - 1 ) )
463 hb_chapter_t * c = hb_list_item( m->job->title->list_chapter,
465 chap_name = c->title;
467 hb_log( "mpeg2: \"%s\" (%d) at frame %u time %"PRId64,
468 chap_name, buf->new_chap, m->nframes, buf->start );
470 else if ( m->nframes == 0 )
472 // this is the first frame returned by the decoder
473 m->first_pts = buf->start;
474 if ( m->job && hb_list_item( m->job->title->list_chapter,
475 m->job->chapter_start - 1 ) )
477 hb_chapter_t * c = hb_list_item( m->job->title->list_chapter,
478 m->job->chapter_start - 1 );
479 hb_log( "mpeg2: \"%s\" (%d) at frame %u time %"PRId64,
480 c->title, m->job->chapter_start, m->nframes, buf->start );
485 m->flag = m->info->display_picture->flags;
487 /* Uncomment this block to see frame-by-frame picture flags, as the video encodes.
488 hb_log("***** MPEG 2 Picture Info for PTS %lld *****", buf->start);
489 if( m->flag & TOP_FIRST )
490 hb_log("MPEG2 Flag: Top field first");
491 if( m->flag & PROGRESSIVE )
492 hb_log("MPEG2 Flag: Progressive");
493 if( m->flag & COMPOSITE )
494 hb_log("MPEG2 Flag: Composite");
496 hb_log("MPEG2 Flag: Skip!");
498 hb_log("MPEG2 Flag: TAGS");
499 if(fm->lag & REPEAT_FIRST )
500 hb_log("MPEG2 Flag: Repeat first field");
501 if( m->flag & COMPOSITE_MASK )
502 hb_log("MPEG2 Flag: Composite mask");
503 hb_log("fields: %d", m->info->display_picture->nb_fields);
505 /* Rotate the cadence tracking. */
507 for(i=11; i > 0; i--)
509 m->cadence[i] = m->cadence[i-1];
512 if ( !(m->flag & PROGRESSIVE) && !(m->flag & TOP_FIRST) )
514 /* Not progressive, not top first...
515 That means it's probably bottom
516 first, 2 fields displayed.
518 //hb_log("MPEG2 Flag: Bottom field first, 2 fields displayed.");
521 else if ( !(m->flag & PROGRESSIVE) && (m->flag & TOP_FIRST) )
523 /* Not progressive, top is first,
524 Two fields displayed.
526 //hb_log("MPEG2 Flag: Top field first, 2 fields displayed.");
529 else if ( (m->flag & PROGRESSIVE) && !(m->flag & TOP_FIRST) && !( m->flag & REPEAT_FIRST ) )
531 /* Progressive, but noting else.
532 That means Bottom first,
535 //hb_log("MPEG2 Flag: Progressive. Bottom field first, 2 fields displayed.");
536 m->cadence[0] = BT_PROG;
538 else if ( (m->flag & PROGRESSIVE) && !(m->flag & TOP_FIRST) && ( m->flag & REPEAT_FIRST ) )
540 /* Progressive, and repeat. .
541 That means Bottom first,
544 //hb_log("MPEG2 Flag: Progressive repeat. Bottom field first, 3 fields displayed.");
545 m->cadence[0] = BTB_PROG;
547 else if ( (m->flag & PROGRESSIVE) && (m->flag & TOP_FIRST) && !( m->flag & REPEAT_FIRST ) )
549 /* Progressive, top first.
550 That means top first,
553 //hb_log("MPEG2 Flag: Progressive. Top field first, 2 fields displayed.");
554 m->cadence[0] = TB_PROG;
556 else if ( (m->flag & PROGRESSIVE) && (m->flag & TOP_FIRST) && ( m->flag & REPEAT_FIRST ) )
558 /* Progressive, top, repeat.
559 That means top first,
562 //hb_log("MPEG2 Flag: Progressive repeat. Top field first, 3 fields displayed.");
563 m->cadence[0] = TBT_PROG;
566 if ( (m->cadence[2] <= TB) && (m->cadence[1] <= TB) && (m->cadence[0] > TB) && (m->cadence[11]) )
567 hb_log("%fs: Video -> Film", (float)buf->start / 90000);
568 if ( (m->cadence[2] > TB) && (m->cadence[1] <= TB) && (m->cadence[0] <= TB) && (m->cadence[11]) )
569 hb_log("%fs: Film -> Video", (float)buf->start / 90000);
571 /* Store picture flags for later use by filters */
572 buf->flags = m->info->display_picture->flags;
574 hb_list_add( list_raw, buf );
577 else if( state == STATE_INVALID )
579 mpeg2_reset( m->libmpeg2, 0 );
583 * Add closed captions to the title if we are scanning (no job).
585 * Just because we don't add this doesn't mean that there aren't any when
586 * we scan, just that noone said anything. So you should be able to add
587 * closed captions some other way (See decmpeg2Init() for alternative
588 * approach of assuming that there are always CC, which is probably
589 * safer - however I want to leave the autodetect in here for now to
592 if( !m->job && m->title &&
593 have_captions( m->info->user_data, m->info->user_data_len ) )
595 hb_subtitle_t *subtitle;
598 while ( ( subtitle = hb_list_item( m->title->list_subtitle, i++ ) ) )
601 * Let's call them 608 subs for now even if they aren't,
602 * since they are the only types we grok.
604 if( subtitle->source == CC608SUB )
612 subtitle = calloc( sizeof( hb_subtitle_t ), 1 );
615 subtitle->format = TEXTSUB;
616 subtitle->source = CC608SUB;
617 subtitle->config.dest = PASSTHRUSUB;
619 snprintf( subtitle->lang, sizeof( subtitle->lang ), "Closed Captions");
621 * The language of the subtitles will be the same as the first audio
622 * track, i.e. the same as the video.
624 hb_audio_t *audio = hb_list_item( m->title->list_audio, 0 );
627 snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ),
628 audio->config.lang.iso639_2);
630 snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ), "und");
632 hb_list_add( m->title->list_subtitle, subtitle );
639 /**********************************************************************
641 **********************************************************************
643 *********************************************************************/
644 static void hb_libmpeg2_close( hb_libmpeg2_t ** _m )
646 hb_libmpeg2_t * m = *_m;
648 mpeg2_close( m->libmpeg2 );
651 for ( i = 0; i < NTAGS; ++i )
653 if ( m->tags[i].cc_buf )
654 hb_buffer_close( &m->tags[i].cc_buf );
661 /**********************************************************************
662 * The decmpeg2 work object
663 **********************************************************************
665 *********************************************************************/
666 struct hb_work_private_s
668 hb_libmpeg2_t * libmpeg2;
672 /**********************************************************************
673 * hb_work_decmpeg2_init
674 **********************************************************************
676 *********************************************************************/
677 static int decmpeg2Init( hb_work_object_t * w, hb_job_t * job )
679 hb_work_private_t * pv;
681 pv = calloc( 1, sizeof( hb_work_private_t ) );
682 w->private_data = pv;
684 pv->libmpeg2 = hb_libmpeg2_init();
685 pv->list = hb_list_init();
687 pv->libmpeg2->job = job;
689 if( job && job->title ) {
690 pv->libmpeg2->title = job->title;
694 * If not scanning, then are we supposed to extract Closed Captions
695 * and send them to the decoder?
697 if( job && hb_list_count( job->list_subtitle ) > 0 )
699 hb_subtitle_t *subtitle;
702 for( i = 0; i < hb_list_count( job->list_subtitle ); i++ )
703 while ( ( subtitle = hb_list_item( job->list_subtitle, i++ ) ) != NULL )
705 if( subtitle->source == CC608SUB )
707 if ( ! pv->libmpeg2->list_subtitle )
709 pv->libmpeg2->list_subtitle = hb_list_init();
711 hb_list_add(pv->libmpeg2->list_subtitle, subtitle);
719 /**********************************************************************
721 **********************************************************************
723 *********************************************************************/
724 static int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
725 hb_buffer_t ** buf_out )
727 hb_work_private_t * pv = w->private_data;
728 hb_buffer_t * buf, * last = NULL;
729 int status = HB_WORK_OK;
731 if( w->title && pv && pv->libmpeg2 && !pv->libmpeg2->title ) {
732 pv->libmpeg2->title = w->title;
735 // The reader found a chapter break. Remove it from the input
736 // stream. If we're reading (as opposed to scanning) start looking
737 // for the next GOP start since that's where the chapter begins.
738 if( (*buf_in)->new_chap )
740 if ( pv->libmpeg2->job )
742 pv->libmpeg2->look_for_break = (*buf_in)->new_chap;
744 (*buf_in)->new_chap = 0;
747 hb_libmpeg2_decode( pv->libmpeg2, *buf_in, pv->list );
749 /* if we got an empty buffer signaling end-of-stream send it downstream */
750 if ( (*buf_in)->size == 0 )
752 hb_list_add( pv->list, *buf_in );
754 status = HB_WORK_DONE;
757 * Purge any pending caption buffer then let the Closed Captions decoder
758 * know that it is the end of the data.
760 if ( pv->libmpeg2->list_subtitle )
762 if ( pv->libmpeg2->last_cc1_buf )
764 cc_send_to_decoder( pv->libmpeg2, pv->libmpeg2->last_cc1_buf );
765 pv->libmpeg2->last_cc1_buf = NULL;
767 cc_send_to_decoder( pv->libmpeg2, hb_buffer_init( 0 ) );
772 while( ( buf = hb_list_item( pv->list, 0 ) ) )
774 hb_list_rem( pv->list, buf );
790 /**********************************************************************
792 **********************************************************************
794 *********************************************************************/
795 static void decmpeg2Close( hb_work_object_t * w )
797 hb_work_private_t * pv = w->private_data;
799 // don't log during scan
800 if ( pv->libmpeg2->job )
802 hb_log( "mpeg2 done: %d frames", pv->libmpeg2->nframes );
804 if ( pv->libmpeg2->last_cc1_buf )
806 hb_buffer_close( &pv->libmpeg2->last_cc1_buf );
808 hb_list_close( &pv->list );
809 if ( pv->libmpeg2->list_subtitle )
811 hb_list_close( &pv->libmpeg2->list_subtitle );
813 hb_libmpeg2_close( &pv->libmpeg2 );
817 static int decmpeg2Info( hb_work_object_t *w, hb_work_info_t *info )
819 hb_work_private_t *pv = w->private_data;
821 memset( info, 0, sizeof(*info) );
823 if ( pv && pv->libmpeg2 && pv->libmpeg2->info && pv->libmpeg2->info->sequence )
825 hb_libmpeg2_t *m = pv->libmpeg2;
827 info->width = m->width;
828 info->height = m->height;
829 info->pixel_aspect_width = m->info->sequence->pixel_width;
830 info->pixel_aspect_height = m->info->sequence->pixel_height;
831 info->aspect = m->aspect_ratio;
833 // if the frame is progressive & NTSC DVD height report it as 23.976 FPS
834 // so that scan can autodetect NTSC film
835 info->rate = 27000000;
836 info->rate_base = ( m->info->display_fbuf && m->info->display_picture &&
837 (m->info->display_picture->flags & PROGRESSIVE) &&
838 (m->height == 480 ) ) ? 1126125 : m->rate;
840 info->bitrate = m->info->sequence->byte_rate * 8;
841 info->profile = m->info->sequence->profile_level_id >> 4;
842 info->level = m->info->sequence->profile_level_id & 0xf;
843 info->name = "mpeg2";
849 hb_work_object_t hb_decmpeg2 =
852 "MPEG-2 decoder (libmpeg2)",