diff mbox series

[FFmpeg-devel,3/6] avcodec/vc1dec: Set pointers for hwaccel even without hwaccel

Message ID AS8P250MB07443061F1B4530006D26FC18F472@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 38f234c06ee0d98c3568120338c1ec4078f8f9cc
Headers show
Series [FFmpeg-devel,1/6] avcodec: Remove redundant pix_fmts from decoders | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 5, 2024, 11:36 p.m. UTC
VC-1 uses a 0x03 escaping scheme like H.26x and our decoder
unescapes data for this purpose, but hardware accelerations
just want the data as-is and therefore get fed the original
data. The pointers to the actual data are only setcorrectly
if avctx->hwaccel is set (after all, they are only used in
this case).

There are two problems with this: The first is that the branch
is pointless; the second is that it is harmful, because
a hardware acceleration may be added after the packet has been
parsed (in case there is a reconfiguration e.g. due to frame
size changes) in which case decoding the first few frames
won't work.

So delete these branches.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vc1dec.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 6eff2ec04c..6462a40fd3 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -846,14 +846,12 @@  static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
                 if (size <= 0) continue;
                 switch (AV_RB32(start)) {
                 case VC1_CODE_FRAME:
-                    if (avctx->hwaccel)
-                        buf_start = start;
+                    buf_start = start;
                     buf_size2 = v->vc1dsp.vc1_unescape_buffer(start + 4, size, buf2);
                     break;
                 case VC1_CODE_FIELD: {
                     int buf_size3;
-                    if (avctx->hwaccel)
-                        buf_start_second_field = start;
+                    buf_start_second_field = start;
                     av_size_mult(sizeof(*slices), n_slices+1, &next_allocated);
                     tmp = next_allocated ? av_fast_realloc(slices, &slices_allocated, next_allocated) : NULL;
                     if (!tmp) {
@@ -918,8 +916,7 @@  static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
                 ret = AVERROR_INVALIDDATA;
                 goto err;
             } else { // found field marker, unescape second field
-                if (avctx->hwaccel)
-                    buf_start_second_field = divider;
+                buf_start_second_field = divider;
                 av_size_mult(sizeof(*slices), n_slices+1, &next_allocated);
                 tmp = next_allocated ? av_fast_realloc(slices, &slices_allocated, next_allocated) : NULL;
                 if (!tmp) {