You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/libvpxdec: pass decoder instances to vpx_init directly
If the alpha decoder init failed we presented the error message from the normal decoder. This change should prevent such mistakes. Signed-off-by: Marton Balint <cus@passwd.hu> Signed-off-by: James Zern <jzern@google.com>
This commit is contained in:
committed by
James Zern
parent
99e0007046
commit
98aa1eb1cb
@@ -42,10 +42,9 @@ typedef struct VPxDecoderContext {
|
|||||||
} VPxContext;
|
} VPxContext;
|
||||||
|
|
||||||
static av_cold int vpx_init(AVCodecContext *avctx,
|
static av_cold int vpx_init(AVCodecContext *avctx,
|
||||||
const struct vpx_codec_iface *iface,
|
struct vpx_codec_ctx* decoder,
|
||||||
int is_alpha_decoder)
|
const struct vpx_codec_iface *iface)
|
||||||
{
|
{
|
||||||
VPxContext *ctx = avctx->priv_data;
|
|
||||||
struct vpx_codec_dec_cfg deccfg = {
|
struct vpx_codec_dec_cfg deccfg = {
|
||||||
.threads = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 16)
|
.threads = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 16)
|
||||||
};
|
};
|
||||||
@@ -53,10 +52,8 @@ static av_cold int vpx_init(AVCodecContext *avctx,
|
|||||||
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
|
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
|
||||||
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
|
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
|
||||||
|
|
||||||
if (vpx_codec_dec_init(
|
if (vpx_codec_dec_init(decoder, iface, &deccfg, 0) != VPX_CODEC_OK) {
|
||||||
is_alpha_decoder ? &ctx->decoder_alpha : &ctx->decoder,
|
const char *error = vpx_codec_error(decoder);
|
||||||
iface, &deccfg, 0) != VPX_CODEC_OK) {
|
|
||||||
const char *error = vpx_codec_error(&ctx->decoder);
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n",
|
av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n",
|
||||||
error);
|
error);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
@@ -199,15 +196,16 @@ static int vpx_decode(AVCodecContext *avctx,
|
|||||||
if (!ctx->has_alpha_channel) {
|
if (!ctx->has_alpha_channel) {
|
||||||
ctx->has_alpha_channel = 1;
|
ctx->has_alpha_channel = 1;
|
||||||
ret = vpx_init(avctx,
|
ret = vpx_init(avctx,
|
||||||
|
&ctx->decoder_alpha,
|
||||||
#if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER
|
#if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER
|
||||||
(avctx->codec_id == AV_CODEC_ID_VP8) ?
|
(avctx->codec_id == AV_CODEC_ID_VP8) ?
|
||||||
&vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo,
|
&vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo
|
||||||
#elif CONFIG_LIBVPX_VP8_DECODER
|
#elif CONFIG_LIBVPX_VP8_DECODER
|
||||||
&vpx_codec_vp8_dx_algo,
|
&vpx_codec_vp8_dx_algo
|
||||||
#else
|
#else
|
||||||
&vpx_codec_vp9_dx_algo,
|
&vpx_codec_vp9_dx_algo
|
||||||
#endif
|
#endif
|
||||||
1);
|
);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -275,7 +273,8 @@ static av_cold int vpx_free(AVCodecContext *avctx)
|
|||||||
#if CONFIG_LIBVPX_VP8_DECODER
|
#if CONFIG_LIBVPX_VP8_DECODER
|
||||||
static av_cold int vp8_init(AVCodecContext *avctx)
|
static av_cold int vp8_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
return vpx_init(avctx, &vpx_codec_vp8_dx_algo, 0);
|
VPxContext *ctx = avctx->priv_data;
|
||||||
|
return vpx_init(avctx, &ctx->decoder, &vpx_codec_vp8_dx_algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
AVCodec ff_libvpx_vp8_decoder = {
|
AVCodec ff_libvpx_vp8_decoder = {
|
||||||
@@ -295,7 +294,8 @@ AVCodec ff_libvpx_vp8_decoder = {
|
|||||||
#if CONFIG_LIBVPX_VP9_DECODER
|
#if CONFIG_LIBVPX_VP9_DECODER
|
||||||
static av_cold int vp9_init(AVCodecContext *avctx)
|
static av_cold int vp9_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
return vpx_init(avctx, &vpx_codec_vp9_dx_algo, 0);
|
VPxContext *ctx = avctx->priv_data;
|
||||||
|
return vpx_init(avctx, &ctx->decoder, &vpx_codec_vp9_dx_algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
AVCodec ff_libvpx_vp9_decoder = {
|
AVCodec ff_libvpx_vp9_decoder = {
|
||||||
|
Reference in New Issue
Block a user