[FFmpeg-cvslog] swscale/aarch64: dotprod implementation of rgba32_to_Y

2025-03-04 Thread Krzysztof Pyrkosz
ffmpeg | branch: master | Krzysztof Pyrkosz  | Mon Mar  3 
22:00:23 2025 +0100| [d765e5f043d981294303fe210d643c5156efeeb3] | committer: 
Martin Storsjö

swscale/aarch64: dotprod implementation of rgba32_to_Y

The idea is to split the 16 bit coefficients into lower and upper half,
invoke udot for the lower half, shift by 8, and follow by udot for the
upper half.

Benchmark on A78:
bgra_to_y_128_c:   682.0 ( 1.00x)
bgra_to_y_128_neon:181.2 ( 3.76x)
bgra_to_y_128_dotprod: 117.8 ( 5.79x)
bgra_to_y_1080_c: 5742.5 ( 1.00x)
bgra_to_y_1080_neon:  1472.5 ( 3.90x)
bgra_to_y_1080_dotprod:906.5 ( 6.33x)
bgra_to_y_1920_c:10194.0 ( 1.00x)
bgra_to_y_1920_neon:  2589.8 ( 3.94x)
bgra_to_y_1920_dotprod:   1573.8 ( 6.48x)

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d765e5f043d981294303fe210d643c5156efeeb3
---

 libswscale/aarch64/input.S   | 88 
 libswscale/aarch64/swscale.c | 17 +
 2 files changed, 105 insertions(+)

diff --git a/libswscale/aarch64/input.S b/libswscale/aarch64/input.S
index 5cb18711fb..c1c0adffc8 100644
--- a/libswscale/aarch64/input.S
+++ b/libswscale/aarch64/input.S
@@ -313,3 +313,91 @@ rgbToUV_neon bgr24, rgb24, element=3
 rgbToUV_neon bgra32, rgba32, element=4
 
 rgbToUV_neon abgr32, argb32, element=4, alpha_first=1
+
+#if HAVE_DOTPROD
+ENABLE_DOTPROD
+
+function ff_bgra32ToY_neon_dotprod, export=1
+cmp w4, #0  // check width > 0
+ldp w12, w11, [x5]  // w12: ry, w11: gy
+ldr w10, [x5, #8]   // w10: by
+b.gt4f
+ret
+endfunc
+
+function ff_rgba32ToY_neon_dotprod, export=1
+cmp w4, #0  // check width > 0
+ldp w10, w11, [x5]  // w10: ry, w11: gy
+ldr w12, [x5, #8]   // w12: by
+b.le3f
+4:
+mov w9, #256// w9 = 1 << (RGB2YUV_SHIFT - 
7)
+movkw9, #8, lsl #16 // w9 += 32 << (RGB2YUV_SHIFT 
- 1)
+dup v6.4s, w9   // w9: const_offset
+
+cmp w4, #16
+mov w7, w10
+bfi w7, w11, 8, 8   // the bfi instructions are 
used to assemble
+bfi w7, w12, 16, 8  // 4 byte r,g,b,0 mask to be 
then used by udot.
+dup v0.4s, w7   // v0 holds the lower byte of 
each coefficient
+
+lsr w6, w10, #8
+lsr w7, w11, #8
+lsr w8, w12, #8
+
+bfi w6, w7, 8, 8
+bfi w6, w8, 16, 8
+dup v1.4s, w6   // v1 holds the upper byte of 
each coefficient
+b.lt2f
+1:
+ld1 { v16.16b, v17.16b, v18.16b, v19.16b }, [x1], #64
+sub w4, w4, #16 // width -= 16
+
+mov v2.16b, v6.16b
+mov v3.16b, v6.16b
+mov v4.16b, v6.16b
+mov v5.16b, v6.16b
+cmp w4, #16 // width >= 16 ?
+
+udotv2.4s, v16.16b, v0.16b
+udotv3.4s, v17.16b, v0.16b
+udotv4.4s, v18.16b, v0.16b
+udotv5.4s, v19.16b, v0.16b
+
+ushrv2.4s, v2.4s, #8
+ushrv3.4s, v3.4s, #8
+ushrv4.4s, v4.4s, #8
+ushrv5.4s, v5.4s, #8
+
+udotv2.4s, v16.16b, v1.16b
+udotv3.4s, v17.16b, v1.16b
+udotv4.4s, v18.16b, v1.16b
+udotv5.4s, v19.16b, v1.16b
+
+sqshrn  v16.4h, v2.4s, #1
+sqshrn2 v16.8h, v3.4s, #1
+sqshrn  v17.4h, v4.4s, #1
+sqshrn2 v17.8h, v5.4s, #1
+
+stp q16, q17, [x0], #32 // store to dst
+b.ge1b
+cbz x4, 3f
+2:
+ldrbw13, [x1]   // w13: r
+ldrbw14, [x1, #1]   // w14: g
+ldrbw15, [x1, #2]   // w15: b
+
+smaddl  x13, w13, w10, x9   // x13 = ry * r + const_offset
+smaddl  x13, w14, w11, x13  // x13 += gy * g
+smaddl  x13, w15, w12, x13  // x13 += by * b
+asr w13, w13, #9// x13 >>= 9
+sub w4, w4, #1  // width--
+add x1, x1, #4
+strhw13, [x0], #2   // stor

[FFmpeg-cvslog] avcodec/aarch64/vvc: Optimize NEON version of vvc_dmvr

2025-03-04 Thread Krzysztof Pyrkosz
ffmpeg | branch: master | Krzysztof Pyrkosz  | Mon Mar  3 
22:32:55 2025 +0100| [71a91485fa05c1ca478de153d8839794606f8edc] | committer: 
Martin Storsjö

avcodec/aarch64/vvc: Optimize NEON version of vvc_dmvr

This patch replaces blocks of instructions performing rounding and
widening shifts with one-liners achieving the same result.

Before and after on A78
dmvr_8_12x20_neon:  86.2 ( 6.90x)
dmvr_8_20x12_neon:  94.8 ( 5.93x)
dmvr_8_20x20_neon: 141.5 ( 6.50x)
dmvr_12_12x20_neon:158.0 ( 3.76x)
dmvr_12_20x12_neon:151.2 ( 3.73x)
dmvr_12_20x20_neon:247.2 ( 3.71x)
dmvr_hv_8_12x20_neon:  423.2 ( 3.75x)
dmvr_hv_8_20x12_neon:  434.0 ( 3.69x)
dmvr_hv_8_20x20_neon:  706.0 ( 3.69x)

dmvr_8_12x20_neon:  77.2 ( 7.70x)
dmvr_8_20x12_neon:  66.5 ( 8.49x)
dmvr_8_20x20_neon:  92.2 ( 9.90x)
dmvr_12_12x20_neon: 80.2 ( 7.38x)
dmvr_12_20x12_neon: 58.2 ( 9.59x)
dmvr_12_20x20_neon: 90.0 (10.15x)
dmvr_hv_8_12x20_neon:  369.0 ( 4.34x)
dmvr_hv_8_20x12_neon:  355.8 ( 4.49x)
dmvr_hv_8_20x20_neon:  574.2 ( 4.51x)

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71a91485fa05c1ca478de153d8839794606f8edc
---

 libavcodec/aarch64/vvc/inter.S | 72 --
 1 file changed, 20 insertions(+), 52 deletions(-)

diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S
index 0edc861f97..967edb7f35 100644
--- a/libavcodec/aarch64/vvc/inter.S
+++ b/libavcodec/aarch64/vvc/inter.S
@@ -251,22 +251,18 @@ function ff_vvc_dmvr_8_neon, export=1
 1:
 cbz w15, 2f
 ldr q0, [src], #16
-uxtlv1.8h, v0.8b
-uxtl2   v2.8h, v0.16b
-ushlv1.8h, v1.8h, v16.8h
-ushlv2.8h, v2.8h, v16.8h
+ushll   v1.8h, v0.8b, #2
+ushll2  v2.8h, v0.16b, #2
 stp q1, q2, [dst], #32
 b   3f
 2:
 ldr d0, [src], #8
-uxtlv1.8h, v0.8b
-ushlv1.8h, v1.8h, v16.8h
+ushll   v1.8h, v0.8b, #2
 str q1, [dst], #16
 3:
 subsheight, height, #1
 ldr s3, [src], #4
-uxtlv4.8h, v3.8b
-ushlv4.4h, v4.4h, v16.4h
+ushll   v4.8h, v3.8b, #2
 st1 {v4.4h}, [dst], x7
 
 add src, src, src_stride
@@ -281,42 +277,24 @@ function ff_vvc_dmvr_12_neon, export=1
 cmp width, #16
 sub src_stride, src_stride, x6, lsl #1
 csetw15, gt // width > 16
-moviv16.8h, #2  // offset4
 sub x7, x7, x6, lsl #1
 1:
 cbz w15, 2f
 ldp q0, q1, [src], #32
-uaddl   v2.4s, v0.4h, v16.4h
-uaddl2  v3.4s, v0.8h, v16.8h
-uaddl   v4.4s, v1.4h, v16.4h
-uaddl2  v5.4s, v1.8h, v16.8h
-ushrv2.4s, v2.4s, #2
-ushrv3.4s, v3.4s, #2
-ushrv4.4s, v4.4s, #2
-ushrv5.4s, v5.4s, #2
-uqxtn   v2.4h, v2.4s
-uqxtn2  v2.8h, v3.4s
-uqxtn   v4.4h, v4.4s
-uqxtn2  v4.8h, v5.4s
-
-stp q2, q4, [dst], #32
+urshr   v0.8h, v0.8h, #2
+urshr   v1.8h, v1.8h, #2
+
+stp q0, q1, [dst], #32
 b   3f
 2:
 ldr q0, [src], #16
-uaddl   v2.4s, v0.4h, v16.4h
-uaddl2  v3.4s, v0.8h, v16.8h
-ushrv2.4s, v2.4s, #2
-ushrv3.4s, v3.4s, #2
-uqxtn   v2.4h, v2.4s
-uqxtn2  v2.8h, v3.4s
-str q2, [dst], #16
+urshr   v0.8h, v0.8h, #2
+str q0, [dst], #16
 3:
 subsheight, height, #1
 ldr d0, [src], #8
-uaddl   v3.4s, v0.4h, v16.4h
-ushrv3.4s, v3.4s, #2
-uqxtn   v3.4h, v3.4s
-st1 {v3.4h}, [dst], x7
+urshr   v0.4h, v0.4h, #2
+st1 {v0.4h}, [dst], x7
 
 add src, src, src_stride
 b.ne

[FFmpeg-cvslog] avcodec/h26[134]dec: Always report the buffer to be completely consumed

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 24 19:30:27 2025 +0100| [e6657d499a6ec5731da5692515b605493a819249] | 
committer: Andreas Rheinhardt

avcodec/h26[134]dec: Always report the buffer to be completely consumed

It is pointless to try to report the true number because
decode_simple_internal() always treats the buffer as
completely consumed for video codecs anyway.
(Apart from that: The h263dec code would report to only
have consumed the header data in case decoding is aborted
due to skip_frame which makes no sense.)

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e6657d499a6ec5731da5692515b605493a819249
---

 libavcodec/h261dec.c | 16 +---
 libavcodec/h263dec.c | 31 ---
 libavcodec/h264dec.c | 15 +--
 3 files changed, 6 insertions(+), 56 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 116f1d43b2..8a2c4d35b4 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -536,20 +536,6 @@ static int h261_decode_gob(H261DecContext *h)
 return -1;
 }
 
-/**
- * returns the number of bytes consumed for building the current frame
- */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size)
-{
-int pos = get_bits_count(&s->gb) >> 3;
-if (pos == 0)
-pos = 1;  // avoid infinite loops (i doubt that is needed but ...)
-if (pos + 10 > buf_size)
-pos = buf_size;   // oops ;)
-
-return pos;
-}
-
 static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict,
  int *got_frame, AVPacket *avpkt)
 {
@@ -615,7 +601,7 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 
 *got_frame = 1;
 
-return get_consumed_bytes(s, buf_size);
+return buf_size;
 }
 
 const FFCodec ff_h261_decoder = {
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 452641e408..fa1146f025 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -170,29 +170,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 return 0;
 }
 
-/**
- * Return the number of bytes consumed for building the current frame.
- */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size)
-{
-int pos = (get_bits_count(&s->gb) + 7) >> 3;
-
-if (s->divx_packed || s->avctx->hwaccel) {
-/* We would have to scan through the whole buf to handle the weird
- * reordering ... */
-return buf_size;
-} else {
-// avoid infinite loops (maybe not needed...)
-if (pos == 0)
-pos = 1;
-// oops ;)
-if (pos + 10 > buf_size)
-pos = buf_size;
-
-return pos;
-}
-}
-
 static int decode_slice(MpegEncContext *s)
 {
 const int part_mask = s->partitioned_frame
@@ -523,7 +500,7 @@ retry:
 }
 }
 if (ret == FRAME_SKIPPED)
-return get_consumed_bytes(s, buf_size);
+return buf_size;
 
 /* skip if the header was thrashed */
 if (ret < 0) {
@@ -587,13 +564,13 @@ retry:
 /* skip B-frames if we don't have reference frames */
 if (!s->last_pic.ptr &&
 (s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
-return get_consumed_bytes(s, buf_size);
+return buf_size;
 if ((avctx->skip_frame >= AVDISCARD_NONREF &&
  s->pict_type == AV_PICTURE_TYPE_B)||
 (avctx->skip_frame >= AVDISCARD_NONKEY &&
  s->pict_type != AV_PICTURE_TYPE_I)||
 avctx->skip_frame >= AVDISCARD_ALL)
-return get_consumed_bytes(s, buf_size);
+return buf_size;
 
 if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
 return ret;
@@ -702,7 +679,7 @@ frame_end:
 if (slice_ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
 return slice_ret;
 else
-return get_consumed_bytes(s, buf_size);
+return buf_size;
 }
 
 static const AVCodecHWConfigInternal *const h263_hw_config_list[] = {
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 45ebe2656d..fd401027d6 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -827,19 +827,6 @@ end:
 return (ret < 0) ? ret : buf_size;
 }
 
-/**
- * Return the number of bytes consumed for building the current frame.
- */
-static int get_consumed_bytes(int pos, int buf_size)
-{
-if (pos == 0)
-pos = 1;// avoid infinite loops (I doubt that is needed but...)
-if (pos + 10 > buf_size)
-pos = buf_size; // oops ;)
-
-return pos;
-}
-
 static int h264_export_enc_params(AVFrame *f, const H264Picture *p)
 {
 AVVideoEncParams *par;
@@ -1100,7 +1087,7 @@ static int h264_decode_frame(AVCodecContext *avctx, 
AVFrame *pict,
 
 ff_h264_unref_picture(&h->last_pic_for_ec);
 
-return get_consumed_bytes(buf_index, buf_size);
+return buf_size;
 }
 
 #define OFFSET(x) offsetof(H264Context, x)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffm

[FFmpeg-cvslog] avcodec/mpegvideo: Move bitstream_buffer to mpeg4videodec

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 25 00:48:08 2025 +0100| [e3ebc1073e06b87ecf110476194c88c4af9b181f] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move bitstream_buffer to mpeg4videodec

This is possible by moving the code using it to open a GetBitContext
from h263dec.c to mpeg4videodec.c.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3ebc1073e06b87ecf110476194c88c4af9b181f
---

 libavcodec/h263dec.c   | 25 ++-
 libavcodec/mpeg4video_parser.c |  4 +-
 libavcodec/mpeg4videodec.c | 95 --
 libavcodec/mpeg4videodec.h |  8 +++-
 libavcodec/mpegvideo.c |  5 ---
 libavcodec/mpegvideo.h |  3 --
 libavcodec/mpegvideo_dec.c |  3 --
 7 files changed, 85 insertions(+), 58 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 2d8c200589..84895a93d4 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -446,26 +446,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 }
 
 retry:
-if (s->divx_packed && s->bitstream_buffer_size) {
-int i;
-for(i=0; i < buf_size-3; i++) {
-if (buf[i]==0 && buf[i+1]==0 && buf[i+2]==1) {
-if (buf[i+3]==0xB0) {
-av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive 
bitstream in packed xvid\n");
-s->bitstream_buffer_size = 0;
-}
-break;
-}
-}
-}
-
-if (s->bitstream_buffer_size && (s->divx_packed || buf_size <= 
MAX_NVOP_SIZE)) // divx 5.01+/xvid frame reorder
-ret = init_get_bits8(&s->gb, s->bitstream_buffer,
- s->bitstream_buffer_size);
-else
-ret = init_get_bits8(&s->gb, buf, buf_size);
-
-s->bitstream_buffer_size = 0;
+// s->gb might be overridden in ff_mpeg4_decode_picture_header() below.
+ret = init_get_bits8(&s->gb, buf, buf_size);
 if (ret < 0)
 return ret;
 
@@ -480,7 +462,7 @@ retry:
 ret = ff_msmpeg4_decode_picture_header(s);
 #endif
 } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
-ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0);
+ret = ff_mpeg4_decode_picture_header(s);
 s->skipped_last_frame = (ret == FRAME_SKIPPED);
 } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
 ret = ff_intel_h263_decode_picture_header(s);
