summaryrefslogtreecommitdiffstats
path: root/multimedia/ffmpeg/patches/124-v4l2-request-vc1-04.patch
blob: 2d8c1bc02e498b4cf2ecd9cda76e9be8fed4e9c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From 9632e3bf306d269c771cd80ce924442db899e61b Mon Sep 17 00:00:00 2001
From: Jernej Skrabec <jernej.skrabec@siol.net>
Date: Thu, 8 Oct 2026 18:40:00 +0200
Subject: [PATCH 4/5] avcodec/vc1: size the bitplanes of reduced resolution
 pictures

A Simple or Main profile picture of a MULTIRES sequence may be coded at
half the width and/or half the height of the sequence (RESPIC). Its
bitplanes have one bit per macroblock of the picture as coded, so
decoding them with the macroblock size of the sequence reads the wrong
number of bits and desyncs the rest of the picture header.

The macroblock layer of such pictures is still decoded at the size of
the sequence, which this does not change, but the header is now parsed
correctly, which is what hardware decoders need.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
OpenWrt: patch 4/5 of LibreELEC's
packages/multimedia/ffmpeg/patches/v4l2-request/0002-v4l2-request-vc1.patch
(LibreELEC commit d38b323eea). Not in FFmpeg 9.1.

 libavcodec/vc1.c | 7 +++++++
 1 file changed, 7 insertions(+)

--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -103,6 +103,13 @@ static int bitplane_decoding(uint8_t* da
 
     width  = v->s.mb_width;
     height = v->s.mb_height >> v->field_mode;
+    /* RESPIC: Simple/Main picture coded at half width and/or height */
+    if (v->profile < PROFILE_ADVANCED && v->multires) {
+        if (v->respic & 1)
+            width  = (v->s.width  / 2 + 15) >> 4;
+        if (v->respic & 2)
+            height = (v->s.height / 2 + 15) >> 4;
+    }
     stride = v->s.mb_stride;
     invert = get_bits1(gb);
     imode = get_vlc2(gb, ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 1);