The median predictor initialization used p->data[plane][0], which only
reads the low byte of 16-bit samples. For >8bpp formats that made the
initial predictor value endian-dependent and produced different bitstreams
on big vs little endian.

Read the full 16-bit sample when bps > 8 in both encoder and decoder,
then update the ffvhuff420p12 vsynth references to match the corrected,
endian-neutral output.

Signed-off-by: jfiusdq <[email protected]>
---
 libavcodec/huffyuvdec.c                    | 5 ++++-
 libavcodec/huffyuvenc.c                    | 5 ++++-
 tests/ref/vsynth/vsynth1-ffvhuff420p12     | 4 ++--
 tests/ref/vsynth/vsynth2-ffvhuff420p12     | 4 ++--
 tests/ref/vsynth/vsynth3-ffvhuff420p12     | 4 ++--
 tests/ref/vsynth/vsynth_lena-ffvhuff420p12 | 4 ++--
 6 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index c98904d497..7b79ee7754 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -987,7 +987,10 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, 
int height,
                         break;
                 }
 
-                lefttop = p->data[plane][0];
+                if (s->bps <= 8)
+                    lefttop = p->data[plane][0];
+                else
+                    lefttop = ((const uint16_t *)p->data[plane])[0];
                 decode_plane_bitstream(s, w, plane);
                 add_median_prediction(s, p->data[plane] + fake_stride, 
p->data[plane], s->temp[0], w, &left, &lefttop);
                 y++;
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index b213d4dc95..aa3de97e39 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -909,7 +909,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
                     y++;
                 }
 
-                lefttop = p->data[plane][0];
+                if (s->bps <= 8)
+                    lefttop = p->data[plane][0];
+                else
+                    lefttop = ((const uint16_t *)p->data[plane])[0];
 
                 for (; y < h; y++) {
                     const uint8_t *dst = p->data[plane] + p->linesize[plane] * 
y;
diff --git a/tests/ref/vsynth/vsynth1-ffvhuff420p12 
b/tests/ref/vsynth/vsynth1-ffvhuff420p12
index 72ff82c006..1a967dad75 100644
--- a/tests/ref/vsynth/vsynth1-ffvhuff420p12
+++ b/tests/ref/vsynth/vsynth1-ffvhuff420p12
@@ -1,4 +1,4 @@
-6210a990bd25c2dcbc72beafe1f806e2 *tests/data/fate/vsynth1-ffvhuff420p12.avi
-12961816 tests/data/fate/vsynth1-ffvhuff420p12.avi
+3691cf99f8055b31ceb0be79e7637803 *tests/data/fate/vsynth1-ffvhuff420p12.avi
+12961884 tests/data/fate/vsynth1-ffvhuff420p12.avi
 c5ccac874dbf808e9088bc3107860042 
*tests/data/fate/vsynth1-ffvhuff420p12.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-ffvhuff420p12 
b/tests/ref/vsynth/vsynth2-ffvhuff420p12
index 328f05fd38..d14f07da88 100644
--- a/tests/ref/vsynth/vsynth2-ffvhuff420p12
+++ b/tests/ref/vsynth/vsynth2-ffvhuff420p12
@@ -1,4 +1,4 @@
-29460ef3dd44f72e5f4e90316ac798b8 *tests/data/fate/vsynth2-ffvhuff420p12.avi
-9977204 tests/data/fate/vsynth2-ffvhuff420p12.avi
+6bb029f07150008ac655787d350d811a *tests/data/fate/vsynth2-ffvhuff420p12.avi
+9977276 tests/data/fate/vsynth2-ffvhuff420p12.avi
 36d7ca943916e1743cefa609eba0205c 
*tests/data/fate/vsynth2-ffvhuff420p12.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-ffvhuff420p12 
b/tests/ref/vsynth/vsynth3-ffvhuff420p12
index 19290b7ffb..b82dd3c077 100644
--- a/tests/ref/vsynth/vsynth3-ffvhuff420p12
+++ b/tests/ref/vsynth/vsynth3-ffvhuff420p12
@@ -1,4 +1,4 @@
-592f3643ba063499c1c477765c08f630 *tests/data/fate/vsynth3-ffvhuff420p12.avi
-161128 tests/data/fate/vsynth3-ffvhuff420p12.avi
+e39b27c7461eedb0c222746a6b133714 *tests/data/fate/vsynth3-ffvhuff420p12.avi
+161152 tests/data/fate/vsynth3-ffvhuff420p12.avi
 a038ad7c3c09f776304ef7accdea9c74 
*tests/data/fate/vsynth3-ffvhuff420p12.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth_lena-ffvhuff420p12 
b/tests/ref/vsynth/vsynth_lena-ffvhuff420p12
index 96ab396c26..9e908d44c2 100644
--- a/tests/ref/vsynth/vsynth_lena-ffvhuff420p12
+++ b/tests/ref/vsynth/vsynth_lena-ffvhuff420p12
@@ -1,4 +1,4 @@
-0930b3d622b78d3c13e80222f95b0be2 *tests/data/fate/vsynth_lena-ffvhuff420p12.avi
-9901820 tests/data/fate/vsynth_lena-ffvhuff420p12.avi
+26018d57e1fa92ef04857e40e8a7e36a *tests/data/fate/vsynth_lena-ffvhuff420p12.avi
+9901856 tests/data/fate/vsynth_lena-ffvhuff420p12.avi
 dde5895817ad9d219f79a52d0bdfb001 
*tests/data/fate/vsynth_lena-ffvhuff420p12.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
-- 
2.47.3


_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to