@@ -631,7 +613,6 @@ retry:
 ff_msmpeg4_decode_ext_header(s, buf_size) < 0)
 s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
 
-av_assert1(s->bitstream_buffer_size == 0);
 frame_end:
 if (!s->studio_profile)
 ff_er_frame_end(&s->er, NULL);
diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c
index b00b523bde..ef9ea923f6 100644
--- a/libavcodec/mpeg4video_parser.c
+++ b/libavcodec/mpeg4video_parser.c
@@ -92,13 +92,13 @@ static int mpeg4_decode_header(AVCodecParserContext *s1, 
AVCodecContext *avctx,
 
 if (avctx->extradata_size && pc->first_picture) {
 init_get_bits(gb, avctx->extradata, avctx->extradata_size * 8);
-ret = ff_mpeg4_decode_picture_header(dec_ctx, gb, 1, 1);
+ret = ff_mpeg4_parse_picture_header(dec_ctx, gb, 1, 1);
 if (ret < 0)
 av_log(avctx, AV_LOG_WARNING, "Failed to parse extradata\n");
 }
 
 init_get_bits(gb, buf, 8 * buf_size);
-ret = ff_mpeg4_decode_picture_header(dec_ctx, gb, 0, 1);
+ret = ff_mpeg4_parse_picture_header(dec_ctx, gb, 0, 1);
 if (s->width && (!avctx->width || !avctx->height ||
  !avctx->coded_width || !avctx->coded_height)) {
 ret = ff_set_dimensions(avctx, s->width, s->height);
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 14e4de9a45..e2ae09125a 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -25,6 +25,7 @@
 #include "config_components.h"
 
 #include "libavutil/internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "codec_internal.h"
@@ -3463,8 +3464,8 @@ static int decode_studiovisualobject(Mpeg4DecContext 
*ctx, GetBitContext *gb)
  * FRAME_SKIPPED if a not coded VOP is found
  * 0 else
  */
-int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb,
-   int header, int parse_only)
+int ff_mpeg4_parse_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb,
+  int header, int parse_only)
 {
 MpegEncContext *s = &ctx->m;
 unsigned startcode, v;
@@ -3621,16 +3622,50 @@ end:
 return decode_vop_header(ctx, gb, parse_only);
 }
 
+int ff_mpeg4_decode_picture_header(MpegEncContext *s)
+{
+Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
+
+if (ctx->bitstream_buffer_size) {
+int buf_size = get_bit

[FFmpeg-cvslog] avcodec/mpegvideo_dec: Move syncing DivX-stuff to mpeg4videodec.c

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 24 17:47:22 2025 +0100| [920217975407bcb9f9ca9ab98a2e2dcb3a98e05a] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Move syncing DivX-stuff to mpeg4videodec.c

It is only used by MPEG-4 (and is used in h263dec.c and can therefore
not just be moved to Mpeg4DecContext...).

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=920217975407bcb9f9ca9ab98a2e2dcb3a98e05a
---

 libavcodec/mpeg4videodec.c | 14 ++
 libavcodec/mpegvideo_dec.c | 16 
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index debcafc4c0..14e4de9a45 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3699,6 +3699,7 @@ static int mpeg4_update_thread_context(AVCodecContext 
*dst,
 s->enhancement_type  = s1->enhancement_type;
 s->scalability   = s1->scalability;
 s->intra_dc_threshold= s1->intra_dc_threshold;
+s->m.divx_packed = s1->m.divx_packed;
 s->divx_version  = s1->divx_version;
 s->divx_build= s1->divx_build;
 s->xvid_build= s1->xvid_build;
@@ -3714,6 +3715,19 @@ static int mpeg4_update_thread_context(AVCodecContext 
*dst,
 memcpy(s->sprite_shift, s1->sprite_shift, sizeof(s1->sprite_shift));
 memcpy(s->sprite_traj,  s1->sprite_traj,  sizeof(s1->sprite_traj));
 
+if (s1->m.bitstream_buffer) {
+av_fast_padded_malloc(&s->m.bitstream_buffer,
+  &s->m.allocated_bitstream_buffer_size,
+  s1->m.bitstream_buffer_size);
+if (!s->m.bitstream_buffer) {
+s->m.bitstream_buffer_size = 0;
+return AVERROR(ENOMEM);
+}
+s->m.bitstream_buffer_size = s1->m.bitstream_buffer_size;
+memcpy(s->m.bitstream_buffer, s1->m.bitstream_buffer,
+   s1->m.bitstream_buffer_size);
+}
+
 if (!init && s1->xvid_build >= 0)
 ff_xvid_idct_init(&s->m.idsp, dst);
 
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index ebbbc1df8b..8d4ba341d5 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -136,22 +136,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
 // B-frame info
 s->low_delay= s1->low_delay;
 
-// DivX handling (doesn't work)
-s->divx_packed  = s1->divx_packed;
-
-if (s1->bitstream_buffer) {
-av_fast_padded_malloc(&s->bitstream_buffer,
-  &s->allocated_bitstream_buffer_size,
-  s1->bitstream_buffer_size);
-if (!s->bitstream_buffer) {
-s->bitstream_buffer_size = 0;
-return AVERROR(ENOMEM);
-}
-s->bitstream_buffer_size = s1->bitstream_buffer_size;
-memcpy(s->bitstream_buffer, s1->bitstream_buffer,
-   s1->bitstream_buffer_size);
-}
-
 // MPEG-2/interlacing info
 memcpy(&s->progressive_sequence, &s1->progressive_sequence,
(char *) &s1->rtp_mode - (char *) &s1->progressive_sequence);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/vc1: Add max_b_frames field to VC1Context

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 24 19:05:32 2025 +0100| [1adc84136e499302a787537dbc9323c4abb647bf] | 
committer: Andreas Rheinhardt

avcodec/vc1: Add max_b_frames field to VC1Context

Don't reuse MpegEncContext.max_b_frames, which is supposed
to be encoder-only.

Reviewed-by: Ramiro Polla 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1adc84136e499302a787537dbc9323c4abb647bf
---

 libavcodec/dxva2_vc1.c | 2 +-
 libavcodec/mss2.c  | 2 +-
 libavcodec/nvdec_vc1.c | 2 +-
 libavcodec/vc1.c   | 4 ++--
 libavcodec/vc1.h   | 1 +
 libavcodec/vdpau_vc1.c | 2 +-
 6 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index bc9ad9648e..a7b440c0d9 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -117,7 +117,7 @@ void ff_dxva2_vc1_fill_picture_parameters(AVCodecContext 
*avctx,
   (v->multires   << 5) |
   (v->resync_marker  << 4) |
   (v->rangered   << 3) |
-  (s->max_b_frames   );
+  (v->max_b_frames   );
 pp->bPicExtrapolation   = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 
: 2;
 pp->bPicDeblocked   = ((!pp->bPicBackwardPrediction && v->overlap) 
   << 6) |
   ((v->profile != PROFILE_ADVANCED && 
v->rangeredfrm) << 5) |
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 1888053eb2..74a25b3e55 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -844,7 +844,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
 v->resync_marker   = 0;
 v->rangered= 0;
 
-v->s.max_b_frames = avctx->max_b_frames = 0;
+v->max_b_frames= avctx->max_b_frames = 0;
 v->quantizer_mode = 0;
 
 v->finterpflag = 0;
diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c
index 0668863cb4..fbfba1ecb4 100644
--- a/libavcodec/nvdec_vc1.c
+++ b/libavcodec/nvdec_vc1.c
@@ -84,7 +84,7 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const 
uint8_t *buffer, u
 .multires  = v->multires,
 .syncmarker= v->resync_marker,
 .rangered  = v->rangered,
-.maxbframes= s->max_b_frames,
+.maxbframes= v->max_b_frames,
 
 .panscan_flag  = v->panscanflag,
 .refdist_flag  = v->refdist_flag,
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index d263c70be7..dec3e16ea2 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -343,7 +343,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, 
VC1Context *v, GetBitCo
"RANGERED should be set to 0 in Simple Profile\n");
 }
 
-v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common
+v->max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common
 v->quantizer_mode = get_bits(gb, 2); //common
 
 v->finterpflag = get_bits1(gb); //common
@@ -431,7 +431,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: 
not supported (yet)\n");
 return -1;
 }
-v->s.max_b_frames = v->s.avctx->max_b_frames = 7;
+v->max_b_frames = v->s.avctx->max_b_frames = 7;
 if (get_bits1(gb)) { //Display Info - decoding is not affected by it
 int w, h, ar = 0;
 av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n");
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 185236662f..b7339bcd5f 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -222,6 +222,7 @@ typedef struct VC1Context{
 int dquant;   ///< How qscale varies with MBs, 2 bits (not in 
Simple)
 int vstransform;  ///< variable-size [48]x[48] transform type + info
 int overlap;  ///< overlapped transforms in use
+int max_b_frames; ///< max number of B-frames
 int quantizer_mode;   ///< 2 bits, quantizer mode used for sequence, see 
QUANT_*
 int finterpflag;  ///< INTERPFRM present
 //@}
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
index d02a454bb8..20208c6dbc 100644
--- a/libavcodec/vdpau_vc1.c
+++ b/libavcodec/vdpau_vc1.c
@@ -92,7 +92,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
 info->multires  = v->multires;
 info->syncmarker= v->resync_marker;
 info->rangered  = v->rangered | (v->rangeredfrm << 1);
-info->maxbframes= v->s.max_b_frames;
+info->maxbframes= v->max_b_frames;
 info->deblockEnable = v->postprocflag & 1;
 info->pquant= v->pq;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscr

[FFmpeg-cvslog] avcodec/h263dec: Don't call ff_thread_finish_setup() unnecessarily

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 24 22:16:36 2025 +0100| [e4470a8e30de8af6150b4a78ea0637ca7d62b824] | 
committer: Andreas Rheinhardt

avcodec/h263dec: Don't call ff_thread_finish_setup() unnecessarily

All hwaccels for MPEG-4/H.263 are run serially even when frame-threading
is in use. Therefore there is no gain in calling
ff_thread_finish_setup() in this case right before outputting
the frame.

Removing this call also allows to revert commit
39a5c0ac0651113750d01f3ee6bcf3819de3d7ee.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e4470a8e30de8af6150b4a78ea0637ca7d62b824
---

 libavcodec/h263dec.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index fa1146f025..2d8c200589 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -575,7 +575,7 @@ retry:
 if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
 return ret;
 
-if (!s->divx_packed && !avctx->hwaccel)
+if (!s->divx_packed)
 ff_thread_finish_setup(avctx);
 
 if (avctx->hwaccel) {
@@ -647,9 +647,6 @@ frame_end:
 if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4)
 ff_mpeg4_frame_end(avctx, buf, buf_size);
 
-if (!s->divx_packed && avctx->hwaccel)
-ff_thread_finish_setup(avctx);
-
 av_assert1(s->pict_type == s->cur_pic.ptr->f->pict_type);
 if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
 if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg4videoenc: Remove dead FF_BUG_MS code

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 24 19:09:32 2025 +0100| [78b26225bac58a8c959d8d180a7a376c21b4bbe3] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videoenc: Remove dead FF_BUG_MS code

Added in 59fa3f96f48d12e189492ca3670991f91c316d4e,
yet avctx->workaround_bugs is never copied to
MpegEncContext.workaround_bugs, so this code is dead
(it seems that this was true even when it was added).
Furthermore, workaround_bugs is flagged as decoder-only,
so just remove the code.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=78b26225bac58a8c959d8d180a7a376c21b4bbe3
---

 libavcodec/mpeg4videoenc.c | 28 +---
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index bc5375002a..0b31576dc5 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -968,13 +968,9 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
 
 put_bits(&s->pb, 1, 0); /* random access vol */
 put_bits(&s->pb, 8, vo_type);   /* video obj type indication */
-if (s->workaround_bugs & FF_BUG_MS) {
-put_bits(&s->pb, 1, 0); /* is obj layer id= no */
-} else {
-put_bits(&s->pb, 1, 1); /* is obj layer id= yes */
-put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */
-put_bits(&s->pb, 3, 1); /* is obj layer priority */
-}
+put_bits(&s->pb, 1, 1); /* is obj layer id= yes */
+put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */
+put_bits(&s->pb, 3, 1); /* is obj layer priority */
 
 aspect_ratio_info = ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
 
@@ -986,14 +982,10 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
 put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
 }
 
-if (s->workaround_bugs & FF_BUG_MS) {
-put_bits(&s->pb, 1, 0); /* vol control parameters= no @@@ */
-} else {
-put_bits(&s->pb, 1, 1); /* vol control parameters= yes */
-put_bits(&s->pb, 2, 1); /* chroma format YUV 420/YV12 */
-put_bits(&s->pb, 1, s->low_delay);
-put_bits(&s->pb, 1, 0); /* vbv parameters= no */
-}
+put_bits(&s->pb, 1, 1); /* vol control parameters= yes */
+put_bits(&s->pb, 2, 1); /* chroma format YUV 420/YV12 */
+put_bits(&s->pb, 1, s->low_delay);
+put_bits(&s->pb, 1, 0); /* vbv parameters= no */
 
 put_bits(&s->pb, 2, RECT_SHAPE);/* vol shape= rectangle */
 put_bits(&s->pb, 1, 1); /* marker bit */
@@ -1059,8 +1051,7 @@ int ff_mpeg4_encode_picture_header(MpegEncContext *s)
 if (s->avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || 
s->picture_number == 0)  // HACK, the reference sw is buggy
 mpeg4_encode_vol_header(s, 0, 0);
 }
-if (!(s->workaround_bugs & FF_BUG_MS))
-mpeg4_encode_gop_header(s);
+mpeg4_encode_gop_header(s);
 }
 
 s->partitioned_frame = s->data_partitioning && s->pict_type != 
AV_PICTURE_TYPE_B;
@@ -1300,8 +1291,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 return AVERROR(ENOMEM);
 init_put_bits(&s->pb, s->avctx->extradata, 1024);
 
-if (!(s->workaround_bugs & FF_BUG_MS))
-mpeg4_encode_visual_object_header(s);
+mpeg4_encode_visual_object_header(s);
 mpeg4_encode_vol_header(s, 0, 0);
 
 //ff_mpeg4_stuffing(&s->pb); ?

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg4videodec: Avoid copying packed bitstream data

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 25 16:21:07 2025 +0100| [4f2becc2dc4668f837b5ba96c11c3426bc120ac0] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Avoid copying packed bitstream data

