lavc: set bit_rate in the decoder context, just after the init stage
Also move the get_bit_rate() function, in order to avoid an undefined symbol reference in avcodec_open2().
This commit is contained in:
parent
6e6bdeb137
commit
3293b1adca
@ -677,6 +677,29 @@ static void avcodec_get_subtitle_defaults(AVSubtitle *sub)
|
|||||||
sub->pts = AV_NOPTS_VALUE;
|
sub->pts = AV_NOPTS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_bit_rate(AVCodecContext *ctx)
|
||||||
|
{
|
||||||
|
int bit_rate;
|
||||||
|
int bits_per_sample;
|
||||||
|
|
||||||
|
switch(ctx->codec_type) {
|
||||||
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
|
case AVMEDIA_TYPE_DATA:
|
||||||
|
case AVMEDIA_TYPE_SUBTITLE:
|
||||||
|
case AVMEDIA_TYPE_ATTACHMENT:
|
||||||
|
bit_rate = ctx->bit_rate;
|
||||||
|
break;
|
||||||
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
|
bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
|
||||||
|
bit_rate = bits_per_sample ? ctx->sample_rate * ctx->channels * bits_per_sample : ctx->bit_rate;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bit_rate = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return bit_rate;
|
||||||
|
}
|
||||||
|
|
||||||
#if FF_API_AVCODEC_OPEN
|
#if FF_API_AVCODEC_OPEN
|
||||||
int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
|
int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
|
||||||
{
|
{
|
||||||
@ -889,6 +912,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (codec_is_decoder(avctx->codec) && !avctx->bit_rate)
|
||||||
|
avctx->bit_rate = get_bit_rate(avctx);
|
||||||
|
|
||||||
ret=0;
|
ret=0;
|
||||||
end:
|
end:
|
||||||
entangled_thread_counter--;
|
entangled_thread_counter--;
|
||||||
@ -1602,29 +1628,6 @@ AVCodec *avcodec_find_decoder_by_name(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_bit_rate(AVCodecContext *ctx)
|
|
||||||
{
|
|
||||||
int bit_rate;
|
|
||||||
int bits_per_sample;
|
|
||||||
|
|
||||||
switch(ctx->codec_type) {
|
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
|
||||||
case AVMEDIA_TYPE_DATA:
|
|
||||||
case AVMEDIA_TYPE_SUBTITLE:
|
|
||||||
case AVMEDIA_TYPE_ATTACHMENT:
|
|
||||||
bit_rate = ctx->bit_rate;
|
|
||||||
break;
|
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
|
||||||
bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
|
|
||||||
bit_rate = bits_per_sample ? ctx->sample_rate * ctx->channels * bits_per_sample : ctx->bit_rate;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
bit_rate = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return bit_rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *avcodec_get_name(enum CodecID id)
|
const char *avcodec_get_name(enum CodecID id)
|
||||||
{
|
{
|
||||||
AVCodec *codec;
|
AVCodec *codec;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 54
|
#define LIBAVCODEC_VERSION_MAJOR 54
|
||||||
#define LIBAVCODEC_VERSION_MINOR 3
|
#define LIBAVCODEC_VERSION_MINOR 3
|
||||||
#define LIBAVCODEC_VERSION_MICRO 100
|
#define LIBAVCODEC_VERSION_MICRO 101
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
LIBAVCODEC_VERSION_MINOR, \
|
LIBAVCODEC_VERSION_MINOR, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user