1 /* $Id: decavcodec.c,v 1.6 2005/03/06 04:08:54 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. */
7 /* This module is Handbrake's interface to the ffmpeg decoder library
8 (libavcodec & small parts of libavformat). It contains four Handbrake
11 decavcodec connects HB to an ffmpeg audio decoder
12 decavcodecv connects HB to an ffmpeg video decoder
14 (Two different routines are needed because the ffmpeg library
15 has different decoder calling conventions for audio & video.
16 The audio decoder should have had its name changed to "decavcodeca"
17 but I got lazy.) These work objects are self-contained & follow all
18 of HB's conventions for a decoder module. They can be used like
19 any other HB decoder (deca52, decmpeg2, etc.).
21 decavcodecai "internal" (incestuous?) version of decavcodec
22 decavcodecvi "internal" (incestuous?) version of decavcodecv
24 These routine are functionally equivalent to the routines above but
25 can only be used by the ffmpeg-based stream reader in libhb/stream.c.
26 The reason they exist is because the ffmpeg library leaves some of
27 the information needed by the decoder in the AVStream (the data
28 structure used by the stream reader) and we need to retrieve it
29 to successfully decode frames. But in HB the reader and decoder
30 modules are in completely separate threads and nothing goes between
31 them but hb_buffers containing frames to be decoded. I.e., there's
32 no easy way for the ffmpeg stream reader to pass a pointer to its
33 AVStream over to the ffmpeg video or audio decoder. So the *i work
34 objects use a private back door to the stream reader to get access
35 to the AVStream (routines hb_ffmpeg_avstream and hb_ffmpeg_context)
36 and the codec_param passed to these work objects is the key to this
37 back door (it's basically an index that allows the correct AVStream
40 The normal & *i objects share a lot of code (the basic frame decoding
41 and bitstream info code is factored out into subroutines that can be
42 called by either) but the top level routines of the *i objects
43 (decavcodecviWork, decavcodecviInfo, etc.) are different because:
44 1) they *have* to use the AVCodecContext that's contained in the
45 reader's AVStream rather than just allocating & using their own,
46 2) the Info routines have access to stuff kept in the AVStream in addition
47 to stuff kept in the AVCodecContext. This shouldn't be necessary but
48 crucial information like video frame rate that should be in the
49 AVCodecContext is either missing or wrong in the version of ffmpeg
50 we're currently using.
52 A consequence of the above is that the non-i work objects *can't* use
53 information from the AVStream because there isn't one - they get their
54 data from either the dvd reader or the mpeg reader, not the ffmpeg stream
55 reader. That means that they have to make up for deficiencies in the
56 AVCodecContext info by using stuff kept in the HB "title" struct. It
57 also means that ffmpeg codecs that randomly scatter state needed by
58 the decoder across both the AVCodecContext & the AVStream (e.g., the
59 VC1 decoder) can't easily be used by the HB mpeg stream reader.
64 #include "libavcodec/avcodec.h"
65 #include "libavformat/avformat.h"
67 static int decavcodecInit( hb_work_object_t *, hb_job_t * );
68 static int decavcodecWork( hb_work_object_t *, hb_buffer_t **, hb_buffer_t ** );
69 static void decavcodecClose( hb_work_object_t * );
70 static int decavcodecInfo( hb_work_object_t *, hb_work_info_t * );
71 static int decavcodecBSInfo( hb_work_object_t *, const hb_buffer_t *, hb_work_info_t * );
73 hb_work_object_t hb_decavcodec =
76 "MPGA decoder (libavcodec)",
84 struct hb_work_private_s
87 AVCodecContext *context;
88 AVCodecParserContext *parser;
90 double pts_next; // next pts we expect to generate
91 int64_t pts; // (video) pts passing from parser to decoder
92 int64_t chap_time; // time of next chap mark (if new_chap != 0)
94 int ignore_pts; // workaround M$ bugs
97 uint32_t decode_errors;
98 double duration; // frame duration (for video)
103 /***********************************************************************
104 * hb_work_decavcodec_init
105 ***********************************************************************
107 **********************************************************************/
108 static int decavcodecInit( hb_work_object_t * w, hb_job_t * job )
112 hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
113 w->private_data = pv;
117 int codec_id = w->codec_param;
120 codec_id = CODEC_ID_MP2;
121 codec = avcodec_find_decoder( codec_id );
122 pv->parser = av_parser_init( codec_id );
124 pv->context = avcodec_alloc_context();
125 avcodec_open( pv->context, codec );
130 /***********************************************************************
132 ***********************************************************************
134 **********************************************************************/
135 static void decavcodecClose( hb_work_object_t * w )
137 hb_work_private_t * pv = w->private_data;
140 av_parser_close(pv->parser);
142 if ( pv->context && pv->context->codec )
144 avcodec_close( pv->context );
148 hb_list_close( &pv->list );
152 /***********************************************************************
154 ***********************************************************************
156 **********************************************************************/
157 static int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
158 hb_buffer_t ** buf_out )
160 hb_work_private_t * pv = w->private_data;
161 hb_buffer_t * in = *buf_in, * buf, * last = NULL;
162 int pos, len, out_size, i, uncompressed_len;
163 short buffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
165 unsigned char *parser_output_buffer;
166 int parser_output_buffer_len;
168 if ( (*buf_in)->size <= 0 )
170 /* EOF on input stream - send it downstream & say that we're done */
178 cur = ( in->start < 0 )? pv->pts_next : in->start;
181 while( pos < in->size )
183 len = av_parser_parse( pv->parser, pv->context,
184 &parser_output_buffer, &parser_output_buffer_len,
185 in->data + pos, in->size - pos, cur, cur );
187 uncompressed_len = 0;
188 if (parser_output_buffer_len)
190 out_size = sizeof(buffer);
191 uncompressed_len = avcodec_decode_audio2( pv->context, buffer,
193 parser_output_buffer,
194 parser_output_buffer_len );
201 buf = hb_buffer_init( 2 * out_size );
203 int sample_size_in_bytes = 2; // Default to 2 bytes
204 switch (pv->context->sample_fmt)
207 sample_size_in_bytes = 2;
209 /* We should handle other formats here - but that needs additional format conversion work below */
210 /* For now we'll just report the error and try to carry on */
212 hb_log("decavcodecWork - Unknown Sample Format from avcodec_decode_audio (%d) !", pv->context->sample_fmt);
217 buf->stop = cur + 90000 * ( out_size / (sample_size_in_bytes * pv->context->channels) ) /
218 pv->context->sample_rate;
222 fl32 = (float *) buf->data;
223 for( i = 0; i < out_size / 2; i++ )
230 last = last->next = buf;
234 *buf_out = last = buf;
246 static int decavcodecInfo( hb_work_object_t *w, hb_work_info_t *info )
248 hb_work_private_t *pv = w->private_data;
250 memset( info, 0, sizeof(*info) );
252 if ( pv && pv->context )
254 AVCodecContext *context = pv->context;
255 info->bitrate = context->bit_rate;
256 info->rate = context->time_base.num;
257 info->rate_base = context->time_base.den;
258 info->profile = context->profile;
259 info->level = context->level;
265 static int decavcodecBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
266 hb_work_info_t *info )
268 hb_work_private_t *pv = w->private_data;
270 memset( info, 0, sizeof(*info) );
272 if ( pv && pv->context )
274 return decavcodecInfo( w, info );
277 // We should parse the bitstream to find its parameters but for right
278 // now we just return dummy values if there's a codec that will handle it.
279 AVCodec *codec = avcodec_find_decoder( w->codec_param? w->codec_param :
283 static char codec_name[64];
285 info->name = strncpy( codec_name, codec->name, sizeof(codec_name)-1 );
286 info->bitrate = 384000;
289 info->channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
295 /* -------------------------------------------------------------
296 * General purpose video decoder using libavcodec
299 static uint8_t *copy_plane( uint8_t *dst, uint8_t* src, int dstride, int sstride,
302 if ( dstride == sstride )
304 memcpy( dst, src, dstride * h );
305 return dst + dstride * h;
307 int lbytes = dstride <= sstride? dstride : sstride;
310 memcpy( dst, src, lbytes );
317 /* Note: assumes frame format is PIX_FMT_YUV420P */
318 static hb_buffer_t *copy_frame( AVCodecContext *context, AVFrame *frame )
320 int w = context->width, h = context->height;
321 hb_buffer_t *buf = hb_buffer_init( w * h * 3 / 2 );
322 uint8_t *dst = buf->data;
324 dst = copy_plane( dst, frame->data[0], w, frame->linesize[0], h );
326 dst = copy_plane( dst, frame->data[1], w, frame->linesize[1], h );
327 dst = copy_plane( dst, frame->data[2], w, frame->linesize[2], h );
332 static int get_frame_buf( AVCodecContext *context, AVFrame *frame )
334 hb_work_private_t *pv = context->opaque;
335 frame->pts = pv->pts;
338 return avcodec_default_get_buffer( context, frame );
341 static void log_chapter( hb_work_private_t *pv, int chap_num, int64_t pts )
343 hb_chapter_t *c = hb_list_item( pv->job->title->list_chapter, chap_num - 1 );
346 hb_log( "%s: \"%s\" (%d) at frame %u time %lld",
347 pv->context->codec->name, c->title, chap_num, pv->nframes, pts );
351 hb_log( "%s: Chapter %d at frame %u time %lld",
352 pv->context->codec->name, chap_num, pv->nframes, pts );
356 static int decodeFrame( hb_work_private_t *pv, uint8_t *data, int size )
361 if ( avcodec_decode_video( pv->context, &frame, &got_picture, data, size ) < 0 )
367 // ffmpeg makes it hard to attach a pts to a frame. if the MPEG ES
368 // packet had a pts we handed it to av_parser_parse (if the packet had
369 // no pts we set it to -1 but before the parse we can't distinguish between
370 // the start of a video frame with no pts & an intermediate packet of
371 // some frame which never has a pts). we hope that when parse returns
372 // the frame to us the pts we originally handed it will be in parser->pts.
373 // we put this pts into pv->pts so that when a avcodec_decode_video
374 // finally gets around to allocating an AVFrame to hold the decoded
375 // frame we can stuff that pts into the frame. if all of these relays
376 // worked at this point frame.pts should hold the frame's pts from the
377 // original data stream or -1 if it didn't have one. in the latter case
378 // we generate the next pts in sequence for it.
379 double pts = frame.pts;
384 if ( pv->duration == 0 )
386 pv->duration = 90000. * pv->context->time_base.num /
387 pv->context->time_base.den;
389 double frame_dur = pv->duration;
390 frame_dur += frame.repeat_pict * frame_dur * 0.5;
391 pv->pts_next = pts + frame_dur;
393 hb_buffer_t *buf = copy_frame( pv->context, &frame );
396 if ( pv->new_chap && buf->start >= pv->chap_time )
398 buf->new_chap = pv->new_chap;
403 log_chapter( pv, buf->new_chap, buf->start );
406 else if ( pv->job && pv->nframes == 0 )
408 log_chapter( pv, pv->job->chapter_start, buf->start );
410 hb_list_add( pv->list, buf );
416 static void decodeVideo( hb_work_private_t *pv, uint8_t *data, int size,
417 int64_t pts, int64_t dts )
420 * The following loop is a do..while because we need to handle both
421 * data & the flush at the end (signaled by size=0). At the end there's
422 * generally a frame in the parser & one or more frames in the decoder
423 * (depending on the bframes setting).
429 int len = av_parser_parse( pv->parser, pv->context, &pout, &pout_len,
430 data + pos, size - pos, pts, dts );
435 pv->pts = pv->parser->pts;
436 decodeFrame( pv, pout, pout_len );
438 } while ( pos < size );
440 /* the stuff above flushed the parser, now flush the decoder */
441 while ( size == 0 && decodeFrame( pv, NULL, 0 ) )
446 static hb_buffer_t *link_buf_list( hb_work_private_t *pv )
448 hb_buffer_t *head = hb_list_item( pv->list, 0 );
452 hb_list_rem( pv->list, head );
454 hb_buffer_t *last = head, *buf;
456 while ( ( buf = hb_list_item( pv->list, 0 ) ) != NULL )
458 hb_list_rem( pv->list, buf );
467 static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
470 hb_work_private_t *pv = calloc( 1, sizeof( hb_work_private_t ) );
471 w->private_data = pv;
473 pv->list = hb_list_init();
475 int codec_id = w->codec_param;
476 pv->parser = av_parser_init( codec_id );
477 pv->context = avcodec_alloc_context2( CODEC_TYPE_VIDEO );
479 /* we have to wrap ffmpeg's get_buffer to be able to set the pts (?!) */
480 pv->context->opaque = pv;
481 pv->context->get_buffer = get_frame_buf;
483 AVCodec *codec = avcodec_find_decoder( codec_id );
485 // we can't call the avstream funcs but the read_header func in the
486 // AVInputFormat may set up some state in the AVContext. In particular
487 // vc1t_read_header allocates 'extradata' to deal with header issues
488 // related to Microsoft's bizarre engineering notions. We alloc a chunk
489 // of space to make vc1 work then associate the codec with the context.
490 pv->context->extradata_size = 32;
491 pv->context->extradata = av_malloc(pv->context->extradata_size);
492 avcodec_open( pv->context, codec );
497 static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
498 hb_buffer_t ** buf_out )
500 hb_work_private_t *pv = w->private_data;
501 hb_buffer_t *in = *buf_in;
507 /* if we got an empty buffer signaling end-of-stream send it downstream */
510 decodeVideo( pv, in->data, in->size, pts, dts );
511 hb_list_add( pv->list, in );
512 *buf_out = link_buf_list( pv );
513 hb_log( "%s done: %u frames, %u decoder errors",
514 pv->context->codec->name, pv->nframes, pv->decode_errors );
521 dts = in->renderOffset;
525 pv->new_chap = in->new_chap;
526 pv->chap_time = pts >= 0? pts : pv->pts_next;
528 decodeVideo( pv, in->data, in->size, pts, dts );
529 hb_buffer_close( &in );
530 *buf_out = link_buf_list( pv );
534 static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info )
536 hb_work_private_t *pv = w->private_data;
538 memset( info, 0, sizeof(*info) );
540 if ( pv && pv->context )
542 AVCodecContext *context = pv->context;
543 info->bitrate = context->bit_rate;
544 info->width = context->width;
545 info->height = context->height;
547 /* ffmpeg gives the frame rate in frames per second while HB wants
548 * it in units of the 27MHz MPEG clock. */
549 info->rate = 27000000;
550 info->rate_base = (int64_t)context->time_base.num * 27000000LL /
551 context->time_base.den;
553 /* Sometimes there's no pixel aspect set in the source. In that case,
554 assume a 1:1 PAR. Otherwise, preserve the source PAR. */
555 info->pixel_aspect_width = context->sample_aspect_ratio.num ?
556 context->sample_aspect_ratio.num : 1;
557 info->pixel_aspect_height = context->sample_aspect_ratio.den ?
558 context->sample_aspect_ratio.den : 1;
560 /* ffmpeg returns the Pixel Aspect Ratio (PAR). Handbrake wants the
561 * Display Aspect Ratio so we convert by scaling by the Storage
562 * Aspect Ratio (w/h). We do the calc in floating point to get the
564 info->aspect = (double)info->pixel_aspect_width *
565 (double)context->width /
566 (double)info->pixel_aspect_height /
567 (double)context->height;
569 info->profile = context->profile;
570 info->level = context->level;
571 info->name = context->codec->name;
577 static int decavcodecvBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
578 hb_work_info_t *info )
583 hb_work_object_t hb_decavcodecv =
586 "Video decoder (libavcodec)",
595 // This is a special decoder for ffmpeg streams. The ffmpeg stream reader
596 // includes a parser and passes information from the parser to the decoder
597 // via a codec context kept in the AVStream of the reader's AVFormatContext.
598 // We *have* to use that codec context to decode the stream or we'll get
599 // garbage. ffmpeg_title_scan put a cookie that can be used to get to that
600 // codec context in our codec_param.
602 // this routine gets the appropriate context pointer from the ffmpeg
603 // stream reader. it can't be called until we get the first buffer because
604 // we can't guarantee that reader will be called before the our init
605 // routine and if our init is called first we'll get a pointer to the
606 // old scan stream (which has already been closed).
607 static void init_ffmpeg_context( hb_work_object_t *w )
609 hb_work_private_t *pv = w->private_data;
610 pv->context = hb_ffmpeg_context( w->codec_param );
612 // during scan the decoder gets closed & reopened which will
613 // close the codec so reopen it if it's not there
614 if ( ! pv->context->codec )
616 AVCodec *codec = avcodec_find_decoder( pv->context->codec_id );
617 avcodec_open( pv->context, codec );
619 // set up our best guess at the frame duration.
620 // the frame rate in the codec is usually bogus but it's sometimes
622 AVStream *st = hb_ffmpeg_avstream( w->codec_param );
624 // XXX because the time bases are so screwed up, we only take values
625 // in the range 8fps - 64fps.
626 if ( st->time_base.num * 64 > st->time_base.den &&
627 st->time_base.den > st->time_base.num * 8 )
631 else if ( st->codec->time_base.num * 64 > st->codec->time_base.den &&
632 st->codec->time_base.den > st->codec->time_base.num * 8 )
634 tb = st->codec->time_base;
636 else if ( st->r_frame_rate.den * 64 > st->r_frame_rate.num &&
637 st->r_frame_rate.num > st->r_frame_rate.den * 8 )
639 tb.num = st->r_frame_rate.den;
640 tb.den = st->r_frame_rate.num;
644 tb.num = 1001; /*XXX*/
645 tb.den = 30000; /*XXX*/
647 pv->duration = 90000. * tb.num / tb.den;
649 // we have to wrap ffmpeg's get_buffer to be able to set the pts (?!)
650 pv->context->opaque = pv;
651 pv->context->get_buffer = get_frame_buf;
654 static void prepare_ffmpeg_buffer( hb_buffer_t * in )
656 // ffmpeg requires an extra 8 bytes of zero at the end of the buffer and
657 // will seg fault in odd, data dependent ways if it's not there. (my guess
658 // is this is a case of a local performance optimization creating a global
659 // performance degradation since all the time wasted by extraneous data
660 // copies & memory zeroing has to be huge compared to the minor reduction
661 // in inner-loop instructions this affords - modern cpus bottleneck on
662 // memory bandwidth not instruction bandwidth).
663 if ( in->size + FF_INPUT_BUFFER_PADDING_SIZE > in->alloc )
665 // have to realloc to add the padding
666 hb_buffer_realloc( in, in->size + FF_INPUT_BUFFER_PADDING_SIZE );
668 memset( in->data + in->size, 0, FF_INPUT_BUFFER_PADDING_SIZE );
671 static int decavcodecviInit( hb_work_object_t * w, hb_job_t * job )
674 hb_work_private_t *pv = calloc( 1, sizeof( hb_work_private_t ) );
675 w->private_data = pv;
677 pv->list = hb_list_init();
682 static int decavcodecviWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
683 hb_buffer_t ** buf_out )
685 hb_work_private_t *pv = w->private_data;
688 init_ffmpeg_context( w );
690 switch ( pv->context->codec_id )
692 // These are the only formats whose timestamps we'll believe.
693 // All others are treated as CFR (i.e., we take the first timestamp
694 // then generate all the others from the frame rate). The reason for
695 // this is that the M$ encoders are so frigging buggy with garbage
696 // like packed b-frames (vfw divx mpeg4) that believing their timestamps
697 // results in discarding more than half the video frames because they'll
698 // be out of sequence (and attempting to reseqence them doesn't work
699 // because it's the timestamps that are wrong, not the decoded frame
700 // order). All hail Redmond, ancestral home of the rich & stupid.
701 case CODEC_ID_MPEG2VIDEO:
702 case CODEC_ID_RAWVIDEO:
712 hb_buffer_t *in = *buf_in;
717 /* if we got an empty buffer signaling end-of-stream send it downstream */
720 /* flush any frames left in the decoder */
721 while ( decodeFrame( pv, NULL, 0 ) )
724 hb_list_add( pv->list, in );
725 *buf_out = link_buf_list( pv );
726 hb_log( "%s done: %u frames, %u decoder errors, %u drops",
727 pv->context->codec->name, pv->nframes, pv->decode_errors,
734 // use the first timestamp as our 'next expected' pts
735 if ( pv->pts_next <= 0 )
737 pv->pts_next = in->start;
740 if ( ! pv->ignore_pts )
745 hb_log( "overwriting pts %lld with %lld (diff %d)",
746 pv->pts, pts, pts - pv->pts );
748 if ( pv->pts_next - pts >= pv->duration )
750 // this frame starts more than a frame time before where
751 // the nominal frame rate says it should - drop it.
752 // log the first 10 drops so we'll know what's going on.
753 if ( pv->ndrops++ < 10 )
755 hb_log( "time reversal next %.0f pts %lld (diff %g)",
756 pv->pts_next, pts, pv->pts_next - pts );
758 hb_buffer_close( &in );
767 pv->new_chap = in->new_chap;
768 pv->chap_time = pts >= 0? pts : pv->pts_next;
770 prepare_ffmpeg_buffer( in );
771 decodeFrame( pv, in->data, in->size );
772 hb_buffer_close( &in );
773 *buf_out = link_buf_list( pv );
777 static int decavcodecviInfo( hb_work_object_t *w, hb_work_info_t *info )
779 if ( decavcodecvInfo( w, info ) )
781 // There are at least three different video frame rates in ffmpeg:
782 // - time_base in the AVStream
783 // - time_base in the AVCodecContext
784 // - r_frame_rate in the AVStream
785 // There's no guidence on which if any of these to believe but the
786 // routine compute_frame_duration tries the stream first then the codec.
787 // In general the codec time base seems bogus & the stream time base is
788 // ok except for wmv's where the stream time base is also bogus but
789 // r_frame_rate is sometimes ok & sometimes a random number.
790 AVStream *st = hb_ffmpeg_avstream( w->codec_param );
792 // XXX because the time bases are so screwed up, we only take values
793 // in the range 8fps - 64fps.
794 if ( st->time_base.num * 64 > st->time_base.den &&
795 st->time_base.den > st->time_base.num * 8 )
799 else if ( st->codec->time_base.num * 64 > st->codec->time_base.den &&
800 st->codec->time_base.den > st->codec->time_base.num * 8 )
802 tb = st->codec->time_base;
804 else if ( st->r_frame_rate.den * 64 > st->r_frame_rate.num &&
805 st->r_frame_rate.num > st->r_frame_rate.den * 8 )
807 tb.num = st->r_frame_rate.den;
808 tb.den = st->r_frame_rate.num;
812 tb.num = 1001; /*XXX*/
813 tb.den = 30000; /*XXX*/
816 // ffmpeg gives the frame rate in frames per second while HB wants
817 // it in units of the 27MHz MPEG clock. */
818 info->rate = 27000000;
819 info->rate_base = (int64_t)tb.num * 27000000LL / tb.den;
825 static void decodeAudio( hb_work_private_t *pv, uint8_t *data, int size )
827 AVCodecContext *context = pv->context;
832 int16_t buffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
833 int out_size = sizeof(buffer);
834 int len = avcodec_decode_audio2( context, buffer, &out_size,
835 data + pos, size - pos );
843 hb_buffer_t *buf = hb_buffer_init( 2 * out_size );
845 double pts = pv->pts_next;
848 pts += out_size * pv->duration;
852 float *fl32 = (float *)buf->data;
854 for( i = 0; i < out_size; ++i )
858 hb_list_add( pv->list, buf );
863 static int decavcodecaiWork( hb_work_object_t *w, hb_buffer_t **buf_in,
864 hb_buffer_t **buf_out )
866 if ( (*buf_in)->size <= 0 )
868 /* EOF on input stream - send it downstream & say that we're done */
874 hb_work_private_t *pv = w->private_data;
877 init_ffmpeg_context( w );
878 pv->duration = 90000. /
879 (double)( pv->context->sample_rate * pv->context->channels );
881 hb_buffer_t *in = *buf_in;
883 if ( in->start >= 0 &&
884 ( pv->pts_next < 0 || ( in->start - pv->pts_next ) > 90*100 ) )
886 pv->pts_next = in->start;
888 prepare_ffmpeg_buffer( in );
889 decodeAudio( pv, in->data, in->size );
890 *buf_out = link_buf_list( pv );
895 hb_work_object_t hb_decavcodecvi =
898 "Video decoder (ffmpeg streams)",
906 hb_work_object_t hb_decavcodecai =
909 "Audio decoder (ffmpeg streams)",