This is possible because the packet is reference-counted
and because we never combine the data from several packets.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f2becc2dc4668f837b5ba96c11c3426bc120ac0
---

 libavcodec/h263dec.c   |  2 +-
 libavcodec/mpeg4videodec.c | 57 +-
 libavcodec/mpeg4videodec.h |  7 +++---
 3 files changed, 25 insertions(+), 41 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 84895a93d4..9ccdd914ce 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -626,7 +626,7 @@ frame_end:
 ff_mpv_frame_end(s);
 
 if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4)
-ff_mpeg4_frame_end(avctx, buf, buf_size);
+ff_mpeg4_frame_end(avctx, avpkt);
 
 av_assert1(s->pict_type == s->cur_pic.ptr->f->pict_type);
 if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index e2ae09125a..eace43b4cb 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -25,7 +25,6 @@
 #include "config_components.h"
 
 #include "libavutil/internal.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "codec_internal.h"
@@ -3626,9 +3625,9 @@ int ff_mpeg4_decode_picture_header(MpegEncContext *s)
 {
 Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 
-if (ctx->bitstream_buffer_size) {
+if (ctx->bitstream_buffer) {
 int buf_size = get_bits_left(&s->gb) / 8U;
-int bitstream_buffer_size = ctx->bitstream_buffer_size;
+int bitstream_buffer_size = ctx->bitstream_buffer->size;
 const uint8_t *buf = s->gb.buffer;
 
 if (s->divx_packed) {
@@ -3642,31 +3641,33 @@ int ff_mpeg4_decode_picture_header(MpegEncContext *s)
 }
 }
 }
-ctx->bitstream_buffer_size = 0;
+ctx->bitstream_buffer->size = 0;
 if (bitstream_buffer_size && (s->divx_packed || buf_size <= 
MAX_NVOP_SIZE)) {// divx 5.01+/xvid frame reorder
-int ret = init_get_bits8(&s->gb, ctx->bitstream_buffer,
+int ret = init_get_bits8(&s->gb, ctx->bitstream_buffer->data,
  bitstream_buffer_size);
 if (ret < 0)
 return ret;
-}
+} else
+av_buffer_unref(&ctx->bitstream_buffer);
 }
 
 return ff_mpeg4_parse_picture_header(ctx, &s->gb, 0, 0);
 }
 
-int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
+int ff_mpeg4_frame_end(AVCodecContext *avctx, const AVPacket *pkt)
 {
 Mpeg4DecContext *ctx = avctx->priv_data;
 MpegEncContext*s = &ctx->m;
+int ret;
 
-av_assert1(ctx->bitstream_buffer_size == 0);
+av_assert1(!ctx->bitstream_buffer || !ctx->bitstream_buffer->size);
 
 /* divx 5.01+ bitstream reorder stuff */
-/* Since this clobbers the input buffer and hwaccel codecs still need the
- * data during hwaccel->end_frame we should not do this any earlier */
 if (s->divx_packed) {
-int current_pos = s->gb.buffer == ctx->bitstream_buffer ? 0 : 
(get_bits_count(&s->gb) >> 3);
+int current_pos = ctx->bitstream_buffer && s->gb.buffer == 
ctx->bitstream_buffer->data ? 0 : (get_bits_count(&s->gb) >> 3);
 int startcode_found = 0;
+uint8_t *buf = pkt->data;
+int buf_size = pkt->size;
 
 if (buf_size - current_pos > 7) {
 
@@ -3689,16 +3690,12 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const 
uint8_t *buf, int buf_size)
"Consider using the mpeg4_unpack_bframes bitstream 
filter without encoding but stream copy to fix it.\n");
 ctx->showed_packed_warning = 1;
 }
-av_fast_padded_malloc(&ctx->bitstream_buffer,
-   &ctx->allocated_bitstream_buffer_size,
-   buf_size - current_pos);
-if (!ctx->bitstream_buffer) {
-ctx->bitstream_buffer_size = 0;
-return AVERROR(ENOMEM);
-}
-memcpy(ctx->bitstream_buffer, buf + current_pos,
-   buf_size - current_pos);
-ctx->bitstream_buffer_size = buf_size - current_pos;
+ret = av_buffer_replace(&ctx->bitstream_buffer, pkt->buf);
+if (ret < 0)
+return ret;
+
+ctx->bitstream_buffer->data = buf + current_pos;
+ctx->bitstream_buffer->size = buf_size - current_pos;
 }
 }
 
@@ -3750,18 +3747,7 @@ static int mpeg4_update_thread_context(AVCodecContext 
*dst,
 memcpy(s->sprite_shift, s1->sprite_shift, sizeof(s1->sprite_s

[FFmpeg-cvslog] avcodec/rv34: Don't update block_index unnecessarily

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun  8 03:11:48 2024 +0200| [592d75dbebb7f7f620c0c70974f4067dd0a389c2] | 
committer: Andreas Rheinhardt

avcodec/rv34: Don't update block_index unnecessarily

It is unused by RV30 and RV40.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=592d75dbebb7f7f620c0c70974f4067dd0a389c2
---

 libavcodec/rv34.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index d94285431e..d8d307f969 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1463,7 +1463,9 @@ static int rv34_decode_slice(RV34DecContext *r, int end, 
const uint8_t* buf, int
 
 ff_init_block_index(s);
 while(!check_slice_end(r, s)) {
-ff_update_block_index(s, 8, 0, 1);
+s->dest[0] += 16;
+s->dest[1] += 8;
+s->dest[2] += 8;
 
 if(r->si.type)
 res = rv34_decode_inter_macroblock(r, r->intra_types + s->mb_x * 4 
+ 4);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Reindent after the previous commit

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 25 21:11:33 2025 +0100| [ca56526d7fb4de3718096871f232d980b7e7bfac] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Reindent after the previous commit

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca56526d7fb4de3718096871f232d980b7e7bfac
---

 libavcodec/mpegvideo_enc.c | 48 +++---
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 0c20fd6953..8c22dbb5f5 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3832,32 +3832,32 @@ static int encode_picture(MpegEncContext *s, const 
AVPacket *pkt)
 s->qscale= 3; //reduce clipping problems
 
 if (s->out_format == FMT_MJPEG) {
-const uint16_t *  luma_matrix = ff_mpeg1_default_intra_matrix;
-const uint16_t *chroma_matrix = ff_mpeg1_default_intra_matrix;
-
 ret = ff_check_codec_matrices(s->avctx, FF_MATRIX_TYPE_INTRA | 
FF_MATRIX_TYPE_CHROMA_INTRA, (7 + s->qscale) / s->qscale, 65535);
 if (ret < 0)
 return ret;
 
 if (s->codec_id != AV_CODEC_ID_AMV) {
-if (s->avctx->intra_matrix) {
-chroma_matrix =
-luma_matrix = s->avctx->intra_matrix;
-}
-if (s->avctx->chroma_intra_matrix)
-chroma_matrix = s->avctx->chroma_intra_matrix;
+const uint16_t *  luma_matrix = ff_mpeg1_default_intra_matrix;
+const uint16_t *chroma_matrix = ff_mpeg1_default_intra_matrix;
 
-/* for mjpeg, we do include qscale in the matrix */
-for(i=1;i<64;i++){
-int j = s->idsp.idct_permutation[i];
+if (s->avctx->intra_matrix) {
+chroma_matrix =
+luma_matrix = s->avctx->intra_matrix;
+}
+if (s->avctx->chroma_intra_matrix)
+chroma_matrix = s->avctx->chroma_intra_matrix;
 
-s->chroma_intra_matrix[j] = av_clip_uint8((chroma_matrix[i] * 
s->qscale) >> 3);
-s->   intra_matrix[j] = av_clip_uint8((  luma_matrix[i] * 
s->qscale) >> 3);
-}
-s->y_dc_scale_table=
-s->c_dc_scale_table = ff_mpeg12_dc_scale_table[s->intra_dc_precision];
-s->chroma_intra_matrix[0] =
-s->intra_matrix[0]  = 
ff_mpeg12_dc_scale_table[s->intra_dc_precision][8];
+/* for mjpeg, we do include qscale in the matrix */
+for (int i = 1; i < 64; i++) {
+int j = s->idsp.idct_permutation[i];
+
+s->chroma_intra_matrix[j] = av_clip_uint8((chroma_matrix[i] * 
s->qscale) >> 3);
+s->   intra_matrix[j] = av_clip_uint8((  luma_matrix[i] * 
s->qscale) >> 3);
+}
+s->y_dc_scale_table =
+s->c_dc_scale_table = 
ff_mpeg12_dc_scale_table[s->intra_dc_precision];
+s->chroma_intra_matrix[0] =
+s->intra_matrix[0]  = 
ff_mpeg12_dc_scale_table[s->intra_dc_precision][8];
 } else {
 static const uint8_t y[32] = 
{13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13};
 static const uint8_t c[32] = 
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14};
@@ -3872,11 +3872,11 @@ static int encode_picture(MpegEncContext *s, const 
AVPacket *pkt)
 s->intra_matrix[0] = 13;
 s->chroma_intra_matrix[0] = 14;
 }
-ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
-  s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
-ff_convert_matrix(s, s->q_chroma_intra_matrix, 
s->q_chroma_intra_matrix16,
-  s->chroma_intra_matrix, s->intra_quant_bias, 8, 
8, 1);
-s->qscale = 8;
+ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
+  s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
+ff_convert_matrix(s, s->q_chroma_intra_matrix, 
s->q_chroma_intra_matrix16,
+  s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 
1);
+s->qscale = 8;
 }
 
 if (s->pict_type == AV_PICTURE_TYPE_I) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg12dec: Don't initialize unused parts of ScanTable

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 24 20:43:46 2025 +0100| [79d6657e138ac4a0f52ec4eaa4f4a2fcea0a7abb] | 
committer: Andreas Rheinhardt

avcodec/mpeg12dec: Don't initialize unused parts of ScanTable

The MPEG-1/2 decoders don't need ScanTable.raster_end
(as the coefficients are unquantized as they are parsed).

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79d6657e138ac4a0f52ec4eaa4f4a2fcea0a7abb
---

 libavcodec/mpeg12dec.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 48b35ed794..abef0a6155 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1228,10 +1228,10 @@ static int 
mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
 s->chroma_420_type= get_bits1(&s->gb);
 s->progressive_frame  = get_bits1(&s->gb);
 
-// We only initialize intra_scantable, as both scantables always coincide
-// and all code therefore only uses the intra one.
-ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,
-  s->alternate_scan ? ff_alternate_vertical_scan : 
ff_zigzag_direct);
+// We only initialize intra_scantable.permutated, as this is all we use.
+ff_permute_scantable(s->intra_scantable.permutated,
+ s->alternate_scan ? ff_alternate_vertical_scan : 
ff_zigzag_direct,
+ s->idsp.idct_permutation);
 
 /* composite display not parsed */
 ff_dlog(s->avctx, "intra_dc_precision=%d\n", s->intra_dc_precision);
@@ -2803,8 +2803,9 @@ static int ipu_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 m->intra_vlc_format = !!(s->flags & 0x20);
 m->alternate_scan = !!(s->flags & 0x10);
 
-ff_init_scantable(m->idsp.idct_permutation, &m->intra_scantable,
-  s->flags & 0x10 ? ff_alternate_vertical_scan : 
ff_zigzag_direct);
+ff_permute_scantable(m->intra_scantable.permutated,
+ s->flags & 0x10 ? ff_alternate_vertical_scan : 
ff_zigzag_direct,
+ m->idsp.idct_permutation);
 
 m->last_dc[0] = m->last_dc[1] = m->last_dc[2] = 1 << (7 + (s->flags & 3));
 m->qscale = 1;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/msmpeg4dec: Remove redundant check

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 25 21:51:20 2025 +0100| [2de9168b563c339d5888aecdd6b923e832cf97ff] | 
committer: Andreas Rheinhardt

avcodec/msmpeg4dec: Remove redundant check

Since d50635cd247e17fe16c63219b9ae80d45a8185b1 the
dct_unquantize_h263_intra functions have set the number of
coefficients to 63 in case of ac_pred, so ff_msmpeg4_decode_block()
doesn't have to bump it on its own.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2de9168b563c339d5888aecdd6b923e832cf97ff
---

 libavcodec/msmpeg4dec.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 7ba6f4b1e6..d42219f464 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -802,9 +802,6 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * 
block,
 if (s->mb_intra) {
  not_coded:
 ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
-if (s->ac_pred) {
-i = 63; /* XXX: not optimal */
-}
 }
 s->block_last_index[n] = i;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/vc1dec: Don't initialize inter_scantable

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 25 22:56:21 2025 +0100| [f76195ff656d6bea68feee783160652e2b3e3d60] | 
committer: Andreas Rheinhardt

avcodec/vc1dec: Don't initialize inter_scantable

It is unused.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f76195ff656d6bea68feee783160652e2b3e3d60
---

 libavcodec/vc1dec.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index f079a8745b..cfd97c4ca6 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -474,8 +474,6 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
 s->y_dc_scale_table = ff_wmv3_dc_scale_table;
 s->c_dc_scale_table = ff_wmv3_dc_scale_table;
 
-ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,
-  ff_wmv1_scantable[0]);
 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,
   ff_wmv1_scantable[1]);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't set qscale_table value prematurely

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun 30 16:04:13 2024 +0200| [ab768b88e069edf839aab84b73a763b3c82993b4] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Don't set qscale_table value prematurely

When there are multiple candidates for macroblock type, the encoder
tries them all. In order to do so, it keeps several sets of states
containing the variables that get modified when encoding
the macroblock and in the end uses the best of these.

Yet one variable was set, but not included in this state:
The current macroblock's qscale value in the current picture's
qscale_table. This may currently be set multiple times in
mpv_reconstruct_mb(), yet it is read when adaptive_quant is true.
Currently, the value read can be the value set by the last attempt
to write the current macroblock and not the initial value.

Fix this by only setting the qscale_table value in one place
outside of mpv_reconstruct_mb() (where it does not belong at all).

Reviewed-by: Ramiro Polla 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab768b88e069edf839aab84b73a763b3c82993b4
---

 libavcodec/mpegvideo_enc.c  |  8 ++--
 tests/ref/seek/vsynth_lena-mpeg4-adap   | 28 ++--
 tests/ref/vsynth/vsynth1-mpeg4-adap |  8 
 tests/ref/vsynth/vsynth2-mpeg4-adap |  8 
 tests/ref/vsynth/vsynth3-mpeg4-adap |  8 
 tests/ref/vsynth/vsynth_lena-mpeg4-adap |  8 
 6 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index bb82a03a41..c5c2e0b8e3 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1118,10 +1118,6 @@ static inline void add_dequant_dct(MpegEncContext *s,
  */
 static void mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
-const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-
-s->cur_pic.qscale_table[mb_xy] = s->qscale;
-
 if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
/* print DCT coefficients */
av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, 
s->mb_y);
@@ -3382,8 +3378,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
 }
 }
 
-s->cur_pic.qscale_table[xy] = best_s.qscale;
-
 copy_context_after_encode(s, &best_s);
 
 pb_bits_count= put_bits_count(&s->pb);
@@ -3538,6 +3532,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
 mpv_reconstruct_mb(s, s->block);
 }
 
