Commit 55bb1c7a authored by Laurent Aimar's avatar Laurent Aimar

* all: - increased avcodec version needed to 4680 (latest release)

        - open the codec after that p_context has been fully initialisated.
        (fix ASV1)
parent 849e41ba
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* encoder.c: video and audio encoder using the ffmpeg library * encoder.c: video and audio encoder using the ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: encoder.c,v 1.15 2003/11/29 13:12:11 fenrir Exp $ * $Id: encoder.c,v 1.16 2003/11/29 18:06:12 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com> * Gildas Bazin <gbazin@netcourrier.com>
...@@ -179,9 +179,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -179,9 +179,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context->height = p_enc->fmt_in.video.i_height; p_context->height = p_enc->fmt_in.video.i_height;
p_context->frame_rate = p_enc->fmt_in.video.i_frame_rate; p_context->frame_rate = p_enc->fmt_in.video.i_frame_rate;
#if LIBAVCODEC_BUILD >= 4662
p_context->frame_rate_base= p_enc->fmt_in.video.i_frame_rate_base; p_context->frame_rate_base= p_enc->fmt_in.video.i_frame_rate_base;
#endif
#if LIBAVCODEC_BUILD >= 4687 #if LIBAVCODEC_BUILD >= 4687
p_context->sample_aspect_ratio = p_context->sample_aspect_ratio =
...@@ -234,14 +232,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -234,14 +232,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context->qmin = p_enc->i_qmin; p_context->qmin = p_enc->i_qmin;
p_context->qmax = p_enc->i_qmax; p_context->qmax = p_enc->i_qmax;
#if LIBAVCODEC_BUILD >= 4673
p_context->mb_decision = p_enc->i_hq; p_context->mb_decision = p_enc->i_hq;
#else
if( p_enc->i_hq )
{
p_context->flags |= CODEC_FLAG_HQ;
}
#endif
if( i_codec_id == CODEC_ID_RAWVIDEO ) if( i_codec_id == CODEC_ID_RAWVIDEO )
{ {
...@@ -318,7 +309,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -318,7 +309,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', '2', 'v' ) ) p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', '2', 'v' ) )
{ {
frame.pts = p_pict->date; frame.pts = p_pict->date;
#if LIBAVCODEC_BUILD >= 4673
if ( frame.pts && mdate() + HURRY_UP_GUARD > frame.pts if ( frame.pts && mdate() + HURRY_UP_GUARD > frame.pts
&& p_enc->b_hurry_up ) && p_enc->b_hurry_up )
{ {
...@@ -326,7 +316,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -326,7 +316,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
p_sys->p_context->mb_decision = FF_MB_DECISION_SIMPLE; p_sys->p_context->mb_decision = FF_MB_DECISION_SIMPLE;
b_hurry_up = 1; b_hurry_up = 1;
} }
#endif
} }
else else
{ {
...@@ -345,12 +334,10 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -345,12 +334,10 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
i_out = avcodec_encode_video( p_sys->p_context, p_sys->p_buffer_out, i_out = avcodec_encode_video( p_sys->p_context, p_sys->p_buffer_out,
AVCODEC_MAX_VIDEO_FRAME_SIZE, &frame ); AVCODEC_MAX_VIDEO_FRAME_SIZE, &frame );
#if LIBAVCODEC_BUILD >= 4673
if ( b_hurry_up ) if ( b_hurry_up )
{ {
p_sys->p_context->mb_decision = p_enc->i_hq; p_sys->p_context->mb_decision = p_enc->i_hq;
} }
#endif
if( i_out > 0 ) if( i_out > 0 )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library * ffmpeg.c: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.64 2003/11/29 13:12:11 fenrir Exp $ * $Id: ffmpeg.c,v 1.65 2003/11/29 18:06:12 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com> * Gildas Bazin <gbazin@netcourrier.com>
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
# include <avcodec.h> # include <avcodec.h>
#endif #endif
#if LIBAVCODEC_BUILD < 4655 #if LIBAVCODEC_BUILD < 4680
# error You must have a libavcodec >= 4655 (get CVS) # error You must have a libavcodec >= 4680 (get CVS)
#endif #endif
#include "ffmpeg.h" #include "ffmpeg.h"
...@@ -244,13 +244,8 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -244,13 +244,8 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
case VLC_FOURCC('m','p','2','v'): case VLC_FOURCC('m','p','2','v'):
case VLC_FOURCC('m','p','g','v'): case VLC_FOURCC('m','p','g','v'):
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
#if LIBAVCODEC_BUILD >= 4676
i_codec = CODEC_ID_MPEG2VIDEO; i_codec = CODEC_ID_MPEG2VIDEO;
psz_name = "MPEG-2 Video"; psz_name = "MPEG-2 Video";
#else
i_codec = CODEC_ID_MPEG1VIDEO;
psz_name = "MPEG-1 Video";
#endif
break; break;
/* MPEG-4 Video */ /* MPEG-4 Video */
...@@ -371,14 +366,12 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -371,14 +366,12 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
psz_name = "I263.I"; psz_name = "I263.I";
break; break;
#if LIBAVCODEC_BUILD >= 4669
/* Flash (H263) variant */ /* Flash (H263) variant */
case VLC_FOURCC('F','L','V','1'): case VLC_FOURCC('F','L','V','1'):
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_FLV1; i_codec = CODEC_ID_FLV1;
psz_name = "Flash Video"; psz_name = "Flash Video";
break; break;
#endif
/* MJPEG */ /* MJPEG */
case VLC_FOURCC( 'M', 'J', 'P', 'G' ): case VLC_FOURCC( 'M', 'J', 'P', 'G' ):
...@@ -445,7 +438,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -445,7 +438,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
break; break;
#endif #endif
#if( ( LIBAVCODEC_BUILD >= 4663 ) && ( !defined( WORDS_BIGENDIAN ) ) ) #if( !defined( WORDS_BIGENDIAN ) )
/* Indeo Video Codecs (Quality of this decoder on ppc is not good) */ /* Indeo Video Codecs (Quality of this decoder on ppc is not good) */
case VLC_FOURCC('I','V','3','1'): case VLC_FOURCC('I','V','3','1'):
case VLC_FOURCC('i','v','3','1'): case VLC_FOURCC('i','v','3','1'):
...@@ -471,7 +464,6 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -471,7 +464,6 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
psz_name ="Creative YUV"; psz_name ="Creative YUV";
break; break;
#if LIBAVCODEC_BUILD >= 4668
/* On2 VP3 Video Codecs */ /* On2 VP3 Video Codecs */
case VLC_FOURCC('V','P','3','1'): case VLC_FOURCC('V','P','3','1'):
case VLC_FOURCC('v','p','3','1'): case VLC_FOURCC('v','p','3','1'):
...@@ -479,52 +471,41 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -479,52 +471,41 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
i_codec = CODEC_ID_VP3; i_codec = CODEC_ID_VP3;
psz_name = "On2's VP3 Video"; psz_name = "On2's VP3 Video";
break; break;
#endif
#if ( !defined( WORDS_BIGENDIAN ) ) #if ( !defined( WORDS_BIGENDIAN ) )
#if LIBAVCODEC_BUILD >= 4668
/* Asus Video (Another thing that doesn't work on PPC) */ /* Asus Video (Another thing that doesn't work on PPC) */
case VLC_FOURCC('A','S','V','1'): case VLC_FOURCC('A','S','V','1'):
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_ASV1; i_codec = CODEC_ID_ASV1;
psz_name = "Asus V1"; psz_name = "Asus V1";
break; break;
#endif
#if LIBAVCODEC_BUILD >= 4677
case VLC_FOURCC('A','S','V','2'): case VLC_FOURCC('A','S','V','2'):
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_ASV2; i_codec = CODEC_ID_ASV2;
psz_name = "Asus V2"; psz_name = "Asus V2";
break; break;
#endif #endif
#endif
#if LIBAVCODEC_BUILD >= 4668
/* FFMPEG Video 1 (lossless codec) */ /* FFMPEG Video 1 (lossless codec) */
case VLC_FOURCC('F','F','V','1'): case VLC_FOURCC('F','F','V','1'):
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_FFV1; i_codec = CODEC_ID_FFV1;
psz_name = "FFMpeg Video 1"; psz_name = "FFMpeg Video 1";
break; break;
#endif
#if LIBAVCODEC_BUILD >= 4669
/* ATI VCR1 */ /* ATI VCR1 */
case VLC_FOURCC('V','C','R','1'): case VLC_FOURCC('V','C','R','1'):
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_VCR1; i_codec = CODEC_ID_VCR1;
psz_name = "ATI VCR1"; psz_name = "ATI VCR1";
break; break;
#endif
#if LIBAVCODEC_BUILD >= 4672
/* Cirrus Logic AccuPak */ /* Cirrus Logic AccuPak */
case VLC_FOURCC('C','L','J','R'): case VLC_FOURCC('C','L','J','R'):
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_CLJR; i_codec = CODEC_ID_CLJR;
psz_name = "Creative Logic AccuPak"; psz_name = "Creative Logic AccuPak";
break; break;
#endif
#if LIBAVCODEC_BUILD >= 4683 #if LIBAVCODEC_BUILD >= 4683
/* Apple Video */ /* Apple Video */
...@@ -585,7 +566,6 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -585,7 +566,6 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
psz_name = "MACE-6 audio"; psz_name = "MACE-6 audio";
break; break;
#if LIBAVCODEC_BUILD >= 4668
/* RealAudio 1.0 */ /* RealAudio 1.0 */
case VLC_FOURCC('1','4','_','4'): case VLC_FOURCC('1','4','_','4'):
i_cat = AUDIO_ES; i_cat = AUDIO_ES;
...@@ -599,7 +579,6 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -599,7 +579,6 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
i_codec = CODEC_ID_RA_288; i_codec = CODEC_ID_RA_288;
psz_name = "RealAudio 2.0"; psz_name = "RealAudio 2.0";
break; break;
#endif
/* MPEG Audio layer 1/2/3 */ /* MPEG Audio layer 1/2/3 */
case VLC_FOURCC('m','p','g','a'): case VLC_FOURCC('m','p','g','a'):
...@@ -609,11 +588,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -609,11 +588,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
break; break;
case VLC_FOURCC('m','p','3',' '): case VLC_FOURCC('m','p','3',' '):
i_cat = AUDIO_ES; i_cat = AUDIO_ES;
#if LIBAVCODEC_BUILD >= 4678
i_codec = CODEC_ID_MP3; i_codec = CODEC_ID_MP3;
#else
i_codec = CODEC_ID_MP3LAME;
#endif
psz_name = "MPEG Audio layer 1/2/3"; psz_name = "MPEG Audio layer 1/2/3";
break; break;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video.c: video decoder using the ffmpeg library * video.c: video decoder using the ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: video.c,v 1.54 2003/11/27 12:32:03 fenrir Exp $ * $Id: video.c,v 1.55 2003/11/29 18:06:12 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com> * Gildas Bazin <gbazin@netcourrier.com>
...@@ -221,22 +221,9 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -221,22 +221,9 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
if( val.b_bool ) p_sys->p_context->flags |= CODEC_FLAG_GRAY; if( val.b_bool ) p_sys->p_context->flags |= CODEC_FLAG_GRAY;
/* Decide if we set CODEC_FLAG_TRUNCATED */ /* Decide if we set CODEC_FLAG_TRUNCATED */
#if LIBAVCODEC_BUILD >= 4662
var_Create( p_dec, "ffmpeg-truncated", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_dec, "ffmpeg-truncated", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_dec, "ffmpeg-truncated", &val ); var_Get( p_dec, "ffmpeg-truncated", &val );
if( val.i_int > 0 ) p_sys->p_context->flags |= CODEC_FLAG_TRUNCATED; if( val.i_int > 0 ) p_sys->p_context->flags |= CODEC_FLAG_TRUNCATED;
#endif
/* ***** Open the codec ***** */
vlc_mutex_lock( lockval.p_address );
if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 )
{
vlc_mutex_unlock( lockval.p_address );
msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
return VLC_EGENERIC;
}
vlc_mutex_unlock( lockval.p_address );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
/* ***** ffmpeg frame skipping ***** */ /* ***** ffmpeg frame skipping ***** */
var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
...@@ -281,21 +268,9 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -281,21 +268,9 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
/* ***** init this codec with special data ***** */ /* ***** init this codec with special data ***** */
if( p_dec->fmt_in.i_extra ) if( p_dec->fmt_in.i_extra )
{ {
int b_gotpicture;
int i_size = p_dec->fmt_in.i_extra; int i_size = p_dec->fmt_in.i_extra;
if( p_sys->i_codec_id == CODEC_ID_MPEG4 ) if( p_sys->i_codec_id == CODEC_ID_SVQ3 )
{
uint8_t *p_vol = malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
memcpy( p_vol, p_dec->fmt_in.p_extra, i_size );
memset( &p_vol[i_size], 0, FF_INPUT_BUFFER_PADDING_SIZE );
avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic,
&b_gotpicture, p_vol, i_size );
free( p_vol );
}
#if LIBAVCODEC_BUILD >= 4666
else if( p_sys->i_codec_id == CODEC_ID_SVQ3 )
{ {
uint8_t *p; uint8_t *p;
...@@ -307,7 +282,6 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -307,7 +282,6 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
memset( &p[4], 0, 8 ); memset( &p[4], 0, 8 );
memcpy( &p[12], p_dec->fmt_in.p_extra, i_size ); memcpy( &p[12], p_dec->fmt_in.p_extra, i_size );
} }
#endif
else else
{ {
p_sys->p_context->extradata_size = i_size; p_sys->p_context->extradata_size = i_size;
...@@ -333,6 +307,18 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -333,6 +307,18 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
p_dec->fmt_out.i_cat = VIDEO_ES; p_dec->fmt_out.i_cat = VIDEO_ES;
p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt ); p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt );
/* ***** Open the codec ***** */
vlc_mutex_lock( lockval.p_address );
if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 )
{
vlc_mutex_unlock( lockval.p_address );
msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
return VLC_EGENERIC;
}
vlc_mutex_unlock( lockval.p_address );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment