1 /*****************************************************************************
2 * video.c: video decoder using ffmpeg library
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: video.c,v 1.37 2003/08/08 17:08:32 gbazin Exp $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Gildas Bazin <gbazin@netcourrier.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
33 #include <vlc/decoder.h>
34 #include <vlc/input.h>
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
43 #ifdef HAVE_FFMPEG_AVCODEC_H
44 # include <ffmpeg/avcodec.h>
52 # ifdef HAVE_POSTPROC_POSTPROCESS_H
53 # include <postproc/postprocess.h>
55 # include <libpostproc/postprocess.h>
58 # include "postprocessing/postprocessing.h"
64 /*****************************************************************************
66 *****************************************************************************/
67 static void ffmpeg_CopyPicture( picture_t *, AVFrame *, vdec_thread_t * );
69 static int ffmpeg_GetFrameBuf ( struct AVCodecContext *, AVFrame * );
70 static void ffmpeg_ReleaseFrameBuf ( struct AVCodecContext *, AVFrame * );
72 /*****************************************************************************
74 *****************************************************************************/
75 static inline uint32_t ffmpeg_PixFmtToChroma( int i_ff_chroma )
77 /* FIXME FIXME some of them are wrong */
82 return( VLC_FOURCC('I','4','2','0') );
84 return( VLC_FOURCC('R','V','2','4') );
87 return( VLC_FOURCC('I','4','2','2') );
89 return( VLC_FOURCC('I','4','4','4') );
99 static vout_thread_t *ffmpeg_CreateVout( vdec_thread_t *p_vdec,
100 AVCodecContext *p_context )
102 vout_thread_t *p_vout;
103 unsigned int i_width = p_context->width;
104 unsigned int i_height = p_context->height;
105 uint32_t i_chroma = ffmpeg_PixFmtToChroma( p_context->pix_fmt );
106 unsigned int i_aspect;
108 if( !i_width || !i_height )
110 return( NULL ); /* Can't create a new vout without display size */
115 /* we make conversion if possible*/
116 i_chroma = VLC_FOURCC('I','4','2','0');
119 i_aspect = VOUT_ASPECT_FACTOR * p_context->aspect_ratio;
122 i_aspect = VOUT_ASPECT_FACTOR * i_width / i_height;
125 /* Spawn a video output if there is none. First we look for our children,
126 * then we look for any other vout that might be available. */
127 p_vout = vout_Request( p_vdec->p_fifo, p_vdec->p_vout,
128 i_width, i_height, i_chroma, i_aspect );
130 if( p_vdec->pp_mode && !p_vdec->pp_context )
132 int32_t i_cpu = p_vdec->p_fifo->p_libvlc->i_cpu;
135 if( i_cpu & CPU_CAPABILITY_MMX )
137 i_flags |= PP_CPU_CAPS_MMX;
139 if( i_cpu & CPU_CAPABILITY_MMXEXT )
141 i_flags |= PP_CPU_CAPS_MMX2;
143 if( i_cpu & CPU_CAPABILITY_3DNOW )
145 i_flags |= PP_CPU_CAPS_3DNOW;
148 switch( p_context->pix_fmt )
150 case PIX_FMT_YUV444P:
151 i_flags |= PP_FORMAT_444;
153 case PIX_FMT_YUV422P:
154 i_flags |= PP_FORMAT_422;
156 case PIX_FMT_YUV411P:
157 i_flags |= PP_FORMAT_411;
160 i_flags |= PP_FORMAT_420;
164 p_vdec->pp_context = pp_get_context( i_width, i_height, i_flags );
171 /*****************************************************************************
173 * Functions that initialize, decode and end the decoding process
175 * Functions exported for ffmpeg.c
176 * * E_( InitThread_Video )
177 * * E_( DecodeThread )
178 * * E_( EndThread_Video )
179 *****************************************************************************/
181 /*****************************************************************************
182 * InitThread: initialize vdec output thread
183 *****************************************************************************
184 * This function is called from decoder_Run and performs the second step
185 * of the initialization. It returns 0 on success. Note that the thread's
186 * flag are not modified inside this function.
188 * ffmpeg codec will be open, some memory allocated. But Vout is not yet
189 * open (done after the first decoded frame)
190 *****************************************************************************/
191 static inline void SetDWBE( void *data, uint32_t dw )
195 p[0] = (dw >> 24 )&0xff;
196 p[1] = (dw >> 16 )&0xff;
197 p[2] = (dw >> 8 )&0xff;
201 int E_( InitThread_Video )( vdec_thread_t *p_vdec )
206 p_vdec->p_ff_pic = avcodec_alloc_frame();
208 if( ( p_vdec->p_format =
209 (BITMAPINFOHEADER *)p_vdec->p_fifo->p_bitmapinfoheader ) != NULL )
211 /* ***** Fill p_context with init values ***** */
212 p_vdec->p_context->width = p_vdec->p_format->biWidth;
213 p_vdec->p_context->height = p_vdec->p_format->biHeight;
217 msg_Warn( p_vdec->p_fifo, "display informations missing" );
218 p_vdec->p_format = NULL;
221 /* ***** Get configuration of ffmpeg plugin ***** */
222 i_tmp = config_GetInt( p_vdec->p_fifo, "ffmpeg-workaround-bugs" );
223 p_vdec->p_context->workaround_bugs = __MAX( __MIN( i_tmp, 99 ), 0 );
225 i_tmp = config_GetInt( p_vdec->p_fifo, "ffmpeg-error-resilience" );
226 p_vdec->p_context->error_resilience = __MAX( __MIN( i_tmp, 99 ), -1 );
228 if( config_GetInt( p_vdec->p_fifo, "grayscale" ) )
230 p_vdec->p_context->flags|= CODEC_FLAG_GRAY;
233 p_vdec->b_hurry_up = config_GetInt(p_vdec->p_fifo, "ffmpeg-hurry-up");
235 /* CODEC_FLAG_TRUNCATED */
237 /* FIXME search real LIBAVCODEC_BUILD */
238 #if LIBAVCODEC_BUILD >= 4662
239 i_truncated = config_GetInt( p_vdec->p_fifo, "ffmpeg-truncated" );
240 if( i_truncated == 1 )
243 ( i_truncated == -1 && ( p_vdec->p_context->width == 0 || p_vdec->p_context->height == 0 ) ) )
246 p_vdec->p_context->flags |= CODEC_FLAG_TRUNCATED;
250 /* ***** Open the codec ***** */
251 if( avcodec_open(p_vdec->p_context, p_vdec->p_codec) < 0 )
253 msg_Err( p_vdec->p_fifo, "cannot open codec (%s)",
254 p_vdec->psz_namecodec );
255 return( VLC_EGENERIC );
259 msg_Dbg( p_vdec->p_fifo, "ffmpeg codec (%s) started",
260 p_vdec->psz_namecodec );
263 p_vdec->b_direct_rendering = 0;
264 if( config_GetInt( p_vdec->p_fifo, "ffmpeg-dr" ) &&
265 p_vdec->p_codec->capabilities & CODEC_CAP_DR1 &&
266 ffmpeg_PixFmtToChroma( p_vdec->p_context->pix_fmt ) &&
267 /* Apparently direct rendering doesn't work with YUV422P */
268 p_vdec->p_context->pix_fmt != PIX_FMT_YUV422P &&
269 !(p_vdec->p_context->width % 16) && !(p_vdec->p_context->height % 16) )
271 /* Some codecs set pix_fmt only after the 1st frame has been decoded,
272 * so we need to do another check in ffmpeg_GetFrameBuf() */
273 p_vdec->b_direct_rendering = 1;
276 /* ***** Load post processing ***** */
278 p_vdec->pp_context = NULL;
279 p_vdec->pp_mode = NULL;
281 if( config_GetInt( p_vdec->p_fifo, "ffmpeg-pp-q" ) > 0 )
283 int i_quality = config_GetInt( p_vdec->p_fifo, "ffmpeg-pp-q" );
284 char *psz_name = config_GetPsz( p_vdec->p_fifo, "ffmpeg-pp-name" );
288 psz_name = strdup( "default" );
290 else if( *psz_name == '\0' )
293 psz_name = strdup( "default" );
297 pp_get_mode_by_name_and_quality( psz_name, i_quality );
299 if( !p_vdec->pp_mode )
301 msg_Err( p_vdec->p_fifo, "failed geting mode for postproc" );
305 msg_Info( p_vdec->p_fifo, "postproc activated" );
309 /* for now we cannot do postproc and dr */
310 p_vdec->b_direct_rendering = 0;
314 msg_Dbg( p_vdec->p_fifo, "no postproc" );
318 /* ffmpeg doesn't properly release old pictures when frames are skipped */
319 if( p_vdec->b_hurry_up ) p_vdec->b_direct_rendering = 0;
321 /* Always use our get_buffer wrapper so we can calculate the
323 p_vdec->p_context->get_buffer = ffmpeg_GetFrameBuf;
324 p_vdec->p_context->release_buffer = ffmpeg_ReleaseFrameBuf;
325 p_vdec->p_context->opaque = p_vdec;
327 if( p_vdec->b_direct_rendering )
329 msg_Dbg( p_vdec->p_fifo, "using direct rendering" );
330 p_vdec->p_context->flags |= CODEC_FLAG_EMU_EDGE;
333 /* ***** init this codec with special data ***** */
334 if( p_vdec->p_format &&
335 p_vdec->p_format->biSize > sizeof(BITMAPINFOHEADER) )
338 int i_size = p_vdec->p_format->biSize - sizeof(BITMAPINFOHEADER);
340 if( p_vdec->i_codec_id == CODEC_ID_MPEG4 )
342 uint8_t *p_vol = malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
344 memcpy( p_vol, &p_vdec->p_format[1], i_size );
345 memset( &p_vol[i_size], 0, FF_INPUT_BUFFER_PADDING_SIZE );
347 avcodec_decode_video( p_vdec->p_context, p_vdec->p_ff_pic,
353 #if LIBAVCODEC_BUILD >= 4666
354 else if( p_vdec->i_codec_id == CODEC_ID_SVQ3 )
358 p_vdec->p_context->extradata_size = i_size + 12;
359 p = p_vdec->p_context->extradata =
360 malloc( p_vdec->p_context->extradata_size );
362 memcpy( &p[0], "SVQ3", 4 );
363 memset( &p[4], 0, 8 );
364 memcpy( &p[12], &p_vdec->p_format[1], i_size );
369 p_vdec->p_context->extradata_size = i_size;
370 p_vdec->p_context->extradata =
371 malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
372 memcpy( p_vdec->p_context->extradata,
373 &p_vdec->p_format[1], i_size );
374 memset( &((uint8_t*)p_vdec->p_context->extradata)[i_size],
375 0, FF_INPUT_BUFFER_PADDING_SIZE );
378 p_vdec->p_vout = NULL;
380 p_vdec->input_pts_previous = 0;
381 p_vdec->input_pts = 0;
383 return( VLC_SUCCESS );
386 /*****************************************************************************
387 * DecodeThread: Called to decode one frame
388 *****************************************************************************
389 * We have to get a frame stored in a pes, give it to ffmpeg decoder and send
390 * the image to the output.
391 *****************************************************************************/
392 void E_( DecodeThread_Video )( vdec_thread_t *p_vdec )
399 picture_t *p_pic; /* vlc picture */
401 /* TODO implement it in a better way */
402 /* A good idea could be to decode all I pictures and see for the other */
403 if( p_vdec->b_hurry_up && p_vdec->i_frame_late > 4 )
406 if( p_vdec->i_frame_late < 8 )
408 p_vdec->p_context->hurry_up = 2;
412 /* too much late picture, won't decode
413 but break picture until a new I, and for mpeg4 ...*/
414 p_vdec->i_frame_late--; /* needed else it will never be decrease */
415 input_ExtractPES( p_vdec->p_fifo, NULL );
422 p_vdec->p_context->hurry_up = 0;
425 if( p_vdec->i_frame_late > 0 &&
426 mdate() - p_vdec->i_frame_late_start > (mtime_t)5000000 )
428 msg_Err( p_vdec->p_fifo, "more than 5 seconds of late video -> "
429 "dropping (to slow computer ?)" );
432 input_ExtractPES( p_vdec->p_fifo, &p_pes );
435 p_vdec->p_fifo->b_error = 1;
439 if( p_pes->i_pts > 0 )
441 p_vdec->input_pts_previous = p_vdec->input_pts;
442 p_vdec->input_pts = p_pes->i_pts;
444 input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
446 } while( p_vdec->input_pts <= 0 || p_vdec->input_pts < mdate() );
449 if( !p_vdec->p_context->width || !p_vdec->p_context->height )
451 p_vdec->p_context->hurry_up = 5;
456 input_ExtractPES( p_vdec->p_fifo, &p_pes );
459 p_vdec->p_fifo->b_error = 1;
463 if( p_pes->i_pts > 0 )
465 p_vdec->input_pts_previous = p_vdec->input_pts;
466 p_vdec->input_pts = p_pes->i_pts;
469 i_frame_size = p_pes->i_pes_size;
471 if( i_frame_size > 0 )
475 /* XXX Don't forget that ffmpeg required a little more bytes
476 * that the real frame size */
477 i_need = i_frame_size + FF_INPUT_BUFFER_PADDING_SIZE + p_vdec->i_buffer;
478 if( p_vdec->i_buffer_size < i_need)
480 p_last = p_vdec->p_buffer;
481 p_vdec->p_buffer = malloc( i_need );
482 p_vdec->i_buffer_size = i_need;
483 if( p_vdec->i_buffer > 0 )
485 memcpy( p_vdec->p_buffer, p_last, p_vdec->i_buffer );
490 E_( GetPESData )( p_vdec->p_buffer + p_vdec->i_buffer,
491 i_frame_size , p_pes );
492 memset( p_vdec->p_buffer + p_vdec->i_buffer + i_frame_size,
493 0, FF_INPUT_BUFFER_PADDING_SIZE );
496 input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
498 } while( i_frame_size <= 0 );
500 i_frame_size += p_vdec->i_buffer;
503 i_used = avcodec_decode_video( p_vdec->p_context,
509 if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error ) return;
512 msg_Dbg( p_vdec->p_fifo,
513 "used:%d framesize:%d (%s picture)",
514 i_used, i_frame_size, b_gotpicture ? "got":"no got" );
518 msg_Warn( p_vdec->p_fifo, "cannot decode one frame (%d bytes)",
520 p_vdec->i_frame_error++;
521 p_vdec->i_buffer = 0;
524 else if( i_used < i_frame_size )
526 memmove( p_vdec->p_buffer,
527 p_vdec->p_buffer + i_used,
528 p_vdec->i_buffer_size - i_used );
530 p_vdec->i_buffer = i_frame_size - i_used;
534 p_vdec->i_buffer = 0;
538 i_frame_size -= i_used;
540 /* Update frame late count*/
541 if( p_vdec->pts <= mdate() )
543 p_vdec->i_frame_late++;
544 if( p_vdec->i_frame_late == 1 )
546 p_vdec->i_frame_late_start = mdate();
551 p_vdec->i_frame_late = 0;
554 if( !b_gotpicture || p_vdec->p_ff_pic->linesize[0] == 0 || !b_drawpicture )
559 if( !p_vdec->b_direct_rendering )
561 p_vdec->p_vout = ffmpeg_CreateVout( p_vdec, p_vdec->p_context );
562 if( !p_vdec->p_vout )
564 msg_Err( p_vdec->p_fifo, "cannot create vout" );
565 p_vdec->p_fifo->b_error = 1; /* abort */
569 /* Get a new picture */
570 while( !(p_pic = vout_CreatePicture( p_vdec->p_vout, 0, 0, 0 ) ) )
572 if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error )
576 msleep( VOUT_OUTMEM_SLEEP );
579 /* fill p_picture_t from AVVideoFrame and do chroma conversion
581 ffmpeg_CopyPicture( p_pic, p_vdec->p_ff_pic, p_vdec );
585 p_pic = (picture_t *)p_vdec->p_ff_pic->opaque;
589 if( p_vdec->p_ff_pic->pts )
591 p_vdec->pts = p_vdec->p_ff_pic->pts;
594 if( p_vdec->pts <= 0 )
596 p_vdec->pts = mdate() + DEFAULT_PTS_DELAY; // FIXME
599 /* Send decoded frame to vout */
600 vout_DatePicture( p_vdec->p_vout, p_pic, p_vdec->pts );
601 vout_DisplayPicture( p_vdec->p_vout, p_pic );
603 /* interpolate the next PTS */
604 if( p_vdec->p_context->frame_rate > 0 )
606 p_vdec->pts += I64C(1000000) * (2 + p_vdec->p_ff_pic->repeat_pict) *
607 p_vdec->p_context->frame_rate_base /
608 (2 * p_vdec->p_context->frame_rate);
611 if( i_frame_size > 0 )
613 goto usenextdata; /* try to use all data */
617 /*****************************************************************************
618 * EndThread: thread destruction
619 *****************************************************************************
620 * This function is called when the thread ends after a sucessful
622 *****************************************************************************/
623 void E_( EndThread_Video )( vdec_thread_t *p_vdec )
627 if( p_vdec->pp_mode )
629 pp_free_mode( p_vdec->pp_mode );
630 if( p_vdec->pp_context )
632 pp_free_context( p_vdec->pp_context );
637 if( p_vdec->p_ff_pic )
639 free( p_vdec->p_ff_pic );
642 /* We are about to die. Reattach video output to p_vlc. */
643 vout_Request( p_vdec->p_fifo, p_vdec->p_vout, 0, 0, 0, 0 );
646 /*****************************************************************************
647 * ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a
648 * picture_t structure (when not in direct rendering mode).
649 *****************************************************************************/
650 static void ffmpeg_CopyPicture( picture_t *p_pic,
652 vdec_thread_t *p_vdec )
663 if( ffmpeg_PixFmtToChroma( p_vdec->p_context->pix_fmt ) )
666 if( p_vdec->pp_mode && p_vdec->pp_context )
668 uint8_t *src[3], *dst[3];
669 int i_src_stride[3], i_dst_stride[3];
671 for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
673 src[i_plane] = p_ff_pic->data[i_plane];
674 dst[i_plane] = p_pic->p[i_plane].p_pixels;
676 i_src_stride[i_plane] = p_ff_pic->linesize[i_plane];
677 i_dst_stride[i_plane] = p_pic->p[i_plane].i_pitch;
679 pp_postprocess( src, i_src_stride,
681 p_vdec->p_context->width,
682 p_vdec->p_context->height,
683 p_ff_pic->qscale_table, p_ff_pic->qstride,
684 p_vdec->pp_mode, p_vdec->pp_context,
685 p_ff_pic->pict_type );
690 for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
692 p_src = p_ff_pic->data[i_plane];
693 p_dst = p_pic->p[i_plane].p_pixels;
694 i_src_stride = p_ff_pic->linesize[i_plane];
695 i_dst_stride = p_pic->p[i_plane].i_pitch;
697 i_size = __MIN( i_src_stride, i_dst_stride );
698 for( i_line = 0; i_line < p_pic->p[i_plane].i_lines; i_line++ )
700 p_vdec->p_fifo->p_vlc->pf_memcpy( p_dst, p_src, i_size );
701 p_src += i_src_stride;
702 p_dst += i_dst_stride;
711 /* we need to convert to I420 */
712 switch( p_vdec->p_context->pix_fmt )
717 case( PIX_FMT_YUV410P ):
718 case( PIX_FMT_YUV411P ):
719 for( i = 0; i < p_pic->i_planes; i++ )
721 dest_pic.data[i] = p_pic->p[i].p_pixels;
722 dest_pic.linesize[i] = p_pic->p[i].i_pitch;
724 img_convert( &dest_pic, PIX_FMT_YUV420P,
725 (AVPicture *)p_ff_pic,
726 p_vdec->p_context->pix_fmt,
727 p_vdec->p_context->width,
728 p_vdec->p_context->height );
731 msg_Err( p_vdec->p_fifo, "don't know how to convert chroma %i",
732 p_vdec->p_context->pix_fmt );
733 p_vdec->p_fifo->b_error = 1;
739 /*****************************************************************************
740 * ffmpeg_GetFrameBuf: callback used by ffmpeg to get a frame buffer.
741 *****************************************************************************
742 * It is used for direct rendering as well as to get the right PTS for each
743 * decoded picture (even in indirect rendering mode).
744 *****************************************************************************/
745 static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
748 vdec_thread_t *p_vdec = (vdec_thread_t *)p_context->opaque;
751 /* Set picture PTS */
752 if( p_context->flags & CODEC_FLAG_TRUNCATED )
754 p_ff_pic->pts = p_vdec->input_pts_previous;
755 p_vdec->input_pts_previous = 0;
759 p_ff_pic->pts = p_vdec->input_pts;
760 p_vdec->input_pts = 0;
763 /* Not much to do in indirect rendering mode */
764 if( !p_vdec->b_direct_rendering )
766 return avcodec_default_get_buffer( p_context, p_ff_pic );
769 /* Some codecs set pix_fmt only after the 1st frame has been decoded,
770 * so this check is necessary. */
771 if( !ffmpeg_PixFmtToChroma( p_context->pix_fmt ) ||
772 p_vdec->p_context->width % 16 || p_vdec->p_context->height % 16 )
774 msg_Dbg( p_vdec->p_fifo, "disabling direct rendering" );
775 p_vdec->b_direct_rendering = 0;
776 return avcodec_default_get_buffer( p_context, p_ff_pic );
779 /* Check and (re)create our vout if needed */
780 p_vdec->p_vout = ffmpeg_CreateVout( p_vdec, p_vdec->p_context );
781 if( !p_vdec->p_vout )
783 msg_Err( p_vdec->p_fifo, "cannot create vout" );
784 p_vdec->p_fifo->b_error = 1; /* abort */
785 p_vdec->b_direct_rendering = 0;
786 return avcodec_default_get_buffer( p_context, p_ff_pic );
789 p_vdec->p_vout->render.b_allow_modify_pics = 0;
791 /* Get a new picture */
792 while( !(p_pic = vout_CreatePicture( p_vdec->p_vout, 0, 0, 0 ) ) )
794 if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error )
796 p_vdec->b_direct_rendering = 0;
797 return avcodec_default_get_buffer( p_context, p_ff_pic );
799 msleep( VOUT_OUTMEM_SLEEP );
801 p_vdec->p_context->draw_horiz_band = NULL;
803 p_ff_pic->opaque = (void*)p_pic;
804 p_ff_pic->type = FF_BUFFER_TYPE_USER;
805 p_ff_pic->data[0] = p_pic->p[0].p_pixels;
806 p_ff_pic->data[1] = p_pic->p[1].p_pixels;
807 p_ff_pic->data[2] = p_pic->p[2].p_pixels;
808 p_ff_pic->data[3] = NULL; /* alpha channel but I'm not sure */
810 p_ff_pic->linesize[0] = p_pic->p[0].i_pitch;
811 p_ff_pic->linesize[1] = p_pic->p[1].i_pitch;
812 p_ff_pic->linesize[2] = p_pic->p[2].i_pitch;
813 p_ff_pic->linesize[3] = 0;
815 if( p_ff_pic->reference != 0 )
817 vout_LinkPicture( p_vdec->p_vout, p_pic );
819 /* FIXME what is that, should give good value */
820 p_ff_pic->age = 256*256*256*64; // FIXME FIXME from ffmpeg
825 static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context,
828 vdec_thread_t *p_vdec = (vdec_thread_t *)p_context->opaque;
831 if( p_ff_pic->type != FF_BUFFER_TYPE_USER )
833 avcodec_default_release_buffer( p_context, p_ff_pic );
837 p_pic = (picture_t*)p_ff_pic->opaque;
839 p_ff_pic->data[0] = NULL;
840 p_ff_pic->data[1] = NULL;
841 p_ff_pic->data[2] = NULL;
842 p_ff_pic->data[3] = NULL;
844 if( p_ff_pic->reference != 0 )
846 vout_UnlinkPicture( p_vdec->p_vout, p_pic );