+s->cur_pic.qscale_table[xy] = s->qscale;
+
 /* clean the MV table in IPS frames for direct mode in B-frames */
 if(s->mb_intra /* && I,P,S_TYPE */){
 s->p_mv_table[xy][0]=0;
diff --git a/tests/ref/seek/vsynth_lena-mpeg4-adap 
b/tests/ref/seek/vsynth_lena-mpeg4-adap
index fe841ef973..491651 100644
--- a/tests/ref/seek/vsynth_lena-mpeg4-adap
+++ b/tests/ref/seek/vsynth_lena-mpeg4-adap
@@ -2,45 +2,45 @@ ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos: 
  5652 size:  6855
 ret: 0 st:-1 flags:0  ts:-1.00
 ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size:  
6855
 ret: 0 st:-1 flags:1  ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 161318 size: 
19176
+ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 161352 size: 
19191
 ret: 0 st: 0 flags:0  ts: 0.80
-ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos:  75056 size: 
19178
+ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos:  75104 size: 
19178
 ret:-1 st: 0 flags:1  ts:-0.32
 ret:-1 st:-1 flags:0  ts: 2.576668
 ret: 0 st:-1 flags:1  ts: 1.470835
-ret: 0 st: 0 flags:1 dts: 1.36 pts: NOPTSpos: 118696 size: 
20018
+ret: 0 st: 0 flags:1 dts: 1.36 pts: NOPTSpos: 118586 size: 
20060
 ret: 0 st: 0 flags:0  ts: 0.36
-ret: 0 st: 0 flags:1 dts: 0.40 pts: NOPTSpos:  35800 size: 
17261
+ret: 0 st: 0 flags:1 dts: 0.40 pts: NOPTSpos:  35840 size: 
17261
 ret:-1 st: 0 flags:1  ts:-0.76
 ret:-1 st:-1 flags:0  ts: 2.153336
 ret: 0 st:-1 flags:1  ts: 1.047503
-ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos:  75056 size: 
19178
+ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos:  75104 size: 
19178
 ret: 0 st: 0 flags:0  ts:-0.04
 ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size:  
6855
 ret: 0 st: 0 flags:1  ts: 2.84
-ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 161318 size: 
19176
+ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 161352 size: 
19191
 ret: 0 st:-1 flags:0  ts: 1.730004
-ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 161318 size: 
19176
+ret: 0 st: 0 flags:1 dts:

[FFmpeg-cvslog] avcodec/motion_est: Avoid branches for put(_no_rnd) selection

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun 30 11:31:04 2024 +0200| [d4fd475005a2febbfcd0b76c8ab3584a87430972] | 
committer: Andreas Rheinhardt

avcodec/motion_est: Avoid branches for put(_no_rnd) selection

MotionEstContext contains pointers (to function pointers) that
have been set on a per-frame basis depending upon no_rounding
in ff_me_init_pic() to avoid branches like these. Also makes
MotionEstContext more independent of MpegEncContext.

Reviewed-by: Ramiro Polla 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d4fd475005a2febbfcd0b76c8ab3584a87430972
---

 libavcodec/motion_est.c | 25 +
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index e4f17fb2d8..46c4ca2dd9 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -661,18 +661,12 @@ static inline int h263_mv4_search(MpegEncContext *s, int 
mx, int my, int shift)
 const uint8_t *ref = c->ref[block][0] + (mx4>>2) + 
(my4>>2)*stride;
 dxy = ((my4 & 3) << 2) | (mx4 & 3);
 
-if(s->no_rounding)
-s->qdsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y, ref, 
stride);
-else
-s->qdsp.put_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
+c->qpel_put[1][dxy](dest_y, ref, stride);
 }else{
 const uint8_t *ref = c->ref[block][0] + (mx4>>1) + 
(my4>>1)*stride;
 dxy = ((my4 & 1) << 1) | (mx4 & 1);
 
-if(s->no_rounding)
-s->hdsp.put_no_rnd_pixels_tab[1][dxy](dest_y, ref, 
stride, h);
-else
-s->hdsp.put_pixels_tab   [1][dxy](dest_y, ref, 
stride, h);
+c->hpel_put[1][dxy](dest_y, ref, stride, h);
 }
 dmin_sum+= (mv_penalty[mx4-pred_x4] + 
mv_penalty[my4-pred_y4])*c->mb_penalty_factor;
 }else
@@ -713,13 +707,8 @@ static inline int h263_mv4_search(MpegEncContext *s, int 
mx, int my, int shift)
 
 offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;
 
-if(s->no_rounding){
-s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad, 
s->last_pic.data[1] + offset, s->uvlinesize, 8);
-s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, 
s->last_pic.data[2] + offset, s->uvlinesize, 8);
-}else{
-s->hdsp.put_pixels_tab   [1][dxy](c->scratchpad, 
s->last_pic.data[1] + offset, s->uvlinesize, 8);
-s->hdsp.put_pixels_tab   [1][dxy](c->scratchpad + 8, 
s->last_pic.data[2] + offset, s->uvlinesize, 8);
-}
+c->hpel_put[1][dxy](c->scratchpad, s->last_pic.data[1] + offset, 
s->uvlinesize, 8);
+c->hpel_put[1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, 
s->uvlinesize, 8);
 
 dmin_sum += c->mb_cmp[1](s, s->new_pic->data[1] + s->mb_x * 8 + 
s->mb_y * 8 * s->uvlinesize, c->scratchpad, s->uvlinesize, 8);
 dmin_sum += c->mb_cmp[1](s, s->new_pic->data[2] + s->mb_x * 8 + 
s->mb_y * 8 * s->uvlinesize, c->scratchpad + 8, s->uvlinesize, 8);
@@ -825,11 +814,7 @@ static int interlaced_search(MpegEncContext *s, int 
ref_index,
 const uint8_t *ref = c->ref[field_select+ref_index][0] + 
(mx_i>>1) + (my_i>>1)*stride;
 dxy = ((my_i & 1) << 1) | (mx_i & 1);
 
-if(s->no_rounding){
-s->hdsp.put_no_rnd_pixels_tab[size][dxy](c->scratchpad, 
ref, stride, h);
-}else{
-s->hdsp.put_pixels_tab   [size][dxy](c->scratchpad, 
ref, stride, h);
-}
+c->hpel_put[size][dxy](c->scratchpad, ref, stride, h);
 dmin = c->mb_cmp[size](s, c->src[block][0], c->scratchpad, 
stride, h);
 dmin+= (mv_penalty[mx_i-c->pred_x] + 
mv_penalty[my_i-c->pred_y] + 1)*c->mb_penalty_factor;
 }else

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] tests/fate/vcodec: Test using mpeg2-quantizers for MPEG-4

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jul  2 19:26:20 2024 +0200| [57ade06ffeb8d5485385693cac0f8213d517cacb] | 
committer: Andreas Rheinhardt

tests/fate/vcodec: Test using mpeg2-quantizers for MPEG-4

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=57ade06ffeb8d5485385693cac0f8213d517cacb
---

 tests/fate/vcodec.mak |  2 +-
 tests/ref/seek/vsynth_lena-mpeg4-rc   | 40 +--
 tests/ref/vsynth/vsynth1-mpeg4-rc |  8 +++
 tests/ref/vsynth/vsynth2-mpeg4-rc |  8 +++
 tests/ref/vsynth/vsynth3-mpeg4-rc |  8 +++
 tests/ref/vsynth/vsynth_lena-mpeg4-rc |  8 +++
 6 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index a91c0ec3e3..f009cc68c8 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -330,7 +330,7 @@ fate-vsynth%-mpeg4-qprd: ENCOPTS = -b 450k -bf 2 
-trellis 1  \
-flags +mv4 -mpv_flags +qp_rd+mv0 \
-cmp 2 -subcmp 2 -mbd rd
 
-fate-vsynth%-mpeg4-rc:   ENCOPTS = -b 400k -bf 2
+fate-vsynth%-mpeg4-rc:   ENCOPTS = -b 400k -bf 2 -mpeg_quant 1
 
 fate-vsynth%-mpeg4-thread:   ENCOPTS = -b 500k -flags +mv4+aic \
-data_partitioning 1 -trellis 1 \
diff --git a/tests/ref/seek/vsynth_lena-mpeg4-rc 
b/tests/ref/seek/vsynth_lena-mpeg4-rc
index e1994af948..a10a3ca07c 100644
--- a/tests/ref/seek/vsynth_lena-mpeg4-rc
+++ b/tests/ref/seek/vsynth_lena-mpeg4-rc
@@ -1,46 +1,46 @@
-ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15766
+ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15471
 ret: 0 st:-1 flags:0  ts:-1.00
-ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15766
+ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15471
 ret: 0 st:-1 flags:1  ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 207954 size: 
13826
+ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 200880 size: 
15568
 ret: 0 st: 0 flags:0  ts: 0.80
-ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos: 153788 size: 
13377
+ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos: 140756 size: 
15473
 ret:-1 st: 0 flags:1  ts:-0.32
 ret:-1 st:-1 flags:0  ts: 2.576668
 ret: 0 st:-1 flags:1  ts: 1.470835
-ret: 0 st: 0 flags:1 dts: 1.36 pts: NOPTSpos: 180950 size: 
13326
+ret: 0 st: 0 flags:1 dts: 1.36 pts: NOPTSpos: 171606 size: 
15125
 ret: 0 st: 0 flags:0  ts: 0.36
-ret: 0 st: 0 flags:1 dts: 0.40 pts: NOPTSpos:  94578 size: 
32807
+ret: 0 st: 0 flags:1 dts: 0.40 pts: NOPTSpos:  84442 size: 
30467
 ret:-1 st: 0 flags:1  ts:-0.76
 ret:-1 st:-1 flags:0  ts: 2.153336
 ret: 0 st:-1 flags:1  ts: 1.047503
-ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos: 153788 size: 
13377
+ret: 0 st: 0 flags:1 dts: 0.88 pts: NOPTSpos: 140756 size: 
15473
 ret: 0 st: 0 flags:0  ts:-0.04
-ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15766
+ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15471
 ret: 0 st: 0 flags:1  ts: 2.84
-ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 207954 size: 
13826
+ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 200880 size: 
15568
 ret: 0 st:-1 flags:0  ts: 1.730004
-ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 207954 size: 
13826
+ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 200880 size: 
15568
 ret: 0 st:-1 flags:1  ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 0.40 pts: NOPTSpos:  94578 size: 
32807
+ret: 0 st: 0 flags:1 dts: 0.40 pts: NOPTSpos:  84442 size: 
30467
 ret: 0 st: 0 flags:0  ts:-0.48
-ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15766
+ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15471
 ret: 0 st: 0 flags:1  ts: 2.40
-ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 207954 size: 
13826
+ret: 0 st: 0 flags:1 dts: 1.84 pts: NOPTSpos: 200880 size: 
15568
 ret: 0 st:-1 flags:0  ts: 1.306672
-ret: 0 st: 0 flags:1 dts: 1.36 pts: NOPTSpos: 180950 size: 
13326
+ret: 0 st: 0 flags:1 dts: 1.36 pts: NOPTSpos: 171606 size: 
15125
 ret: 0 st:-1 flags:1  ts: 0.200839
-ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15766
+ret: 0 st: 0 flags:1 dts: 0.00 pts: NOPTSpos:   5652 size: 
15471
 ret: 0 st: 0 flags:0  ts:-0.92
-ret: 0   

[FFmpeg-cvslog] avcodec/mips/mpegvideo_mmi: Don't check alternate_scan unnecessarily

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul  1 22:43:33 2024 +0200| [ab38ff9161b9cf52684d3ad1e2ccc60fa01eaa6d] | 
committer: Andreas Rheinhardt

avcodec/mips/mpegvideo_mmi: Don't check alternate_scan unnecessarily

Forgotten in 4f7aeffd8c3607aea6464a20eba4cc9106173c52.

Reviewed-by: Ramiro Polla 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab38ff9161b9cf52684d3ad1e2ccc60fa01eaa6d
---

 libavcodec/mips/mpegvideo_mmi.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/mips/mpegvideo_mmi.c b/libavcodec/mips/mpegvideo_mmi.c
index 7af421db6b..87d4aafd8c 100644
--- a/libavcodec/mips/mpegvideo_mmi.c
+++ b/libavcodec/mips/mpegvideo_mmi.c
@@ -356,10 +356,7 @@ void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, 
int16_t *block,
 
 assert(s->block_last_index[n]>=0);
 
-if (s->alternate_scan)
-nCoeffs = 63;
-else
-nCoeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
+nCoeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
 
 if (n < 4)
 block0 = block[0] * s->y_dc_scale;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_dec: Use picture-dimensions in ff_print_debug_info()

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul  1 01:31:12 2024 +0200| [973c7a0c652dbac5f171e61dcf94f42de094eaa2] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Use picture-dimensions in ff_print_debug_info()

It will allow to avoid the special case for VC-1 field pictures.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=973c7a0c652dbac5f171e61dcf94f42de094eaa2
---

 libavcodec/mpegvideo_dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 44f1ba1592..53e02ad91c 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -404,7 +404,7 @@ void ff_print_debug_info(const MpegEncContext *s, const 
MPVPicture *p, AVFrame *
 {
 ff_print_debug_info2(s->avctx, pict, p->mb_type,
  p->qscale_table, p->motion_val,
- s->mb_width, s->mb_height, s->mb_stride, 
s->quarter_sample);
+ p->mb_width, p->mb_height, p->mb_stride, 
s->quarter_sample);
 }
 
 int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/msmpeg4dec: Avoid branch

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul  1 19:52:34 2024 +0200| [18fc118f6541467d1493e71831df195f91cca1c7] | 
committer: Andreas Rheinhardt

avcodec/msmpeg4dec: Avoid branch

A non-LTO-compiler can't optimize this away.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18fc118f6541467d1493e71831df195f91cca1c7
---

 libavcodec/msmpeg4dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index da65ea797f..7ba6f4b1e6 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -799,8 +799,8 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * 
block,
 }
 CLOSE_READER(re, &s->gb);
   }
- not_coded:
 if (s->mb_intra) {
+ not_coded:
 ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
 if (s->ac_pred) {
 i = 63; /* XXX: not optimal */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/msmpeg4dec: Don't process unnecessarily many coefficients

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul  1 19:18:06 2024 +0200| [4912a2d88ea242baf966eaa7d55dd547d4785d0f] | 
committer: Andreas Rheinhardt

avcodec/msmpeg4dec: Don't process unnecessarily many coefficients

This code has been added in f5957f3fe2b8dfda13a9750acc3e3a03cd5d39c9
when support for WMV1 has been added. It was needed for decoding
inter macroblocks, as WMV1 uses a different scantable and
the ScanTable and ScanTable.raster_end was not yet introduced
(the H263 unquantize function instead used a hardcoded version
of ff_zigzag_direct's raster_end). In other words,
there is no reason to continue to do so for WMV1 inter blocks.
(Apart from that: WMV1 inter blocks don't use
dct_unquantize_h263_inter any more, as unquantizing happens
when parsing the block via specialized RL VLC tables.)

It is also not needed for WMV1/2 intra blocks (for non-ac_pred
it uses the correct ScanTable used by the h263 unquantize
intra function; for ac_pred, the number is overridden)
as well as for WMV2 inter-blocks (raster_end is not really
used in this case; the ordinary ScanTable is used in case
abt_type is zero, otherwise there are two different ScanTables
and block_last_index is overridden in wmv2dec.c).

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4912a2d88ea242baf966eaa7d55dd547d4785d0f
---

 libavcodec/msmpeg4dec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 12bef4f506..da65ea797f 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -806,7 +806,6 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * 
block,
 i = 63; /* XXX: not optimal */
 }
 }
-if (s->msmpeg4_version >= MSMP4_WMV1 && i > 0) i=63; //FIXME/XXX optimize
 s->block_last_index[n] = i;
 
 return 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/vc1dec: Reenable debug-info output for field pictures

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul  1 01:43:58 2024 +0200| [a885351ad0a8f569671b086bd027b43acec3e6b1] | 
committer: Andreas Rheinhardt

avcodec/vc1dec: Reenable debug-info output for field pictures

Effectively reverts c59b5e3d1e0121ea23b5b326529f5bdca44cf982.
This is possible now that ff_print_debug_info2() uses
the MPVPicture dimensions.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a885351ad0a8f569671b086bd027b43acec3e6b1
---

 libavcodec/vc1dec.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 2c314e7b55..f079a8745b 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1366,14 +1366,12 @@ image:
 if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
 if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0)
 goto err;
