mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
webp: Fix alpha initialisation
ff_get_format() in the next patch will reject formats which aren't in the offered list, so the hack in 7cb9296db872c4221453e5411f242ebcfca62664 is no longer valid. Change the hack by adding a new field in the VP8 decoder context to indicate that it's actually WebP and don't call ff_get_format() at all in that case.
This commit is contained in:
parent
2fcb009011
commit
57623cba13
@ -2515,7 +2515,9 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
if (!is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) {
|
||||
if (s->actually_webp) {
|
||||
// avctx->pix_fmt already set in caller.
|
||||
} else if (!is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) {
|
||||
enum AVPixelFormat pix_fmts[] = {
|
||||
#if CONFIG_VP8_VAAPI_HWACCEL
|
||||
AV_PIX_FMT_VAAPI,
|
||||
|
@ -140,6 +140,7 @@ typedef struct VP8Context {
|
||||
VP8ThreadData *thread_data;
|
||||
AVCodecContext *avctx;
|
||||
enum AVPixelFormat pix_fmt;
|
||||
int actually_webp;
|
||||
|
||||
VP8Frame *framep[4];
|
||||
VP8Frame *next_framep[4];
|
||||
|
@ -1288,16 +1288,6 @@ static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum AVPixelFormat webp_get_format(AVCodecContext *avctx,
|
||||
const enum AVPixelFormat *formats)
|
||||
{
|
||||
WebPContext *s = avctx->priv_data;
|
||||
if (s->has_alpha)
|
||||
return AV_PIX_FMT_YUVA420P;
|
||||
else
|
||||
return AV_PIX_FMT_YUV420P;
|
||||
}
|
||||
|
||||
static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
|
||||
int *got_frame, uint8_t *data_start,
|
||||
unsigned int data_size)
|
||||
@ -1309,7 +1299,11 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
|
||||
if (!s->initialized) {
|
||||
ff_vp8_decode_init(avctx);
|
||||
s->initialized = 1;
|
||||
avctx->get_format = webp_get_format;
|
||||
s->v.actually_webp = 1;
|
||||
if (s->has_alpha)
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
|
||||
else
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
}
|
||||
s->lossless = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user