Commit d228d52f authored by Jun Zhao's avatar Jun Zhao Committed by Mark Thompson

lavc/vp8: Support resolution changes in the VP8 decoder hwaccel

Use the following command to reproduce this issue:
make fate-vp8-size-change HWACCEL="vaapi -vaapi_device \
/dev/dri/renderD128 -hwaccel_output_format yuv420p"
SAMPLES=../fate-suite/.

At the same time, reconstruct the public logic as a function.
Signed-off-by: 's avatarYun Zhou <yunx.z.zhou@intel.com>
Signed-off-by: 's avatarJun Zhao <jun.zhao@intel.com>
Signed-off-by: 's avatarMark Thompson <sw@jkqxz.net>
parent b2d27d91
...@@ -167,6 +167,22 @@ static VP8Frame *vp8_find_free_buffer(VP8Context *s) ...@@ -167,6 +167,22 @@ static VP8Frame *vp8_find_free_buffer(VP8Context *s)
return frame; return frame;
} }
static enum AVPixelFormat get_pixel_format(VP8Context *s)
{
enum AVPixelFormat pix_fmts[] = {
#if CONFIG_VP8_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI,
#endif
#if CONFIG_VP8_NVDEC_HWACCEL
AV_PIX_FMT_CUDA,
#endif
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE,
};
return ff_get_format(s->avctx, pix_fmts);
}
static av_always_inline static av_always_inline
int update_dimensions(VP8Context *s, int width, int height, int is_vp7) int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
{ {
...@@ -182,6 +198,13 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7) ...@@ -182,6 +198,13 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
return ret; return ret;
} }
if (!s->actually_webp && !is_vp7) {
s->pix_fmt = get_pixel_format(s);
if (s->pix_fmt < 0)
return AVERROR(EINVAL);
avctx->pix_fmt = s->pix_fmt;
}
s->mb_width = (s->avctx->coded_width + 15) / 16; s->mb_width = (s->avctx->coded_width + 15) / 16;
s->mb_height = (s->avctx->coded_height + 15) / 16; s->mb_height = (s->avctx->coded_height + 15) / 16;
...@@ -2598,18 +2621,7 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -2598,18 +2621,7 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (s->actually_webp) { if (s->actually_webp) {
// avctx->pix_fmt already set in caller. // avctx->pix_fmt already set in caller.
} else if (!is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) { } else if (!is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) {
enum AVPixelFormat pix_fmts[] = { s->pix_fmt = get_pixel_format(s);
#if CONFIG_VP8_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI,
#endif
#if CONFIG_VP8_NVDEC_HWACCEL
AV_PIX_FMT_CUDA,
#endif
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE,
};
s->pix_fmt = ff_get_format(s->avctx, pix_fmts);
if (s->pix_fmt < 0) { if (s->pix_fmt < 0) {
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto err; goto err;
......
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