-if (!v->field_mode)
-ff_print_debug_info(s, s->cur_pic.ptr, pict);
+ff_print_debug_info(s, s->cur_pic.ptr, pict);
 *got_frame = 1;
 } else if (s->last_pic.ptr) {
 if ((ret = av_frame_ref(pict, s->last_pic.ptr->f)) < 0)
 goto err;
-if (!v->field_mode)
-ff_print_debug_info(s, s->last_pic.ptr, pict);
+ff_print_debug_info(s, s->last_pic.ptr, pict);
 *got_frame = 1;
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/h261dec: Remove dead check

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul  1 12:30:29 2024 +0200| [9c16d54a166630e960505389da5f53a6da710c62] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Remove dead check

H.261 does not have non-reference frames.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9c16d54a166630e960505389da5f53a6da710c62
---

 libavcodec/h261dec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index cabca33c8d..50ac53167d 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -587,8 +587,7 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 return ret;
 }
 
-if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == 
AV_PICTURE_TYPE_B) ||
-(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != 
AV_PICTURE_TYPE_I) ||
+if ((avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != 
AV_PICTURE_TYPE_I) ||
  avctx->skip_frame >= AVDISCARD_ALL)
 return buf_size;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg12dec: Remove write-only assignments

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul  8 14:55:45 2024 +0200| [db8546dff71475ce34fd7658c3c8da53aa03afbe] | 
committer: Andreas Rheinhardt

avcodec/mpeg12dec: Remove write-only assignments

This decoder unquantizes while parsing blocks
and does not use dct_unquantize_mpeg1_intra
(which uses *_dc_scale) at all.

repeat_field was unused since
e0a3d744a0d5a9a25fb85c9bba17e3b07d3ba29b.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db8546dff71475ce34fd7658c3c8da53aa03afbe
---

 libavcodec/mpeg12dec.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 262e213a61..48b35ed794 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -72,7 +72,6 @@ enum Mpeg2ClosedCaptionsFormat {
 
 typedef struct Mpeg1Context {
 MpegEncContext mpeg_enc_ctx;
-int repeat_field;   /* true if we must repeat the field */
 AVPanScan pan_scan; /* some temporary storage for the panscan */
 enum AVStereo3DType stereo3d_type;
 int has_stereo3d;
@@ -781,7 +780,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
 ff_mpeg12_init_vlcs();
 
 s2->chroma_format  = 1;
-s->repeat_field= 0;
 avctx->color_range = AVCOL_RANGE_MPEG;
 return 0;
 }
@@ -1050,8 +1048,6 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, 
const uint8_t *buf,
 av_log(avctx, AV_LOG_DEBUG,
"vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
 
-s->y_dc_scale = 8;
-s->c_dc_scale = 8;
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg12dec: Really disable scratchpad allocations

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 25 16:40:56 2025 +0100| [8d871622542bd596ecf041eceb11716a2b4e47bb] | 
committer: Andreas Rheinhardt

avcodec/mpeg12dec: Really disable scratchpad allocations

ba341be09533a077075c71fce5f9dc5b73504234 disabled them for
the main thread only, not the slice threads.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d871622542bd596ecf041eceb11716a2b4e47bb
---

 libavcodec/mpeg12dec.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index abef0a6155..843640edbf 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1001,7 +1001,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if ((ret = ff_mpv_common_init(s)) < 0)
 return ret;
 if (!s->avctx->lowres)
-ff_mpv_framesize_disable(&s->sc);
+for (int i = 0; i < s->slice_context_count; i++)
+ff_mpv_framesize_disable(&s->thread_context[i]->sc);
 }
 return 0;
 }
@@ -1874,7 +1875,8 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
 if ((ret = ff_mpv_common_init(s)) < 0)
 return ret;
 if (!s->avctx->lowres)
