1 /*****************************************************************************
2 * video.c: video decoder using ffmpeg library
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: video.c,v 1.39 2003/08/12 17:01:35 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 p_vdec->b_has_b_frames = VLC_FALSE;
385 return( VLC_SUCCESS );
388 /*****************************************************************************
389 * DecodeThread: Called to decode one frame
390 *****************************************************************************
391 * We have to get a frame stored in a pes, give it to ffmpeg decoder and send
392 * the image to the output.
393 *****************************************************************************/
394 void E_( DecodeThread_Video )( vdec_thread_t *p_vdec )
401 picture_t *p_pic; /* vlc picture */
403 /* TODO implement it in a better way */
404 /* A good idea could be to decode all I pictures and see for the other */
405 if( p_vdec->b_hurry_up && p_vdec->i_frame_late > 4 )
408 if( p_vdec->i_frame_late < 8 )
410 p_vdec->p_context->hurry_up = 2;
414 /* too much late picture, won't decode
415 but break picture until a new I, and for mpeg4 ...*/
416 p_vdec->i_frame_late--; /* needed else it will never be decrease */
417 input_ExtractPES( p_vdec->p_fifo, NULL );
424 p_vdec->p_context->hurry_up = 0;
427 if( p_vdec->i_frame_late > 0 &&
428 mdate() - p_vdec->i_frame_late_start > (mtime_t)5000000 )
430 msg_Err( p_vdec->p_fifo, "more than 5 seconds of late video -> "
431 "dropping (to slow computer ?)" );
434 input_ExtractPES( p_vdec->p_fifo, &p_pes );
437 p_vdec->p_fifo->b_error = 1;
441 if( p_pes->i_pts > 0 )
443 p_vdec->input_pts_previous = p_vdec->input_pts;
444 p_vdec->input_pts = p_pes->i_pts;
446 input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
448 } while( p_vdec->input_pts <= 0 || p_vdec->input_pts < mdate() );
451 if( !p_vdec->p_context->width || !p_vdec->p_context->height )
453 p_vdec->p_context->hurry_up = 5;
458 input_ExtractPES( p_vdec->p_fifo, &p_pes );
461 p_vdec->p_fifo->b_error = 1;
465 if( p_pes->i_pts > 0 )
467 p_vdec->input_pts_previous = p_vdec->input_pts;
468 p_vdec->input_pts = p_pes->i_pts;
471 i_frame_size = p_pes->i_pes_size;
473 if( i_frame_size > 0 )
477 /* XXX Don't forget that ffmpeg required a little more bytes
478 * that the real frame size */
479 i_need = i_frame_size + FF_INPUT_BUFFER_PADDING_SIZE + p_vdec->i_buffer;
480 if( p_vdec->i_buffer_size < i_need)
482 p_last = p_vdec->p_buffer;
483 p_vdec->p_buffer = malloc( i_need );
484 p_vdec->i_buffer_size = i_need;
485 if( p_vdec->i_buffer > 0 )
487 memcpy( p_vdec->p_buffer, p_last, p_vdec->i_buffer );
492 E_( GetPESData )( p_vdec->p_buffer + p_vdec->i_buffer,
493 i_frame_size , p_pes );
494 memset( p_vdec->p_buffer + p_vdec->i_buffer + i_frame_size,
495 0, FF_INPUT_BUFFER_PADDING_SIZE );
498 input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
500 } while( i_frame_size <= 0 );
502 i_frame_size += p_vdec->i_buffer;
505 i_used = avcodec_decode_video( p_vdec->p_context,
511 if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error ) return;
514 msg_Dbg( p_vdec->p_fifo,
515 "used:%d framesize:%d (%s picture)",
516 i_used, i_frame_size, b_gotpicture ? "got":"no got" );
520 msg_Warn( p_vdec->p_fifo, "cannot decode one frame (%d bytes)",
522 p_vdec->i_frame_error++;
523 p_vdec->i_buffer = 0;
526 else if( i_used < i_frame_size )
528 memmove( p_vdec->p_buffer,
529 p_vdec->p_buffer + i_used,
530 p_vdec->i_buffer_size - i_used );
532 p_vdec->i_buffer = i_frame_size - i_used;
536 p_vdec->i_buffer = 0;
540 i_frame_size -= i_used;
542 /* Update frame late count*/
543 if( p_vdec->pts <= mdate() )
545 p_vdec->i_frame_late++;
546 if( p_vdec->i_frame_late == 1 )
548 p_vdec->i_frame_late_start = mdate();
553 p_vdec->i_frame_late = 0;
556 if( !b_gotpicture || p_vdec->p_ff_pic->linesize[0] == 0 || !b_drawpicture )
561 if( !p_vdec->b_direct_rendering )
563 p_vdec->p_vout = ffmpeg_CreateVout( p_vdec, p_vdec->p_context );
564 if( !p_vdec->p_vout )
566 msg_Err( p_vdec->p_fifo, "cannot create vout" );
567 p_vdec->p_fifo->b_error = 1; /* abort */
571 /* Get a new picture */
572 while( !(p_pic = vout_CreatePicture( p_vdec->p_vout, 0, 0, 0 ) ) )
574 if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error )
578 msleep( VOUT_OUTMEM_SLEEP );
581 /* fill p_picture_t from AVVideoFrame and do chroma conversion
583 ffmpeg_CopyPicture( p_pic, p_vdec->p_ff_pic, p_vdec );
587 p_pic = (picture_t *)p_vdec->p_ff_pic->opaque;
591 * There is an ugly hack here because some demuxers pass us a dts instead
592 * of a pts so this screw up things for streams with B frames. */
593 if( p_vdec->p_ff_pic->pict_type == FF_B_TYPE )
594 p_vdec->b_has_b_frames = VLC_TRUE;
595 if( p_vdec->p_ff_pic->pts &&
596 ( !p_vdec->p_context->has_b_frames || !p_vdec->b_has_b_frames ||
597 p_vdec->p_ff_pic->pict_type == FF_B_TYPE ) )
599 p_vdec->pts = p_vdec->p_ff_pic->pts;
600 msg_Err( p_vdec->p_fifo, "new pts: "I64Fd, p_vdec->pts );
603 if( p_vdec->pts <= 0 )
605 p_vdec->pts = mdate() + DEFAULT_PTS_DELAY; // FIXME
608 /* Send decoded frame to vout */
609 vout_DatePicture( p_vdec->p_vout, p_pic, p_vdec->pts );
610 vout_DisplayPicture( p_vdec->p_vout, p_pic );
612 /* interpolate the next PTS */
613 if( p_vdec->p_context->frame_rate > 0 )
615 p_vdec->pts += I64C(1000000) * (2 + p_vdec->p_ff_pic->repeat_pict) *
616 p_vdec->p_context->frame_rate_base /
617 (2 * p_vdec->p_context->frame_rate);
620 if( i_frame_size > 0 )
622 goto usenextdata; /* try to use all data */
626 /*****************************************************************************
627 * EndThread: thread destruction
628 *****************************************************************************
629 * This function is called when the thread ends after a sucessful
631 *****************************************************************************/
632 void E_( EndThread_Video )( vdec_thread_t *p_vdec )
636 if( p_vdec->pp_mode )
638 pp_free_mode( p_vdec->pp_mode );
639 if( p_vdec->pp_context )
641 pp_free_context( p_vdec->pp_context );
646 if( p_vdec->p_ff_pic )
648 free( p_vdec->p_ff_pic );
651 /* We are about to die. Reattach video output to p_vlc. */
652 vout_Request( p_vdec->p_fifo, p_vdec->p_vout, 0, 0, 0, 0 );
655 /*****************************************************************************
656 * ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a
657 * picture_t structure (when not in direct rendering mode).
658 *****************************************************************************/
659 static void ffmpeg_CopyPicture( picture_t *p_pic,
661 vdec_thread_t *p_vdec )
672 if( ffmpeg_PixFmtToChroma( p_vdec->p_context->pix_fmt ) )
675 if( p_vdec->pp_mode && p_vdec->pp_context )
677 uint8_t *src[3], *dst[3];
678 int i_src_stride[3], i_dst_stride[3];
680 for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
682 src[i_plane] = p_ff_pic->data[i_plane];
683 dst[i_plane] = p_pic->p[i_plane].p_pixels;
685 i_src_stride[i_plane] = p_ff_pic->linesize[i_plane];
686 i_dst_stride[i_plane] = p_pic->p[i_plane].i_pitch;
688 pp_postprocess( src, i_src_stride,
690 p_vdec->p_context->width,
691 p_vdec->p_context->height,
692 p_ff_pic->qscale_table, p_ff_pic->qstride,
693 p_vdec->pp_mode, p_vdec->pp_context,
694 p_ff_pic->pict_type );
699 for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
701 p_src = p_ff_pic->data[i_plane];
702 p_dst = p_pic->p[i_plane].p_pixels;
703 i_src_stride = p_ff_pic->linesize[i_plane];
704 i_dst_stride = p_pic->p[i_plane].i_pitch;
706 i_size = __MIN( i_src_stride, i_dst_stride );
707 for( i_line = 0; i_line < p_pic->p[i_plane].i_lines; i_line++ )
709 p_vdec->p_fifo->p_vlc->pf_memcpy( p_dst, p_src, i_size );
710 p_src += i_src_stride;
711 p_dst += i_dst_stride;
720 /* we need to convert to I420 */
721 switch( p_vdec->p_context->pix_fmt )
726 case( PIX_FMT_YUV410P ):
727 case( PIX_FMT_YUV411P ):
728 for( i = 0; i < p_pic->i_planes; i++ )
730 dest_pic.data[i] = p_pic->p[i].p_pixels;
731 dest_pic.linesize[i] = p_pic->p[i].i_pitch;
733 img_convert( &dest_pic, PIX_FMT_YUV420P,
734 (AVPicture *)p_ff_pic,
735 p_vdec->p_context->pix_fmt,
736 p_vdec->p_context->width,
737 p_vdec->p_context->height );
740 msg_Err( p_vdec->p_fifo, "don't know how to convert chroma %i",
741 p_vdec->p_context->pix_fmt );
742 p_vdec->p_fifo->b_error = 1;
748 /*****************************************************************************
749 * ffmpeg_GetFrameBuf: callback used by ffmpeg to get a frame buffer.
750 *****************************************************************************
751 * It is used for direct rendering as well as to get the right PTS for each
752 * decoded picture (even in indirect rendering mode).
753 *****************************************************************************/
754 static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
757 vdec_thread_t *p_vdec = (vdec_thread_t *)p_context->opaque;
760 /* Set picture PTS */
761 if( p_context->flags & CODEC_FLAG_TRUNCATED )
763 p_ff_pic->pts = p_vdec->input_pts_previous;
764 p_vdec->input_pts_previous = 0;
768 p_ff_pic->pts = p_vdec->input_pts;
769 p_vdec->input_pts = 0;
772 /* Not much to do in indirect rendering mode */
773 if( !p_vdec->b_direct_rendering )
775 return avcodec_default_get_buffer( p_context, p_ff_pic );
778 /* Some codecs set pix_fmt only after the 1st frame has been decoded,
779 * so this check is necessary. */
780 if( !ffmpeg_PixFmtToChroma( p_context->pix_fmt ) ||
781 p_vdec->p_context->width % 16 || p_vdec->p_context->height % 16 )
783 msg_Dbg( p_vdec->p_fifo, "disabling direct rendering" );
784 p_vdec->b_direct_rendering = 0;
785 return avcodec_default_get_buffer( p_context, p_ff_pic );
788 /* Check and (re)create our vout if needed */
789 p_vdec->p_vout = ffmpeg_CreateVout( p_vdec, p_vdec->p_context );
790 if( !p_vdec->p_vout )
792 msg_Err( p_vdec->p_fifo, "cannot create vout" );
793 p_vdec->p_fifo->b_error = 1; /* abort */
794 p_vdec->b_direct_rendering = 0;
795 return avcodec_default_get_buffer( p_context, p_ff_pic );
798 p_vdec->p_vout->render.b_allow_modify_pics = 0;
800 /* Get a new picture */
801 while( !(p_pic = vout_CreatePicture( p_vdec->p_vout, 0, 0, 0 ) ) )
803 if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error )
805 p_vdec->b_direct_rendering = 0;
806 return avcodec_default_get_buffer( p_context, p_ff_pic );
808 msleep( VOUT_OUTMEM_SLEEP );
810 p_vdec->p_context->draw_horiz_band = NULL;
812 p_ff_pic->opaque = (void*)p_pic;
813 p_ff_pic->type = FF_BUFFER_TYPE_USER;
814 p_ff_pic->data[0] = p_pic->p[0].p_pixels;
815 p_ff_pic->data[1] = p_pic->p[1].p_pixels;
816 p_ff_pic->data[2] = p_pic->p[2].p_pixels;
817 p_ff_pic->data[3] = NULL; /* alpha channel but I'm not sure */
819 p_ff_pic->linesize[0] = p_pic->p[0].i_pitch;
820 p_ff_pic->linesize[1] = p_pic->p[1].i_pitch;
821 p_ff_pic->linesize[2] = p_pic->p[2].i_pitch;
822 p_ff_pic->linesize[3] = 0;
824 if( p_ff_pic->reference != 0 )
826 vout_LinkPicture( p_vdec->p_vout, p_pic );
828 /* FIXME what is that, should give good value */
829 p_ff_pic->age = 256*256*256*64; // FIXME FIXME from ffmpeg
834 static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context,
837 vdec_thread_t *p_vdec = (vdec_thread_t *)p_context->opaque;
840 if( p_ff_pic->type != FF_BUFFER_TYPE_USER )
842 avcodec_default_release_buffer( p_context, p_ff_pic );
846 p_pic = (picture_t*)p_ff_pic->opaque;
848 p_ff_pic->data[0] = NULL;
849 p_ff_pic->data[1] = NULL;
850 p_ff_pic->data[2] = NULL;
851 p_ff_pic->data[3] = NULL;
853 if( p_ff_pic->reference != 0 )
855 vout_UnlinkPicture( p_vdec->p_vout, p_pic );