Browse Source

avcodec: pass the whole es_format when looking for a codec.

pull/162/head
Steve Lhomme 2 years ago
parent
commit
8828f7d7c4
  1. 3
      modules/codec/avcodec/avcodec.c
  2. 2
      modules/codec/avcodec/avcodec.h
  3. 6
      modules/codec/avcodec/encoder.c
  4. 8
      modules/codec/avcodec/fourcc.c
  5. 2
      modules/demux/avformat/mux.c
  6. 3
      modules/packetizer/avparser.c

3
modules/codec/avcodec/avcodec.c

@ -230,8 +230,7 @@ AVCodecContext *ffmpeg_AllocContext( decoder_t *p_dec,
const AVCodec *p_codec = NULL;
/* *** determine codec type *** */
if( !GetFfmpegCodec( p_dec->fmt_in->i_cat, p_dec->fmt_in->i_codec,
&i_codec_id, &psz_namecodec ) ||
if( !GetFfmpegCodec( p_dec->fmt_in, &i_codec_id, &psz_namecodec ) ||
i_codec_id == AV_CODEC_ID_RAWVIDEO )
return NULL;

2
modules/codec/avcodec/avcodec.h

@ -24,7 +24,7 @@
#include "avcommon.h"
/* VLC <-> avcodec tables */
bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
bool GetFfmpegCodec( const es_format_t *,
enum AVCodecID *pi_ffmpeg_codec, const char **ppsz_name );
vlc_fourcc_t GetVlcFourcc( enum AVCodecID i_ffmpeg_codec );
vlc_fourcc_t GetVlcAudioFormat( int i_sample_fmt );

6
modules/codec/avcodec/encoder.c

@ -336,8 +336,7 @@ int InitVideoEnc( vlc_object_t *p_this )
psz_namecodec = "MPEG-1 video";
break;
}
if( GetFfmpegCodec( VIDEO_ES, p_enc->fmt_out.i_codec, &i_codec_id,
&psz_namecodec ) )
if( GetFfmpegCodec( &p_enc->fmt_out, &i_codec_id, &psz_namecodec ) )
break;
bool uv_flipped;
if( FindFfmpegChroma( p_enc->fmt_out.i_codec, &uv_flipped ) != AV_PIX_FMT_NONE )
@ -350,8 +349,7 @@ int InitVideoEnc( vlc_object_t *p_this )
case AUDIO_ES:
encoder_ops = &audio_ops;
if( GetFfmpegCodec( AUDIO_ES, p_enc->fmt_out.i_codec, &i_codec_id,
&psz_namecodec ) )
if( GetFfmpegCodec( &p_enc->fmt_out, &i_codec_id, &psz_namecodec ) )
break;
/* fall through */
default:

8
modules/codec/avcodec/fourcc.c

@ -556,13 +556,13 @@ static const struct vlc_avcodec_fourcc spu_codecs[] =
/* ffmpeg only: AV_CODEC_ID_ASS */
};
bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
bool GetFfmpegCodec( const es_format_t *es,
enum AVCodecID *pi_ffmpeg_codec, const char **ppsz_name )
{
const struct vlc_avcodec_fourcc *base;
size_t count;
switch( cat )
switch( es->i_cat )
{
case VIDEO_ES:
base = video_codecs;
@ -581,7 +581,7 @@ bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
count = 0;
}
i_fourcc = vlc_fourcc_GetCodec( cat, i_fourcc );
vlc_fourcc_t i_fourcc = vlc_fourcc_GetCodec( es->i_cat, es->i_codec );
for( size_t i = 0; i < count; i++ )
{
@ -590,7 +590,7 @@ bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
if( pi_ffmpeg_codec != NULL )
*pi_ffmpeg_codec = base[i].i_codec;
if( ppsz_name )
*ppsz_name = vlc_fourcc_GetDescription( cat, i_fourcc );
*ppsz_name = vlc_fourcc_GetDescription( es->i_cat, i_fourcc );
return true;
}
}

2
modules/demux/avformat/mux.c

@ -204,7 +204,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
msg_Dbg( p_mux, "adding input" );
if( !GetFfmpegCodec( fmt->i_cat, fmt->i_codec, &i_codec_id, NULL )
if( !GetFfmpegCodec( fmt, &i_codec_id, NULL )
|| i_codec_id == AV_CODEC_ID_NONE )
{
msg_Dbg( p_mux, "couldn't find codec for fourcc '%4.4s'",

3
modules/packetizer/avparser.c

@ -91,8 +91,7 @@ int avparser_OpenPacketizer( vlc_object_t *p_this )
enum AVCodecID i_avcodec_id;
if( !GetFfmpegCodec( p_dec->fmt_in->i_cat, p_dec->fmt_in->i_codec,
&i_avcodec_id, NULL ) )
if( !GetFfmpegCodec( p_dec->fmt_in, &i_avcodec_id, NULL ) )
return VLC_EGENERIC;
/* init avcodec */

Loading…
Cancel
Save