-ff_mpv_framesize_disable(&s->sc);
+for (int i = 0; i < s->slice_context_count; i++)
+ff_mpv_framesize_disable(&s->thread_context[i]->sc);
 
 for (i = 0; i < 64; i++) {
 int j = s->idsp.idct_permutation[i];

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Add AV_CODEC_CAP_DR1

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun 30 17:44:46 2024 +0200| [b3ba961df68437e68aa8cc0a33c5b85574935971] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Add AV_CODEC_CAP_DR1

The mpegvideo-based encoders do one uncommon thing with
the packet's data given by ff_alloc_packet(): They potentially
reallocate it. But this only affects the internal buffer
and is not user-facing at all, so one can nevertheless
use the AV_CODEC_CAP_DR1 for them.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3ba961df68437e68aa8cc0a33c5b85574935971
---

 libavcodec/flvenc.c| 2 +-
 libavcodec/h261enc.c   | 2 +-
 libavcodec/ituh263enc.c| 5 +++--
 libavcodec/mjpegenc.c  | 5 +++--
 libavcodec/mpeg12enc.c | 6 --
 libavcodec/mpeg4videoenc.c | 3 ++-
 libavcodec/msmpeg4enc.c| 6 +++---
 libavcodec/rv10enc.c   | 2 +-
 libavcodec/rv20enc.c   | 2 +-
 libavcodec/speedhqenc.c| 2 +-
 libavcodec/wmv2enc.c   | 2 +-
 11 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c
index 40eec07b3e..cbe3b7f056 100644
--- a/libavcodec/flvenc.c
+++ b/libavcodec/flvenc.c
@@ -98,6 +98,7 @@ const FFCodec ff_flv_encoder = {
 .p.type = AVMEDIA_TYPE_VIDEO,
 .p.id   = AV_CODEC_ID_FLV1,
 .p.priv_class   = &ff_mpv_enc_class,
+.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 .priv_data_size = sizeof(MpegEncContext),
 .init   = ff_mpv_encode_init,
 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
@@ -106,5 +107,4 @@ const FFCodec ff_flv_encoder = {
 .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_NONE},
 .color_ranges   = AVCOL_RANGE_MPEG,
-.p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 };
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index c694862462..dabab9d80a 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -383,6 +383,7 @@ const FFCodec ff_h261_encoder = {
 .p.type = AVMEDIA_TYPE_VIDEO,
 .p.id   = AV_CODEC_ID_H261,
 .p.priv_class   = &ff_mpv_enc_class,
+.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 .priv_data_size = sizeof(H261EncContext),
 .init   = ff_mpv_encode_init,
 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
@@ -391,5 +392,4 @@ const FFCodec ff_h261_encoder = {
 .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_NONE },
 .color_ranges   = AVCOL_RANGE_MPEG,
-.p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 };
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 8c41e45ab2..1ef4a8f88e 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -922,7 +922,7 @@ const FFCodec ff_h263_encoder = {
 .p.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE},
 .color_ranges   = AVCOL_RANGE_MPEG,
 .p.priv_class   = &h263_class,
-.p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .priv_data_size = sizeof(MpegEncContext),
 .init   = ff_mpv_encode_init,
@@ -954,7 +954,8 @@ const FFCodec ff_h263p_encoder = {
 .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE },
 .color_ranges   = AVCOL_RANGE_MPEG,
 .p.priv_class   = &h263p_class,
-.p.capabilities = AV_CODEC_CAP_SLICE_THREADS | 
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS |
+  AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .priv_data_size = sizeof(MpegEncContext),
 .init   = ff_mpv_encode_init,
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 40da602a6d..c2e8b93a34 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -669,7 +669,8 @@ FFCodec ff_mjpeg_encoder = {
 .init   = ff_mpv_encode_init,
 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
 .close  = mjpeg_encode_close,
-.p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS |
+.p.capabilities = AV_CODEC_CAP_DR1 |
+  AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS |
   AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES,
 .p.pix_fmts = (const enum AVPixelFormat[]) {
@@ -696,6 +697,7 @@ const FFCodec ff_amv_encoder = {
 CODEC_LONG_NAME("AMV Video"),
 .p.type = AVMEDIA_TYPE_VIDEO,
 .p.id   = AV_CODEC_ID_AMV,
+.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,

[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't do unnecessary work for AMV

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 25 20:56:57 2025 +0100| [772df653566d2d3f69f6e84da8b884ff110253c7] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Don't do unnecessary work for AMV

Up until now, the initialization of AMV's matrices happened
after the initialization for MJPEG matrices, overwriting
the earlier data. This commit changes this.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=772df653566d2d3f69f6e84da8b884ff110253c7
---

 libavcodec/mpegvideo_enc.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index c5c2e0b8e3..0c20fd6953 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3839,6 +3839,7 @@ static int encode_picture(MpegEncContext *s, const 
AVPacket *pkt)
 if (ret < 0)
 return ret;
 
+if (s->codec_id != AV_CODEC_ID_AMV) {
 if (s->avctx->intra_matrix) {
 chroma_matrix =
 luma_matrix = s->avctx->intra_matrix;
@@ -3857,13 +3858,7 @@ static int encode_picture(MpegEncContext *s, const 
AVPacket *pkt)
 s->c_dc_scale_table = ff_mpeg12_dc_scale_table[s->intra_dc_precision];
 s->chroma_intra_matrix[0] =
 s->intra_matrix[0]  = 
ff_mpeg12_dc_scale_table[s->intra_dc_precision][8];
-ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
-   s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
-ff_convert_matrix(s, s->q_chroma_intra_matrix, 
s->q_chroma_intra_matrix16,
-   s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1);
-s->qscale= 8;
-
-if (s->codec_id == AV_CODEC_ID_AMV) {
+} else {
 static const uint8_t y[32] = 
{13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13};
 static const uint8_t c[32] = 
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14};
 for (int i = 1; i < 64; i++) {
@@ -3876,12 +3871,12 @@ static int encode_picture(MpegEncContext *s, const 
AVPacket *pkt)
 s->c_dc_scale_table = c;
 s->intra_matrix[0] = 13;
 s->chroma_intra_matrix[0] = 14;
+}
 ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
   s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
 ff_convert_matrix(s, s->q_chroma_intra_matrix, 
s->q_chroma_intra_matrix16,
   s->chroma_intra_matrix, s->intra_quant_bias, 8, 
8, 1);
 s->qscale = 8;
-}
 }
 
 if (s->pict_type == AV_PICTURE_TYPE_I) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] tests/fate/vcodec: Test H.261 loop-filter

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jul  6 23:50:47 2024 +0200| [a5d590963c06b7041f41e668e2bfe04ee71fecc5] | 
committer: Andreas Rheinhardt

tests/fate/vcodec: Test H.261 loop-filter

Increases coverage.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5d590963c06b7041f41e668e2bfe04ee71fecc5
---

 tests/fate/vcodec.mak |  2 +-
 tests/ref/seek/vsynth_lena-h261   | 28 ++--
 tests/ref/vsynth/vsynth1-h261 |  8 
 tests/ref/vsynth/vsynth2-h261 |  8 
 tests/ref/vsynth/vsynth_lena-h261 |  8 
 5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index f009cc68c8..8a9083d4ed 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -204,7 +204,7 @@ fate-vsynth%-flv:ENCOPTS = -qscale 10
 fate-vsynth%-flv:FMT = flv
 
 FATE_VCODEC-$(call ENCDEC, H261, AVI)   += h261 h261-trellis
-fate-vsynth%-h261:   ENCOPTS = -qscale 11
+fate-vsynth%-h261:   ENCOPTS = -qscale 11 -flags +loop
 fate-vsynth%-h261-trellis:   ENCOPTS = -qscale 12 -trellis 1 -mbd rd
 
 FATE_VCODEC-$(call ENCDEC, H263, AVI)   += h263 h263-obmc h263p
diff --git a/tests/ref/seek/vsynth_lena-h261 b/tests/ref/seek/vsynth_lena-h261
index dabf6a3014..2560d6fda9 100644
--- a/tests/ref/seek/vsynth_lena-h261
+++ b/tests/ref/seek/vsynth_lena-h261
@@ -2,45 +2,45 @@ ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 
  5652 size:  9645
 ret: 0 st:-1 flags:0  ts:-1.00
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5652 size:  
9645
 ret: 0 st:-1 flags:1  ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 1.44 pts: 1.44 pos: 126498 size: 
11377
+ret: 0 st: 0 flags:1 dts: 1.44 pts: 1.44 pos: 122896 size: 
11377
 ret: 0 st: 0 flags:0  ts: 0.80
-ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:  82056 size: 
10322
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:  79230 size: 
10322
 ret:-1 st: 0 flags:1  ts:-0.32
 ret:-1 st:-1 flags:0  ts: 2.576668
 ret: 0 st:-1 flags:1  ts: 1.470835
-ret: 0 st: 0 flags:1 dts: 1.44 pts: 1.44 pos: 126498 size: 
11377
+ret: 0 st: 0 flags:1 dts: 1.44 pts: 1.44 pos: 122896 size: 
11377
 ret: 0 st: 0 flags:0  ts: 0.36
-ret: 0 st: 0 flags:1 dts: 0.48 pts: 0.48 pos:  44668 size:  
9404
+ret: 0 st: 0 flags:1 dts: 0.48 pts: 0.48 pos:  42130 size:  
9404
 ret:-1 st: 0 flags:1  ts:-0.76
 ret:-1 st:-1 flags:0  ts: 2.153336
 ret: 0 st:-1 flags:1  ts: 1.047503
-ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:  82056 size: 
10322
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:  79230 size: 
10322
 ret: 0 st: 0 flags:0  ts:-0.04
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5652 size:  
9645
 ret: 0 st: 0 flags:1  ts: 2.84
-ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 175860 size: 
11707
+ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 171314 size: 
11707
 ret: 0 st:-1 flags:0  ts: 1.730004
-ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 175860 size: 
11707
+ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 171314 size: 
11707
 ret: 0 st:-1 flags:1  ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 0.48 pts: 0.48 pos:  44668 size:  
9404
+ret: 0 st: 0 flags:1 dts: 0.48 pts: 0.48 pos:  42130 size:  
9404
 ret: 0 st: 0 flags:0  ts:-0.48
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5652 size:  
9645
 ret: 0 st: 0 flags:1  ts: 2.40
-ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 175860 size: 
11707
+ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 171314 size: 
11707
 ret: 0 st:-1 flags:0  ts: 1.306672
-ret: 0 st: 0 flags:1 dts: 1.44 pts: 1.44 pos: 126498 size: 
11377
+ret: 0 st: 0 flags:1 dts: 1.44 pts: 1.44 pos: 122896 size: 
11377
 ret: 0 st:-1 flags:1  ts: 0.200839
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5652 size:  
9645
 ret: 0 st: 0 flags:0  ts:-0.92
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5652 size:  
9645
 ret: 0 st: 0 flags:1  ts: 2.00
-ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 175860 size: 
11707
+ret: 0 st: 0 flags:1 dts: 1.92 pts: 1.92 pos: 171314 size: 
11707
 ret: 0 st:-1 flags:0  ts: 0.883340
-ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:  82056 size: 
10322
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:  79230 size: 
10322
 ret:-1 st:-1 flags:1  ts:-0.222493
 ret:-1 st: 0 flags:0  ts: 2.68
 ret: 0 

[FFmpeg-cvslog] avcodec/h261dec: Inline constant

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jul  7 00:10:37 2024 +0200| [3474475e5853c2c109d90b95a299ffc380dd2b24] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Inline constant

The value here has been set in ff_set_qscale() from
ff_mpeg1_dc_scale_table, all of whose entries are 8.

Reviewed-by: Ramiro Polla 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3474475e5853c2c109d90b95a299ffc380dd2b24
---

 libavcodec/h261dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 50ac53167d..116f1d43b2 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -262,7 +262,7 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
  * being coded as  . */
 if (level == 255)
 level = 128;
-block[0] = level * s->y_dc_scale;
+block[0] = level * 8;
 i= 1;
 } else if (coded) {
 // Run  Level   Code

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_dec: Don't sync max_b_frames

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 24 16:37:19 2025 +0100| [4c0960e968228f059e88dd464b10e8b53ac24b9e] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Don't sync max_b_frames

Only the VC-1 decoder (which does not use frame-threading)
and encoders use it.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4c0960e968228f059e88dd464b10e8b53ac24b9e
---

 libavcodec/mpegvideo_dec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 53e02ad91c..ebbbc1df8b 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -134,7 +134,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
(char *) &s1->last_time_base);
 
 // B-frame info
-s->max_b_frames = s1->max_b_frames;
 s->low_delay= s1->low_delay;
 
 // DivX handling (doesn't work)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] tests/fate/vcodec: Test alternate_scan

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jul  2 00:45:50 2024 +0200| [c960b42efca6112584ce2b25e9654bb2adb0ff12] | 
committer: Andreas Rheinhardt

tests/fate/vcodec: Test alternate_scan

Encoding was untested before this.
Notice that the filesize degradation is partially due to
mpegvideo no longer using progressive_sequence and
progressive_frame.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c960b42efca6112584ce2b25e9654bb2adb0ff12
---

 tests/fate/vcodec.mak  | 2 +-
 tests/ref/vsynth/vsynth1-mpeg2 | 4 ++--
 tests/ref/vsynth/vsynth2-mpeg2 | 4 ++--
 tests/ref/vsynth/vsynth3-mpeg2 | 8 
 tests/ref/vsynth/vsynth_lena-mpeg2 | 4 ++--
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index a12eb43f22..a91c0ec3e3 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -263,7 +263,7 @@ FATE_VCODEC-$(call ENCDEC, MPEG2VIDEO, MPEG2VIDEO 
MPEGVIDEO) += $(FATE_MPEG2)
 $(FATE_MPEG2:%=fate-vsynth\%-%): FMT= mpeg2video
 $(FATE_MPEG2:%=fate-vsynth\%-%): CODEC  = mpeg2video
 
-fate-vsynth%-mpeg2:  ENCOPTS = -qscale 10
+fate-vsynth%-mpeg2:  ENCOPTS = -qscale 10 -alternate_scan 1
 fate-vsynth%-mpeg2-422:  ENCOPTS = -b:v 1000k   \
-bf 2\
-trellis 1   \
diff --git a/tests/ref/vsynth/vsynth1-mpeg2 b/tests/ref/vsynth/vsynth1-mpeg2
index 0f06f380cf..658bf30f98 100644
--- a/tests/ref/vsynth/vsynth1-mpeg2
+++ b/tests/ref/vsynth/vsynth1-mpeg2
@@ -1,4 +1,4 @@
-89d9481c12d2342e256b322d317e81c4 *tests/data/fate/vsynth1-mpeg2.mpeg2video
-728400 tests/data/fate/vsynth1-mpeg2.mpeg2video
+7568d0abb159228f138463c6713f9281 *tests/data/fate/vsynth1-mpeg2.mpeg2video
+739643 tests/data/fate/vsynth1-mpeg2.mpeg2video
 66c2a14725ba0a6f1535b9a62768977b *tests/data/fate/vsynth1-mpeg2.out.rawvideo
 stddev:7.65 PSNR: 30.45 MAXDIFF:   84 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-mpeg2 b/tests/ref/vsynth/vsynth2-mpeg2
index 869948adeb..7a73b9968c 100644
--- a/tests/ref/vsynth/vsynth2-mpeg2
+++ b/tests/ref/vsynth/vsynth2-mpeg2
@@ -1,4 +1,4 @@
-38afa638d9ac0b9c7ccebb8073412920 *tests/data/fate/vsynth2-mpeg2.mpeg2video
-268153 tests/data/fate/vsynth2-mpeg2.mpeg2video
+1f29c2bdddcc13e2e659d7dfc0e6ba0e *tests/data/fate/vsynth2-mpeg2.mpeg2video
+280927 tests/data/fate/vsynth2-mpeg2.mpeg2video
 bbddc9948fadfcc79487b391417ba8ed *tests/data/fate/vsynth2-mpeg2.out.rawvideo
 stddev:5.55 PSNR: 33.23 MAXDIFF:   77 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-mpeg2 b/tests/ref/vsynth/vsynth3-mpeg2
index d2e5b9fffc..f64bb9ccb3 100644
--- a/tests/ref/vsynth/vsynth3-mpeg2
+++ b/tests/ref/vsynth/vsynth3-mpeg2
@@ -1,4 +1,4 @@
-d95da92e3e77e32e3766ed9a95241f98 *tests/data/fate/vsynth3-mpeg2.mpeg2video
-29567 tests/data/fate/vsynth3-mpeg2.mpeg2video
-1df6a406c3959c6de7651b4e4fd98a36 *tests/data/fate/vsynth3-mpeg2.out.rawvideo
-stddev:9.12 PSNR: 28.93 MAXDIFF:   63 bytes:86700/86700
+c28c9a900c9975af2ad4ab7e5ac40a71 *tests/data/fate/vsynth3-mpeg2.mpeg2video
+36239 tests/data/fate/vsynth3-mpeg2.mpeg2video
+c1ece16d7ab1564032dda15553f856f9 *tests/data/fate/vsynth3-mpeg2.out.rawvideo
+stddev:9.05 PSNR: 28.99 MAXDIFF:   66 bytes:86700/86700
diff --git a/tests/ref/vsynth/vsynth_lena-mpeg2 
b/tests/ref/vsynth/vsynth_lena-mpeg2
index 699a47b652..d0e29f2f33 100644
--- a/tests/ref/vsynth/vsynth_lena-mpeg2
+++ b/tests/ref/vsynth/vsynth_lena-mpeg2
@@ -1,4 +1,4 @@
-6071414a26d41ae9c4cc5477d8ca19eb *tests/data/fate/vsynth_lena-mpeg2.mpeg2video
-198673 tests/data/fate/vsynth_lena-mpeg2.mpeg2video
+2883a9fd2680e34629b6eef87f7cac1b *tests/data/fate/vsynth_lena-mpeg2.mpeg2video
+213032 tests/data/fate/vsynth_lena-mpeg2.mpeg2video
 9efe4846a75d9b7387d1e3bb1e5db29a 
*tests/data/fate/vsynth_lena-mpeg2.out.rawvideo
 stddev:4.96 PSNR: 34.20 MAXDIFF:   59 bytes:  7603200/  7603200

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] fftools/ffmpeg_filter: also remove display matrix side data from buffered frames

2025-03-04 Thread James Almer
ffmpeg | branch: release/7.1 | James Almer  | Thu Feb 27 
23:38:09 2025 -0300| [f023d2c61b3c178cb6d279ff51472ca16f239674] | committer: 
James Almer

fftools/ffmpeg_filter: also remove display matrix side data from buffered frames

Some frames may be buffered before a complex filtergraph can be configured.
This change ensures the side data removal in the cases where autorotation is
enabled also applies to them.

Fixes ticket #11487

Signed-off-by: James Almer 
(cherry picked from commit 01f63ef0b44fa70d87edaf52f19fcdb2ae7446b3)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f023d2c61b3c178cb6d279ff51472ca16f239674
---

 fftools/ffmpeg_filter.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 38c7676a7e..3ef6818c72 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1998,6 +1998,10 @@ static int configure_filtergraph(FilterGraph *fg, 
FilterGraphThread *fgt)
 if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE) {
 sub2video_frame(&ifp->ifilter, tmp, !fgt->graph);
 } else {
+if (ifp->type_src == AVMEDIA_TYPE_VIDEO) {
+if (ifp->displaymatrix_applied)
+av_frame_remove_side_data(tmp, 
AV_FRAME_DATA_DISPLAYMATRIX);
+}
 ret = av_buffersrc_add_frame(ifp->filter, tmp);
 }
 av_frame_free(&tmp);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/rtp_av1: Add necessary headers

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Mar  4 15:34:38 2025 +0100| [9e2773034ba177861e32b746b5dbd8d0370661a5] | 
committer: Andreas Rheinhardt

avformat/rtp_av1: Add necessary headers

Also use a void* instead of an AVFormatContext as logctx in parse_leb.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e2773034ba177861e32b746b5dbd8d0370661a5
---

 libavformat/rtp_av1.h | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavformat/rtp_av1.h b/libavformat/rtp_av1.h
index a353fc0e4e..29ac81f844 100644
--- a/libavformat/rtp_av1.h
+++ b/libavformat/rtp_av1.h
@@ -29,6 +29,10 @@
 #ifndef AVFORMAT_RTP_AV1_H
 #define AVFORMAT_RTP_AV1_H
 
+#include 
+
+#include "libavutil/log.h"
+
 // define a couple of flags and bit fields
 #define AV1B_OBU_FORBIDDEN  7
 #define AV1F_OBU_FORBIDDEN  (1u << AV1B_OBU_FORBIDDEN)
@@ -88,7 +92,7 @@ static inline void write_leb_n(uint8_t *lebptr, uint32_t 
length, unsigned int nu
 }
 
 /// securely parse LEB bytes and return the resulting encoded length
-static inline unsigned int parse_leb(AVFormatContext *ctx, const uint8_t 
*buf_ptr,
+static inline unsigned int parse_leb(void *logctx, const uint8_t *buf_ptr,
  uint32_t buffer_size, uint32_t *obu_size) 
{
 uint8_t leb128;
 unsigned int num_lebs = 0;
@@ -96,7 +100,7 @@ static inline unsigned int parse_leb(AVFormatContext *ctx, 
const uint8_t *buf_pt
 do {
 uint32_t leb7;
 if (!buffer_size) {
-av_log(ctx, AV_LOG_ERROR, "AV1: Out of data in OBU size field AV1 
RTP packet\n");
+av_log(logctx, AV_LOG_ERROR, "AV1: Out of data in OBU size field 
AV1 RTP packet\n");
 return 0;
 }
 leb128 = *buf_ptr++;
@@ -107,13 +111,13 @@ static inline unsigned int parse_leb(AVFormatContext 
*ctx, const uint8_t *buf_pt
  * of violation here. It is legal, though, to have the most significant
  * bytes with all zero bits (in the lower 7 bits). */
 if (((num_lebs == 4) && (leb7 >= 0x10)) || ((num_lebs > 4) && leb7)) {
-av_log(ctx, AV_LOG_ERROR, "AV1: OBU size field exceeds 32 bit in 
AV1 RTP packet\n");
+av_log(logctx, AV_LOG_ERROR, "AV1: OBU size field exceeds 32 bit 
in AV1 RTP packet\n");
 return 0;
 }
 if ((num_lebs == 7) && (leb128 >= 0x80)) {
 /* leb128 is defined to be up to 8 bytes (why???), 8th byte MUST 
NOT
  * indicate continuation */
-av_log(ctx, AV_LOG_ERROR, "AV1: OBU size field consists of too 
many bytes in AV1 RTP packet\n");
+av_log(logctx, AV_LOG_ERROR, "AV1: OBU size field consists of too 
many bytes in AV1 RTP packet\n");
 return 0;
 }
 // shifts >= 32 are undefined in C!

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec: Remove leftover alpha declarations

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Mar  2 05:18:43 2025 +0100| [19e907cd725eba0246ca6bfe9526f8bbde0c5729] | 
committer: Andreas Rheinhardt

avcodec: Remove leftover alpha declarations

Forgotten in cdd139d760688b14849d02ee1907f68fe692c24e.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=19e907cd725eba0246ca6bfe9526f8bbde0c5729
---

 libavcodec/blockdsp.h| 1 -
 libavcodec/hpeldsp.h | 1 -
 libavcodec/idctdsp.h | 2 --
 libavcodec/me_cmp.h  | 1 -
 libavcodec/mpegvideo.h   | 1 -
 libavcodec/pixblockdsp.h | 2 --
 6 files changed, 8 deletions(-)

diff --git a/libavcodec/blockdsp.h b/libavcodec/blockdsp.h
index 6d751d797b..f83068ce53 100644
--- a/libavcodec/blockdsp.h
+++ b/libavcodec/blockdsp.h
@@ -38,7 +38,6 @@ typedef struct BlockDSPContext {
 
 void ff_blockdsp_init(BlockDSPContext *c);
 
-void ff_blockdsp_init_alpha(BlockDSPContext *c);
 void ff_blockdsp_init_arm(BlockDSPContext *c);
 void ff_blockdsp_init_ppc(BlockDSPContext *c);
 void ff_blockdsp_init_riscv(BlockDSPContext *c);
diff --git a/libavcodec/hpeldsp.h b/libavcodec/hpeldsp.h
index 45e81b10a5..41a46f0760 100644
--- a/libavcodec/hpeldsp.h
+++ b/libavcodec/hpeldsp.h
@@ -97,7 +97,6 @@ typedef struct HpelDSPContext {
 void ff_hpeldsp_init(HpelDSPContext *c, int flags);
 
 void ff_hpeldsp_init_aarch64(HpelDSPContext *c, int flags);
-void ff_hpeldsp_init_alpha(HpelDSPContext *c, int flags);
 void ff_hpeldsp_init_arm(HpelDSPContext *c, int flags);
 void ff_hpeldsp_init_ppc(HpelDSPContext *c, int flags);
 void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags);
diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h
index c08242881c..7783d7098a 100644
--- a/libavcodec/idctdsp.h
+++ b/libavcodec/idctdsp.h
@@ -98,8 +98,6 @@ void ff_idctdsp_init(IDCTDSPContext *c, struct AVCodecContext 
*avctx);
 
 void ff_idctdsp_init_aarch64(IDCTDSPContext *c, struct AVCodecContext *avctx,
  unsigned high_bit_depth);
-void ff_idctdsp_init_alpha(IDCTDSPContext *c, struct AVCodecContext *avctx,
-   unsigned high_bit_depth);
 void ff_idctdsp_init_arm(IDCTDSPContext *c, struct AVCodecContext *avctx,
  unsigned high_bit_depth);
 void ff_idctdsp_init_ppc(IDCTDSPContext *c, struct AVCodecContext *avctx,
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 9053327c4c..4aefcf1622 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -76,7 +76,6 @@ typedef struct MECmpContext {
 
 void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx);
-void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_ppc(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext *avctx);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 48fc1d418e..ac38d112f9 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -561,7 +561,6 @@ void ff_mpv_common_defaults(MpegEncContext *s);
 
 int ff_mpv_common_init(MpegEncContext *s);
 void ff_mpv_common_init_arm(MpegEncContext *s);
-void ff_mpv_common_init_axp(MpegEncContext *s);
 void ff_mpv_common_init_neon(MpegEncContext *s);
 void ff_mpv_common_init_ppc(MpegEncContext *s);
 void ff_mpv_common_init_x86(MpegEncContext *s);
diff --git a/libavcodec/pixblockdsp.h b/libavcodec/pixblockdsp.h
index cac5f3d4a2..215b0905d7 100644
--- a/libavcodec/pixblockdsp.h
+++ b/libavcodec/pixblockdsp.h
@@ -44,8 +44,6 @@ typedef struct PixblockDSPContext {
 void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx);
 void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c, AVCodecContext *avctx,
  unsigned high_bit_depth);
-void ff_pixblockdsp_init_alpha(PixblockDSPContext *c, AVCodecContext *avctx,
-   unsigned high_bit_depth);
 void ff_pixblockdsp_init_arm(PixblockDSPContext *c, AVCodecContext *avctx,
  unsigned high_bit_depth);
 void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, AVCodecContext *avctx,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg12dec: Use proper logcontext

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Mar  4 23:06:38 2025 +0100| [883120aaf04a42252ff95d0f48934006feb8a94c] | 
committer: Andreas Rheinhardt

avcodec/mpeg12dec: Use proper logcontext

When used with the "mpegvideo" or "mpeg1video" decoder (which do not
have a private class) this would lead to the log callback receiving
a non-NULL object with a NULL AVClass pointer. The default log callback
handles this gracefully, yet it is probably an API violation.

Reviewed-by: Ramiro Polla 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=883120aaf04a42252ff95d0f48934006feb8a94c
---

 libavcodec/mpeg12dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 843640edbf..14c028379e 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1655,11 +1655,11 @@ static int mpeg_decode_slice(MpegEncContext *s, int 
mb_y,
 }
 eos: // end of slice
 if (get_bits_left(&s->gb) < 0) {
-av_log(s, AV_LOG_ERROR, "overread %d\n", -get_bits_left(&s->gb));
+av_log(s->avctx, AV_LOG_ERROR, "overread %d\n", 
-get_bits_left(&s->gb));
 return AVERROR_INVALIDDATA;
 }
 *buf += (get_bits_count(&s->gb) - 1) / 8;
-ff_dlog(s, "Slice start:%d %d  end:%d %d\n", s->resync_mb_x, 
s->resync_mb_y, s->mb_x, s->mb_y);
+ff_dlog(s->avctx, "Slice start:%d %d  end:%d %d\n", s->resync_mb_x, 
s->resync_mb_y, s->mb_x, s->mb_y);
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/mpegenc, mpegts. mxfenc: Mark (de)muxers declarations as internal

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Mar  2 15:56:31 2025 +0100| [56cfbe3c9fcc45b95a5ef0e103721aec348e32de] | 
committer: Andreas Rheinhardt

avformat/mpegenc, mpegts. mxfenc: Mark (de)muxers declarations as internal

Otherwise compilers might emit code that presumes there to be
a GOT which can't be fixed by the linker.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=56cfbe3c9fcc45b95a5ef0e103721aec348e32de
---

 libavformat/mpegenc.c | 9 +
 libavformat/mpegts.c  | 3 ++-
 libavformat/mxfenc.c  | 5 +++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 6b6763c30f..30a034a418 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "libavutil/attributes.h"
+#include "libavutil/attributes_internal.h"
 #include "libavutil/fifo.h"
 #include "libavutil/log.h"
 #include "libavutil/mathematics.h"
@@ -88,10 +89,10 @@ typedef struct MpegMuxContext {
 int preload;
 } MpegMuxContext;
 
-extern const FFOutputFormat ff_mpeg1vcd_muxer;
-extern const FFOutputFormat ff_mpeg2dvd_muxer;
-extern const FFOutputFormat ff_mpeg2svcd_muxer;
-extern const FFOutputFormat ff_mpeg2vob_muxer;
+EXTERN const FFOutputFormat ff_mpeg1vcd_muxer;
+EXTERN const FFOutputFormat ff_mpeg2dvd_muxer;
+EXTERN const FFOutputFormat ff_mpeg2svcd_muxer;
+EXTERN const FFOutputFormat ff_mpeg2vob_muxer;
 
 static int put_pack_header(AVFormatContext *ctx, uint8_t *buf,
int64_t timestamp)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 765bedec5c..54594b3a11 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -21,6 +21,7 @@
 
 #include "config_components.h"
 
+#include "libavutil/attributes_internal.h"
 #include "libavutil/buffer.h"
 #include "libavutil/crc.h"
 #include "libavutil/internal.h"
@@ -274,7 +275,7 @@ typedef struct PESContext {
 int merged_st;
 } PESContext;
 
-extern const FFInputFormat ff_mpegts_demuxer;
+EXTERN const FFInputFormat ff_mpegts_demuxer;
 
 static struct Program * get_program(MpegTSContext *ts, unsigned int programid)
 {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index a482a6a352..ffb207576a 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 
+#include "libavutil/attributes_internal.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/random_seed.h"
@@ -66,8 +67,8 @@
 #include "config.h"
 #include "version.h"
 
-extern const FFOutputFormat ff_mxf_d10_muxer;
-extern const FFOutputFormat ff_mxf_opatom_muxer;
+EXTERN const FFOutputFormat ff_mxf_d10_muxer;
+EXTERN const FFOutputFormat ff_mxf_opatom_muxer;
 
 #define IS_D10(s)((s)->oformat == &ff_mxf_d10_muxer.p)
 #define IS_OPATOM(s) ((s)->oformat == &ff_mxf_opatom_muxer.p)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avutil/attributes_internal: Add EXTERN macro for extern+hidden

2025-03-04 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Mar  2 15:27:48 2025 +0100| [57f184221df261e041fcacc29fc1d4da196436ef] | 
committer: Andreas Rheinhardt

avutil/attributes_internal: Add EXTERN macro for extern+hidden

This is inspired by the equivalent dav1d attribute introduced
by Henrik Gramner in e4c4af02f3de5e6cea6f81272a2981c0fa7bae28.
Also already use it to beautify declarations.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=57f184221df261e041fcacc29fc1d4da196436ef
---

 libavcodec/mathops.h| 2 +-
 libavcodec/me_cmp.h | 2 +-
 libavcodec/vp9dsp.h | 2 +-
 libavutil/attributes_internal.h | 2 ++
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 84a924f31b..3e074ddf47 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -33,7 +33,7 @@
 extern const uint32_t ff_inverse[257];
 extern const uint8_t ff_log2_run[41];
 extern const uint8_t ff_sqrt_tab[256];
-extern const uint8_t attribute_visibility_hidden ff_crop_tab[256 + 2 * 
MAX_NEG_CROP];
+EXTERN const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP];
 extern const uint8_t ff_zigzag_direct[64];
 extern const uint8_t ff_zigzag_scan[16+1];
 
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 4aefcf1622..0857ed03e2 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -25,7 +25,7 @@
 
 #include "avcodec.h"
 
-extern const uint32_t attribute_visibility_hidden ff_square_tab[512];
+EXTERN const uint32_t ff_square_tab[512];
 
 
 /* minimum alignment rules ;)
diff --git a/libavcodec/vp9dsp.h b/libavcodec/vp9dsp.h
index 772848e349..0e93224e17 100644
--- a/libavcodec/vp9dsp.h
+++ b/libavcodec/vp9dsp.h
@@ -121,7 +121,7 @@ typedef struct VP9DSPContext {
 vp9_scaled_mc_func smc[5][N_FILTERS][2];
 } VP9DSPContext;
 
-extern const int16_t attribute_visibility_hidden 
ff_vp9_subpel_filters[3][16][8];
+EXTERN const int16_t ff_vp9_subpel_filters[3][16][8];
 
 void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact);
 
diff --git a/libavutil/attributes_internal.h b/libavutil/attributes_internal.h
index 3df1ee6af3..bc85ce77ff 100644
--- a/libavutil/attributes_internal.h
+++ b/libavutil/attributes_internal.h
@@ -31,4 +31,6 @@
 #define FF_VISIBILITY_POP_HIDDEN
 #endif
 
+#define EXTERN extern attribute_visibility_hidden
+
 #endif /* AVUTIL_ATTRIBUTES_INTERNAL_H */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] aarch64/hevcdsp_idct_neon: Optimize idct dc

2025-03-04 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Thu Feb 20 
00:50:23 2025 +0800| [5977bff569b1e1feecf681059472f4106c1573cb] | committer: 
Zhao Zhili

aarch64/hevcdsp_idct_neon: Optimize idct dc

clang does better than the assembly code before the patch, especially
for small size:

hevc_idct_4x4_dc_8_c:   11.2 ( 1.00x)
hevc_idct_4x4_dc_8_neon:15.5 ( 0.73x)
hevc_idct_4x4_dc_10_c:  12.0 ( 1.00x)
hevc_idct_4x4_dc_10_neon:   15.2 ( 0.79x)
hevc_idct_8x8_dc_8_c:   13.2 ( 1.00x)
hevc_idct_8x8_dc_8_neon:18.2 ( 0.73x)
hevc_idct_8x8_dc_10_c:  13.5 ( 1.00x)
hevc_idct_8x8_dc_10_neon:   17.2 ( 0.78x)
hevc_idct_16x16_dc_8_c: 41.8 ( 1.00x)
hevc_idct_16x16_dc_8_neon:  37.8 ( 1.11x)
hevc_idct_16x16_dc_10_c:41.8 ( 1.00x)
hevc_idct_16x16_dc_10_neon: 37.8 ( 1.11x)
hevc_idct_32x32_dc_8_c:130.2 ( 1.00x)
hevc_idct_32x32_dc_8_neon: 132.2 ( 0.98x)
hevc_idct_32x32_dc_10_c:   130.2 ( 1.00x)
hevc_idct_32x32_dc_10_neon:132.2 ( 0.98x)

This patch basically clone what the compiler does, so the performance
is the same.

Reviewed-by: Martin Storsjö 
Signed-off-by: Zhao Zhili 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5977bff569b1e1feecf681059472f4106c1573cb
---

 libavcodec/aarch64/hevcdsp_idct_neon.S | 59 ++
 1 file changed, 31 insertions(+), 28 deletions(-)

diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S 
b/libavcodec/aarch64/hevcdsp_idct_neon.S
index 3cac6e6db9..2337ed8ba3 100644
--- a/libavcodec/aarch64/hevcdsp_idct_neon.S
+++ b/libavcodec/aarch64/hevcdsp_idct_neon.S
@@ -888,38 +888,41 @@ function ff_hevc_transform_luma_4x4_neon_8, export=1
 ret
 endfunc
 
+.macro idct_8x8_dc_store offset
+.irpi, 0x0, 0x20, 0x40, 0x60
+stp q0, q0, [x0, #(\offset + \i)]
+.endr
+.endm
+
+.macro idct_16x16_dc_store
+.irpindex, 0x0, 0x80, 0x100, 0x180
+idct_8x8_dc_store offset=\index
+.endr
+.endm
+
 // void ff_hevc_idct_NxN_dc_DEPTH_neon(int16_t *coeffs)
 .macro idct_dc size, bitdepth
 function ff_hevc_idct_\size\()x\size\()_dc_\bitdepth\()_neon, export=1
-ld1r{v4.8h}, [x0]
-srshr   v4.8h,  v4.8h,  #1
-srshr   v0.8h,  v4.8h,  #(14 - \bitdepth)
-srshr   v1.8h,  v4.8h,  #(14 - \bitdepth)
-.if \size > 4
-srshr   v2.8h,  v4.8h,  #(14 - \bitdepth)
-srshr   v3.8h,  v4.8h,  #(14 - \bitdepth)
-.if \size > 16 /* dc 32x32 */
-mov x2,  #4
+ldrsh   w1, [x0]
+add w1, w1, #1
+asr w1, w1, #1
+add w1, w1, #(1 << (13 - \bitdepth))
+asr w1, w1, #(14 - \bitdepth)
+dup v0.8h, w1
+
+.if \size < 8
+stp q0, q0, [x0]
+.elseif \size < 16
+idct_8x8_dc_store 0x0
+.elseif \size < 32
+idct_16x16_dc_store
+.else
+add x2, x0, #(32 * 32 * 2)
 1:
-subsx2,  x2, #1
-.endif
-add x12,  x0, #64
-mov x13,  #128
-.if \size > 8 /* dc 16x16 */
-st1 {v0.8h-v3.8h},  [x0], x13
-st1 {v0.8h-v3.8h}, [x12], x13
-st1 {v0.8h-v3.8h},  [x0], x13
-st1 {v0.8h-v3.8h}, [x12], x13
-st1 {v0.8h-v3.8h},  [x0], x13
-st1 {v0.8h-v3.8h}, [x12], x13
-.endif /* dc 8x8 */
-st1 {v0.8h-v3.8h},  [x0], x13
-st1 {v0.8h-v3.8h}, [x12], x13
-.if \size > 16 /* dc 32x32 */
-bne 1b
-.endif
-.else /* dc 4x4 */
-st1 {v0.8h-v1.8h},  [x0]
+idct_16x16_dc_store
+add x0, x0, #(16 * 16 * 2)
+cmp x0, x2
+b.lt1b
 .endif
 ret
 endfunc

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/movenc: Add AVS3 support

2025-03-04 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Tue Feb 18 
19:24:48 2025 +0800| [a053516e644e07d1e625901539671c3682c7af49] | committer: 
Zhao Zhili

avformat/movenc: Add AVS3 support

'avs3' is registered at mp4ra.org. The Avs3ConfigurationBox 'av3c'
inside 'avs3' hasn't been registered yet, but is specified by the
AVS3 spec.

Signed-off-by: Zhao Zhili 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a053516e644e07d1e625901539671c3682c7af49
---

 libavformat/movenc.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 76dce9e6e5..af013e1fc6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1540,6 +1540,38 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack 
*track)
 return update_size(pb, pos);
 }
 
+/* AVS3 Intelligent Media Coding
+ * Information Technology - Intelligent Media Coding
+ * Part 6: Intelligent Media Format
+ */
+static int mov_write_av3c(AVIOContext *pb, const uint8_t *data, int len)
+{
+if (len < 4)
+return AVERROR_INVALIDDATA;
+
+if (data[0] == 1) {
+// In Avs3DecoderConfigurationRecord format
+avio_write(pb, data, len);
+return 0;
+}
+
+avio_w8(pb, 1); // version
+avio_wb16(pb, len); // sequence_header_length
+avio_write(pb, data, len);  // sequence_header
+avio_w8(pb, 0xFC);  // Only support library_dependency_idc = 0
+
+return 0;
+}
+
+static int mov_write_av3c_tag(AVIOContext *pb, MOVTrack *track)
+{
+int64_t pos = avio_tell(pb);
+avio_wb32(pb, 0);
+ffio_wfourcc(pb, "av3c");
+mov_write_av3c(pb, track->vos_data, track->vos_len);
+return update_size(pb, pos);
+}
+
 static int mov_write_vpcc_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
 {
 int64_t pos = avio_tell(pb);
@@ -2738,6 +2770,8 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 } else if (track->par->codec_id == AV_CODEC_ID_R10K) {
 if (track->par->codec_tag == MKTAG('R','1','0','k'))
 mov_write_dpxe_tag(pb, track);
+} else if (track->par->codec_id == AV_CODEC_ID_AVS3) {
+mov_write_av3c_tag(pb, track);
 } else if (track->vos_len > 0)
 mov_write_glbl_tag(pb, track);
 
@@ -8646,6 +8680,8 @@ static const AVCodecTag codec_mp4_tags[] = {
 { AV_CODEC_ID_PCM_F64BE,   MOV_MP4_FPCM_TAG  },
 { AV_CODEC_ID_PCM_F64LE,   MOV_MP4_FPCM_TAG  },
 
+{ AV_CODEC_ID_AVS3,MKTAG('a', 'v', 's', '3') },
+
 { AV_CODEC_ID_NONE,   0 },
 };
 #if CONFIG_MP4_MUXER || CONFIG_PSP_MUXER

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/isom_tags: Add tag for AVS3

2025-03-04 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Mon Feb 24 
21:51:46 2025 +0800| [2d7966aee158682d3112c0f293254a96ef26950c] | committer: 
Zhao Zhili

avformat/isom_tags: Add tag for AVS3

Signed-off-by: Zhao Zhili 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d7966aee158682d3112c0f293254a96ef26950c
---

 libavformat/isom_tags.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index a476efb8f1..f05762beec 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -297,6 +297,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 
 { AV_CODEC_ID_LCEVC, MKTAG('l', 'v', 'c', '1') }, /* LCEVC raw payload */
 
+{ AV_CODEC_ID_AVS3, MKTAG('a', 'v', 's', '3') },
+
 { AV_CODEC_ID_NONE, 0 },
 };
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/libuavs3d: process extradata

2025-03-04 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Mon Feb 24 
21:51:51 2025 +0800| [5a32496962853beb302ebce307821c7c960fa54f] | committer: 
Zhao Zhili

avcodec/libuavs3d: process extradata

Signed-off-by: Zhao Zhili 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5a32496962853beb302ebce307821c7c960fa54f
---

 libavcodec/libuavs3d.c | 120 -
 1 file changed, 89 insertions(+), 31 deletions(-)

diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c
index 53b5faafc5..a22494340c 100644
--- a/libavcodec/libuavs3d.c
+++ b/libavcodec/libuavs3d.c
@@ -106,6 +106,91 @@ FF_ENABLE_DEPRECATION_WARNINGS
 uavs3d_img_cpy_cvt(&frm_out, dec_frame, dec_frame->bit_depth);
 }
 
+#define UAVS3D_CHECK_INVALID_RANGE(v, l, r) ((v)<(l)||(v)>(r))
+
+static int libuavs3d_on_seq_header(AVCodecContext *avctx)
+{
+uavs3d_context *h = avctx->priv_data;
+uavs3d_io_frm_t *frm_dec = &h->dec_frame;
+struct uavs3d_com_seqh_t *seqh = frm_dec->seqhdr;
+int ret;
+
+if (UAVS3D_CHECK_INVALID_RANGE(seqh->frame_rate_code, 0, 15)) {
+av_log(avctx, AV_LOG_ERROR, "Invalid frame rate code: %d.\n", 
seqh->frame_rate_code);
+seqh->frame_rate_code = 3; // default 25 fps
+} else {
+avctx->framerate.num = 
ff_avs3_frame_rate_tab[seqh->frame_rate_code].num;
+avctx->framerate.den = 
ff_avs3_frame_rate_tab[seqh->frame_rate_code].den;
+}
+avctx->has_b_frames = seqh->output_reorder_delay;
+avctx->pix_fmt = seqh->bit_depth_internal == 8 ? AV_PIX_FMT_YUV420P : 
AV_PIX_FMT_YUV420P10LE;
+ret = ff_set_dimensions(avctx, seqh->horizontal_size, seqh->vertical_size);
+if (ret < 0)
+return ret;
+h->got_seqhdr = 1;
+
+if (seqh->colour_description) {
+if (UAVS3D_CHECK_INVALID_RANGE(seqh->colour_primaries, 0, 9) ||
+UAVS3D_CHECK_INVALID_RANGE(seqh->transfer_characteristics, 0, 14) 
||
+UAVS3D_CHECK_INVALID_RANGE(seqh->matrix_coefficients, 0, 11)) {
+av_log(avctx, AV_LOG_ERROR,
+   "Invalid colour description: primaries: %d"
+   "transfer characteristics: %d"
+   "matrix coefficients: %d.\n",
+   seqh->colour_primaries,
+   seqh->transfer_characteristics,
+   seqh->matrix_coefficients);
+} else {
+avctx->color_primaries = 
ff_avs3_color_primaries_tab[seqh->colour_primaries];
+avctx->color_trc   = ff_avs3_color_transfer_tab 
[seqh->transfer_characteristics];
+avctx->colorspace  = ff_avs3_color_matrix_tab   
[seqh->matrix_coefficients];
+}
+}
+
+return 0;
+}
+
+static int libuavs3d_decode_extradata(AVCodecContext *avctx)
+{
+uavs3d_context *h = avctx->priv_data;
+uint8_t *header = avctx->extradata;
+int header_size = avctx->extradata_size;
+uavs3d_io_frm_t *frm_dec = &h->dec_frame;
+
+if (avctx->extradata_size < 4) {
+av_log(avctx, AV_LOG_WARNING, "Invalid extradata size %d\n",
+   avctx->extradata_size);
+return 0;
+}
+
+if (header[0] == 1) {
+// Skip configurationVersion and sequence_header_length
+header += 3;
+// Also remove library_dependency_idc at the end
+header_size -= 4;
+}
+
+frm_dec->nal_type = 0;
+frm_dec->pkt_pos = 0;
+frm_dec->pkt_size = header_size;
+frm_dec->bs = header;
+frm_dec->bs_len = header_size;
+frm_dec->pts = 0;
+frm_dec->dts = 0;
+uavs3d_decode(h->dec_handle, frm_dec);
+if (frm_dec->nal_type == NAL_SEQ_HEADER) {
+int ret = libuavs3d_on_seq_header(avctx);
+if (ret < 0)
+av_log(avctx, AV_LOG_WARNING,
+   "Process sequence header failed, %s\n", av_err2str(ret));
+} else {
+av_log(avctx, AV_LOG_WARNING,
+   "Missing sequence header in extradata\n");
+}
+
+return 0;
+}
+
 static av_cold int libuavs3d_init(AVCodecContext *avctx)
 {
 uavs3d_context *h = avctx->priv_data;
@@ -120,6 +205,9 @@ static av_cold int libuavs3d_init(AVCodecContext *avctx)
 return AVERROR(ENOMEM);
 }
 
+if (avctx->extradata)
+return libuavs3d_decode_extradata(avctx);
+
 return 0;
 }
 
@@ -146,7 +234,6 @@ static void libuavs3d_flush(AVCodecContext * avctx)
 }
 }
 
-#define UAVS3D_CHECK_INVALID_RANGE(v, l, r) ((v)<(l)||(v)>(r))
 static int libuavs3d_decode_frame(AVCodecContext *avctx, AVFrame *frm,
   int *got_frame, AVPacket *avpkt)
 {
@@ -207,38 +294,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 buf_ptr += bs_len;
 
 if (frm_dec->nal_type == NAL_SEQ_HEADER) {
-struct uavs3d_com_seqh_t *seqh = frm_dec->seqhdr;
-if (UAVS3D_CHECK_INVALID_RANGE(seqh->frame_rate_code, 0, 15)) {
-av_log(avctx, AV_LOG_ERROR, "Invalid frame rate code: 
%d.\n", seqh->frame_rate_code);
-seqh->frame_rate_cod

[FFmpeg-cvslog] aarch64/hevcdsp_idct_neon: Add implementation for idct dc 12

2025-03-04 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Thu Feb 20 
00:50:31 2025 +0800| [3e9777dc7546425651bc265a49187d6bbb42bdf4] | committer: 
Zhao Zhili

aarch64/hevcdsp_idct_neon: Add implementation for idct dc 12

Reduce binary size at the same time. The performance compared to clang -O3
is the same.

Reviewed-by: Martin Storsjö 
Signed-off-by: Zhao Zhili 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3e9777dc7546425651bc265a49187d6bbb42bdf4
---

 libavcodec/aarch64/hevcdsp_idct_neon.S| 43 +++
 libavcodec/aarch64/hevcdsp_init_aarch64.c |  8 ++
 2 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S 
b/libavcodec/aarch64/hevcdsp_idct_neon.S
index 2337ed8ba3..954ce2407a 100644
--- a/libavcodec/aarch64/hevcdsp_idct_neon.S
+++ b/libavcodec/aarch64/hevcdsp_idct_neon.S
@@ -901,15 +901,33 @@ endfunc
 .endm
 
 // void ff_hevc_idct_NxN_dc_DEPTH_neon(int16_t *coeffs)
-.macro idct_dc size, bitdepth
-function ff_hevc_idct_\size\()x\size\()_dc_\bitdepth\()_neon, export=1
+.macro idct_dc size
+function ff_hevc_idct_\size\()x\size\()_dc_10_neon, export=1
 ldrsh   w1, [x0]
 add w1, w1, #1
 asr w1, w1, #1
-add w1, w1, #(1 << (13 - \bitdepth))
-asr w1, w1, #(14 - \bitdepth)
-dup v0.8h, w1
+add w1, w1, #(1 << (13 - 10))
+asr w1, w1, #(14 - 10)
+b   2f
+endfunc
+
+function ff_hevc_idct_\size\()x\size\()_dc_12_neon, export=1
+ldrsh   w1, [x0]
+add w1, w1, #1
+asr w1, w1, #1
+add w1, w1, #(1 << (13 - 12))
+asr w1, w1, #(14 - 12)
+b   2f
+endfunc
 
+function ff_hevc_idct_\size\()x\size\()_dc_8_neon, export=1
+ldrsh   w1, [x0]
+add w1, w1, #1
+asr w1, w1, #1
+add w1, w1, #(1 << (13 - 8))
+asr w1, w1, #(14 - 8)
+2:
+dup v0.8h, w1
 .if \size < 8
 stp q0, q0, [x0]
 .elseif \size < 16
@@ -928,14 +946,7 @@ function 
ff_hevc_idct_\size\()x\size\()_dc_\bitdepth\()_neon, export=1
 endfunc
 .endm
 
-idct_dc 4, 8
-idct_dc 4, 10
-
-idct_dc 8, 8
-idct_dc 8, 10
-
-idct_dc 16, 8
-idct_dc 16, 10
-
-idct_dc 32, 8
-idct_dc 32, 10
+idct_dc 4
+idct_dc 8
+idct_dc 16
+idct_dc 32
diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c 
b/libavcodec/aarch64/hevcdsp_init_aarch64.c
index 386d7c59c8..5dd470baaa 100644
--- a/libavcodec/aarch64/hevcdsp_init_aarch64.c
+++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c
@@ -91,6 +91,10 @@ void ff_hevc_idct_4x4_dc_10_neon(int16_t *coeffs);
 void ff_hevc_idct_8x8_dc_10_neon(int16_t *coeffs);
 void ff_hevc_idct_16x16_dc_10_neon(int16_t *coeffs);
 void ff_hevc_idct_32x32_dc_10_neon(int16_t *coeffs);
+void ff_hevc_idct_4x4_dc_12_neon(int16_t *coeffs);
+void ff_hevc_idct_8x8_dc_12_neon(int16_t *coeffs);
+void ff_hevc_idct_16x16_dc_12_neon(int16_t *coeffs);
+void ff_hevc_idct_32x32_dc_12_neon(int16_t *coeffs);
 void ff_hevc_transform_luma_4x4_neon_8(int16_t *coeffs);
 
 #define NEON8_FNASSIGN(member, v, h, fn, ext) \
@@ -267,5 +271,9 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, 
const int bit_depth)
 c->add_residual[1] = ff_hevc_add_residual_8x8_12_neon;
 c->add_residual[2] = ff_hevc_add_residual_16x16_12_neon;
 c->add_residual[3] = ff_hevc_add_residual_32x32_12_neon;
+c->idct_dc[0]  = ff_hevc_idct_4x4_dc_12_neon;
+c->idct_dc[1]  = ff_hevc_idct_8x8_dc_12_neon;
+c->idct_dc[2]  = ff_hevc_idct_16x16_dc_12_neon;
+c->idct_dc[3]  = ff_hevc_idct_32x32_dc_12_neon;
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/exr: do not output 32bit floats when a file stores 16bit floats

2025-03-04 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan  9 23:08:23 2025 +0100| [0e917389fe73c932049635d947bba076f1709589] | 
committer: Michael Niedermayer

avcodec/exr: do not output 32bit floats when a file stores 16bit floats

exr should not do a internal pixel format convert

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0e917389fe73c932049635d947bba076f1709589
---

 libavcodec/exr.c   | 65 ++
 tests/ref/fate/exr-rgb-b44a-half-negative-4x4  |  2 +-
 .../fate/exr-rgb-scanline-b44-half-float-12x8-l1   |  2 +-
 tests/ref/fate/exr-rgb-scanline-half-b44-12x8  |  2 +-
 tests/ref/fate/exr-rgb-scanline-half-b44-13x9  |  2 +-
 tests/ref/fate/exr-rgb-scanline-half-piz-bw|  2 +-
 tests/ref/fate/exr-rgb-scanline-half-piz-color |  2 +-
 tests/ref/fate/exr-rgb-scanline-half-piz-dw-large  |  2 +-
 tests/ref/fate/exr-rgb-scanline-half-piz-dw-t01|  2 +-
 tests/ref/fate/exr-rgb-scanline-half-piz-dw-t08|  2 +-
 tests/ref/fate/exr-rgb-scanline-half-zip-dw-large  |  2 +-
 .../ref/fate/exr-rgb-scanline-pxr24-float-half-l2  |  2 +-
 .../ref/fate/exr-rgb-scanline-pxr24-half-float-l1  |  2 +-
 tests/ref/fate/exr-rgb-scanline-raw-half-float-l1  |  2 +-
 tests/ref/fate/exr-rgb-scanline-rle-half-float-l1  |  2 +-
 .../ref/fate/exr-rgb-scanline-zip-half-0x0-0x  |  2 +-
 tests/ref/fate/exr-rgb-scanline-zip-half-float-l1  |  2 +-
 tests/ref/fate/exr-rgb-scanline-zip1-half-float-l1 |  2 +-
 ...xr-rgb-scanline-zip1-half-float-l1-zero-offsets |  2 +-
 tests/ref/fate/exr-rgb-tile-half-float-b44-12x8-l1 |  2 +-
 tests/ref/fate/exr-rgb-tile-half-piz-dw-large  |  2 +-
 tests/ref/fate/exr-rgb-tile-half-raw-12x8  |  2 +-
 tests/ref/fate/exr-rgb-tile-half-zip   |  2 +-
 tests/ref/fate/exr-rgb-tile-pxr24-float-half-l2|  2 +-
 tests/ref/fate/exr-rgb-tile-pxr24-half-float-l1|  2 +-
 tests/ref/fate/exr-rgb-tile-raw-half-float-l1  |  2 +-
 tests/ref/fate/exr-rgb-tile-rle-half-float-l1  |  2 +-
 tests/ref/fate/exr-rgb-tile-zip-half-float-l1  |  2 +-
 tests/ref/fate/exr-rgb-tile-zip1-half-float-l1 |  2 +-
 tests/ref/fate/exr-rgba-multiscanline-half-b44 |  2 +-
 .../fate/exr-rgba-scanline-float-half-b44-12x8-l2  |  2 +-
 .../fate/exr-rgba-scanline-float-half-b44-13x9-l2  |  2 +-
 .../fate/exr-rgba-scanline-float-half-b44a-12x8-l2 |  2 +-
 .../fate/exr-rgba-scanline-float-half-b44a-13x9-l2 |  2 +-
 tests/ref/fate/exr-rgba-zip16-16x32-flag4  |  2 +-
 tests/ref/fate/exr-slice-pxr24 |  2 +-
 tests/ref/fate/exr-slice-raw   |  2 +-
 tests/ref/fate/exr-slice-rle   |  2 +-
 tests/ref/fate/exr-slice-zip1  |  2 +-
 tests/ref/fate/exr-slice-zip16 |  2 +-
 tests/ref/fate/exr-y-scanline-zip-half-12x8|  2 +-
 tests/ref/fate/exr-y-tile-zip-half-12x8|  2 +-
 tests/ref/fate/exr-ya-scanline-zip-half-12x8   |  2 +-
 43 files changed, 83 insertions(+), 66 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 4bac0be89b..7e8020a0ff 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1185,7 +1185,7 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 int line, col = 0;
 uint64_t tile_x, tile_y, tile_level_x, tile_level_y;
 const uint8_t *src;
-int step = s->desc->flags & AV_PIX_FMT_FLAG_FLOAT ? 4 : 2 * 
s->desc->nb_components;
+int step = s->desc->comp[0].step;
 int bxmin = 0, axmax = 0, window_xoffset = 0;
 int window_xmin, window_xmax, window_ymin, window_ymax;
 int data_xoffset, data_yoffset, data_window_offset, xsize, ysize;
@@ -1365,7 +1365,7 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
  if (s->channel_offsets[3] >= 0)
 channel_buffer[3] = src + (td->xsize * s->channel_offsets[3]) + 
data_window_offset;
 
-if (s->desc->flags & AV_PIX_FMT_FLAG_FLOAT) {
+if (s->desc->flags & AV_PIX_FMT_FLAG_PLANAR || s->desc->nb_components == 1 
) {
 /* todo: change this when a floating point pixel format with luma with 
alpha is implemented */
 int channel_count = s->channel_offsets[3] >= 0 ? 4 : rgb_channel_count;
 if (s->is_luma) {
@@ -1379,19 +1379,20 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 
 for (i = 0; i < ysize; i++, ptr += p->linesize[plane]) {
 const uint8_t *src;
-union av_intfloat32 *ptr_x;
-
-src = channel_buffer[c];
-ptr_x = (union av_intfloat32 *)ptr;
-
-// Zero out the start if xmin is not 0
-memset(ptr_x, 0, bxmin);
-ptr_x += window_xoffset;
 
 if (s->pixel_type == EXR_FLOAT ||
 s->compression == EXR_DWAA ||
 s->compression == EXR_DWAB) {
 // 32-bit
+