[FFmpeg-cvslog] fate/vvc: add vvc-conformance-RPR_A_4

2024-06-20 Thread Frank Plowman
ffmpeg | branch: master | Frank Plowman  | Mon Jun 10 
17:46:58 2024 +| [0eacad6921c6835d0432f02b1aa5ec9b492a3572] | committer: 
James Almer

fate/vvc: add vvc-conformance-RPR_A_4

  BeforeAfter
-
make fate-vvc CPU Time (No ASM)  131.52s  134.83s
libavcodec/vvc/* Line Coverage 95.3%96.9%
inter_template.c Line Coverage 74.3%88.2%
inter.c Line Coverage  85.3%99.2%

Signed-off-by: Frank Plowman 

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

 tests/fate/vvc.mak | 1 +
 tests/ref/fate/vvc-conformance-RPR_A_4 | 9 +
 2 files changed, 10 insertions(+)

diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
index 0ff287eea6..3e762ec65e 100644
--- a/tests/fate/vvc.mak
+++ b/tests/fate/vvc.mak
@@ -14,6 +14,7 @@ VVC_SAMPLES_10BIT =   \
 POC_A_1   \
 PPS_B_1   \
 RAP_A_1   \
+RPR_A_4   \
 SAO_A_3   \
 SCALING_A_1   \
 SLICES_A_3\
diff --git a/tests/ref/fate/vvc-conformance-RPR_A_4 
b/tests/ref/fate/vvc-conformance-RPR_A_4
new file mode 100644
index 00..58ae0f3861
--- /dev/null
+++ b/tests/ref/fate/vvc-conformance-RPR_A_4
@@ -0,0 +1,9 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 832x480
+#sar 0: 0/1
+0,  0,  0,1,  1198080, 0x2c12c2be
+0,  1,  1,1,  1198080, 0x47275378
+0,  2,  2,1,  1198080, 0x5d7b0327
+0,  3,  3,1,  1198080, 0x0b15318a

___
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: split off generic NAL function helpers into their own file

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun Jun 16 13:55:25 
2024 -0300| [53c8d417edb0e156f39e50b4166279ac7144318f] | committer: James Almer

avformat: split off generic NAL function helpers into their own file

Signed-off-by: James Almer 

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

 libavformat/Makefile   |   2 +-
 libavformat/avc.c  | 164 +--
 libavformat/avc.h  |  37 
 libavformat/flvenc.c   |   3 +-
 libavformat/hevc.c |   7 +-
 libavformat/hlsenc.c   |   1 +
 libavformat/matroskaenc.c  |   1 +
 libavformat/movenc.c   |   5 +-
 libavformat/movenccenc.c   |   5 +-
 libavformat/mxfenc.c   |   3 +-
 libavformat/nal.c  | 190 +
 libavformat/nal.h  |  67 +++
 libavformat/rtpenc_h264_hevc.c |   9 +-
 libavformat/sdp.c  |   5 +-
 libavformat/vvc.c  |   7 +-
 15 files changed, 288 insertions(+), 218 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index af31d6f795..7ca68a7036 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -35,7 +35,7 @@ OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
 
 # subsystems
 OBJS-$(CONFIG_ISO_MEDIA) += isom.o
-OBJS-$(CONFIG_ISO_WRITER)+= av1.o avc.o hevc.o vvc.o vpcc.o
+OBJS-$(CONFIG_ISO_WRITER)+= av1.o avc.o hevc.o nal.o vvc.o 
vpcc.o
 OBJS-$(CONFIG_IAMFDEC)   += iamf_reader.o iamf_parse.o iamf.o
 OBJS-$(CONFIG_IAMFENC)   += iamf_writer.o iamf.o
 OBJS-$(CONFIG_NETWORK)   += network.o
diff --git a/libavformat/avc.c b/libavformat/avc.c
index 047ea88077..e4040928cd 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -26,118 +26,7 @@
 #include "avio.h"
 #include "avc.h"
 #include "avio_internal.h"
-
-static const uint8_t *avc_find_startcode_internal(const uint8_t *p, const 
uint8_t *end)
-{
-const uint8_t *a = p + 4 - ((intptr_t)p & 3);
-
-for (end -= 3; p < a && p < end; p++) {
-if (p[0] == 0 && p[1] == 0 && p[2] == 1)
-return p;
-}
-
-for (end -= 3; p < end; p += 4) {
-uint32_t x = *(const uint32_t*)p;
-//  if ((x - 0x01000100) & (~x) & 0x80008000) // little endian
-//  if ((x - 0x00010001) & (~x) & 0x00800080) // big endian
-if ((x - 0x01010101) & (~x) & 0x80808080) { // generic
-if (p[1] == 0) {
-if (p[0] == 0 && p[2] == 1)
-return p;
-if (p[2] == 0 && p[3] == 1)
-return p+1;
-}
-if (p[3] == 0) {
-if (p[2] == 0 && p[4] == 1)
-return p+2;
-if (p[4] == 0 && p[5] == 1)
-return p+3;
-}
-}
-}
-
-for (end += 3; p < end; p++) {
-if (p[0] == 0 && p[1] == 0 && p[2] == 1)
-return p;
-}
-
-return end + 3;
-}
-
-const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end){
-const uint8_t *out = avc_find_startcode_internal(p, end);
-if(pnalus);
-while (nal_start < end && !*(nal_start++));
-if (nal_start == end)
-break;
-
-nal_end = ff_avc_find_startcode(nal_start, end);
-if (pb) {
-avio_wb32(pb, nal_end - nal_start);
-avio_write(pb, nal_start, nal_end - nal_start);
-} else if (list->nb_nalus >= nalu_limit) {
-return AVERROR(ERANGE);
-} else {
-NALU *tmp = av_fast_realloc(list->nalus, &list->nalus_array_size,
-(list->nb_nalus + 1) * 
sizeof(*list->nalus));
-if (!tmp)
-return AVERROR(ENOMEM);
-list->nalus = tmp;
-tmp[list->nb_nalus++] = (NALU){ .offset = nal_start - p,
-.size   = nal_end - nal_start };
-}
-size += 4 + nal_end - nal_start;
-nal_start = nal_end;
-}
-return size;
-}
-
-int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
-{
-return avc_parse_nal_units(pb, NULL, buf_in, size);
-}
-
-int ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size)
-{
-list->nb_nalus = 0;
-return avc_parse_nal_units(NULL, list, buf, size);
-}
-
-void ff_nal_units_write_list(const NALUList *list, AVIOContext *pb,
- const uint8_t *buf)
-{
-for (unsigned i = 0; i < list->nb_nalus; i++) {
-avio_wb32(pb, list->nalus[i].size);
-avio_write(pb, buf + list->nalus[i].offset, list->nalus[i].size);
-}
-}
-
-int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
-{
-AVIOContext *pb;
-int ret = avio_open_dyn_buf(&pb);
-if(ret < 0)
-return ret;
-
-ff_avc_parse_nal_

[FFmpeg-cvslog] libavcodec/amfenc: Update AMF release version

2024-06-20 Thread Araz Iusubov
ffmpeg | branch: master | Araz Iusubov  | Thu Jun 13 
18:19:00 2024 +0200| [696bd64d01d6e62474c27cf27557457cf297d08d] | committer: 
James Almer

libavcodec/amfenc: Update AMF release version

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

 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 95565994fe..7d47065c52 100755
--- a/configure
+++ b/configure
@@ -7350,7 +7350,7 @@ fi
 
 enabled amf &&
 check_cpp_condition amf "AMF/core/Version.h" \
-"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | 
AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x00010004001d"
+"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | 
AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x000100040021"
 
 # Funny iconv installations are not unusual, so check it after all flags have 
been set
 if enabled libc_iconv; then

___
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] libavcodec/amfenc: Update AMF encoder options

2024-06-20 Thread Araz Iusubov
ffmpeg | branch: master | Araz Iusubov  | Thu Jun 13 
18:19:01 2024 +0200| [02430680b02ee42472148e67e178b6d1c2ac43fd] | committer: 
James Almer

libavcodec/amfenc: Update AMF encoder options

Encoder options have been updated to the current version of the AMF.

Signed-off-by: Araz Iusubov 

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

 libavcodec/amfenc_av1.c  | 108 +++
 libavcodec/amfenc_h264.c | 146 ++-
 libavcodec/amfenc_hevc.c | 143 ++
 3 files changed, 259 insertions(+), 138 deletions(-)

diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c
index 9f18aac648..d40c71cb33 100644
--- a/libavcodec/amfenc_av1.c
+++ b/libavcodec/amfenc_av1.c
@@ -25,15 +25,16 @@
 #define OFFSET(x) offsetof(AmfContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
-{ "usage",  "Set the encoding usage",   
OFFSET(usage),  AV_OPT_TYPE_INT,   {.i64 = 
AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING }, 
AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING, 
AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY, VE, .unit = "usage" },
-{ "transcoding","", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING }, 0, 0, VE, .unit = "usage" },
-{ "lowlatency", "", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY }, 0, 0, VE, .unit = "usage" },
 
-{ "profile","Set the profile (default main)",   
OFFSET(profile),AV_OPT_TYPE_INT,{.i64 = 
AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN }, AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN, 
AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN, VE, .unit = "profile" },
+{ "usage",  "Set the encoding usage",   
OFFSET(usage),  AV_OPT_TYPE_INT,   {.i64 = -1 }, -1, 
AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY, VE, .unit = "usage" },
+{ "transcoding","Generic Transcoding",  0, 
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING  
 }, 0, 0, VE, .unit = "usage" },
+{ "lowlatency", "Low latency usecase",  0, 
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY  
 }, 0, 0, VE, .unit = "usage" },
+
+{ "profile","Set the profile",   OFFSET(profile),  
  AV_OPT_TYPE_INT,{.i64 = -1 }, -1, 
AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN, VE, .unit = "profile" },
 { "main",   "", 0, AV_OPT_TYPE_CONST,{.i64 = 
AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN }, 0, 0, VE, .unit = "profile" },
 
-{ "level",  "Set the encoding level (default auto)",
OFFSET(level),  AV_OPT_TYPE_INT,{.i64 = 0 }, 0, 
AMF_VIDEO_ENCODER_AV1_LEVEL_7_3, VE, .unit = "level" },
-{ "auto",   "", 0, AV_OPT_TYPE_CONST, {.i64 = 0
   }, 0, 0, VE, .unit = "level" },
+{ "level",  "Set the encoding level (default auto)",
OFFSET(level),  AV_OPT_TYPE_INT,{.i64 = -1 }, -1, 
AMF_VIDEO_ENCODER_AV1_LEVEL_7_3, VE, .unit = "level" },
+{ "auto",   "", 0, AV_OPT_TYPE_CONST, {.i64 = -1   
   }, 0, 0, VE, .unit = "level" },
 { "2.0","", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_LEVEL_2_0 }, 0, 0, VE, .unit = "level" },
 { "2.1","", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_LEVEL_2_1 }, 0, 0, VE, .unit = "level" },
 { "2.2","", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_LEVEL_2_2 }, 0, 0, VE, .unit = "level" },
@@ -59,11 +60,12 @@ static const AVOption options[] = {
 { "7.2","", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_LEVEL_7_2 }, 0, 0, VE, .unit = "level" },
 { "7.3","", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_LEVEL_7_3 }, 0, 0, VE, .unit = "level" },
 
-{ "quality","Set the encoding quality", 
OFFSET(quality),AV_OPT_TYPE_INT,   {.i64 = 
AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED }, 
AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_HIGH_QUALITY, 
AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED, VE, .unit = "quality" },
+{ "quality","Set the encoding quality preset", 
OFFSET(quality), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 
AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED, VE, .unit = "quality" },
+{ "preset", "Set the encoding quality preset", 
OFFSET(quality), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 
AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED, VE, .unit = "quality" },
+{ "high_quality",   "", 0, AV_OPT_TYPE_CONST, {.i64 = 
AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_HI

[FFmpeg-cvslog] lavc/vvc: Invalidate PPSs which refer to a changed SPS

2024-06-20 Thread Frank Plowman
ffmpeg | branch: master | Frank Plowman  | Fri Jun 14 
10:37:17 2024 +0100| [8d6014dbc6fb7c324a114030761901220ebc3540] | committer: 
Nuo Mi

lavc/vvc: Invalidate PPSs which refer to a changed SPS

When the SPS associated with a particular SPS ID changes, invalidate all
the PPSs which use that SPS ID.  Fixes crashes with illegal bitstreams.
This is done in the CBS, rather than in libavcodec/vvc/ps.c like the SPS
ID reuse validation, as parts of the CBS parsing process for PPSs
depend on the SPS being referred to.

Signed-off-by: Frank Plowman 

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

 libavcodec/cbs_h2645.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index c5f167334d..e2389f124e 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -789,9 +789,28 @@ static int cbs_h26 ## h26n ## _replace_ ## 
ps_var(CodedBitstreamContext *ctx, \
 }
 
 cbs_h266_replace_ps(6, VPS, vps, vps_video_parameter_set_id)
-cbs_h266_replace_ps(6, SPS, sps, sps_seq_parameter_set_id)
 cbs_h266_replace_ps(6, PPS, pps, pps_pic_parameter_set_id)
 
+static int cbs_h266_replace_sps(CodedBitstreamContext *ctx,
+CodedBitstreamUnit *unit)
+{
+CodedBitstreamH266Context *priv = ctx->priv_data;
+H266RawSPS *sps = unit->content;
+unsigned int id = sps->sps_seq_parameter_set_id;
+int err = ff_cbs_make_unit_refcounted(ctx, unit);
+if (err < 0)
+return err;
+av_assert0(unit->content_ref);
+if (priv->sps[id] && memcmp(priv->sps[id], unit->content_ref, 
sizeof(*priv->sps[id]))) {
+for (unsigned int i = 0; i < VVC_MAX_PPS_COUNT; i++) {
+if (priv->pps[i] && priv->pps[i]->pps_seq_parameter_set_id == id)
+ff_refstruct_unref(&priv->pps[i]);
+}
+}
+ff_refstruct_replace(&priv->sps[id], unit->content_ref);
+return 0;
+}
+
 static int cbs_h266_replace_ph(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit,
H266RawPictureHeader *ph)

___
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] avdevice/avfoundation: add external video devices

2024-06-20 Thread Theo Fabi
ffmpeg | branch: master | Theo Fabi  | Sun Jun  9 15:51:08 
2024 -0400| [d6d14b3a15cbe0c2e8f3a8607f98edfcab56e330] | committer: Thilo 
Borgmann

avdevice/avfoundation: add external video devices

Video devices categorized by AVFoundation as
'AVCaptureDeviceTypeExternal(Unknown)' (like USB video streams) were not
recognized by libavdevice.

Signed-off-by: Theo Fabi 

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

 libavdevice/avfoundation.m | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e558ad7d90..c5a09c6563 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -788,6 +788,9 @@ static NSArray* getDevicesWithMediaType(AVMediaType 
mediaType) {
 #endif
 #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 17 || 
(TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 14))
 [deviceTypes addObject: AVCaptureDeviceTypeContinuityCamera];
+[deviceTypes addObject: AVCaptureDeviceTypeExternal];
+#elif (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 14)
+[deviceTypes addObject: AVCaptureDeviceTypeExternalUnknown];
 #endif
 } else if (mediaType == AVMediaTypeAudio) {
 #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 17 || 
(TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 14))

___
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: Avoid branches for flipping no_rounding

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri May 10 20:10:46 2024 +0200| [80c2d7c89061e3511b815c355c1885111e029923] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Avoid branches for flipping no_rounding

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index eda2305630..6ad5b0eb39 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -713,6 +713,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->modified_quant  = s->h263_aic;
 s->loop_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 
0;
 s->unrestricted_mv = s->obmc || s->loop_filter || s->umvplus;
+s->flipflop_rounding = 1;
 
 /* /Fx */
 /* These are just to be sure */
@@ -746,6 +747,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->out_format  = FMT_H263;
 s->h263_pred   = 1;
 s->unrestricted_mv = 1;
+s->flipflop_rounding = 1;
 s->low_delay   = s->max_b_frames ? 0 : 1;
 avctx->delay   = s->low_delay ? 0 : (s->max_b_frames + 1);
 break;
@@ -1829,10 +1831,7 @@ vbv_retry:
 s->mb_skipped = 0;// done in frame_start()
 // done in encode_picture() so we must undo it
 if (s->pict_type == AV_PICTURE_TYPE_P) {
-if (s->flipflop_rounding  ||
-s->codec_id == AV_CODEC_ID_H263P ||
-s->codec_id == AV_CODEC_ID_MPEG4)
-s->no_rounding ^= 1;
+s->no_rounding ^= s->flipflop_rounding;
 }
 if (s->pict_type != AV_PICTURE_TYPE_B) {
 s->time_base   = s->last_time_base;
@@ -3576,8 +3575,7 @@ static int encode_picture(MpegEncContext *s, const 
AVPacket *pkt)
 if(s->pict_type==AV_PICTURE_TYPE_I){
 s->no_rounding = s->msmpeg4_version >= MSMP4_V3;
 }else if(s->pict_type!=AV_PICTURE_TYPE_B){
-if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || 
s->codec_id == AV_CODEC_ID_MPEG4)
-s->no_rounding ^= 1;
+s->no_rounding ^= s->flipflop_rounding;
 }
 
 if (s->avctx->flags & AV_CODEC_FLAG_PASS2) {

___
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: Don't pretend dct_init can fail

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 06:16:16 2024 +0200| [4339d2c11cb9261bd9927e6b209165eaf049fa12] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Don't pretend dct_init can fail

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 6692a44ebb..a340b2afc8 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -273,7 +273,7 @@ static void gray8(uint8_t *dst, const uint8_t *src, 
ptrdiff_t linesize, int h)
 }
 
 /* init common dct for both encoder and decoder */
-static av_cold int dct_init(MpegEncContext *s)
+static av_cold void dct_init(MpegEncContext *s)
 {
 ff_blockdsp_init(&s->bdsp);
 ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
@@ -314,8 +314,6 @@ static av_cold int dct_init(MpegEncContext *s)
 #elif ARCH_MIPS
 ff_mpv_common_init_mips(s);
 #endif
-
-return 0;
 }
 
 av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st,

___
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: Combine identical checks

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat May  4 00:30:22 2024 +0200| [91fce67691088fca6311fa38f7a56900f028775b] | 
committer: Andreas Rheinhardt

avcodec/vc1: Combine identical checks

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/vc1.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 987e77fcc7..d263c70be7 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -583,21 +583,23 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, 
VC1Context *v, GetBitContex
 
 static void rotate_luts(VC1Context *v)
 {
-#define ROTATE(DEF, L, N, C, A) do {  \
-if (v->s.pict_type == AV_PICTURE_TYPE_BI || v->s.pict_type == 
AV_PICTURE_TYPE_B) { \
-C = A;\
-} else {  \
+if (v->s.pict_type == AV_PICTURE_TYPE_BI || v->s.pict_type == 
AV_PICTURE_TYPE_B) {
+v->curr_use_ic = &v->aux_use_ic;
+v->curr_luty   = v->aux_luty;
+v->curr_lutuv  = v->aux_lutuv;
+} else {
+#define ROTATE(DEF, L, N, C) do { \
 DEF;  \
 memcpy(&tmp, L   , sizeof(tmp));  \
 memcpy(L   , N   , sizeof(tmp));  \
 memcpy(N   , &tmp, sizeof(tmp));  \
 C = N;\
-} \
 } while(0)
 
-ROTATE(int tmp, &v->last_use_ic, &v->next_use_ic, 
v->curr_use_ic, &v->aux_use_ic);
-ROTATE(uint8_t tmp[2][256], v->last_luty,   v->next_luty,   v->curr_luty,  
 v->aux_luty);
-ROTATE(uint8_t tmp[2][256], v->last_lutuv,  v->next_lutuv,  v->curr_lutuv, 
 v->aux_lutuv);
+ROTATE(int tmp, &v->last_use_ic, &v->next_use_ic, 
v->curr_use_ic);
+ROTATE(uint8_t tmp[2][256],  v->last_luty,v->next_luty,   
v->curr_luty);
+ROTATE(uint8_t tmp[2][256],  v->last_lutuv,   v->next_lutuv,  
v->curr_lutuv);
+}
 
 INIT_LUT(32, 0, v->curr_luty[0], v->curr_lutuv[0], 0);
 INIT_LUT(32, 0, v->curr_luty[1], v->curr_lutuv[1], 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] configure: Remove obsolete mpeg4_decoder->mpeg4video_parser dependency

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 07:41:04 2024 +0200| [5805b860fe713177430f26b8617bb2bc3c2e7e8f] | 
committer: Andreas Rheinhardt

configure: Remove obsolete mpeg4_decoder->mpeg4video_parser dependency

Obsolete since 3ceffe783965767e62d59e8e68ecd265c98460ec.

Signed-off-by: Andreas Rheinhardt 

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

 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 7d47065c52..3bca638459 100755
--- a/configure
+++ b/configure
@@ -3015,7 +3015,7 @@ mpeg1video_decoder_select="mpegvideodec"
 mpeg1video_encoder_select="mpegvideoenc"
 mpeg2video_decoder_select="mpegvideodec"
 mpeg2video_encoder_select="mpegvideoenc"
-mpeg4_decoder_select="h263_decoder mpeg4video_parser"
+mpeg4_decoder_select="h263_decoder"
 mpeg4_encoder_select="h263_encoder qpeldsp"
 msa1_decoder_select="mss34dsp"
 mscc_decoder_select="inflate_wrapper"

___
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: Use VLC symbol table

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 18:48:39 2024 +0200| [0876b160d6d9fd4c960585927c4381baaffb15ad] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Use VLC symbol table

This is possible now that MB_TYPE_CBP and MB_TYPE_QUANT
fit into an int16_t; only MB_TYPE_H261_FIL needs to
be remapped to MB_TYPE_CODEC_SPECIFIC.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h261.h | 5 +++--
 libavcodec/h261data.c | 2 +-
 libavcodec/h261dec.c  | 9 -
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/h261.h b/libavcodec/h261.h
index 67c362be93..11a8a8685a 100644
--- a/libavcodec/h261.h
+++ b/libavcodec/h261.h
@@ -28,6 +28,7 @@
 #ifndef AVCODEC_H261_H
 #define AVCODEC_H261_H
 
+#include "mpegutils.h"
 #include "mpegvideo.h"
 #include "rl.h"
 
@@ -38,13 +39,13 @@ typedef struct H261Context {
 int mtype;
 } H261Context;
 
-#define MB_TYPE_H261_FIL 0x80
+#define MB_TYPE_H261_FIL MB_TYPE_CODEC_SPECIFIC
 
 extern const uint8_t ff_h261_mba_code[35];
 extern const uint8_t ff_h261_mba_bits[35];
 extern const uint8_t ff_h261_mtype_code[10];
 extern const uint8_t ff_h261_mtype_bits[10];
-extern const int ff_h261_mtype_map[10];
+extern const uint16_t ff_h261_mtype_map[10];
 extern const uint8_t ff_h261_mv_tab[17][2];
 extern const uint8_t ff_h261_cbp_tab[63][2];
 extern RLTable ff_h261_rl_tcoeff;
diff --git a/libavcodec/h261data.c b/libavcodec/h261data.c
index a9891edd0a..bccd9e5f56 100644
--- a/libavcodec/h261data.c
+++ b/libavcodec/h261data.c
@@ -72,7 +72,7 @@ const uint8_t ff_h261_mtype_bits[10] = {
 2, 6
 };
 
-const int ff_h261_mtype_map[10] = {
+const uint16_t ff_h261_mtype_map[10] = {
 MB_TYPE_INTRA4x4,
 MB_TYPE_INTRA4x4 | MB_TYPE_QUANT,
 MB_TYPE_CBP,
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 392f1aef1d..05279b9ec5 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -67,9 +67,10 @@ static av_cold void h261_decode_init_static(void)
 VLC_INIT_STATIC_TABLE(h261_mba_vlc, H261_MBA_VLC_BITS, 35,
   ff_h261_mba_bits, 1, 1,
   ff_h261_mba_code, 1, 1, 0);
-VLC_INIT_STATIC_TABLE(h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
-  ff_h261_mtype_bits, 1, 1,
-  ff_h261_mtype_code, 1, 1, 0);
+VLC_INIT_STATIC_SPARSE_TABLE(h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
+ ff_h261_mtype_bits, 1, 1,
+ ff_h261_mtype_code, 1, 1,
+ ff_h261_mtype_map,  2, 2, 0);
 VLC_INIT_STATIC_TABLE(h261_mv_vlc, H261_MV_VLC_BITS, 17,
   &ff_h261_mv_tab[0][1], 2, 1,
   &ff_h261_mv_tab[0][0], 2, 1, 0);
@@ -418,8 +419,6 @@ static int h261_decode_mb(H261DecContext *h)
com->mtype);
 return SLICE_ERROR;
 }
-av_assert0(com->mtype < FF_ARRAY_ELEMS(ff_h261_mtype_map));
-com->mtype = ff_h261_mtype_map[com->mtype];
 
 // Read mquant
 if (IS_QUANT(com->mtype))

___
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: Set dct_unquantize earlier

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 06:20:12 2024 +0200| [091d00663721d28d926a835d554c2f7dfdd064b6] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Set dct_unquantize earlier

Set them in ff_mpv_idct_init() so that they are already set
in ff_mpv_decode_init(). This is in preparation for avoiding
to set dct_unquantize in every ff_mpv_frame_start().

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegvideo.c | 50 +-
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index a340b2afc8..6df669b744 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -273,7 +273,7 @@ static void gray8(uint8_t *dst, const uint8_t *src, 
ptrdiff_t linesize, int h)
 }
 
 /* init common dct for both encoder and decoder */
-static av_cold void dct_init(MpegEncContext *s)
+static av_cold void dsp_init(MpegEncContext *s)
 {
 ff_blockdsp_init(&s->bdsp);
 ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
@@ -291,29 +291,6 @@ static av_cold void dct_init(MpegEncContext *s)
 s->hdsp.put_no_rnd_pixels_tab[1][i] = gray8;
 }
 }
-
-s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c;
-s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c;
-s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c;
-s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c;
-s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c;
-if (s->avctx->flags & AV_CODEC_FLAG_BITEXACT)
-s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact;
-s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c;
-
-#if HAVE_INTRINSICS_NEON
-ff_mpv_common_init_neon(s);
-#endif
-
-#if ARCH_ARM
-ff_mpv_common_init_arm(s);
-#elif ARCH_PPC
-ff_mpv_common_init_ppc(s);
-#elif ARCH_X86
-ff_mpv_common_init_x86(s);
-#elif ARCH_MIPS
-ff_mpv_common_init_mips(s);
-#endif
 }
 
 av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
@@ -357,6 +334,29 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s)
  s->idsp.idct_permutation);
 ff_permute_scantable(s->permutated_intra_v_scantable, 
ff_alternate_vertical_scan,
  s->idsp.idct_permutation);
+
+s->dct_unquantize_h263_intra  = dct_unquantize_h263_intra_c;
+s->dct_unquantize_h263_inter  = dct_unquantize_h263_inter_c;
+s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c;
+s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c;
+s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c;
+if (s->avctx->flags & AV_CODEC_FLAG_BITEXACT)
+s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact;
+s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c;
+
+#if HAVE_INTRINSICS_NEON
+ff_mpv_common_init_neon(s);
+#endif
+
+#if ARCH_ARM
+ff_mpv_common_init_arm(s);
+#elif ARCH_PPC
+ff_mpv_common_init_ppc(s);
+#elif ARCH_X86
+ff_mpv_common_init_x86(s);
+#elif ARCH_MIPS
+ff_mpv_common_init_mips(s);
+#endif
 }
 
 static int init_duplicate_context(MpegEncContext *s)
@@ -716,7 +716,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 av_image_check_size(s->width, s->height, 0, s->avctx))
 return AVERROR(EINVAL);
 
-dct_init(s);
+dsp_init(s);
 
 /* set chroma shifts */
 ret = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,

___
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 nonsense information from error message

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 18:50:54 2024 +0200| [c94d81ce00862f3bb8558356284caeb6ca7234db] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Remove nonsense information from error message

The "invalid mtype index" here is always -1, because that is
the value the VLC api uses for not existent leafs in an incomplete tree.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 05279b9ec5..b62575b7b3 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -415,8 +415,7 @@ static int h261_decode_mb(H261DecContext *h)
 // Read mtype
 com->mtype = get_vlc2(&s->gb, h261_mtype_vlc, H261_MTYPE_VLC_BITS, 2);
 if (com->mtype < 0) {
-av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index %d\n",
-   com->mtype);
+av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index\n");
 return SLICE_ERROR;
 }
 

___
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: Set dct_unquantize ptrs only once when possible

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 07:22:48 2024 +0200| [18f1aca3e8ac550a83a293cb0a210f9df1a8a5d1] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Set dct_unquantize ptrs only once when possible

Everything except dct_unquantize_intra for MPEG-4 need only
be set once.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h263dec.c   |  8 
 libavcodec/mpegvideo_dec.c | 21 +++--
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index eee7978452..75fcf1 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -110,6 +110,9 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
 break;
 case AV_CODEC_ID_MPEG4:
+// dct_unquantize_inter is only used with MPEG-2 quantizers,
+// so we can already set dct_unquantize_inter here once and for all.
+s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
 break;
 case AV_CODEC_ID_MSMPEG4V1:
 s->h263_pred   = 1;
@@ -523,6 +526,11 @@ retry:
 goto retry;
 if (s->studio_profile != (s->idsp.idct == NULL))
 ff_mpv_idct_init(s);
+if (s->mpeg_quant) {
+s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
+} else {
+s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
+}
 }
 
 /* After H.263 & MPEG-4 header decode we have the height, width,
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 0a50cfac5b..ad35505819 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -59,6 +59,13 @@ int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext 
*avctx)
 s->codec_tag   = ff_toupper4(avctx->codec_tag);
 
 ff_mpv_idct_init(s);
+
+// dct_unquantize defaults for H.261 and H.263;
+// they might change on a per-frame basis for MPEG-4.
+// Unused by the MPEG-1/2 decoders.
+s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
+s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
+
 ff_h264chroma_init(&s->h264chroma, 8); //for lowres
 
 if (s->picture_pool)  // VC-1 can call this multiple times
@@ -393,20 +400,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext 
*avctx)
 if (ret < 0)
 return ret;
 
-/* set dequantizer, we can't do it during init as
- * it might change for MPEG-4 and we can't do it in the header
- * decode as init is not called for MPEG-4 there yet */
-if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
-s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
-s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
-} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
-s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
-s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
-} else {
-s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
-s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
-}
-
 if (s->avctx->debug & FF_DEBUG_NOMC)
 color_frame(s->cur_pic.ptr->f, 0x80);
 

___
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/mpegutils: Remap MB_TYPE_ACPRED, add codec-specific MB_TYPE

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 09:07:33 2024 +0200| [dd1e804a987d7464d9bfd7c25dd9ef295223bd36] | 
committer: Andreas Rheinhardt

avcodec/mpegutils: Remap MB_TYPE_ACPRED, add codec-specific MB_TYPE

MB_TYPE_ACPRED is currently reused for MB_TYPE_REF0 by H.264,
so that the value fits into an uint16_t. Given that MB_TYPE_ACPRED
is not subject to any such restriction (apart from fitting into
32bits), it can be remapped to a hithereto unused bit.
The then available bit will be declared to be codec-specific
(i.e. unused by generic code), so that H.264 can use it
for MB_TYPE_REF0 and so that it can be reused later for
e.g. MB_TYPE_H261_FIL.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h264_parse.h | 2 +-
 libavcodec/mpegutils.c  | 2 +-
 libavcodec/mpegutils.h  | 5 -
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h264_parse.h b/libavcodec/h264_parse.h
index 4ee863df66..3481451c10 100644
--- a/libavcodec/h264_parse.h
+++ b/libavcodec/h264_parse.h
@@ -33,7 +33,7 @@
 #include "get_bits.h"
 #include "h264_ps.h"
 
-#define MB_TYPE_REF0   MB_TYPE_ACPRED // dirty but it fits in 16 bit
+#define MB_TYPE_REF0   MB_TYPE_CODEC_SPECIFIC
 #define MB_TYPE_8x8DCT 0x0100
 
 // This table must be here because scan8[constant] must be known at compiletime
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 92ebdd3a98..4b1bcaa995 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -109,7 +109,7 @@ static char get_type_mv_char(int mb_type)
 // Type & MV direction
 if (IS_PCM(mb_type))
 return 'P';
-else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
+else if (IS_ACPRED(mb_type))
 return 'A';
 else if (IS_INTRA4x4(mb_type))
 return 'i';
diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
index 3da1e7ed38..0cca4f0a2f 100644
--- a/libavcodec/mpegutils.h
+++ b/libavcodec/mpegutils.h
@@ -45,7 +45,6 @@
 #define MB_TYPE_8x8(1 <<  6)
 #define MB_TYPE_INTERLACED (1 <<  7)
 #define MB_TYPE_DIRECT2(1 <<  8) // FIXME
-#define MB_TYPE_ACPRED (1 <<  9)
 #define MB_TYPE_GMC(1 << 10)
 #define MB_TYPE_SKIP   (1 << 11)
 #define MB_TYPE_P0L0   (1 << 12)
@@ -57,9 +56,13 @@
 #define MB_TYPE_L0L1   (MB_TYPE_L0   | MB_TYPE_L1)
 #define MB_TYPE_QUANT  (1 << 16)
 #define MB_TYPE_CBP(1 << 17)
+#define MB_TYPE_ACPRED (1 << 18)
 
 #define MB_TYPE_INTRAMB_TYPE_INTRA4x4 // default mb_type if there is just 
one type
 
+// The following MB-type can be used by each codec as it sees fit.
+#define MB_TYPE_CODEC_SPECIFIC  (1 << 9)
+
 #define IS_INTRA4x4(a)   ((a) & MB_TYPE_INTRA4x4)
 #define IS_INTRA16x16(a) ((a) & MB_TYPE_INTRA16x16)
 #define IS_PCM(a)((a) & MB_TYPE_INTRA_PCM)

___
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/mpegutils: Remap MB_TYPE_{GMC,SKIP,CBP,QUANT}

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 18:36:49 2024 +0200| [4cdd684e86136c42719632cbdcc7647d0f60f87f] | 
committer: Andreas Rheinhardt

avcodec/mpegutils: Remap MB_TYPE_{GMC,SKIP,CBP,QUANT}

Do this to make MB_TYPE_{CBP,QUANT} fit into an int16_t,
so that can be used in a VLC symbol table.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegutils.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
index 0cca4f0a2f..8597ca18b8 100644
--- a/libavcodec/mpegutils.h
+++ b/libavcodec/mpegutils.h
@@ -45,8 +45,8 @@
 #define MB_TYPE_8x8(1 <<  6)
 #define MB_TYPE_INTERLACED (1 <<  7)
 #define MB_TYPE_DIRECT2(1 <<  8) // FIXME
-#define MB_TYPE_GMC(1 << 10)
-#define MB_TYPE_SKIP   (1 << 11)
+#define MB_TYPE_CBP(1 << 10)
+#define MB_TYPE_QUANT  (1 << 11)
 #define MB_TYPE_P0L0   (1 << 12)
 #define MB_TYPE_P1L0   (1 << 13)
 #define MB_TYPE_P0L1   (1 << 14)
@@ -54,8 +54,8 @@
 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
 #define MB_TYPE_L0L1   (MB_TYPE_L0   | MB_TYPE_L1)
-#define MB_TYPE_QUANT  (1 << 16)
-#define MB_TYPE_CBP(1 << 17)
+#define MB_TYPE_GMC(1 << 16)
+#define MB_TYPE_SKIP   (1 << 17)
 #define MB_TYPE_ACPRED (1 << 18)
 
 #define MB_TYPE_INTRAMB_TYPE_INTRA4x4 // default mb_type if there is just 
one type

___
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/mpegutils: Remove always-false check

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 20:49:31 2024 +0200| [07ae09bdf18b117e809224fbddcca6eaf7273c4b] | 
committer: Andreas Rheinhardt

avcodec/mpegutils: Remove always-false check

SVQ3 does not call ff_print_debug_info2().

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 4b1bcaa995..acc4989aba 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -165,7 +165,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame 
*pict,
 if ((avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) && mbtype_table 
&& motion_val[0]) {
 const int shift = 1 + quarter_sample;
 const int scale = 1 << shift;
-const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || 
avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1;
+const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 ? 2 : 1;
 const int mv_stride  = (mb_width << mv_sample_log2) +
(avctx->codec->id == AV_CODEC_ID_H264 ? 0 : 
1);
 int mb_x, mb_y, mbcount = 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/mpeg4videodec: Use VLC symbol table

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun  3 04:45:34 2024 +0200| [e7d6300c10834b782a2e2b274d4a9f1fc4cf8efe] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Use VLC symbol table

Possible now that MB_TYPE_L1 (which does not fit into
an int16_t) is no longer used).

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg4videodec.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index ebbd845129..116dc1507e 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -67,7 +67,7 @@ static VLCElem studio_chroma_dc[528];
 
 static const uint8_t mpeg4_block_count[4] = { 0, 6, 8, 12 };
 
-static const int mb_type_b_map[4] = {
+static const int16_t mb_type_b_map[4] = {
 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV,
 MB_TYPE_BIDIR_MV| MB_TYPE_16x16,
 MB_TYPE_BACKWARD_MV | MB_TYPE_16x16,
@@ -1845,7 +1845,6 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t 
block[6][64])
 av_log(s->avctx, AV_LOG_ERROR, "illegal MB_type\n");
 return AVERROR_INVALIDDATA;
 }
-mb_type = mb_type_b_map[mb_type];
 if (modb2) {
 cbp = 0;
 } else {
@@ -3794,9 +3793,10 @@ static av_cold void mpeg4_init_static(void)
 VLC_INIT_STATIC_TABLE_FROM_LENGTHS(sprite_trajectory, 
SPRITE_TRAJ_VLC_BITS, 15,
ff_sprite_trajectory_lens, 1,
NULL, 0, 0, 0, 0);
-VLC_INIT_STATIC_TABLE(mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 4,
-  &ff_mb_type_b_tab[0][1], 2, 1,
-  &ff_mb_type_b_tab[0][0], 2, 1, 0);
+VLC_INIT_STATIC_SPARSE_TABLE(mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 4,
+ &ff_mb_type_b_tab[0][1], 2, 1,
+ &ff_mb_type_b_tab[0][0], 2, 1,
+ mb_type_b_map, 2, 2, 0);
 }
 
 static av_cold int decode_init(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/mpegutils: Don't use MB_TYPE_L[01] for mpegvideo

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun  3 00:07:04 2024 +0200| [f5d5b80f3c58eec38d97ffcc8a4d24cd2eba2de0] | 
committer: Andreas Rheinhardt

avcodec/mpegutils: Don't use MB_TYPE_L[01] for mpegvideo

MB_TYPE_L[01] is based upon H.264 terminology (it stands for
list); yet the mpegvideo based decoders don't have lists
of reference frames, they have at most one forward and one
backward reference. So use terminology based upon this.

This also has a second advantage: MB_TYPE_L[01] is actually
an OR of two flags (which are set independently for H.264,
but aren't for mpegvideo). Switching to different flags
makes the flags fit into an int16_t, which will be useful
in future commits.

The only downside to this is a very small amount of code
in error_resilience.c and mpegutils.c (the only code shared
between the H.264 decoder and mpegvideo).

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/error_resilience.c |  8 +++
 libavcodec/h261dec.c  |  4 ++--
 libavcodec/ituh263dec.c   | 44 +--
 libavcodec/ituh263enc.c   |  4 ++--
 libavcodec/mpeg12dec.c| 44 +--
 libavcodec/mpeg4video.c   |  6 ++---
 libavcodec/mpeg4videodec.c| 53 ---
 libavcodec/mpegutils.c| 23 +++
 libavcodec/mpegutils.h| 10 
 libavcodec/msmpeg4dec.c   |  8 +++
 libavcodec/rv34.c | 18 +++
 libavcodec/wmv2dec.c  | 12 +-
 12 files changed, 123 insertions(+), 111 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 56844d5084..6edc2dc15f 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -902,6 +902,7 @@ void ff_er_frame_end(ERContext *s, int *decode_error_flags)
 int threshold = 50;
 int is_intra_likely;
 int size = s->b8_stride * 2 * s->mb_height;
+int guessed_mb_type;
 
 /* We do not support ER of field pictures yet,
  * though it should not crash if enabled. */
@@ -1117,16 +1118,15 @@ void ff_er_frame_end(ERContext *s, int 
*decode_error_flags)
 is_intra_likely = is_intra_more_likely(s);
 
 /* set unknown mb-type to most likely */
+guessed_mb_type = is_intra_likely ? MB_TYPE_INTRA4x4 :
+ (MB_TYPE_16x16 | (s->avctx->codec_id == 
AV_CODEC_ID_H264 ? MB_TYPE_L0 : MB_TYPE_FORWARD_MV));
 for (i = 0; i < s->mb_num; i++) {
 const int mb_xy = s->mb_index2xy[i];
 int error = s->error_status_table[mb_xy];
 if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
 continue;
 
-if (is_intra_likely)
-s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
-else
-s->cur_pic.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
+s->cur_pic.mb_type[mb_xy] = guessed_mb_type;
 }
 
 // change inter to intra blocks if no reference frames are available
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index b62575b7b3..be285ce5e9 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -232,7 +232,7 @@ static int h261_decode_mb_skipped(H261DecContext *h, int 
mba1, int mba2)
 
 s->mv_dir  = MV_DIR_FORWARD;
 s->mv_type = MV_TYPE_16X16;
-s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
+s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | 
MB_TYPE_FORWARD_MV;
 s->mv[0][0][0] = 0;
 s->mv[0][0][1] = 0;
 s->mb_skipped  = 1;
@@ -460,7 +460,7 @@ static int h261_decode_mb(H261DecContext *h)
 //set motion vectors
 s->mv_dir  = MV_DIR_FORWARD;
 s->mv_type = MV_TYPE_16X16;
-s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
+s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
 s->mv[0][0][0] = h->current_mv_x * 2; // gets divided by 2 
in motion compensation
 s->mv[0][0][1] = h->current_mv_y * 2;
 
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 0809048362..47ad891391 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -60,18 +60,18 @@
 #define CBPC_B_VLC_BITS 3
 
 static const int h263_mb_type_b_map[15]= {
-MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
-MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP,
-MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT,
-  MB_TYPE_L0 | 
MB_TYPE_16x16,
-  MB_TYPE_L0   | MB_TYPE_CBP | 
MB_TYPE_16x16,
-  MB_TYPE_L0   | MB_TYPE_CBP | MB_TYPE_QUANT | 
MB_TYPE_16x16,
-  MB_TYPE_L1 | 
MB_TYPE_16x16,
-  MB_T

[FFmpeg-cvslog] avcodec/mpeg12dec: Use VLC symbol table

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun  3 05:07:44 2024 +0200| [010951239c6de2d32d6572d1390cdaf8f6c63452] | 
committer: Andreas Rheinhardt

avcodec/mpeg12dec: Use VLC symbol table

Possible by using MB_TYPE_CODEC_SPECIFIC for MB_TYPE_ZERO_MV
and due to the MB_TYPE_*_MV flags fitting into an int16_t.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg12.c| 42 +-
 libavcodec/mpeg12dec.c | 28 
 libavcodec/mpeg12dec.h |  2 ++
 3 files changed, 35 insertions(+), 37 deletions(-)

diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 62d7fd1814..444ea83f3c 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -31,14 +31,12 @@
 #include "libavutil/avassert.h"
 #include "libavutil/thread.h"
 
-#include "avcodec.h"
 #include "mpegvideo.h"
-#include "mpeg12.h"
 #include "mpeg12codecs.h"
 #include "mpeg12data.h"
 #include "mpeg12dec.h"
+#include "mpegutils.h"
 #include "rl.h"
-#include "startcode.h"
 
 static const uint8_t table_mb_ptype[7][2] = {
 { 3, 5 }, // 0x01 MB_INTRA
@@ -64,6 +62,30 @@ static const uint8_t table_mb_btype[11][2] = {
 { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
 };
 
+static const int16_t ptype2mb_type[7] = {
+MB_TYPE_INTRA,
+MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | 
MB_TYPE_16x16,
+MB_TYPE_FORWARD_MV,
+MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
+MB_TYPE_QUANT | MB_TYPE_INTRA,
+MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | 
MB_TYPE_16x16,
+MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
+};
+
+static const int16_t btype2mb_type[11] = {
+MB_TYPE_INTRA,
+MB_TYPE_BACKWARD_MV,
+MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
+MB_TYPE_FORWARD_MV,
+MB_TYPE_FORWARD_MV  | MB_TYPE_CBP,
+MB_TYPE_BIDIR_MV,
+MB_TYPE_BIDIR_MV| MB_TYPE_CBP,
+MB_TYPE_QUANT | MB_TYPE_INTRA,
+MB_TYPE_QUANT | MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
+MB_TYPE_QUANT | MB_TYPE_FORWARD_MV  | MB_TYPE_CBP,
+MB_TYPE_QUANT | MB_TYPE_BIDIR_MV| MB_TYPE_CBP,
+};
+
 av_cold void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM 
rl_vlc[],
const int8_t table_run[], const uint8_t 
table_level[],
int n, unsigned static_size, int flags)
@@ -146,12 +168,14 @@ static av_cold void mpeg12_init_vlcs(void)
   &ff_mpeg12_mbPatTable[0][1], 2, 1,
   &ff_mpeg12_mbPatTable[0][0], 2, 1, 0);
 
-VLC_INIT_STATIC_TABLE(ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
-  &table_mb_ptype[0][1], 2, 1,
-  &table_mb_ptype[0][0], 2, 1, 0);
-VLC_INIT_STATIC_TABLE(ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
-  &table_mb_btype[0][1], 2, 1,
-  &table_mb_btype[0][0], 2, 1, 0);
+VLC_INIT_STATIC_SPARSE_TABLE(ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
+ &table_mb_ptype[0][1], 2, 1,
+ &table_mb_ptype[0][0], 2, 1,
+ ptype2mb_type, 2, 2, 0);
+VLC_INIT_STATIC_SPARSE_TABLE(ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
+ &table_mb_btype[0][1], 2, 1,
+ &table_mb_btype[0][0], 2, 1,
+ btype2mb_type, 2, 2, 0);
 
 ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_mpeg12_run,
   ff_mpeg12_level, MPEG12_RL_NB_ELEMS,
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 601106138e..e0e9a8fb1e 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -93,32 +93,6 @@ typedef struct Mpeg1Context {
 int64_t timecode_frame_start;  /*< GOP timecode frame start number, in non 
drop frame format */
 } Mpeg1Context;
 
-#define MB_TYPE_ZERO_MV   0x2000
-
-static const uint32_t ptype2mb_type[7] = {
-MB_TYPE_INTRA,
-MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | 
MB_TYPE_16x16,
-MB_TYPE_FORWARD_MV,
-MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
-MB_TYPE_QUANT | MB_TYPE_INTRA,
-MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | 
MB_TYPE_16x16,
-MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
-};
-
-static const uint32_t btype2mb_type[11] = {
-MB_TYPE_INTRA,
-MB_TYPE_BACKWARD_MV,
-MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
-MB_TYPE_FORWARD_MV,
-MB_TYPE_FORWARD_MV  | MB_TYPE_CBP,
-MB_TYPE_BIDIR_MV,
-MB_TYPE_BIDIR_MV| MB_TYPE_CB

[FFmpeg-cvslog] avcodec/mpegutils: Move H.264-only macros to h264dec.h

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  2 20:32:23 2024 +0200| [f161d9449aa63282e7bee2cd80ecaf117e4d5530] | 
committer: Andreas Rheinhardt

avcodec/mpegutils: Move H.264-only macros to h264dec.h

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h264dec.h   | 8 
 libavcodec/mpegutils.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index fc50df90f2..ccd7583bf4 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -93,6 +93,14 @@
 
 #define IS_REF0(a) ((a) & MB_TYPE_REF0)
 #define IS_8x8DCT(a)   ((a) & MB_TYPE_8x8DCT)
+#define IS_SUB_8X8(a)  ((a) & MB_TYPE_16x16) // note reused
+#define IS_SUB_8X4(a)  ((a) & MB_TYPE_16x8)  // note reused
+#define IS_SUB_4X8(a)  ((a) & MB_TYPE_8x16)  // note reused
+#define IS_SUB_4X4(a)  ((a) & MB_TYPE_8x8)   // note reused
+#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list
+
+// does this mb use listX, note does not work if subMBs
+#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * 
(list
 
 /**
  * Memory management control operation.
diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
index 0408e4cbd6..c82e07ebd7 100644
--- a/libavcodec/mpegutils.h
+++ b/libavcodec/mpegutils.h
@@ -82,16 +82,8 @@
 #define IS_16X8(a)   ((a) & MB_TYPE_16x8)
 #define IS_8X16(a)   ((a) & MB_TYPE_8x16)
 #define IS_8X8(a)((a) & MB_TYPE_8x8)
-#define IS_SUB_8X8(a)((a) & MB_TYPE_16x16) // note reused
-#define IS_SUB_8X4(a)((a) & MB_TYPE_16x8)  // note reused
-#define IS_SUB_4X8(a)((a) & MB_TYPE_8x16)  // note reused
-#define IS_SUB_4X4(a)((a) & MB_TYPE_8x8)   // note reused
 #define IS_ACPRED(a) ((a) & MB_TYPE_ACPRED)
 #define IS_QUANT(a)  ((a) & MB_TYPE_QUANT)
-#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list
-
-// does this mb use listX, note does not work if subMBs
-#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * 
(list
 
 #define HAS_CBP(a)   ((a) & MB_TYPE_CBP)
 #define HAS_FORWARD_MV(a)  ((a) & MB_TYPE_FORWARD_MV)

___
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/ituh263dec: Use VLC symbol table

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun  3 06:11:48 2024 +0200| [0ef8f0f96553dba8eeb75b087d6499550bcbdabb] | 
committer: Andreas Rheinhardt

avcodec/ituh263dec: Use VLC symbol table

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/ituh263dec.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 47ad891391..e0f3034e57 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -59,7 +59,7 @@
 #define H263_MBTYPE_B_VLC_BITS 6
 #define CBPC_B_VLC_BITS 3
 
-static const int h263_mb_type_b_map[15]= {
+static const int16_t h263_mb_type_b_map[15]= {
 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV,
 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV| MB_TYPE_CBP,
 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV| MB_TYPE_CBP | MB_TYPE_QUANT,
@@ -125,9 +125,10 @@ static av_cold void h263_decode_init_vlc(void)
 ff_h263_init_rl_inter();
 VLC_INIT_RL(ff_h263_rl_inter, 554);
 INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554);
-VLC_INIT_STATIC_TABLE(h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
-  &ff_h263_mbtype_b_tab[0][1], 2, 1,
-  &ff_h263_mbtype_b_tab[0][0], 2, 1, 0);
+VLC_INIT_STATIC_SPARSE_TABLE(h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
+ &ff_h263_mbtype_b_tab[0][1], 2, 1,
+ &ff_h263_mbtype_b_tab[0][0], 2, 1,
+ h263_mb_type_b_map, 2, 2, 0);
 VLC_INIT_STATIC_TABLE(cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
   &ff_cbpc_b_tab[0][1], 2, 1,
   &ff_cbpc_b_tab[0][0], 2, 1, 0);
@@ -911,8 +912,6 @@ int ff_h263_decode_mb(MpegEncContext *s,
 av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", 
s->mb_x, s->mb_y);
 return SLICE_ERROR;
 }
-
-mb_type= h263_mb_type_b_map[ mb_type ];
 }while(!mb_type);
 
 s->mb_intra = IS_INTRA(mb_type);

___
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/dvenc: Check for availability of interlaced dct cmp func

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 23:26:20 2024 +0200| [422711d1a514c0c83101ce5204967de1ab4a2aba] | 
committer: Andreas Rheinhardt

avcodec/dvenc: Check for availability of interlaced dct cmp func

Not every type of comparison function implements every function.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/dvenc.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 71f9b71c7b..5336ff149c 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -70,7 +70,6 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 {
 DVEncContext *s = avctx->priv_data;
 FDCTDSPContext fdsp;
-MECmpContext mecc;
 PixblockDSPContext pdsp;
 int ret;
 
@@ -95,19 +94,24 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
*avctx)
 
 ff_dv_init_dynamic_tables(s->work_chunks, s->sys);
 
+if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+MECmpContext mecc;
+
+memset(&mecc,0, sizeof(mecc));
+ff_me_cmp_init(&mecc, avctx);
+ret = ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp);
+if (ret < 0)
+return ret;
+if (!mecc.ildct_cmp[5])
+return AVERROR(EINVAL);
+s->ildct_cmp = mecc.ildct_cmp[5];
+}
+
 memset(&fdsp,0, sizeof(fdsp));
-memset(&mecc,0, sizeof(mecc));
 memset(&pdsp,0, sizeof(pdsp));
 ff_fdctdsp_init(&fdsp, avctx);
-ff_me_cmp_init(&mecc, avctx);
 ff_pixblockdsp_init(&pdsp, avctx);
-ret = ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp);
-if (ret < 0)
-return AVERROR(EINVAL);
-
 s->get_pixels = pdsp.get_pixels;
-s->ildct_cmp  = mecc.ildct_cmp[5];
-
 s->fdct[0]= fdsp.fdct;
 s->fdct[1]= fdsp.fdct248;
 

___
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: Avoid excessive inlining

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat May  4 21:31:44 2024 +0200| [415a3c32c94bf43c0ab9d369a382cece0cfd8882] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Avoid excessive inlining

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6ad5b0eb39..11f2a72804 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2484,7 +2484,7 @@ static av_always_inline void 
encode_mb_internal(MpegEncContext *s,
 }
 }
 
-static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int 
motion_y)
+static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
 {
 if (s->chroma_format == CHROMA_420)
 encode_mb_internal(s, motion_x, motion_y,  8, 8, 6, 1, 1, CHROMA_420);
@@ -2559,9 +2559,9 @@ static inline void 
copy_context_after_encode(MpegEncContext *d,
 d->esc3_level_length= s->esc3_level_length;
 }
 
-static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, 
MpegEncContext *best,
-   PutBitContext pb[2], PutBitContext pb2[2], 
PutBitContext tex_pb[2],
-   int *dmin, int *next_block, int motion_x, int 
motion_y)
+static void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, 
MpegEncContext *best,
+ PutBitContext pb[2], PutBitContext pb2[2], 
PutBitContext tex_pb[2],
+ int *dmin, int *next_block, int motion_x, int 
motion_y)
 {
 int score;
 uint8_t *dest_backup[3];

___
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/motion_est: Factor one-time initialization out of ff_init_me

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 18:09:22 2024 +0200| [bbd355355d5717004e23385c05bec92ee94182da] | 
committer: Andreas Rheinhardt

avcodec/motion_est: Factor one-time initialization out of ff_init_me

The majority of the stuff performed in it needs to be done only
once; so factor it out into a function of its own to be called
in the user's init function.
Also avoid using MpegEncContext in it, to separate the two
a bit more.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/motion_est.c| 89 +-
 libavcodec/motion_est.h|  9 -
 libavcodec/mpegvideo_enc.c | 19 --
 libavcodec/snowenc.c   | 11 +++---
 libavcodec/svq1enc.c   |  5 ++-
 5 files changed, 80 insertions(+), 53 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 162472d693..ee28a4a445 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -305,45 +305,40 @@ static int zero_cmp(MpegEncContext *s, const uint8_t *a, 
const uint8_t *b,
 static void zero_hpel(uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h){
 }
 
-int ff_init_me(MpegEncContext *s){
-MotionEstContext * const c= &s->me;
-int cache_size= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1dia_size)&255, 
FFABS(s->avctx->pre_dia_size)&255);
+av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx, 
MECmpContext *mecc)
+{
+int cache_size = FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1pre_dia_size) & 255);
 int ret;
 
-if(FFMIN(s->avctx->dia_size, s->avctx->pre_dia_size) < -FFMIN(ME_MAP_SIZE, 
MAX_SAB_SIZE)){
-av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB 
diamond\n");
-return -1;
+if (FFMIN(avctx->dia_size, avctx->pre_dia_size) < -FFMIN(ME_MAP_SIZE, 
MAX_SAB_SIZE)) {
+av_log(avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB 
diamond\n");
+return AVERROR(EINVAL);
 }
 
-c->avctx= s->avctx;
+c->avctx = avctx;
 
-if(s->codec_id == AV_CODEC_ID_H261)
-c->avctx->me_sub_cmp = c->avctx->me_cmp;
+if (avctx->codec_id == AV_CODEC_ID_H261)
+avctx->me_sub_cmp = avctx->me_cmp;
 
-if(cache_size < 2*dia_size && !c->stride){
-av_log(s->avctx, AV_LOG_INFO, "ME_MAP size may be a little small for 
the selected diamond size\n");
-}
+if (cache_size < 2 * dia_size)
+av_log(avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the 
selected diamond size\n");
 
-ret  = ff_set_cmp(&s->mecc, s->mecc.me_pre_cmp, c->avctx->me_pre_cmp);
-ret |= ff_set_cmp(&s->mecc, s->mecc.me_cmp, c->avctx->me_cmp);
-ret |= ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, c->avctx->me_sub_cmp);
-ret |= ff_set_cmp(&s->mecc, s->mecc.mb_cmp, c->avctx->mb_cmp);
+ret  = ff_set_cmp(mecc, mecc->me_pre_cmp, avctx->me_pre_cmp);
+ret |= ff_set_cmp(mecc, mecc->me_cmp, avctx->me_cmp);
+ret |= ff_set_cmp(mecc, mecc->me_sub_cmp, avctx->me_sub_cmp);
+ret |= ff_set_cmp(mecc, mecc->mb_cmp, avctx->mb_cmp);
 if (ret < 0)
 return ret;
 
-c->flags= get_flags(c, 0, c->avctx->me_cmp&FF_CMP_CHROMA);
-c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA);
-c->mb_flags = get_flags(c, 0, c->avctx->mb_cmp&FF_CMP_CHROMA);
+c->flags = get_flags(c, 0, avctx->me_cmp & FF_CMP_CHROMA);
+c->sub_flags = get_flags(c, 0, avctx->me_sub_cmp & FF_CMP_CHROMA);
+c->mb_flags  = get_flags(c, 0, avctx->mb_cmp & FF_CMP_CHROMA);
 
-/*FIXME s->no_rounding b_type*/
-if (s->avctx->flags & AV_CODEC_FLAG_QPEL) {
+if (avctx->codec_id == AV_CODEC_ID_H261) {
+c->sub_motion_search = no_sub_motion_search;
+} else if (avctx->flags & AV_CODEC_FLAG_QPEL) {
 c->sub_motion_search= qpel_motion_search;
-c->qpel_avg = s->qdsp.avg_qpel_pixels_tab;
-if (s->no_rounding)
-c->qpel_put = s->qdsp.put_no_rnd_qpel_pixels_tab;
-else
-c->qpel_put = s->qdsp.put_qpel_pixels_tab;
 }else{
 if(c->avctx->me_sub_cmp&FF_CMP_CHROMA)
 c->sub_motion_search= hpel_motion_search;
@@ -354,6 +349,32 @@ int ff_init_me(MpegEncContext *s){
 else
 c->sub_motion_search= hpel_motion_search;
 }
+
+/* 8x8 fullpel search would need a 4x4 chroma compare, which we do
+ * not have yet, and even if we had, the motion estimation code
+ * does not expect it. */
+if (avctx->codec_id != AV_CODEC_ID_SNOW) {
+if ((avctx->me_cmp & FF_CMP_CHROMA) /* && !s->mecc.me_cmp[2] */)
+mecc->me_cmp[2] = zero_cmp;
+if ((avctx->me_sub_cmp & FF_CMP_CHROMA) && !mecc->me_sub_cmp[2])
+mecc->me_sub_cmp[2] = zero_cmp;
+}
+
+return 0;
+}
+
+void ff_me_init_pic(MpegEncContext *s)
+{
+MotionEstContext * const c= &s->me;
+
+/*FIXME s->no_rounding b_type*/
+

[FFmpeg-cvslog] avcodec/mpegvideo_enc: Check for existence of ildct cmp functions

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 04:37:02 2024 +0200| [c46711d44f89b4d4ed6a4b6a771f3b23214e7f36] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Check for existence of ildct cmp functions

Not all compare functions are implemented for all compare function
types. Therefore check for the existence of the used functions.
Fixes issue #10245.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 11f2a72804..c97120de21 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -910,8 +910,14 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 
 s->quant_precision = 5;
 
-ret  = ff_set_cmp(&s->mecc, s->mecc.ildct_cmp,  avctx->ildct_cmp);
-ret |= ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
+if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+ret = ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, avctx->ildct_cmp);
+if (ret < 0)
+return ret;
+if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4])
+return AVERROR(EINVAL);
+}
+ret = ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
 if (ret < 0)
 return AVERROR(EINVAL);
 

___
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/me_cmp: Constify ff_set_cmp()

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 18:33:37 2024 +0200| [1367ef198a83b08253a7f872cd0b1508dbeb2441] | 
committer: Andreas Rheinhardt

avcodec/me_cmp: Constify ff_set_cmp()

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/me_cmp.c | 2 +-
 libavcodec/me_cmp.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index fe39009093..5cea792c95 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -473,7 +473,7 @@ static int zero_cmp(MpegEncContext *s, const uint8_t *a, 
const uint8_t *b,
 return 0;
 }
 
-int ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
+int ff_set_cmp(const MECmpContext *c, me_cmp_func *cmp, int type)
 {
 int ret = 0;
 int i;
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index fee0ecb28e..14d19bd142 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -90,7 +90,7 @@ void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext 
*avctx);
 void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx);
 
-int ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type);
+int ff_set_cmp(const MECmpContext *c, me_cmp_func *cmp, int type);
 
 void ff_dsputil_init_dwt(MECmpContext *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/me_cmp, motion_est: Move me_(pre_)?_cmp etc. to MotionEstContext

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 18:47:25 2024 +0200| [182e647a64bc85f74a03da9f1c96c9111e7b27d4] | 
committer: Andreas Rheinhardt

avcodec/me_cmp, motion_est: Move me_(pre_)?_cmp etc. to MotionEstContext

MECmpContext has several arrays of function pointers that
are not set by ff_me_cmp_init(), but that are set by users
to one of the other arrays via ff_set_cmp().

One of these other users is the motion estimation API.
It uses MECmpContext.(me_pre|me|me_sub|mb)_cmp. It is
basically the only user of these arrays.

This commit therefore moves these arrays to MotionEstContext;
this has the additional advantage of making motion_est.c
more independent from MpegEncContext.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/me_cmp.h  |  4 ---
 libavcodec/motion_est.c  | 42 ++--
 libavcodec/motion_est.h  |  7 -
 libavcodec/motion_est_template.c | 60 
 libavcodec/snowenc.c |  6 ++--
 tests/checkasm/motion.c  |  4 ---
 6 files changed, 60 insertions(+), 63 deletions(-)

diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 14d19bd142..67e3816829 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -70,10 +70,6 @@ typedef struct MECmpContext {
 me_cmp_func dct_max[6];
 me_cmp_func dct264_sad[6];
 
-me_cmp_func me_pre_cmp[6];
-me_cmp_func me_cmp[6];
-me_cmp_func me_sub_cmp[6];
-me_cmp_func mb_cmp[6];
 me_cmp_func ildct_cmp[6]; // only width 16 used
 me_cmp_func frame_skip_cmp[6]; // only width 8 used
 
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index ee28a4a445..b29d0c6d96 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -305,7 +305,7 @@ static int zero_cmp(MpegEncContext *s, const uint8_t *a, 
const uint8_t *b,
 static void zero_hpel(uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h){
 }
 
-av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx, 
MECmpContext *mecc)
+av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx, const 
MECmpContext *mecc)
 {
 int cache_size = FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1pre_dia_size) & 255);
@@ -324,10 +324,10 @@ av_cold int ff_me_init(MotionEstContext *c, 
AVCodecContext *avctx, MECmpContext
 if (cache_size < 2 * dia_size)
 av_log(avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the 
selected diamond size\n");
 
-ret  = ff_set_cmp(mecc, mecc->me_pre_cmp, avctx->me_pre_cmp);
-ret |= ff_set_cmp(mecc, mecc->me_cmp, avctx->me_cmp);
-ret |= ff_set_cmp(mecc, mecc->me_sub_cmp, avctx->me_sub_cmp);
-ret |= ff_set_cmp(mecc, mecc->mb_cmp, avctx->mb_cmp);
+ret  = ff_set_cmp(mecc, c->me_pre_cmp, avctx->me_pre_cmp);
+ret |= ff_set_cmp(mecc, c->me_cmp, avctx->me_cmp);
+ret |= ff_set_cmp(mecc, c->me_sub_cmp, avctx->me_sub_cmp);
+ret |= ff_set_cmp(mecc, c->mb_cmp, avctx->mb_cmp);
 if (ret < 0)
 return ret;
 
@@ -354,10 +354,10 @@ av_cold int ff_me_init(MotionEstContext *c, 
AVCodecContext *avctx, MECmpContext
  * not have yet, and even if we had, the motion estimation code
  * does not expect it. */
 if (avctx->codec_id != AV_CODEC_ID_SNOW) {
-if ((avctx->me_cmp & FF_CMP_CHROMA) /* && !s->mecc.me_cmp[2] */)
-mecc->me_cmp[2] = zero_cmp;
-if ((avctx->me_sub_cmp & FF_CMP_CHROMA) && !mecc->me_sub_cmp[2])
-mecc->me_sub_cmp[2] = zero_cmp;
+if ((avctx->me_cmp & FF_CMP_CHROMA) /* && !c->me_cmp[2] */)
+c->me_cmp[2] = zero_cmp;
+if ((avctx->me_sub_cmp & FF_CMP_CHROMA) && !c->me_sub_cmp[2])
+c->me_sub_cmp[2] = zero_cmp;
 }
 
 return 0;
@@ -649,7 +649,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int 
mx, int my, int shift)
 
 dmin4= c->sub_motion_search(s, &mx4, &my4, dmin4, block, block, size, 
h);
 
-if (s->mecc.me_sub_cmp[0] != s->mecc.mb_cmp[0]) {
+if (c->me_sub_cmp[0] != c->mb_cmp[0]) {
 int dxy;
 const int offset= ((block&1) + (block>>1)*stride)*8;
 uint8_t *dest_y = c->scratchpad + offset;
@@ -691,11 +691,11 @@ static inline int h263_mv4_search(MpegEncContext *s, int 
mx, int my, int shift)
 if(same)
 return INT_MAX;
 
-if (s->mecc.me_sub_cmp[0] != s->mecc.mb_cmp[0]) {
-dmin_sum += s->mecc.mb_cmp[0](s,
-  s->new_pic->data[0] +
-  s->mb_x * 16 + s->mb_y * 16 * stride,
-  c->scratchpad, stride, 16);
+if (c->me_sub_cmp[0] != c->mb_cmp[0]) {
+dmin_sum += c->mb_cmp[0](s,
+ s->new_pic->data[0] +
+ s->mb_x * 16 + s->mb_y * 16 * stride,
+   

[FFmpeg-cvslog] avcodec/motion_est: Store remaining required me_cmp_funcs

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 23:51:41 2024 +0200| [10e7633cd7d4b727c6cc0c907f1150e0359d7087] | 
committer: Andreas Rheinhardt

avcodec/motion_est: Store remaining required me_cmp_funcs

This avoids using MpegEncContext.mecc; it already allows
to avoid touching the latter for snowenc and svq1enc.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/motion_est.c | 7 +--
 libavcodec/motion_est.h | 3 +++
 libavcodec/snowenc.c| 1 -
 libavcodec/svq1enc.c| 1 -
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 13f3d8040e..e783e79a94 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -332,6 +332,9 @@ av_cold int ff_me_init(MotionEstContext *c, AVCodecContext 
*avctx,
 if (ret < 0)
 return ret;
 
+c->sse = mecc->sse[0];
+memcpy(c->pix_abs, mecc->pix_abs, sizeof(c->pix_abs));
+
 c->flags = get_flags(c, 0, avctx->me_cmp & FF_CMP_CHROMA);
 c->sub_flags = get_flags(c, 0, avctx->me_sub_cmp & FF_CMP_CHROMA);
 c->mb_flags  = get_flags(c, 0, avctx->mb_cmp & FF_CMP_CHROMA);
@@ -397,7 +400,7 @@ void ff_me_init_pic(MpegEncContext *s)
 
 #define CHECK_SAD_HALF_MV(suffix, x, y) \
 {\
-d  = s->mecc.pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + 
((x) >> 1), stride, h); \
+d  = c->pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + ((x) >> 
1), stride, h); \
 d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\
 COPY3_IF_LT(dminh, d, dx, x, dy, y)\
 }
@@ -973,7 +976,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
 /* At this point (mx,my) are full-pell and the relative displacement */
 ppix = c->ref[0][0] + (my * s->linesize) + mx;
 
-vard = s->mecc.sse[0](NULL, pix, ppix, s->linesize, 16);
+vard = c->sse(NULL, pix, ppix, s->linesize, 16);
 
 s->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
 c->mc_mb_var_sum_temp += (vard+128)>>8;
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index 243b73ff4e..12f7cd43ab 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -89,6 +89,9 @@ typedef struct MotionEstContext {
 me_cmp_func me_sub_cmp[6];
 me_cmp_func mb_cmp[6];
 
+me_cmp_func pix_abs[2][4];
+me_cmp_func sse;
+
 op_pixels_func(*hpel_put)[4];
 op_pixels_func(*hpel_avg)[4];
 qpel_mc_func(*qpel_put)[16];
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 819a7933fe..9db4314efb 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1869,7 +1869,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 mpv->qscale = (mpv->lambda*139 + FF_LAMBDA_SCALE*64) >> 
(FF_LAMBDA_SHIFT + 7);
 enc->lambda2  = mpv->lambda2 = (mpv->lambda*mpv->lambda + 
FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT;
 
-mpv->mecc = enc->mecc; //move
 mpv->qdsp = enc->qdsp; //move
 mpv->hdsp = s->hdsp;
 ff_me_init_pic(&enc->m);
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 5413508217..6e687166b8 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -373,7 +373,6 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 s->m.cur_pic.motion_val[0]   = s->motion_val8[plane] + 2;
 s->m.p_mv_table  = s->motion_val16[plane] +
s->m.mb_stride + 1;
-s->m.mecc= s->mecc; // move
 ff_me_init_pic(&s->m);
 
 s->m.me.dia_size  = s->avctx->dia_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/me_cmp,dvenc,mpegvideo: Move ildct_cmp to its users

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 21:05:58 2024 +0200| [b1a31b32abc19df329cf61fa23febd8252978fd3] | 
committer: Andreas Rheinhardt

avcodec/me_cmp,dvenc,mpegvideo: Move ildct_cmp to its users

MECmpContext.ildct_cmp is an array of function pointers that
are not set by ff_me_cmp_init(), but that are set by users
to one of the other arrays via ff_set_cmp().

Remove these pointers from MECmpContext and add pointers
for the actually used functions to its users. (The DV encoder
already did so.)

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/dvenc.c |  7 ---
 libavcodec/me_cmp.h|  2 --
 libavcodec/mpegvideo.h |  2 ++
 libavcodec/mpegvideo_enc.c | 49 +++---
 tests/checkasm/motion.c|  1 -
 5 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 5336ff149c..1f68c85c48 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -96,15 +96,16 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
*avctx)
 
 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
 MECmpContext mecc;
+me_cmp_func ildct_cmp[6];
 
 memset(&mecc,0, sizeof(mecc));
 ff_me_cmp_init(&mecc, avctx);
-ret = ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp);
+ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp);
 if (ret < 0)
 return ret;
-if (!mecc.ildct_cmp[5])
+if (!ildct_cmp[5])
 return AVERROR(EINVAL);
-s->ildct_cmp = mecc.ildct_cmp[5];
+s->ildct_cmp = ildct_cmp[5];
 }
 
 memset(&fdsp,0, sizeof(fdsp));
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 4f964ca188..b9abc7fb8e 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -70,8 +70,6 @@ typedef struct MECmpContext {
 me_cmp_func dct_max[6];
 me_cmp_func dct264_sad[6];
 
-me_cmp_func ildct_cmp[6]; // only width 16 used
-
 me_cmp_func pix_abs[2][4];
 me_cmp_func median_sad[6];
 } MECmpContext;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index df46433a82..44695776ad 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -506,6 +506,8 @@ typedef struct MpegEncContext {
 int mpv_flags;  ///< flags set by private options
 int quantizer_noise_shaping;
 
+me_cmp_func ildct_cmp[2]; ///< 0 = intra, 1 = non-intra
+
 /**
  * ratecontrol qmin qmax limiting method
  * 0-> clipping, 1-> use a nice continuous function to limit qscale within 
qmin/qmax.
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6ec8fa2e0b..6059bdee11 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -319,6 +319,15 @@ static av_cold int me_cmp_init(MpegEncContext *s, 
AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 s->frame_skip_cmp_fn = me_cmp[1];
+if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+ret = ff_set_cmp(&s->mecc, me_cmp, avctx->ildct_cmp);
+if (ret < 0)
+return ret;
+if (!me_cmp[0] || !me_cmp[4])
+return AVERROR(EINVAL);
+s->ildct_cmp[0] = me_cmp[0];
+s->ildct_cmp[1] = me_cmp[4];
+}
 
 return 0;
 }
@@ -929,14 +938,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 
 s->quant_precision = 5;
 
-if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
-ret = ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, avctx->ildct_cmp);
-if (ret < 0)
-return ret;
-if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4])
-return AVERROR(EINVAL);
-}
-
 if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
 ff_h263_encode_init(s);
 #if CONFIG_MSMPEG4ENC
@@ -2209,15 +2210,15 @@ static av_always_inline void 
encode_mb_internal(MpegEncContext *s,
 int progressive_score, interlaced_score;
 
 s->interlaced_dct = 0;
-progressive_score = s->mecc.ildct_cmp[4](s, ptr_y, NULL, wrap_y, 
8) +
-s->mecc.ildct_cmp[4](s, ptr_y + wrap_y * 8,
- NULL, wrap_y, 8) - 400;
+progressive_score = s->ildct_cmp[1](s, ptr_y, NULL, wrap_y, 8) +
+s->ildct_cmp[1](s, ptr_y + wrap_y * 8,
+NULL, wrap_y, 8) - 400;
 
 if (progressive_score > 0) {
-interlaced_score = s->mecc.ildct_cmp[4](s, ptr_y,
-NULL, wrap_y * 2, 8) +
-   s->mecc.ildct_cmp[4](s, ptr_y + wrap_y,
-NULL, wrap_y * 2, 8);
+interlaced_score = s->ildct_cmp[1](s, ptr_y,
+   NULL, wrap_y * 2, 8) +

[FFmpeg-cvslog] avcodec/me_cmp, mpegvideo: Move frame_skip_cmp to MpegEncContext

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 19:39:10 2024 +0200| [cd2e46a3508d123db9d235b71dd06d495d1eecde] | 
committer: Andreas Rheinhardt

avcodec/me_cmp, mpegvideo: Move frame_skip_cmp to MpegEncContext

MECmpContext has several arrays of function pointers that
are not set by ff_me_cmp_init(), but that are set by users
to one of the other arrays via ff_set_cmp().

One of these other users is mpegvideo_enc; it is the only user
of MECmpContext.frame_skip_cmp and it only uses one of these
function pointers at all.

This commit therefore moves this function pointer to MpegEncContext;
and removes the array from MECmpContext.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/me_cmp.h|  1 -
 libavcodec/mpegvideo.h |  1 +
 libavcodec/mpegvideo_enc.c | 10 ++
 tests/checkasm/motion.c|  1 -
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 67e3816829..4f964ca188 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -71,7 +71,6 @@ typedef struct MECmpContext {
 me_cmp_func dct264_sad[6];
 
 me_cmp_func ildct_cmp[6]; // only width 16 used
-me_cmp_func frame_skip_cmp[6]; // only width 8 used
 
 me_cmp_func pix_abs[2][4];
 me_cmp_func median_sad[6];
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 60dcf65288..df46433a82 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -542,6 +542,7 @@ typedef struct MpegEncContext {
 int frame_skip_factor;
 int frame_skip_exp;
 int frame_skip_cmp;
+me_cmp_func frame_skip_cmp_fn;
 
 int scenechange_threshold;
 int noise_reduction;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 5b8d877935..6ec8fa2e0b 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -308,12 +308,17 @@ av_cold void ff_dct_encode_init(MpegEncContext *s)
 
 static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx)
 {
+me_cmp_func me_cmp[6];
 int ret;
 
 ff_me_cmp_init(&s->mecc, avctx);
 ret = ff_me_init(&s->me, avctx, &s->mecc);
 if (ret < 0)
 return ret;
+ret = ff_set_cmp(&s->mecc, me_cmp, s->frame_skip_cmp);
+if (ret < 0)
+return ret;
+s->frame_skip_cmp_fn = me_cmp[1];
 
 return 0;
 }
@@ -931,9 +936,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4])
 return AVERROR(EINVAL);
 }
-ret = ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
-if (ret < 0)
-return AVERROR(EINVAL);
 
 if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
 ff_h263_encode_init(s);
@@ -1311,7 +1313,7 @@ static int skip_check(MpegEncContext *s, const MPVPicture 
*p, const MPVPicture *
 int off = p->shared ? 0 : 16;
 const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) 
+ off;
 const uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * 
stride);
-int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8);
+int v = s->frame_skip_cmp_fn(s, dptr, rptr, stride, 8);
 
 switch (FFABS(s->frame_skip_exp)) {
 case 0: score=  FFMAX(score, v);  break;
diff --git a/tests/checkasm/motion.c b/tests/checkasm/motion.c
index 2bf49afc77..8f9915c63a 100644
--- a/tests/checkasm/motion.c
+++ b/tests/checkasm/motion.c
@@ -95,7 +95,6 @@ static void test_motion(const char *name, me_cmp_func 
test_func)
 XX(vsse)   
\
 XX(nsse)   
\
 XX(ildct_cmp)  
\
-XX(frame_skip_cmp) 
\
 XX(median_sad)
 
 // tests for functions not yet implemented

___
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: Avoid branch for sse vs nsse cmp

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon May 13 00:08:08 2024 +0200| [eb3415912b187dcef9cfb3a076db579fdf82600d] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Avoid branch for sse vs nsse cmp

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegvideo.h |  1 +
 libavcodec/mpegvideo_enc.c | 23 +++
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 44695776ad..79c5561793 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -507,6 +507,7 @@ typedef struct MpegEncContext {
 int quantizer_noise_shaping;
 
 me_cmp_func ildct_cmp[2]; ///< 0 = intra, 1 = non-intra
+me_cmp_func n_sse_cmp[2]; ///< either SSE or NSSE cmp func
 
 /**
  * ratecontrol qmin qmax limiting method
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8022fe474a..3d659fa290 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -329,6 +329,14 @@ static av_cold int me_cmp_init(MpegEncContext *s, 
AVCodecContext *avctx)
 s->ildct_cmp[1] = me_cmp[4];
 }
 
+if (avctx->mb_cmp == FF_CMP_NSSE) {
+s->n_sse_cmp[0] = s->mecc.nsse[0];
+s->n_sse_cmp[1] = s->mecc.nsse[1];
+} else {
+s->n_sse_cmp[0] = s->mecc.sse[0];
+s->n_sse_cmp[1] = s->mecc.sse[1];
+}
+
 return 0;
 }
 
@@ -2664,21 +2672,12 @@ static int sse_mb(MpegEncContext *s){
 if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
 
 if(w==16 && h==16)
-  if(s->avctx->mb_cmp == FF_CMP_NSSE){
-return s->mecc.nsse[0](s, s->new_pic->data[0] + s->mb_x * 16 + s->mb_y 
* s->linesize * 16,
+return s->n_sse_cmp[0](s, s->new_pic->data[0] + s->mb_x * 16 + s->mb_y 
* s->linesize * 16,
s->dest[0], s->linesize, 16) +
-   s->mecc.nsse[1](s, s->new_pic->data[1] + s->mb_x * chroma_mb_w 
+ s->mb_y * s->uvlinesize * chroma_mb_h,
+   s->n_sse_cmp[1](s, s->new_pic->data[1] + s->mb_x * chroma_mb_w 
+ s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[1], s->uvlinesize, chroma_mb_h) +
-   s->mecc.nsse[1](s, s->new_pic->data[2] + s->mb_x * chroma_mb_w 
+ s->mb_y * s->uvlinesize * chroma_mb_h,
+   s->n_sse_cmp[1](s, s->new_pic->data[2] + s->mb_x * chroma_mb_w 
+ s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[2], s->uvlinesize, chroma_mb_h);
-  }else{
-return s->mecc.sse[0](NULL, s->new_pic->data[0] + s->mb_x * 16 + 
s->mb_y * s->linesize * 16,
-  s->dest[0], s->linesize, 16) +
-   s->mecc.sse[1](NULL, s->new_pic->data[1] + s->mb_x * 
chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
-  s->dest[1], s->uvlinesize, chroma_mb_h) +
-   s->mecc.sse[1](NULL, s->new_pic->data[2] + s->mb_x * 
chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
-  s->dest[2], s->uvlinesize, chroma_mb_h);
-  }
 else
 return  sse(s, s->new_pic->data[0] + s->mb_x * 16 + s->mb_y * 
s->linesize * 16,
 s->dest[0], w, h, s->linesize) +

___
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/me_cmp, motion_est: Sanitize permissible cmp_funcs

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 23:15:46 2024 +0200| [d163eefd4756111d188c40b3ee4b6cd91e8b9d64] | 
committer: Andreas Rheinhardt

avcodec/me_cmp, motion_est: Sanitize permissible cmp_funcs

Several of the potential choices of comparison functions
need an initialized MpegEncContext (initialized for encoding,
not only ff_mpv_common_init()) or they crash when called.
Modify ff_set_cmp() to check for this.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/dvenc.c |   2 +-
 libavcodec/me_cmp.c| 116 -
 libavcodec/me_cmp.h|   9 +++-
 libavcodec/motion_est.c|  11 +++--
 libavcodec/motion_est.h|   2 +-
 libavcodec/mpegvideo_enc.c |   6 +--
 libavcodec/snowenc.c   |   2 +-
 libavcodec/svq1enc.c   |   2 +-
 8 files changed, 73 insertions(+), 77 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 1f68c85c48..505f253e6d 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -100,7 +100,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
*avctx)
 
 memset(&mecc,0, sizeof(mecc));
 ff_me_cmp_init(&mecc, avctx);
-ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp);
+ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp, 0);
 if (ret < 0)
 return ret;
 if (!ildct_cmp[5])
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index 5cea792c95..8368b0c1cb 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include 
+
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
@@ -473,74 +475,60 @@ static int zero_cmp(MpegEncContext *s, const uint8_t *a, 
const uint8_t *b,
 return 0;
 }
 
-int ff_set_cmp(const MECmpContext *c, me_cmp_func *cmp, int type)
+av_cold int ff_set_cmp(const MECmpContext *c, me_cmp_func *cmp, int type, int 
mpvenc)
 {
-int ret = 0;
-int i;
-
-memset(cmp, 0, sizeof(void *) * 6);
-
-for (i = 0; i < 6; i++) {
-switch (type & 0xFF) {
-case FF_CMP_SAD:
-cmp[i] = c->sad[i];
-break;
-case FF_CMP_MEDIAN_SAD:
-cmp[i] = c->median_sad[i];
-break;
-case FF_CMP_SATD:
-cmp[i] = c->hadamard8_diff[i];
-break;
-case FF_CMP_SSE:
-cmp[i] = c->sse[i];
-break;
-case FF_CMP_DCT:
-cmp[i] = c->dct_sad[i];
-break;
-case FF_CMP_DCT264:
-cmp[i] = c->dct264_sad[i];
-break;
-case FF_CMP_DCTMAX:
-cmp[i] = c->dct_max[i];
-break;
-case FF_CMP_PSNR:
-cmp[i] = c->quant_psnr[i];
-break;
-case FF_CMP_BIT:
-cmp[i] = c->bit[i];
-break;
-case FF_CMP_RD:
-cmp[i] = c->rd[i];
-break;
-case FF_CMP_VSAD:
-cmp[i] = c->vsad[i];
-break;
-case FF_CMP_VSSE:
-cmp[i] = c->vsse[i];
-break;
-case FF_CMP_ZERO:
-cmp[i] = zero_cmp;
-break;
-case FF_CMP_NSSE:
-cmp[i] = c->nsse[i];
-break;
-#if CONFIG_DWT
-case FF_CMP_W53:
-cmp[i]= c->w53[i];
-break;
-case FF_CMP_W97:
-cmp[i]= c->w97[i];
-break;
+#define ENTRY(CMP_FLAG, ARRAY, MPVENC_ONLY)  \
+[FF_CMP_ ## CMP_FLAG] = {\
+.offset= offsetof(MECmpContext, ARRAY),  \
+.mpv_only  = MPVENC_ONLY,\
+.available = 1,  \
+}
+static const struct {
+char available;
+char mpv_only;
+uint16_t offset;
+} cmp_func_list[] = {
+ENTRY(SAD,sad,0),
+ENTRY(SSE,sse,0),
+ENTRY(SATD,   hadamard8_diff, 0),
+ENTRY(DCT,dct_sad,1),
+ENTRY(PSNR,   quant_psnr, 1),
+ENTRY(BIT,bit,1),
+ENTRY(RD, rd, 1),
+ENTRY(VSAD,   vsad,   0),
+ENTRY(VSSE,   vsse,   0),
+ENTRY(NSSE,   nsse,   0),
+#if CONFIG_SNOW_DECODER || CONFIG_SNOW_ENCODER
+ENTRY(W53,w53,0),
+ENTRY(W97,w97,0),
 #endif
-default:
-av_log(NULL, AV_LOG_ERROR,
-   "invalid cmp function selection\n");
-ret = -1;
-break;
-}
+ENTRY(DCTMAX, dct_max,1),
+#if CONFIG_GPL
+ENTRY(DCT264, dct264_sad, 1),
+#endif
+ENTRY(MEDIAN_SAD, median_sad, 0),
+};
+const me_cmp_fun

[FFmpeg-cvslog] avcodec/mpegvideo_enc: Only keep what is used from MECmpContext

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon May 13 00:25:20 2024 +0200| [3b67ab85eefd36af8fb369423f6f623b85977fe7] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Only keep what is used from MECmpContext

A MECmpContext is quite big (792B here) and given
how ff_update_duplicate_context() works, it is (unfortunately)
copied quite frequently when using slice threading.
Therefore keep only what is needed from MECmpContext
and remove MECmpContext from MpegEncContext.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/me_cmp.c  |  4 +--
 libavcodec/mpeg4videoenc.c   |  2 +-
 libavcodec/mpegvideo.h   |  4 ++-
 libavcodec/mpegvideo_enc.c   | 59 +---
 libavcodec/x86/me_cmp_init.c |  2 +-
 5 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index b94d512660..592ee76084 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -653,7 +653,7 @@ static int dct_sad8x8_c(MpegEncContext *s, const uint8_t 
*src1,
 
 s->pdsp.diff_pixels_unaligned(temp, src1, src2, stride);
 s->fdsp.fdct(temp);
-return s->mecc.sum_abs_dctelem(temp);
+return s->sum_abs_dctelem(temp);
 }
 
 #if CONFIG_GPL
@@ -819,7 +819,7 @@ static int rd8x8_c(MpegEncContext *s, const uint8_t *src1, 
const uint8_t *src2,
 
 s->idsp.idct_add(lsrc2, 8, temp);
 
-distortion = s->mecc.sse[1](NULL, lsrc2, lsrc1, 8, 8);
+distortion = s->sse_cmp[1](NULL, lsrc2, lsrc1, 8, 8);
 
 return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7);
 }
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 583ea9de6f..84b603f312 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -673,7 +673,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t 
block[6][64],
 }
 diff = diff * 256 / (xe * ye);
 } else {
-diff = s->mecc.sad[0](NULL, p_pic, b_pic, 
s->linesize, 16);
+diff = s->sad_cmp[0](NULL, p_pic, b_pic, 
s->linesize, 16);
 }
 if (diff > s->qscale * 70) {  // FIXME check that 70 
is optimal
 s->mb_skipped = 0;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 79c5561793..844da6881f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -220,7 +220,6 @@ typedef struct MpegEncContext {
 H264ChromaContext h264chroma;
 HpelDSPContext hdsp;
 IDCTDSPContext idsp;
-MECmpContext mecc;
 MpegvideoEncDSPContext mpvencdsp;
 PixblockDSPContext pdsp;
 QpelDSPContext qdsp;
@@ -508,6 +507,9 @@ typedef struct MpegEncContext {
 
 me_cmp_func ildct_cmp[2]; ///< 0 = intra, 1 = non-intra
 me_cmp_func n_sse_cmp[2]; ///< either SSE or NSSE cmp func
+me_cmp_func sad_cmp[2];
+me_cmp_func sse_cmp[2];
+int (*sum_abs_dctelem)(const int16_t *block);
 
 /**
  * ratecontrol qmin qmax limiting method
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 3d659fa290..73e1a69490 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -308,19 +308,20 @@ av_cold void ff_dct_encode_init(MpegEncContext *s)
 
 static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx)
 {
+MECmpContext mecc;
 me_cmp_func me_cmp[6];
 int ret;
 
-ff_me_cmp_init(&s->mecc, avctx);
-ret = ff_me_init(&s->me, avctx, &s->mecc, 1);
+ff_me_cmp_init(&mecc, avctx);
+ret = ff_me_init(&s->me, avctx, &mecc, 1);
 if (ret < 0)
 return ret;
-ret = ff_set_cmp(&s->mecc, me_cmp, s->frame_skip_cmp, 1);
+ret = ff_set_cmp(&mecc, me_cmp, s->frame_skip_cmp, 1);
 if (ret < 0)
 return ret;
 s->frame_skip_cmp_fn = me_cmp[1];
 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
-ret = ff_set_cmp(&s->mecc, me_cmp, avctx->ildct_cmp, 1);
+ret = ff_set_cmp(&mecc, me_cmp, avctx->ildct_cmp, 1);
 if (ret < 0)
 return ret;
 if (!me_cmp[0] || !me_cmp[4])
@@ -329,12 +330,18 @@ static av_cold int me_cmp_init(MpegEncContext *s, 
AVCodecContext *avctx)
 s->ildct_cmp[1] = me_cmp[4];
 }
 
+s->sum_abs_dctelem = mecc.sum_abs_dctelem;
+
+s->sse_cmp[0] = mecc.sse[0];
+s->sse_cmp[1] = mecc.sse[1];
+s->sad_cmp[0] = mecc.sad[0];
+s->sad_cmp[1] = mecc.sad[1];
 if (avctx->mb_cmp == FF_CMP_NSSE) {
-s->n_sse_cmp[0] = s->mecc.nsse[0];
-s->n_sse_cmp[1] = s->mecc.nsse[1];
+s->n_sse_cmp[0] = mecc.nsse[0];
+s->n_sse_cmp[1] = mecc.nsse[1];
 } else {
-s->n_sse_cmp[0] = s->mecc.sse[0];
-s->n_sse_cmp[1] = s->mecc.sse[1];
+s->n_sse_cmp[0] = mecc.sse[0];
+s->n_sse_cmp[1] = mecc.sse[1];
 }
 
 return 0;
@@ -1123,8 +1130,8 

[FFmpeg-cvslog] avcodec/me_cmp: Zero MECmpContext in ff_me_cmp_init()

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun May 12 23:57:54 2024 +0200| [8b4f7c066373a4c373292c54b469a172d63fed35] | 
committer: Andreas Rheinhardt

avcodec/me_cmp: Zero MECmpContext in ff_me_cmp_init()

Not every function will be set, so zero the context
to initialize everything.

This also allows to remove an initialization in dvenc.c.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/dvenc.c| 1 -
 libavcodec/me_cmp.c   | 2 ++
 libavcodec/tests/motion.c | 2 --
 tests/checkasm/motion.c   | 3 ---
 4 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 505f253e6d..19137e8b50 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -98,7 +98,6 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 MECmpContext mecc;
 me_cmp_func ildct_cmp[6];
 
-memset(&mecc,0, sizeof(mecc));
 ff_me_cmp_init(&mecc, avctx);
 ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp, 0);
 if (ret < 0)
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index 8368b0c1cb..b94d512660 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -995,6 +995,8 @@ WRAPPER8_16_SQ(bit8x8_c, bit16_c)
 
 av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
 {
+memset(c, 0, sizeof(*c));
+
 c->sum_abs_dctelem = sum_abs_dctelem_c;
 
 /* TODO [0] 16  [1] 8 */
diff --git a/libavcodec/tests/motion.c b/libavcodec/tests/motion.c
index caa8ecb8be..c37fc551c3 100644
--- a/libavcodec/tests/motion.c
+++ b/libavcodec/tests/motion.c
@@ -131,12 +131,10 @@ int main(int argc, char **argv)
 ctx = avcodec_alloc_context3(NULL);
 ctx->flags |= AV_CODEC_FLAG_BITEXACT;
 av_force_cpu_flags(0);
-memset(&cctx, 0, sizeof(cctx));
 ff_me_cmp_init(&cctx, ctx);
 for (c = 0; c < flags_size; c++) {
 int x;
 av_force_cpu_flags(flags[c]);
-memset(&mmxctx, 0, sizeof(mmxctx));
 ff_me_cmp_init(&mmxctx, ctx);
 
 for (x = 0; x < 2; x++) {
diff --git a/tests/checkasm/motion.c b/tests/checkasm/motion.c
index bfd1a3c17b..7e322da0d5 100644
--- a/tests/checkasm/motion.c
+++ b/tests/checkasm/motion.c
@@ -116,9 +116,6 @@ static void check_motion(void)
 AVCodecContext av_ctx = { .codec_id = AV_CODEC_ID_NONE, .flags = 
AV_CODEC_FLAG_BITEXACT };
 MECmpContext me_ctx;
 
-memset(&me_ctx, 0, sizeof(me_ctx));
-
-
 ff_me_cmp_init(&me_ctx, &av_ctx);
 
 for (int i = 0; i < FF_ARRAY_ELEMS(me_ctx.pix_abs); 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: Don't update qscale unnecessarily

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 06:26:07 2024 +0200| [f8b8f161634c5917b7cddbb3dd37440afd9105f9] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Don't update qscale unnecessarily

The new value will be overwritten in ff_set_qscale() below.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6d26b2d619..125d16e694 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2163,11 +2163,11 @@ static av_always_inline void 
encode_mb_internal(MpegEncContext *s,
 const int mb_xy = mb_x + mb_y * s->mb_stride;
 
 s->lambda = s->lambda_table[mb_xy];
-update_qscale(s);
+s->lambda2 = (s->lambda * s->lambda + FF_LAMBDA_SCALE / 2) >>
+ FF_LAMBDA_SHIFT;
 
 if (!(s->mpv_flags & FF_MPV_FLAG_QP_RD)) {
-s->qscale = s->cur_pic.qscale_table[mb_xy];
-s->dquant = s->qscale - last_qp;
+s->dquant = s->cur_pic.qscale_table[mb_xy] - last_qp;
 
 if (s->out_format == FMT_H263) {
 s->dquant = av_clip(s->dquant, -2, 2);

___
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/mpegutils: Fix ff_draw_horiz_band()

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun  4 12:14:10 2024 +0200| [c28e553cbfa70ba0ca635271f5154301889fb706] | 
committer: Andreas Rheinhardt

avcodec/mpegutils: Fix ff_draw_horiz_band()

Broken in 5ecf5b93dda9d0c69875b80d28929f0d97dd7d06.

More precisely, 3994623df2efd2749631c3492184dd8d4ffa9d1b changed
the precursor of ff_mpv_reconstruct_mb() to always decode
to the first row of macroblocks for B pictures when
a draw_horiz_band callback is set and to (they are exported to
the caller via said callback and each row overwrites the previously
decoded row; this was probably intended as a cache-optimization).
This first macroblock row was used as source for the draw_horiz_band
callback.

This of course means that the ordinary output B-frame was not
decoded correctly at all. Therefore the first aforementioned commit
removed this special handling of draw_horiz_band; yet it did not
remove the special handling for B-frames in ff_draw_horiz_band(),
which broke draw_horiz_band for B-frames. This commit fixes this.

(Actually, draw_horiz_band was already broken before
5ecf5b93dda9d0c69875b80d28929f0d97dd7d06 when using slice-threading:
All slice-threads would write to the first row of macroblocks
for B-frames, leading to data races. It seems no one has ever complained
about this, just as no one has ever complained about the breakage
caused by 5ecf5b93dda9d0c69875b80d28929f0d97dd7d06. Probably no one
uses draw_horiz_band.)

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegutils.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index a567165fd9..a53996852f 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -57,6 +57,7 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 int first_field, int low_delay)
 {
 const int field_pic = picture_structure != PICT_FRAME;
+const AVPixFmtDescriptor *desc;
 const AVFrame *src;
 int offset[AV_NUM_DATA_POINTERS];
 
@@ -82,21 +83,13 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 else
 return;
 
-if (cur->pict_type == AV_PICTURE_TYPE_B &&
-picture_structure == PICT_FRAME &&
-avctx->codec_id != AV_CODEC_ID_SVQ3) {
-for (int i = 0; i < AV_NUM_DATA_POINTERS; i++)
-offset[i] = 0;
-} else {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
-int vshift = desc->log2_chroma_h;
-
-offset[0] = y * src->linesize[0];
-offset[1] =
-offset[2] = (y >> vshift) * src->linesize[1];
-for (int i = 3; i < AV_NUM_DATA_POINTERS; i++)
-offset[i] = 0;
-}
+desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+
+offset[0] = y * src->linesize[0];
+offset[1] =
+offset[2] = (y >> desc->log2_chroma_h) * src->linesize[1];
+for (int i = 3; i < AV_NUM_DATA_POINTERS; i++)
+offset[i] = 0;
 
 emms_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/mpv_reconstruct_mb_template: Don't unnecessarily copy data

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun  4 02:44:56 2024 +0200| [3acf351e7753a2fd82e0d4a42f197f3a3e8b2ab5] | 
committer: Andreas Rheinhardt

avcodec/mpv_reconstruct_mb_template: Don't unnecessarily copy data

There is no reason to use a temporary buffer as destination
for the new macroblock before copying it into its proper place.
(Originally, this has been added in commit
b68ab2609c67d07b6f12ed65125d76bf9a054479 due to concerns about
copying from GPU memory.)

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegpicture.h |  1 -
 libavcodec/mpv_reconstruct_mb_template.c | 23 ++-
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index 86504fe8ca..d3f39bbae6 100644
--- a/libavcodec/mpegpicture.h
+++ b/libavcodec/mpegpicture.h
@@ -35,7 +35,6 @@ typedef struct ScratchpadContext {
 uint8_t *obmc_scratchpad;
 union {
 uint8_t *scratchpad_buf;  ///< the other *_scratchpad point into this 
buffer
-uint8_t *b_scratchpad;///< scratchpad used for writing into write 
only buffers
 uint8_t *rd_scratchpad;   ///< scratchpad for rate distortion mb 
decision
 };
 int  linesize;///< linesize that the buffers in this 
context have been allocated for
diff --git a/libavcodec/mpv_reconstruct_mb_template.c 
b/libavcodec/mpv_reconstruct_mb_template.c
index 6ad353ddfd..e39b3d0e73 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -80,11 +80,10 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t 
block[12][64],
   s->avctx->mb_decision != FF_MB_DECISION_RD))  // FIXME precalc
 #endif /* IS_ENCODER */
 {
-uint8_t *dest_y, *dest_cb, *dest_cr;
+uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = 
s->dest[2];
 int dct_linesize, dct_offset;
 const int linesize   = s->cur_pic.linesize[0]; //not s->linesize as 
this would be wrong for field pics
 const int uvlinesize = s->cur_pic.linesize[1];
-const int readable   = IS_ENCODER || lowres_flag || s->pict_type != 
AV_PICTURE_TYPE_B;
 const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8;
 
 /* avoid copy if macroblock skipped in last frame too */
@@ -106,16 +105,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 dct_linesize = linesize << s->interlaced_dct;
 dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
 
-if (readable) {
-dest_y  = s->dest[0];
-dest_cb = s->dest[1];
-dest_cr = s->dest[2];
-} else {
-dest_y  = s->sc.b_scratchpad;
-dest_cb = s->sc.b_scratchpad + 16 * linesize;
-dest_cr = s->sc.b_scratchpad + 32 * linesize;
-}
-
 if (!s->mb_intra) {
 /* motion handling */
 /* decoding or more than one mb_type (MC was already done 
otherwise) */
@@ -169,7 +158,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t 
block[12][64],
 if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type 
== AV_PICTURE_TYPE_B)
||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type 
!= AV_PICTURE_TYPE_I)
|| s->avctx->skip_idct >= AVDISCARD_ALL)
-goto skip_idct;
+return;
 }
 
 /* add dct residue */
@@ -288,14 +277,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 }
 } //gray
 }
-}
-skip_idct:
-if (!readable) {
-s->hdsp.put_pixels_tab[0][0](s->dest[0], dest_y, linesize, 16);
-if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], 
dest_cb, uvlinesize, 16 >> s->chroma_y_shift);
-s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], 
dest_cr, uvlinesize, 16 >> s->chroma_y_shift);
-}
 #endif /* !IS_ENCODER */
 }
 }

___
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: Initialize qscale tab for all codecs

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 06:19:27 2024 +0200| [85cc6478b64f9f59c585de6329b8d2e403f3c95d] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Initialize qscale tab for all codecs

Calling it is the first thing ff_clean_h263_qscales() and
ff_clean_mpeg4_qscales() do anyway.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h263enc.h   | 1 -
 libavcodec/ituh263enc.c| 2 --
 libavcodec/mpegvideo_enc.c | 6 +++---
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h
index cd5ded1593..6e07440b30 100644
--- a/libavcodec/h263enc.h
+++ b/libavcodec/h263enc.h
@@ -32,7 +32,6 @@ void ff_h263_encode_mb(MpegEncContext *s,
int motion_x, int motion_y);
 void ff_h263_encode_mba(MpegEncContext *s);
 
-void ff_init_qscale_tab(MpegEncContext *s);
 void ff_clean_h263_qscales(MpegEncContext *s);
 
 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code);
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 8d0c4147bf..b1fe4e241e 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -274,8 +274,6 @@ void ff_clean_h263_qscales(MpegEncContext *s){
 int i;
 int8_t * const qscale_table = s->cur_pic.qscale_table;
 
-ff_init_qscale_tab(s);
-
 for(i=1; imb_num; i++){
 if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ 
s->mb_index2xy[i-1] ] >2)
 qscale_table[ s->mb_index2xy[i] ]= qscale_table[ 
s->mb_index2xy[i-1] ]+2;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 73e1a69490..6d26b2d619 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -237,7 +237,7 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t 
*matrix)
 /**
  * init s->cur_pic.qscale_table from s->lambda_table
  */
-void ff_init_qscale_tab(MpegEncContext *s)
+static void init_qscale_tab(MpegEncContext *s)
 {
 int8_t * const qscale_table = s->cur_pic.qscale_table;
 int i;
@@ -3542,6 +3542,8 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
 }
 
 if(s->adaptive_quant){
+init_qscale_tab(s);
+
 switch(s->codec_id){
 case AV_CODEC_ID_MPEG4:
 if (CONFIG_MPEG4_ENCODER)
@@ -3553,8 +3555,6 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
 if (CONFIG_H263_ENCODER)
 ff_clean_h263_qscales(s);
 break;
-default:
-ff_init_qscale_tab(s);
 }
 
 s->lambda= s->lambda_table[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: Disable allocating scratchpad buffers when possible

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun  4 11:33:04 2024 +0200| [ba341be09533a077075c71fce5f9dc5b73504234] | 
committer: Andreas Rheinhardt

avcodec/mpeg12dec: Disable allocating scratchpad buffers when possible

They are no longer used by the MPEG-1/2 decoders except when
using lowres.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg12dec.c   |  4 
 libavcodec/mpegpicture.h | 10 ++
 2 files changed, 14 insertions(+)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index e0e9a8fb1e..7485b7c65f 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1000,6 +1000,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);
 }
 return 0;
 }
@@ -1874,6 +1876,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 (i = 0; i < 64; i++) {
 int j = s->idsp.idct_permutation[i];
diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index d3f39bbae6..196aa9b744 100644
--- a/libavcodec/mpegpicture.h
+++ b/libavcodec/mpegpicture.h
@@ -21,6 +21,7 @@
 #ifndef AVCODEC_MPEGPICTURE_H
 #define AVCODEC_MPEGPICTURE_H
 
+#include 
 #include 
 #include 
 
@@ -135,6 +136,15 @@ int ff_mpv_pic_check_linesize(void *logctx, const struct 
AVFrame *f,
 int ff_mpv_framesize_alloc(AVCodecContext *avctx,
ScratchpadContext *sc, int linesize);
 
+/**
+ * Disable allocating the ScratchpadContext's buffers in future calls
+ * to ff_mpv_framesize_alloc().
+ */
+static inline void ff_mpv_framesize_disable(ScratchpadContext *sc)
+{
+sc->linesize = INT_MAX;
+}
+
 void ff_mpv_unref_picture(MPVWorkPicture *pic);
 void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic);
 void ff_mpv_replace_picture(MPVWorkPicture *dst, const MPVWorkPicture *src);

___
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 alloc framesize-bufs in update_thread_ctx

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun  4 11:39:25 2024 +0200| [39660bf964df6361896e0f2289f33379c383dad7] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Don't alloc framesize-bufs in update_thread_ctx

It is always allocated in ff_mpv_frame_start(), so the only
reason to put it into ff_mpeg_update_thread_context()
would be for the case that a frame-threaded decoder
that supports coded fields implements frame-threading.

The only mpegvideo-decoders supporting coded fields
are MPEG-1/2 and VC-1. The latter's bitstream requires
both coded fields to be part of the same access unit/packet,
so that every frame thread will always call ff_mpv_frame_start()
itself. The former only "need" the framesize buffers when
using lowres. If MPEG-1/2 gains frame-threading, one could either
perform framesize allocation in its update_thread_context
or when starting a field.

(Given that the next packet may trigger a reinitialization
due to a frame size change, it was possible for the buffers
that were allocated here to be thrown away unused.)

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index ad35505819..b3753b6ad2 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -160,14 +160,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
s1->bitstream_buffer_size);
 }
 
-// linesize-dependent scratch buffer allocation
-ret = ff_mpv_framesize_alloc(s->avctx, &s->sc, s1->linesize);
-if (ret < 0) {
-av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate context "
-   "scratch buffers.\n");
-return ret;
-}
-
 // 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/svq1enc: Stop copying PutBitContext unnecessarily

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun  6 01:21:55 2024 +0200| [0b0a4a7e69c0cd80ec7f9caf925ad9e4bc7d0810] | 
committer: Andreas Rheinhardt

avcodec/svq1enc: Stop copying PutBitContext unnecessarily

Possible since 404fe63e23433aa559cee5366cb26f78b425e7e5.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 6e687166b8..4065c9b21a 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -468,16 +468,14 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 
 put_bits(&s->reorder_pb[5], SVQ1_BLOCK_INTER_LEN, 
SVQ1_BLOCK_INTER_CODE);
 
-s->m.pb = s->reorder_pb[5];
 mx  = motion_ptr[0];
 my  = motion_ptr[1];
 av_assert1(mx >= -32 && mx <= 31);
 av_assert1(my >= -32 && my <= 31);
 av_assert1(pred_x >= -32 && pred_x <= 31);
 av_assert1(pred_y >= -32 && pred_y <= 31);
-ff_h263_encode_motion(&s->m.pb, mx - pred_x, 1);
-ff_h263_encode_motion(&s->m.pb, my - pred_y, 1);
-s->reorder_pb[5] = s->m.pb;
+ff_h263_encode_motion(&s->reorder_pb[5], mx - pred_x, 1);
+ff_h263_encode_motion(&s->reorder_pb[5], my - pred_y, 1);
 score[1]+= lambda * 
put_bits_count(&s->reorder_pb[5]);
 
 dxy = (mx & 1) + 2 * (my & 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/mpegutils: Don't output wrong mb skip values

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  9 08:40:20 2024 +0200| [952a32e9a0b10bac36a0a2fee631c97ef5175304] | 
committer: Andreas Rheinhardt

avcodec/mpegutils: Don't output wrong mb skip values

The earlier code had two problems:
1. For reference frames that are not directly output (happens unless
low_delay is set), the mb skip values referred to the next reference
frame to be decoded.
2. For non-reference frames, every macroblock was always considered
skipped.
This makes the output (worse than) useless; that no one ever
complained about this shows that this feature is not really used.
It is therefore removed.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h264dec.c   |  2 +-
 libavcodec/mpegutils.c | 12 ++--
 libavcodec/mpegutils.h |  2 +-
 libavcodec/mpegvideo_dec.c |  2 +-
 4 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index fd23e367b4..c77d8f42db 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -979,7 +979,7 @@ static int finalize_frame(H264Context *h, AVFrame *dst, 
H264Picture *out, int *g
 *got_frame = 1;
 
 if (CONFIG_MPEGVIDEODEC) {
-ff_print_debug_info2(h->avctx, dst, NULL,
+ff_print_debug_info2(h->avctx, dst,
  out->mb_type,
  out->qscale_table,
  out->motion_val,
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index a53996852f..73b6650b70 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -153,7 +153,7 @@ static char get_interlacement_char(int mb_type)
 }
 
 void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
-  const uint8_t *mbskip_table, const uint32_t 
*mbtype_table,
+  const uint32_t *mbtype_table,
   const int8_t *qscale_table, int16_t (*const 
motion_val[2])[2],
   int mb_width, int mb_height, int mb_stride, int 
quarter_sample)
 {
@@ -248,7 +248,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame 
*pict,
 return;
 
 
-if (avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
+if (avctx->debug & (FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
 int x,y;
 AVBPrint buf;
 int n;
@@ -267,8 +267,6 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame 
*pict,
 av_bprint_chars(&buf, ' ', margin_left);
 
 n = 0;
-if (avctx->debug & FF_DEBUG_SKIP)
-n++;
 if (avctx->debug & FF_DEBUG_QP)
 n += 2;
 if (avctx->debug & FF_DEBUG_MB_TYPE)
@@ -284,12 +282,6 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame 
*pict,
 for (x = 0; x < mb_width; x++) {
 if (x == 0)
 av_bprintf(&buf, "%*d ", margin_left - 1, y << 4);
-if (avctx->debug & FF_DEBUG_SKIP) {
-int count = mbskip_table ? mbskip_table[x + y * mb_stride] 
: 0;
-if (count > 9)
-count = 9;
-av_bprintf(&buf, "%1d", count);
-}
 if (avctx->debug & FF_DEBUG_QP) {
 av_bprintf(&buf, "%2d", qscale_table[x + y * mb_stride]);
 }
diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
index c82e07ebd7..e4ce26d299 100644
--- a/libavcodec/mpegutils.h
+++ b/libavcodec/mpegutils.h
@@ -106,7 +106,7 @@ void ff_draw_horiz_band(AVCodecContext *avctx, const 
AVFrame *cur, const AVFrame
  * Print debugging info for the given picture.
  */
 void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
-  const uint8_t *mbskip_table, const uint32_t 
*mbtype_table,
+  const uint32_t *mbtype_table,
   const int8_t *qscale_table, int16_t (*const 
motion_val[2])[2],
   int mb_width, int mb_height, int mb_stride, int 
quarter_sample);
 
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index e95b5a0940..4e279d9fa8 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -408,7 +408,7 @@ void ff_mpv_frame_end(MpegEncContext *s)
 
 void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame 
*pict)
 {
-ff_print_debug_info2(s->avctx, pict, s->mbskip_table, p->mb_type,
+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);
 }

___
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 s

[FFmpeg-cvslog] avcodec/mpegvideo_dec: Don't keep droppable in sync in update_thread_ctx

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun  6 08:21:13 2024 +0200| [b2195a238c330e960700f8821e9c0751ee77946d] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Don't keep droppable in sync in update_thread_ctx

It is not a stream property, but a property of an individual picture
(in fact, it is only set by the FLV decoder that does not even support
frame threading).

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index b3753b6ad2..e95b5a0940 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -142,7 +142,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
 // B-frame info
 s->max_b_frames = s1->max_b_frames;
 s->low_delay= s1->low_delay;
-s->droppable= s1->droppable;
 
 // DivX handling (doesn't work)
 s->divx_packed  = s1->divx_packed;

___
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_block: Remove unnecessary assignments

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun  8 01:24:35 2024 +0200| [6e1ca92206ad5c149f69693191a61aa98a1b5209] | 
committer: Andreas Rheinhardt

avcodec/vc1_block: Remove unnecessary assignments

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 640f7329ca..384979caf5 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -2675,12 +2675,11 @@ static int vc1_decode_i_blocks_adv(VC1Context *v)
 }
 
 // do frame decode
-s->mb_x = s->mb_y = 0;
 s->mb_intra = 1;
 s->first_slice_line = 1;
+s->mb_x = 0;
 s->mb_y = s->start_mb_y;
 if (s->start_mb_y) {
-s->mb_x = 0;
 init_block_index(v);
 memset(&s->coded_block[s->block_index[0] - s->b8_stride], 0,
(1 + s->b8_stride) * sizeof(*s->coded_block));

___
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/ituh263enc: Inline constants

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun  6 01:36:14 2024 +0200| [d40b46f47c0945b9bc10f10b95294bae02f2c2ae] | 
committer: Andreas Rheinhardt

avcodec/ituh263enc: Inline constants

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/ituh263enc.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index b1fe4e241e..3982b1e675 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -709,9 +709,8 @@ void ff_h263_encode_motion(PutBitContext *pb, int val, int 
f_code)
 int range, bit_size, sign, code, bits;
 
 if (val == 0) {
-/* zero vector */
-code = 0;
-put_bits(pb, ff_mvtab[code][1], ff_mvtab[code][0]);
+/* zero vector -- corresponds to ff_mvtab[0] */
+put_bits(pb, 1, 1);
 } else {
 bit_size = f_code - 1;
 range = 1 << bit_size;
@@ -741,7 +740,7 @@ static av_cold void init_mv_penalty_and_fcode(void)
 for(mv=-MAX_DMV; mv<=MAX_DMV; mv++){
 int len;
 
-if(mv==0) len= ff_mvtab[0][1];
+if (mv==0) len = 1; // ff_mvtab[0][1]
 else{
 int val, bit_size, code;
 
@@ -755,7 +754,7 @@ static av_cold void init_mv_penalty_and_fcode(void)
 if(code<33){
 len= ff_mvtab[code][1] + 1 + bit_size;
 }else{
-len= ff_mvtab[32][1] + av_log2(code>>5) + 2 + bit_size;
+len = 12 /* ff_mvtab[32][1] */ + av_log2(code>>5) + 2 + 
bit_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/h263enc: Remove no-output code

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun  6 03:36:48 2024 +0200| [646ace34cd1562cc699e0b99f9e26c63f318e224] | 
committer: Andreas Rheinhardt

avcodec/h263enc: Remove no-output code

The no-output mode (guarded by AV_CODEC_FLAG2_NO_OUTPUT)
does not provide a noteworthy speedup; in fact, it even
turned out to be slower than the code with the no-output
code removed (ordinary encode: 153259721 decicycles,
noout encode: 153259721; encode with this patch applied:
152451581 decicycles; timings are for encode_frame callbacks
when encoding a 1080p sample to MPEG-4).

(Furthermore, this code was broken for most of its existence
(since 9207dc3b0db368bb9cf5eb295cbc1129c2975e31) and no one
noticed, so the no-output mode is probably not used at all.)

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h263enc.h | 29 ++---
 1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h
index 6e07440b30..784500ca7a 100644
--- a/libavcodec/h263enc.h
+++ b/libavcodec/h263enc.h
@@ -37,36 +37,11 @@ void ff_clean_h263_qscales(MpegEncContext *s);
 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code);
 void ff_h263_update_mb(MpegEncContext *s);
 
-static inline int h263_get_motion_length(int val, int f_code)
-{
-int bit_size, code, sign;
-
-if (val == 0) {
-return 1; /* ff_mvtab[0][1] */
-} else {
-bit_size = f_code - 1;
-/* modulo encoding */
-val  = sign_extend(val, 6 + bit_size);
-sign = val >> 31;
-val  = (val ^ sign) - sign; /* val = FFABS(val) */
-val--;
-code = (val >> bit_size) + 1;
-
-return ff_mvtab[code][1] + 1 + bit_size;
-}
-}
-
 static inline void ff_h263_encode_motion_vector(MpegEncContext * s,
 int x, int y, int f_code)
 {
-if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) {
-skip_put_bits(&s->pb,
-  h263_get_motion_length(x, f_code) +
-  h263_get_motion_length(y, f_code));
-} else {
-ff_h263_encode_motion(&s->pb, x, f_code);
-ff_h263_encode_motion(&s->pb, y, f_code);
-}
+ff_h263_encode_motion(&s->pb, x, f_code);
+ff_h263_encode_motion(&s->pb, y, f_code);
 }
 
 static inline int get_p_cbp(MpegEncContext * s,

___
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/mpeg12enc: Use AVCodecContext, not priv ctx as logctx

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jun  9 23:54:37 2024 +0200| [0c88303c0c4307c53fc2fbd18d3a9e5cb55752a7] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Use AVCodecContext, not priv ctx as logctx

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 140fda4bc2..066a60d02a 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -180,7 +180,6 @@ static int find_frame_rate_index(MPEG12EncContext *mpeg12)
 static av_cold int encode_init(AVCodecContext *avctx)
 {
 MPEG12EncContext *const mpeg12 = avctx->priv_data;
-MpegEncContext *const s = &mpeg12->mpeg;
 int ret;
 int max_size = avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 16383 : 4095;
 
@@ -259,7 +258,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
 if (mpeg12->tc_opt_str) {
 AVRational rate = ff_mpeg12_frame_rate_tab[mpeg12->frame_rate_index];
-int ret = av_timecode_init_from_string(&mpeg12->tc, rate, 
mpeg12->tc_opt_str, s);
+int ret = av_timecode_init_from_string(&mpeg12->tc, rate, 
mpeg12->tc_opt_str, avctx);
 if (ret < 0)
 return ret;
 mpeg12->drop_frame_timecode  = !!(mpeg12->tc.flags & 
AV_TIMECODE_FLAG_DROPFRAME);

___
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: Remove always-false check

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun  8 02:01:38 2024 +0200| [1d270e99f96511ae5667e101663e6cba6d890cdd] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Remove always-false check

All valid values of dc_lum and dc_chrom are in the range 0..9,
because they are initialized via tables with 10 elements.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 18329132aa..130cde7a9d 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -895,7 +895,7 @@ static inline int mpeg4_decode_dc(MpegEncContext *s, int n, 
int *dir_ptr)
 else
 code = get_vlc2(&s->gb, dc_chrom, DC_VLC_BITS, 1);
 
-if (code < 0 || code > 9 /* && s->nbit < 9 */) {
+if (code < 0) {
 av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
 return AVERROR_INVALIDDATA;
 }

___
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: Don't initialize unused stuff

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Jun  7 22:43:10 2024 +0200| [7bccf63de5d89f21561456613cf58f44ef87edbd] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Don't initialize unused stuff

Only the intra scantable is used for studio profile.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg4videodec.c | 17 ++---
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index f1b542cebf..18329132aa 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3430,21 +3430,8 @@ static int decode_studio_vop_header(Mpeg4DecContext 
*ctx, GetBitContext *gb)
 s->q_scale_type = get_bits1(gb);
 }
 
-if (s->alternate_scan) {
-ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   
ff_alternate_vertical_scan);
-ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   
ff_alternate_vertical_scan);
-ff_permute_scantable(s->permutated_intra_h_scantable, 
ff_alternate_vertical_scan,
- s->idsp.idct_permutation);
-ff_permute_scantable(s->permutated_intra_v_scantable, 
ff_alternate_vertical_scan,
- s->idsp.idct_permutation);
-} else {
-ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   
ff_zigzag_direct);
-ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   
ff_zigzag_direct);
-ff_permute_scantable(s->permutated_intra_h_scantable, 
ff_alternate_horizontal_scan,
- s->idsp.idct_permutation);
-ff_permute_scantable(s->permutated_intra_v_scantable, 
ff_alternate_vertical_scan,
- s->idsp.idct_permutation);
-}
+ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,
+  s->alternate_scan ? ff_alternate_vertical_scan : 
ff_zigzag_direct);
 
 mpeg4_load_default_matrices(s);
 

___
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/msmpeg4enc: Combine writing bits

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun 10 00:11:05 2024 +0200| [89a0cec7903da5dceb2bd027d16a82773146e35a] | 
committer: Andreas Rheinhardt

avcodec/msmpeg4enc: Combine writing bits

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index 642a0ff100..3103a73663 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -71,8 +71,7 @@ void ff_msmpeg4_code012(PutBitContext *pb, int n)
 if (n == 0) {
 put_bits(pb, 1, 0);
 } else {
-put_bits(pb, 1, 1);
-put_bits(pb, 1, (n >= 2));
+put_bits(pb, 2, 2 | (n >= 2));
 }
 }
 

___
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_block: Simplify resetting coded_block

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun  8 01:28:16 2024 +0200| [963bdac226b611664bdd033a8b3a914e5e148ebd] | 
committer: Andreas Rheinhardt

avcodec/vc1_block: Simplify resetting coded_block

Everything that init_block_index() sets will be overwritten
a few lines below again, so don't call it and simply calculate
the only thing that is used (namely block_index[0]) manually.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 384979caf5..1d622b1a67 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -2680,8 +2680,7 @@ static int vc1_decode_i_blocks_adv(VC1Context *v)
 s->mb_x = 0;
 s->mb_y = s->start_mb_y;
 if (s->start_mb_y) {
-init_block_index(v);
-memset(&s->coded_block[s->block_index[0] - s->b8_stride], 0,
+memset(&s->coded_block[(2 * s->mb_y - 1) * s->b8_stride - 2], 0,
(1 + s->b8_stride) * sizeof(*s->coded_block));
 }
 for (; s->mb_y < s->end_mb_y; s->mb_y++) {

___
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: Inline constants

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Jun  7 21:53:33 2024 +0200| [d197a8d6b63aced7e544b1341336c57d612460d1] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Inline constants

Partitioned macroblocks are always 8bit and not studio profile.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 116dc1507e..f1b542cebf 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -949,8 +949,7 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
 int dir = 0;
 
 mb_num++;
-ff_update_block_index(s, s->avctx->bits_per_raw_sample,
-  s->avctx->lowres, s->chroma_x_shift);
+ff_update_block_index(s, 8, s->avctx->lowres, 1);
 if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1)
 s->first_slice_line = 0;
 
@@ -1141,8 +1140,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, 
int mb_count)
 const int xy = s->mb_x + s->mb_y * s->mb_stride;
 
 mb_num++;
-ff_update_block_index(s, s->avctx->bits_per_raw_sample,
-  s->avctx->lowres, s->chroma_x_shift);
+ff_update_block_index(s, 8, s->avctx->lowres, 1);
 if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1)
 s->first_slice_line = 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/mpeg12enc: Pass AVCodecContext* directly

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun 10 00:02:20 2024 +0200| [a1a8a03373d7a4f13b38c79870aa12f2e3118449] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Pass AVCodecContext* directly

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg12enc.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 066a60d02a..e35c916b61 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -137,16 +137,15 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const int8_t 
max_level[],
 }
 
 #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
-static int find_frame_rate_index(MPEG12EncContext *mpeg12)
+static int find_frame_rate_index(AVCodecContext *avctx, MPEG12EncContext 
*mpeg12)
 {
-MpegEncContext *const s = &mpeg12->mpeg;
 int i;
 AVRational bestq = (AVRational) {0, 0};
 AVRational ext;
-AVRational target = av_inv_q(s->avctx->time_base);
+AVRational target = av_inv_q(avctx->time_base);
 
 for (i = 1; i < 14; i++) {
-if (s->avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&
+if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&
 i >= 9)
 break;
 
@@ -154,7 +153,7 @@ static int find_frame_rate_index(MPEG12EncContext *mpeg12)
 for (ext.den=1; ext.den <= 32; ext.den++) {
 AVRational q = av_mul_q(ext, ff_mpeg12_frame_rate_tab[i]);
 
-if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO && (ext.den!=1 || 
ext.num!=1))
+if (avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO && (ext.den!=1 
|| ext.num!=1))
 continue;
 if (av_gcd(ext.den, ext.num) != 1)
 continue;
@@ -236,7 +235,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 if ((ret = ff_mpv_encode_init(avctx)) < 0)
 return ret;
 
-if (find_frame_rate_index(mpeg12) < 0) {
+if (find_frame_rate_index(avctx, mpeg12) < 0) {
 if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
 av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d 
fps\n",
avctx->time_base.den, avctx->time_base.num);

___
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: Simplify decoding GOB header

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun 10 07:19:01 2024 +0200| [c1097556c734a418354fa23c403e0237a5e93bb5] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Simplify decoding GOB header

h261_resync() can be completely removed, because
h261_decode_gob_header() checks for a GOB header itself if
gob_start_code_skipped is zero.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 2038afc591..f1c1e1a48a 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -165,31 +165,6 @@ static int h261_decode_gob_header(H261DecContext *h)
 return 0;
 }
 
-/**
- * Decode the group of blocks / video packet header.
- * @return <0 if no resync found
- */
-static int h261_resync(H261DecContext *h)
-{
-MpegEncContext *const s = &h->s;
-int ret;
-
-if (h->gob_start_code_skipped) {
-ret = h261_decode_gob_header(h);
-if (ret >= 0)
-return 0;
-} else {
-if (show_bits(&s->gb, 15) == 0) {
-ret = h261_decode_gob_header(h);
-if (ret >= 0)
-return 0;
-}
-// OK, it is not where it is supposed to be ...
-}
-
-return -1;
-}
-
 /**
  * Decode skipped macroblocks.
  * @return 0
@@ -626,7 +601,7 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 s->mb_y = 0;
 
 while (h->gob_number < (s->mb_height == 18 ? 12 : 5)) {
-if (h261_resync(h) < 0)
+if (h261_decode_gob_header(h) < 0)
 break;
 h261_decode_gob(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] avcodec/h261dec: Fix UB NULL + 0, remove broken resync code

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun 10 07:16:28 2024 +0200| [18b059f208f779f10ca1f5699e8054a647610632] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Fix UB NULL + 0, remove broken resync code

last_resync_gb is never initialized, causing NULL + 0
in align_get_bits(). In addition to that, the loop is never
entered.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 8671800c3e..2038afc591 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -172,7 +172,7 @@ static int h261_decode_gob_header(H261DecContext *h)
 static int h261_resync(H261DecContext *h)
 {
 MpegEncContext *const s = &h->s;
-int left, ret;
+int ret;
 
 if (h->gob_start_code_skipped) {
 ret = h261_decode_gob_header(h);
@@ -185,22 +185,6 @@ static int h261_resync(H261DecContext *h)
 return 0;
 }
 // OK, it is not where it is supposed to be ...
-s->gb = s->last_resync_gb;
-align_get_bits(&s->gb);
-left = get_bits_left(&s->gb);
-
-for (; left > 15 + 1 + 4 + 5; left -= 8) {
-if (show_bits(&s->gb, 15) == 0) {
-GetBitContext bak = s->gb;
-
-ret = h261_decode_gob_header(h);
-if (ret >= 0)
-return 0;
-
-s->gb = bak;
-}
-skip_bits(&s->gb, 8);
-}
 }
 
 return -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: Join loops when initializing ScanTable

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 20:38:42 2024 +0200| [f694db87cad98720957eef22ac5c02b825cc13cc] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Join loops when initializing ScanTable

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegvideo.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 6df669b744..b9a0469335 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -296,20 +296,13 @@ static av_cold void dsp_init(MpegEncContext *s)
 av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
const uint8_t *src_scantable)
 {
-int end;
-
 st->scantable = src_scantable;
 
-for (int i = 0; i < 64; i++) {
+for (int i = 0, end = -1; i < 64; i++) {
 int j = src_scantable[i];
 st->permutated[i] = permutation[j];
-}
-
-end = -1;
-for (int i = 0; i < 64; i++) {
-int j = st->permutated[i];
-if (j > end)
-end = j;
+if (permutation[j] > end)
+end = permutation[j];
 st->raster_end[i] = end;
 }
 }

___
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/mpv_reconstruct_mb_template: Optimize always-true branch away

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 13:36:40 2024 +0200| [2e5287e519dc0f99ade473096c9b6742f0d8114b] | 
committer: Andreas Rheinhardt

avcodec/mpv_reconstruct_mb_template: Optimize always-true branch away

There are only two mpegvideo decoders that use another
(software) pixel format than YUV420: MPEG-1/2 and
the MPEG-4 studio profile. Neither of these use this part
of the code, so one can optimize the 422 code away when
this code is compiled for the decoder.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpv_reconstruct_mb_template.c 
b/libavcodec/mpv_reconstruct_mb_template.c
index e39b3d0e73..257767e80b 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -172,7 +172,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t 
block[12][64],
 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 
block_size, dct_linesize, s->qscale);
 
 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-if (s->chroma_y_shift) {
+av_assert2(IS_ENCODER || s->chroma_y_shift);
+if (!IS_ENCODER || s->chroma_y_shift) {
 add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, 
s->chroma_qscale);
 add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, 
s->chroma_qscale);
 } 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] avcodec/mpegvideo_dec: Remove unnecessary FFMIN

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 14:05:20 2024 +0200| [66709df4036b51c29d451de9621e76dfb898caf0] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Remove unnecessary FFMIN

No mpegvideo-based decoder supports lowres > 3,
so the FFMIN here are unnecessary.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegvideo_dec.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 4e279d9fa8..684f31947c 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -483,11 +483,13 @@ static inline int hpel_motion_lowres(MpegEncContext *s,
  int motion_x, int motion_y)
 {
 const int lowres   = s->avctx->lowres;
-const int op_index = FFMIN(lowres, 3);
+const int op_index = lowres;
 const int s_mask   = (2 << lowres) - 1;
 int emu = 0;
 int sx, sy;
 
+av_assert2(op_index <= 3);
+
 if (s->quarter_sample) {
 motion_x /= 2;
 motion_y /= 2;
@@ -536,12 +538,15 @@ static av_always_inline void 
mpeg_motion_lowres(MpegEncContext *s,
 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
 ptrdiff_t uvlinesize, linesize;
 const int lowres = s->avctx->lowres;
-const int op_index   = FFMIN(lowres - 1 + s->chroma_x_shift, 3);
+const int op_index   = lowres - 1 + s->chroma_x_shift;
 const int block_s= 8 >> lowres;
 const int s_mask = (2 << lowres) - 1;
 const int h_edge_pos = s->h_edge_pos >> lowres;
 const int v_edge_pos = s->v_edge_pos >> lowres;
 int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h;
+
+av_assert2(op_index <= 3);
+
 linesize   = s->cur_pic.linesize[0] << field_based;
 uvlinesize = s->cur_pic.linesize[1] << field_based;
 
@@ -666,7 +671,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext 
*s,
 int mx, int my)
 {
 const int lowres = s->avctx->lowres;
-const int op_index   = FFMIN(lowres, 3);
+const int op_index   = lowres;
 const int block_s= 8 >> lowres;
 const int s_mask = (2 << lowres) - 1;
 const int h_edge_pos = s->h_edge_pos >> lowres + 1;
@@ -675,6 +680,8 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext 
*s,
 ptrdiff_t offset;
 const uint8_t *ptr;
 
+av_assert2(op_index <= 3);
+
 if (s->quarter_sample) {
 mx /= 2;
 my /= 2;

___
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/mpv_reconstruct_mb_template: Optimize WMV2 code away if possible

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 22:28:36 2024 +0200| [0f92fecebb783d8d9e86473a12a0f724a0f78f34] | 
committer: Andreas Rheinhardt

avcodec/mpv_reconstruct_mb_template: Optimize WMV2 code away if possible

The WMV2 decoder does not support lowres, so one can optimize
the WMV2 specific code away in the lowres version of this function.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpv_reconstruct_mb_template.c 
b/libavcodec/mpv_reconstruct_mb_template.c
index 257767e80b..4b16974827 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -187,7 +187,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t 
block[12][64],
 }
 }
 #if !IS_ENCODER
-  else if (is_mpeg12 == DEFINITELY_MPEG12 || (s->codec_id != 
AV_CODEC_ID_WMV2)) {
+  else if (is_mpeg12 == DEFINITELY_MPEG12 || lowres_flag || 
(s->codec_id != AV_CODEC_ID_WMV2)) {
 add_dct(s, block[0], 0, dest_y  , 
dct_linesize);
 add_dct(s, block[1], 1, dest_y  + block_size, 
dct_linesize);
 add_dct(s, block[2], 2, dest_y + dct_offset , 
dct_linesize);

___
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: Don't reset gob_start_code_skipped in h261_decode_init()

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jun 10 06:23:12 2024 +0200| [fb1acbc94192aa2ba6cc2479bd9b5a8d678cfc31] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Don't reset gob_start_code_skipped in h261_decode_init()

It always gets reset at the start of h261_decode_frame().

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index be285ce5e9..8671800c3e 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -97,8 +97,6 @@ static av_cold int h261_decode_init(AVCodecContext *avctx)
 s->low_delay   = 1;
 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
-h->gob_start_code_skipped = 0;
-
 ff_thread_once(&init_static_once, h261_decode_init_static);
 
 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/mpeg_er: Don't set block_index unnecessarily

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jun 12 08:37:53 2024 +0200| [65d5ccb808ec93de46a2458ea8cc082ce4460f34] | 
committer: Andreas Rheinhardt

avcodec/mpeg_er: Don't set block_index unnecessarily

ff_init_block_index() sets MpegEncContext.dest and
MpegEncContext.block_index. The latter is unused by
ff_mpv_reconstruct_mb() (which is what this code is
preparatory for) and dest is overwritten a few lines below.
So don't initialize block_index at all.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index e7b3197bb1..fe7dcd7efb 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -76,10 +76,6 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int 
mv_dir, int mv_type,
 s->mcsel  = 0;
 memcpy(s->mv, mv, sizeof(*mv));
 
-ff_init_block_index(s);
-ff_update_block_index(s, s->avctx->bits_per_raw_sample,
-  s->avctx->lowres, s->chroma_x_shift);
-
 s->bdsp.clear_blocks(s->block[0]);
 if (!s->chroma_y_shift)
 s->bdsp.clear_blocks(s->block[6]);

___
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: Don't initialize unused inter_scantable

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jun 11 22:45:40 2024 +0200| [c41818dc5dc14eb944761204e7b0ac179a6dcd1a] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Don't initialize unused inter_scantable

inter_scantable is only used by the dct_unquantize_h263_inter
functions, yet this is not used by the MPEG-4 decoder at all
(in case H.263 quantization is used, the unquantization already
happens in mpeg4_decode_block()).

Also move the common initialization of ff_permute_scantable()
out of the if.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg4videodec.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 130cde7a9d..77bd3e9947 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3251,22 +3251,17 @@ static int decode_vop_header(Mpeg4DecContext *ctx, 
GetBitContext *gb,
 } else
 s->alternate_scan = 0;
 }
-
 if (s->alternate_scan) {
-ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   
ff_alternate_vertical_scan);
 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   
ff_alternate_vertical_scan);
 ff_permute_scantable(s->permutated_intra_h_scantable, 
ff_alternate_vertical_scan,
  s->idsp.idct_permutation);
-ff_permute_scantable(s->permutated_intra_v_scantable, 
ff_alternate_vertical_scan,
- s->idsp.idct_permutation);
 } else {
-ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   
ff_zigzag_direct);
 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   
ff_zigzag_direct);
 ff_permute_scantable(s->permutated_intra_h_scantable, 
ff_alternate_horizontal_scan,
  s->idsp.idct_permutation);
-ff_permute_scantable(s->permutated_intra_v_scantable, 
ff_alternate_vertical_scan,
- s->idsp.idct_permutation);
 }
+ff_permute_scantable(s->permutated_intra_v_scantable, 
ff_alternate_vertical_scan,
+ s->idsp.idct_permutation);
 
 /* Skip at this point when only parsing since the remaining
  * data is not useful for a parser and requires the

___
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: Simplify decoding motion vectors

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun 13 15:45:19 2024 +0200| [9933dfe103166c43569a3b5bd4649b2e7fcefa0a] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Simplify decoding motion vectors

Don't use a LUT to negate followed by a conditional ordinary
negation immediately thereafter. Instead fold the two.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 6df8588bb6..852de8d535 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -208,10 +208,6 @@ static int h261_decode_mb_skipped(H261DecContext *h, int 
mba1, int mba2)
 return 0;
 }
 
-static const int mvmap[17] = {
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16
-};
-
 static int decode_mv_component(GetBitContext *gb, int v)
 {
 int mv_diff = get_vlc2(gb, h261_mv_vlc, H261_MV_VLC_BITS, 2);
@@ -220,9 +216,7 @@ static int decode_mv_component(GetBitContext *gb, int v)
 if (mv_diff < 0)
 return v;
 
-mv_diff = mvmap[mv_diff];
-
-if (mv_diff && !get_bits1(gb))
+if (mv_diff && get_bits1(gb))
 mv_diff = -mv_diff;
 
 v += mv_diff;

___
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/rv10: Remove write-only assignments

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun 13 15:51:56 2024 +0200| [fee9520716da1e1eb5ddfc0c041932bf8e1ba696] | 
committer: Andreas Rheinhardt

avcodec/rv10: Remove write-only assignments

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/rv10.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 3dcee0a065..c6baaa0269 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -498,12 +498,6 @@ static int rv10_decode_packet(AVCodecContext *avctx, const 
uint8_t *buf,
 s->rv10_first_dc_coded[0] = 0;
 s->rv10_first_dc_coded[1] = 0;
 s->rv10_first_dc_coded[2] = 0;
-s->block_wrap[0] =
-s->block_wrap[1] =
-s->block_wrap[2] =
-s->block_wrap[3] = s->b8_stride;
-s->block_wrap[4] =
-s->block_wrap[5] = s->mb_stride;
 ff_init_block_index(s);
 
 /* decode each macroblock */

___
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: Unquantize coefficients while parsing them

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun 13 15:05:52 2024 +0200| [f793074784ae79dabc4f83b61710161b3fe3288c] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Unquantize coefficients while parsing them

This is beneficial for performance: When concatenating
the file from the vsynth1-h261 fate-test 100 times,
performance (measured by timing the codec's decode callback)
improved by 9.6%.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h261dec.c | 11 +--
 libavcodec/mpegvideo_dec.c   | 11 ++-
 libavcodec/mpegvideo_enc.c   |  2 +-
 libavcodec/mpv_reconstruct_mb_template.c | 24 
 4 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index f1c1e1a48a..6df8588bb6 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -244,6 +244,7 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
 int level, i, j, run;
 const RLTable *rl = &ff_h261_rl_tcoeff;
 const uint8_t *scan_table;
+const int qmul = s->qscale << 1, qadd = (s->qscale - 1) | 1;
 
 /* For the variable length encoding there are two code tables, one being
  * used for the first transmitted LEVEL in INTER, INTER + MC and
@@ -265,7 +266,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;
+block[0] = level * s->y_dc_scale;
 i= 1;
 } else if (coded) {
 // Run  Level   Code
@@ -276,7 +277,8 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
 i = 0;
 if (check & 0x2) {
 skip_bits(&s->gb, 2);
-block[0] = (check & 0x1) ? -1 : 1;
+block[0] = qmul + qadd;
+block[0] *= (check & 0x1) ? -1 : 1;
 i= 1;
 }
 } else {
@@ -306,10 +308,15 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
 run   = SHOW_UBITS(re, &s->gb, 6) + 1;
 SKIP_CACHE(re, &s->gb, 6);
 level = SHOW_SBITS(re, &s->gb, 8);
+if (level > 0)
+level = level * qmul + qadd;
+else if (level < 0)
+level = level * qmul - qadd;
 SKIP_COUNTER(re, &s->gb, 6 + 8);
 } else if (level == 0) {
 break;
 } else {
+level = level * qmul + qadd;
 if (SHOW_UBITS(re, &s->gb, 1))
 level = -level;
 SKIP_COUNTER(re, &s->gb, 1);
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 684f31947c..da88a35120 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -927,15 +927,16 @@ void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t 
block[12][64])
}
 }
 
+av_assert2((s->out_format <= FMT_H261) == (s->out_format == FMT_H261 || 
s->out_format == FMT_MPEG1));
 if (!s->avctx->lowres) {
 #if !CONFIG_SMALL
-if (s->out_format == FMT_MPEG1)
-mpv_reconstruct_mb_internal(s, block, 0, DEFINITELY_MPEG12);
+if (s->out_format <= FMT_H261)
+mpv_reconstruct_mb_internal(s, block, 0, DEFINITELY_MPEG12_H261);
 else
-mpv_reconstruct_mb_internal(s, block, 0, NOT_MPEG12);
+mpv_reconstruct_mb_internal(s, block, 0, NOT_MPEG12_H261);
 #else
-mpv_reconstruct_mb_internal(s, block, 0, MAY_BE_MPEG12);
+mpv_reconstruct_mb_internal(s, block, 0, MAY_BE_MPEG12_H261);
 #endif
 } else
-mpv_reconstruct_mb_internal(s, block, 1, MAY_BE_MPEG12);
+mpv_reconstruct_mb_internal(s, block, 1, MAY_BE_MPEG12_H261);
 }
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 125d16e694..d05a93d249 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1101,7 +1101,7 @@ static void mpv_reconstruct_mb(MpegEncContext *s, int16_t 
block[12][64])
}
 }
 
-mpv_reconstruct_mb_internal(s, block, 0, MAY_BE_MPEG12);
+mpv_reconstruct_mb_internal(s, block, 0, MAY_BE_MPEG12_H261);
 }
 
 static int get_sae(const uint8_t *src, int ref, int stride)
diff --git a/libavcodec/mpv_reconstruct_mb_template.c 
b/libavcodec/mpv_reconstruct_mb_template.c
index 4b16974827..dca982ae0f 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -20,9 +20,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define NOT_MPEG120
-#define MAY_BE_MPEG12 1
-#define DEFINITELY_MPEG12 2
+#define NOT_MPEG12_H2610
+#define MAY_BE_MPEG12_H261 1
+#define DEFINITELY_MPEG12_H261 2
 
 /* put block[] to dest[] */
 static inline void put_dct(MpegEncCo

[FFmpeg-cvslog] avcodec/h261enc, msmpeg4: Avoid setting dc_scale_tables unnecessarily

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun 13 08:46:56 2024 +0200| [1745d12d6741dc1c43442c58bd2f5d78aac6fd28] | 
committer: Andreas Rheinhardt

avcodec/h261enc, msmpeg4: Avoid setting dc_scale_tables unnecessarily

It is unnecessary because ff_mpeg1_dc_scale_table is the default
for both dc_scale_tables.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h261enc.c | 3 ---
 libavcodec/msmpeg4.c | 4 +---
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 01bce533a0..dd4419ec8c 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -34,7 +34,6 @@
 #include "mpegvideo.h"
 #include "h261.h"
 #include "h261enc.h"
-#include "mpegvideodata.h"
 #include "mpegvideoenc.h"
 
 static uint8_t uni_h261_rl_len [64*64*2*2];
@@ -388,8 +387,6 @@ av_cold int ff_h261_encode_init(MpegEncContext *s)
 
 s->min_qcoeff   = -127;
 s->max_qcoeff   = 127;
-s->y_dc_scale_table =
-s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
 s->ac_esc_length= 6+6+8;
 
 s->intra_ac_vlc_length  = s->inter_ac_vlc_length  = 
uni_h261_rl_len;
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 50fd581a83..872dc8db67 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -41,7 +41,6 @@
 #include "mpeg4videodata.h"
 #include "msmpeg4data.h"
 #include "msmpeg4_vc1_data.h"
-#include "mpegvideodata.h"
 
 /*
  * You can also call this codec: MPEG-4 with a twist!
@@ -122,8 +121,7 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
 switch(s->msmpeg4_version){
 case MSMP4_V1:
 case MSMP4_V2:
-s->y_dc_scale_table=
-s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
+// Correct *_dc_scale_tables (ff_mpeg1_dc_scale_table) is the default
 break;
 case MSMP4_V3:
 if(s->workaround_bugs){

___
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: Don't set framerate multiple times

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun 13 15:48:26 2024 +0200| [eb0beffcb33c034d2e611957ea69b8be5d456004] | 
committer: Andreas Rheinhardt

avcodec/h261dec: Don't set framerate multiple times

Just do it once during init.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 852de8d535..cabca33c8d 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -87,6 +87,8 @@ static av_cold int h261_decode_init(AVCodecContext *avctx)
 MpegEncContext *const s = &h->s;
 int ret;
 
+avctx->framerate = (AVRational) { 3, 1001 };
+
 s->private_ctx = &h->common;
 // set defaults
 ret = ff_mpv_decode_init(s, avctx);
@@ -473,8 +475,6 @@ static int h261_decode_picture_header(H261DecContext *h)
 /* temporal reference */
 skip_bits(&s->gb, 5); /* picture timestamp */
 
-s->avctx->framerate = (AVRational) { 3, 1001 };
-
 /* PTYPE starts here */
 skip_bits1(&s->gb); /* split screen off */
 skip_bits1(&s->gb); /* camera  off */

___
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/mpeg_er: Simplify disabling IDCT

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jun 13 20:18:16 2024 +0200| [7b539ca3e6bae701d88096ff8dc3db7f13b7318a] | 
committer: Andreas Rheinhardt

avcodec/mpeg_er: Simplify disabling IDCT

The error resilience code does not make up block coefficients
and therefore zeroes them in order to disable the IDCT.
But this can be done in a simpler manner, namely by setting
block_last_index to a negative value. Doing so also has
the advantage that the dct_unquantize functions are never even
called for those codecs that do not use ff_mpv_reconstruct_mb()
for ordinary decoding (namely RV-30/40 and the VC-1 family).

This approach would not work for intra macroblocks (there is always
at least one coefficient for them and therefore there is no check
for block_last_index for them), but this does not happen at all.
Add an assert for this.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg_er.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index fe7dcd7efb..3cbdeeebec 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -16,6 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/mem.h"
 #include "error_resilience.h"
 #include "mpegvideo.h"
@@ -67,6 +68,8 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int 
mv_dir, int mv_type,
 {
 MpegEncContext *s = opaque;
 
+av_assert1(!mb_intra);
+
 s->mv_dir = mv_dir;
 s->mv_type= mv_type;
 s->mb_intra   = mb_intra;
@@ -76,9 +79,9 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int 
mv_dir, int mv_type,
 s->mcsel  = 0;
 memcpy(s->mv, mv, sizeof(*mv));
 
-s->bdsp.clear_blocks(s->block[0]);
-if (!s->chroma_y_shift)
-s->bdsp.clear_blocks(s->block[6]);
+// The following disables the IDCT.
+for (size_t i = 0; i < FF_ARRAY_ELEMS(s->block_last_index); i++)
+s->block_last_index[i] = -1;
 
 s->dest[0] = s->cur_pic.data[0] +
  s->mb_y * 16 * s->linesize +

___
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/rv10: Use ff_h263_decode_init()

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Jun 14 17:38:26 2024 +0200| [c735552b0b7fc5ab744fd8f652d27e490c6bccd9] | 
committer: Andreas Rheinhardt

avcodec/rv10: Use ff_h263_decode_init()

The RV10 and RV20 decoders use ff_h263_decode_mb() and also the
H.263 DSP and VLCs. Despite not calling ff_h263_decode_frame(),
it is nevertheless beneficial to call ff_h263_decode_init()
to reduce code duplication.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h263dec.c |  2 ++
 libavcodec/rv10.c| 19 +++
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 75fcf1..19a57582ad 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -135,6 +135,8 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 s->msmpeg4_version = MSMP4_WMV2;
 break;
 case AV_CODEC_ID_H263I:
+case AV_CODEC_ID_RV10:
+case AV_CODEC_ID_RV20:
 break;
 case AV_CODEC_ID_FLV1:
 s->h263_flv = 1;
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index c6baaa0269..65060d4ece 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -346,7 +346,6 @@ static av_cold void rv10_init_static(void)
 rv_dc_chrom.table[(0x1FE << (DC_VLC_BITS - 9)) + i].sym = 255;
 rv_dc_chrom.table[(0x1FE << (DC_VLC_BITS - 9)) + i].len = 18;
 }
-ff_h263_decode_init_vlc();
 }
 
 static av_cold int rv10_decode_init(AVCodecContext *avctx)
@@ -364,16 +363,12 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
avctx->coded_height, 0, avctx)) < 0)
 return ret;
 
-ret = ff_mpv_decode_init(s, avctx);
+ret = ff_h263_decode_init(avctx);
 if (ret < 0)
 return ret;
 
-s->out_format  = FMT_H263;
-
-rv->orig_width  =
-s->width= avctx->coded_width;
-rv->orig_height =
-s->height   = avctx->coded_height;
+rv->orig_width  = avctx->coded_width;
+rv->orig_height = avctx->coded_height;
 
 s->h263_long_vectors = ((uint8_t *) avctx->extradata)[3] & 1;
 rv->sub_id   = AV_RB32((uint8_t *) avctx->extradata + 4);
@@ -382,7 +377,6 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
 minor_ver = RV_GET_MINOR_VER(rv->sub_id);
 micro_ver = RV_GET_MICRO_VER(rv->sub_id);
 
-s->low_delay = 1;
 switch (major_ver) {
 case 1:
 s->rv10_version = micro_ver ? 3 : 1;
@@ -405,13 +399,6 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
((uint32_t *) avctx->extradata)[0]);
 }
 
-avctx->pix_fmt = AV_PIX_FMT_YUV420P;
-
-if ((ret = ff_mpv_common_init(s)) < 0)
-return ret;
-
-ff_h263dsp_init(&s->h263dsp);
-
 /* init static VLCs */
 ff_thread_once(&init_static_once, rv10_init_static);
 

___
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: Move quant_precision to Mpeg4DecContext

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Jun 14 18:03:06 2024 +0200| [594723ec3825c912a19d2fc6e1c6b01d0242452e] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move quant_precision to Mpeg4DecContext

It is an MPEG-4-only value; it is always five for the MPEG-4
encoder, so just hardcode this value and move the MpegEncContext
field to Mpeg4DecContext.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h263dec.c   |  1 -
 libavcodec/mpeg4video_parser.c |  2 +-
 libavcodec/mpeg4videodec.c | 20 ++--
 libavcodec/mpeg4videodec.h |  2 ++
 libavcodec/mpeg4videoenc.c |  2 +-
 libavcodec/mpegvideo.h |  1 -
 libavcodec/mpegvideo_enc.c |  2 --
 libavcodec/vaapi_mpeg4.c   |  2 +-
 8 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 19a57582ad..a81786479d 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -99,7 +99,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
-s->quant_precision = 5;
 s->decode_mb   = ff_h263_decode_mb;
 s->low_delay   = 1;
 
diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c
index 402594e01d..b00b523bde 100644
--- a/libavcodec/mpeg4video_parser.c
+++ b/libavcodec/mpeg4video_parser.c
@@ -122,7 +122,7 @@ static av_cold int 
mpeg4video_parse_init(AVCodecParserContext *s)
 struct Mp4vParseContext *pc = s->priv_data;
 
 pc->first_picture   = 1;
-pc->dec_ctx.m.quant_precision = 5;
+pc->dec_ctx.quant_precision   = 5;
 pc->dec_ctx.m.slice_context_count = 1;
 pc->dec_ctx.showed_packed_warning = 1;
 return 0;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 77bd3e9947..debcafc4c0 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -728,7 +728,7 @@ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext 
*ctx)
 s->mb_y = mb_num / s->mb_width;
 
 if (ctx->shape != BIN_ONLY_SHAPE) {
-int qscale = get_bits(&s->gb, s->quant_precision);
+int qscale = get_bits(&s->gb, ctx->quant_precision);
 if (qscale)
 s->chroma_qscale = s->qscale = qscale;
 }
@@ -2706,17 +2706,16 @@ static int decode_vol_header(Mpeg4DecContext *ctx, 
GetBitContext *gb)
 // FIXME sadct disable bit if verid!=1 && shape not rect
 
 if (get_bits1(gb) == 1) {   /* not_8_bit */
-s->quant_precision = get_bits(gb, 4);   /* quant_precision */
+ctx->quant_precision = get_bits(gb, 4); /* quant_precision */
 if (get_bits(gb, 4) != 8)   /* bits_per_pixel */
 av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n");
-if (s->quant_precision != 5)
+if (ctx->quant_precision != 5)
 av_log(s->avctx, AV_LOG_ERROR,
-   "quant precision %d\n", s->quant_precision);
-if (s->quant_precision<3 || s->quant_precision>9) {
-s->quant_precision = 5;
-}
+   "quant precision %d\n", ctx->quant_precision);
+if (ctx->quant_precision < 3 || ctx->quant_precision > 9)
+ctx->quant_precision = 5;
 } else {
-s->quant_precision = 5;
+ctx->quant_precision = 5;
 }
 
 // FIXME a bunch of grayscale shape things
@@ -2904,7 +2903,7 @@ no_cplx_est:
 av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, 
ps:%d, low_delay:%d  %s%s%s%s\n",
s->avctx->framerate.den, s->avctx->framerate.num,
ctx->time_increment_bits,
-   s->quant_precision,
+   ctx->quant_precision,
s->progressive_sequence,
s->low_delay,
ctx->scalability ? "scalability " :"" , s->quarter_sample ? 
"qpel " : "",
@@ -3286,7 +3285,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, 
GetBitContext *gb,
 }
 
 if (ctx->shape != BIN_ONLY_SHAPE) {
-s->chroma_qscale = s->qscale = get_bits(gb, s->quant_precision);
+s->chroma_qscale = s->qscale = get_bits(gb, ctx->quant_precision);
 if (s->qscale == 0) {
 av_log(s->avctx, AV_LOG_ERROR,
"Error, header damaged or not MPEG-4 header (qscale=0)\n");
@@ -3798,6 +3797,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 s->low_delay = 0; /* default, might be overridden in the vol header during 
header parsing */
 s->decode_mb = mpeg4_decode_mb;
 ctx->time_increment_bits = 4; /* default value for broken headers */
+ctx->quant_precision = 5;
 
 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
 
diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h
index 4a26d18987..734237b16f 100644
--- a/libavcodec/m

[FFmpeg-cvslog] avcodec/motion_est: Optimize dead code away

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun 15 08:45:12 2024 +0200| [b28bf830cd1aaf78502c81502446cf43bacb11ae] | 
committer: Andreas Rheinhardt

avcodec/motion_est: Optimize dead code away

H.261 does not have B-frames.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/motion_est.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index e783e79a94..554fc9780e 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -537,7 +537,7 @@ static inline void set_p_mv_tables(MpegEncContext * s, int 
mx, int my, int mv4)
 /**
  * get fullpel ME search limits.
  */
-static inline void get_limits(MpegEncContext *s, int x, int y)
+static inline void get_limits(MpegEncContext *s, int x, int y, int bframe)
 {
 MotionEstContext * const c= &s->me;
 int range= c->avctx->me_range >> (1 + !!(c->flags&FLAG_QPEL));
@@ -551,7 +551,7 @@ static inline void get_limits(MpegEncContext *s, int x, int 
y)
 c->ymin = - y - 16;
 c->xmax = - x + s->width;
 c->ymax = - y + s->height;
-} else if (s->out_format == FMT_H261){
+} else if (!(av_builtin_constant_p(bframe) && bframe) && s->out_format == 
FMT_H261){
 // Search range of H.261 is different from other codec standards
 c->xmin = (x > 15) ? - 15 : 0;
 c->ymin = (y > 15) ? - 15 : 0;
@@ -921,7 +921,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
 c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, 
c->avctx->mb_cmp);
 c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_DMV;
 
-get_limits(s, 16*mb_x, 16*mb_y);
+get_limits(s, 16*mb_x, 16*mb_y, 0);
 c->skip=0;
 
 /* intra / predictive decision */
@@ -1088,7 +1088,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
 c->pre_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, 
c->avctx->me_pre_cmp);
 c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_DMV;
 
-get_limits(s, 16*mb_x, 16*mb_y);
+get_limits(s, 16*mb_x, 16*mb_y, 0);
 c->skip=0;
 
 P_LEFT[0]   = s->p_mv_table[xy + 1][0];
@@ -1140,7 +1140,7 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, 
int mb_y,
 
 c->current_mv_penalty= mv_penalty;
 
-get_limits(s, 16*mb_x, 16*mb_y);
+get_limits(s, 16*mb_x, 16*mb_y, 1);
 
 if (s->motion_est != FF_ME_ZERO) {
 P_LEFT[0] = mv_table[mot_xy - 1][0];
@@ -1489,7 +1489,7 @@ static inline int direct_search(MpegEncContext * s, int 
mb_x, int mb_y)
 if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
 dmin= get_mb_score(s, mx, my, 0, 0, 0, 16, 1);
 
-get_limits(s, 16*mb_x, 16*mb_y); //restore c->?min/max, maybe not needed
+get_limits(s, 16*mb_x, 16*mb_y, 1); //restore c->?min/max, maybe not needed
 
 mv_table[mot_xy][0]= mx;
 mv_table[mot_xy][1]= my;
@@ -1509,7 +1509,7 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
 init_ref(c, s->new_pic->data, s->last_pic.data,
  s->next_pic.data, 16 * mb_x, 16 * mb_y, 2);
 
-get_limits(s, 16*mb_x, 16*mb_y);
+get_limits(s, 16*mb_x, 16*mb_y, 1);
 
 c->skip=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/h261enc: Inline constants

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun 15 06:53:37 2024 +0200| [bbb10f1d8342b8f8682b0594aa479fdb90387ef1] | 
committer: Andreas Rheinhardt

avcodec/h261enc: Inline constants

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h261enc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index dd4419ec8c..8e08c749d1 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -133,8 +133,8 @@ static void h261_encode_motion(PutBitContext *pb, int val)
 {
 int sign, code;
 if (val == 0) {
-code = 0;
-put_bits(pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]);
+// Corresponds to ff_h261_mv_tab[0]
+put_bits(pb, 1, 1);
 } else {
 if (val > 15)
 val -= 32;
@@ -227,7 +227,7 @@ static void h261_encode_block(H261EncContext *h, int16_t 
*block, int n)
 }
 }
 if (last_index > -1)
-put_bits(&s->pb, rl->table_vlc[0][1], rl->table_vlc[0][0]); // EOB
+put_bits(&s->pb, 2, 0x2); // EOB
 }
 
 void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],

___
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: Move setting dct_unquant funcs to h263dec.c

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Jun 14 18:07:15 2024 +0200| [48cdb7d579a55ab0d7dac25409ad838e0e82fa74] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Move setting dct_unquant funcs to h263dec.c

It is a better place for it; no non-h263-based decoder needs
these functions any more (both H.261 and the error resilience
code recently stopped doing so).

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h263dec.c   | 5 +
 libavcodec/mpegvideo_dec.c | 6 --
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index a81786479d..0c23012584 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -102,6 +102,11 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 s->decode_mb   = ff_h263_decode_mb;
 s->low_delay   = 1;
 
+// dct_unquantize defaults for H.263;
+// they might change on a per-frame basis for MPEG-4.
+s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
+s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
+
 /* select sub codec */
 switch (avctx->codec->id) {
 case AV_CODEC_ID_H263:
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index da88a35120..1cab108935 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -60,12 +60,6 @@ int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext 
*avctx)
 
 ff_mpv_idct_init(s);
 
-// dct_unquantize defaults for H.261 and H.263;
-// they might change on a per-frame basis for MPEG-4.
-// Unused by the MPEG-1/2 decoders.
-s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
-s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
-
 ff_h264chroma_init(&s->h264chroma, 8); //for lowres
 
 if (s->picture_pool)  // VC-1 can call this multiple times

___
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/rv10: Avoid indirection

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Jun 14 19:56:12 2024 +0200| [64d2bca4520f1bbc7e977cab306afc85f65b1937] | 
committer: Andreas Rheinhardt

avcodec/rv10: Avoid indirection

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 65060d4ece..753c6c6cb3 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -385,11 +385,11 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
 case 2:
 if (minor_ver >= 2) {
 s->low_delay   = 0;
-s->avctx->has_b_frames = 1;
+avctx->has_b_frames = 1;
 }
 break;
 default:
-av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", rv->sub_id);
+av_log(avctx, AV_LOG_ERROR, "unknown header %X\n", rv->sub_id);
 avpriv_request_sample(avctx, "RV1/2 version");
 return AVERROR_PATCHWELCOME;
 }

___
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: Constify pointers to static storage

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun 15 10:08:49 2024 +0200| [390dbcb8b8d69a8f10362c58a7bafbfa51eb7148] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Constify pointers to static storage

These must not be modified (even when they are initialized at runtime
and therefore modifiable).

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index abeb235277..620ca08869 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3914,8 +3914,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
 int coeff_count[64];
 int qmul, qadd, start_i, last_non_zero, i, dc;
 const int esc_length= s->ac_esc_length;
-uint8_t * length;
-uint8_t * last_length;
+const uint8_t *length, *last_length;
 const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
 int mpeg2_qscale;
 

___
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/h261enc: Fix ac_vlc_length tables

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun 15 18:44:18 2024 +0200| [3a5202d026c3ec2591b0a8bdff6ac7d09b8a9c1e] | 
committer: Andreas Rheinhardt

avcodec/h261enc: Fix ac_vlc_length tables

These tables are supposed to contain the number of bits needed
to encode a given (run, level) pair. Yet the number of bits
for pairs needing the escape code was wrong (it only contained
the escape code and not the bits needed for run and level).

Furthermore, H.261 (a format with explicit end-of-block codes)
does not work well together with the RLTable API from rl.c:
The EOB code is the first one in ff_h261_rl_tcoeff's VLC table
and has a run value of zero. Therefore the result of get_rl_index()
is off by one for run == 0 and level values with explicit
(run, level) pair.

Fixing this necessitated changing the ref files of the
vsynth*-h261-trellis tests. Both filesizes as well as PSNR
decreased. If one used a qscale value of 11 for this test,
one would have received files with about the same size as
before this patch (with qscale 12), but with better PSNR.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h261enc.c  | 59 +++
 tests/ref/vsynth/vsynth1-h261-trellis |  8 ++---
 tests/ref/vsynth/vsynth2-h261-trellis |  8 ++---
 tests/ref/vsynth/vsynth_lena-h261-trellis |  8 ++---
 4 files changed, 24 insertions(+), 59 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index b19830d578..a901c32e42 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -38,14 +38,15 @@
 
 #define H261_MAX_RUN   26
 #define H261_MAX_LEVEL 15
+#define H261_ESC_LEN   (6 + 6 + 8)
 
 static struct VLCLUT {
 uint8_t len;
 uint16_t code;
 } vlc_lut[H261_MAX_RUN + 1][32 /* 0..2 * H261_MAX_LEN are used */];
 
-static uint8_t uni_h261_rl_len [64*64*2*2];
-#define UNI_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
+static uint8_t uni_h261_rl_len [64 * 128];
+static uint8_t uni_h261_rl_len_last[64 * 128];
 
 typedef struct H261EncContext {
 MpegEncContext s;
@@ -320,51 +321,10 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t 
block[6][64],
 }
 }
 
-static av_cold void init_uni_h261_rl_tab(const RLTable *rl, uint8_t *len_tab)
-{
-int slevel, run, last;
-
-av_assert0(MAX_LEVEL >= 64);
-av_assert0(MAX_RUN   >= 63);
-
-for(slevel=-64; slevel<64; slevel++){
-if(slevel==0) continue;
-for(run=0; run<64; run++){
-for(last=0; last<=1; last++){
-const int index= UNI_ENC_INDEX(last, run, slevel+64);
-int level= slevel < 0 ? -slevel : slevel;
-int len, code;
-
-len_tab[index]= 100;
-
-/* ESC0 */
-code= get_rl_index(rl, 0, run, level);
-len=  rl->table_vlc[code][1] + 1;
-if(last)
-len += 2;
-
-if(code!=rl->n && len < len_tab[index]){
-len_tab [index]= len;
-}
-/* ESC */
-len = rl->table_vlc[rl->n][1];
-if(last)
-len += 2;
-
-if(len < len_tab[index]){
-len_tab [index]= len;
-}
-}
-}
-}
-}
-
 static av_cold void h261_encode_init_static(void)
 {
-static uint8_t h261_rl_table_store[2][2 * MAX_RUN + MAX_LEVEL + 3];
-
-ff_rl_init(&ff_h261_rl_tcoeff, h261_rl_table_store);
-init_uni_h261_rl_tab(&ff_h261_rl_tcoeff, uni_h261_rl_len);
+memset(uni_h261_rl_len,  H261_ESC_LEN, sizeof(uni_h261_rl_len));
+memset(uni_h261_rl_len_last, H261_ESC_LEN + 2 /* EOB */, 
sizeof(uni_h261_rl_len_last));
 
 // The following loop is over the ordinary elements, not EOB or escape.
 for (size_t i = 1; i < FF_ARRAY_ELEMS(ff_h261_tcoeff_vlc) - 1; i++) {
@@ -375,6 +335,11 @@ static av_cold void h261_encode_init_static(void)
 
 vlc_lut[run][H261_MAX_LEVEL + level] = (struct VLCLUT){ len, code << 1 
};
 vlc_lut[run][H261_MAX_LEVEL - level] = (struct VLCLUT){ len, (code << 
1) | 1 };
+
+uni_h261_rl_len [UNI_AC_ENC_INDEX(run, 64 + level)] = len;
+uni_h261_rl_len [UNI_AC_ENC_INDEX(run, 64 - level)] = len;
+uni_h261_rl_len_last[UNI_AC_ENC_INDEX(run, 64 + level)] = len + 2;
+uni_h261_rl_len_last[UNI_AC_ENC_INDEX(run, 64 - level)] = len + 2;
 }
 }
 
@@ -398,10 +363,10 @@ av_cold int ff_h261_encode_init(MpegEncContext *s)
 
 s->min_qcoeff   = -127;
 s->max_qcoeff   = 127;
-s->ac_esc_length= 6+6+8;
+s->ac_esc_length= H261_ESC_LEN;
 
 s->intra_ac_vlc_length  = s->inter_ac_vlc_length  = 
uni_h261_rl_len;
-s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = 
uni_h261_rl_len + 128*64;
+s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = 
uni

[FFmpeg-cvslog] avcodec/h261enc: Avoid RLTable when writing macroblock

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun 15 17:26:14 2024 +0200| [f3829cc72d74f41e0eb82bf968315de2b119a8a3] | 
committer: Andreas Rheinhardt

avcodec/h261enc: Avoid RLTable when writing macroblock

The RLTable API in rl.c is not well designed for codecs with
an explicit end-of-block code. ff_h261_rl_tcoeff's vlc has
the EOB code as first element (presumably so that the decoder
can check for it via "if (level == 0)") and this implies
that the indices returned by get_rl_index() are off by one
for run == 0 which is therefore explicitly checked.

This commit changes this by adding a simple LUT for the
values not requiring escaping. It is easy to directly
include the sign bit into this, so this has also been done.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h261enc.c | 51 +++
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 8e08c749d1..b19830d578 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -36,6 +36,14 @@
 #include "h261enc.h"
 #include "mpegvideoenc.h"
 
+#define H261_MAX_RUN   26
+#define H261_MAX_LEVEL 15
+
+static struct VLCLUT {
+uint8_t len;
+uint16_t code;
+} vlc_lut[H261_MAX_RUN + 1][32 /* 0..2 * H261_MAX_LEN are used */];
+
 static uint8_t uni_h261_rl_len [64*64*2*2];
 #define UNI_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
 
@@ -165,10 +173,8 @@ static inline int get_cbp(MpegEncContext *s, int16_t 
block[6][64])
 static void h261_encode_block(H261EncContext *h, int16_t *block, int n)
 {
 MpegEncContext *const s = &h->s;
-int level, run, i, j, last_index, last_non_zero, sign, slevel, code;
-const RLTable *rl;
+int level, run, i, j, last_index, last_non_zero;
 
-rl = &ff_h261_rl_tcoeff;
 if (s->mb_intra) {
 /* DC coef */
 level = block[0];
@@ -204,24 +210,18 @@ static void h261_encode_block(H261EncContext *h, int16_t 
*block, int n)
 level = block[j];
 if (level) {
 run= i - last_non_zero - 1;
-sign   = 0;
-slevel = level;
-if (level < 0) {
-sign  = 1;
-level = -level;
-}
-code = get_rl_index(rl, 0 /*no last in H.261, EOB is used*/,
-run, level);
-if (run == 0 && level < 16)
-code += 1;
-put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-if (code == rl->n) {
-put_bits(&s->pb, 6, run);
-av_assert1(slevel != 0);
-av_assert1(level <= 127);
-put_sbits(&s->pb, 8, slevel);
+
+if (run <= H261_MAX_RUN &&
+(unsigned)(level + H261_MAX_LEVEL) <= 2 * H261_MAX_LEVEL &&
+vlc_lut[run][level + H261_MAX_LEVEL].len) {
+put_bits(&s->pb, vlc_lut[run][level + H261_MAX_LEVEL].len,
+ vlc_lut[run][level + H261_MAX_LEVEL].code);
 } else {
-put_bits(&s->pb, 1, sign);
+/* Escape */
+put_bits(&s->pb, 6 + 6, (1 << 6) | run);
+av_assert1(level != 0);
+av_assert1(FFABS(level) <= 127);
+put_sbits(&s->pb, 8, level);
 }
 last_non_zero = i;
 }
@@ -365,6 +365,17 @@ static av_cold void h261_encode_init_static(void)
 
 ff_rl_init(&ff_h261_rl_tcoeff, h261_rl_table_store);
 init_uni_h261_rl_tab(&ff_h261_rl_tcoeff, uni_h261_rl_len);
+
+// The following loop is over the ordinary elements, not EOB or escape.
+for (size_t i = 1; i < FF_ARRAY_ELEMS(ff_h261_tcoeff_vlc) - 1; i++) {
+unsigned run   = ff_h261_tcoeff_run[i];
+unsigned level = ff_h261_tcoeff_level[i];
+unsigned len   = ff_h261_tcoeff_vlc[i][1] + 1 /* sign */;
+unsigned code  = ff_h261_tcoeff_vlc[i][0];
+
+vlc_lut[run][H261_MAX_LEVEL + level] = (struct VLCLUT){ len, code << 1 
};
+vlc_lut[run][H261_MAX_LEVEL - level] = (struct VLCLUT){ len, (code << 
1) | 1 };
+}
 }
 
 av_cold int ff_h261_encode_init(MpegEncContext *s)

___
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/h261data: Make some tables non-static

2024-06-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Jun 15 17:21:16 2024 +0200| [3874442db29d7344169850ca6f8feb5e5629aa1d] | 
committer: Andreas Rheinhardt

avcodec/h261data: Make some tables non-static

This will allow to avoid the indirection via ff_h261_rl_tcoeff
in future commits.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h261.h |  4 
 libavcodec/h261data.c | 12 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h261.h b/libavcodec/h261.h
index 11a8a8685a..4279a12677 100644
--- a/libavcodec/h261.h
+++ b/libavcodec/h261.h
@@ -50,6 +50,10 @@ extern const uint8_t ff_h261_mv_tab[17][2];
 extern const uint8_t ff_h261_cbp_tab[63][2];
 extern RLTable ff_h261_rl_tcoeff;
 
+extern const uint16_t ff_h261_tcoeff_vlc[65][2];
+extern const int8_t ff_h261_tcoeff_level[64];
+extern const int8_t ff_h261_tcoeff_run[64];
+
 void ff_h261_loop_filter(MpegEncContext *s);
 
 #endif /* AVCODEC_H261_H */
diff --git a/libavcodec/h261data.c b/libavcodec/h261data.c
index bccd9e5f56..3ee750f98c 100644
--- a/libavcodec/h261data.c
+++ b/libavcodec/h261data.c
@@ -104,7 +104,7 @@ const uint8_t ff_h261_cbp_tab[63][2] = {
 };
 
 // H.261 VLC table for transform coefficients
-static const uint16_t h261_tcoeff_vlc[65][2] = {
+const uint16_t ff_h261_tcoeff_vlc[65][2] = {
 {  0x2,  2 }, {  0x3,  2 }, {  0x4,  4 }, {  0x5,  5 },
 {  0x6,  7 }, { 0x26,  8 }, { 0x21,  8 }, {  0xa, 10 },
 { 0x1d, 12 }, { 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 },
@@ -124,7 +124,7 @@ static const uint16_t h261_tcoeff_vlc[65][2] = {
 {  0x1,  6 }  // escape
 };
 
-static const int8_t h261_tcoeff_level[64] = {
+const int8_t ff_h261_tcoeff_level[64] = {
 0, 1,  2,  3,  4,  5,  6,  7,
 8, 9, 10, 11, 12, 13, 14, 15,
 1, 2,  3,  4,  5,  6,  7,  1,
@@ -135,7 +135,7 @@ static const int8_t h261_tcoeff_level[64] = {
 1, 1,  1,  1,  1,  1,  1,  1
 };
 
-static const int8_t h261_tcoeff_run[64] = {
+const int8_t ff_h261_tcoeff_run[64] = {
  0,
  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  1,
@@ -150,7 +150,7 @@ static const int8_t h261_tcoeff_run[64] = {
 RLTable ff_h261_rl_tcoeff = {
 64,
 64,
-h261_tcoeff_vlc,
-h261_tcoeff_run,
-h261_tcoeff_level,
+ff_h261_tcoeff_vlc,
+ff_h261_tcoeff_run,
+ff_h261_tcoeff_level,
 };

___
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] ffprobe: always print all Stereo3D fields

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Jun 18 15:44:24 
2024 -0300| [5140d8334e3bc95a9070e6d2e6d71f4a5f016d53] | committer: James Almer

ffprobe: always print all Stereo3D fields

ffprobe is meant to generate parseable output, and if a field is present, it
should be printed even if it has a default value.

Signed-off-by: James Almer 

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

 fftools/ffprobe.c|  9 +++--
 tests/ref/fate/matroska-spherical-mono   |  3 +++
 tests/ref/fate/matroska-spherical-mono-remux |  6 ++
 tests/ref/fate/matroska-stereo_mode  | 12 
 tests/ref/fate/matroska-vp8-alpha-remux  |  3 +++
 tests/ref/fate/mov-spherical-mono|  3 +++
 6 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a814cb5ade..d7ba980ff9 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2546,12 +2546,9 @@ static void print_pkt_side_data(WriterContext *w,
 print_int("inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
 print_str("view", av_stereo3d_view_name(stereo->view));
 print_str("primary_eye", 
av_stereo3d_primary_eye_name(stereo->primary_eye));
-if (stereo->baseline)
-print_int("baseline", stereo->baseline);
-if (stereo->horizontal_disparity_adjustment.num && 
stereo->horizontal_disparity_adjustment.den)
-print_q("horizontal_disparity_adjustment", 
stereo->horizontal_disparity_adjustment, '/');
-if (stereo->horizontal_field_of_view)
-print_int("horizontal_field_of_view", 
stereo->horizontal_field_of_view);
+print_int("baseline", stereo->baseline);
+print_q("horizontal_disparity_adjustment", 
stereo->horizontal_disparity_adjustment, '/');
+print_int("horizontal_field_of_view", 
stereo->horizontal_field_of_view);
 } else if (sd->type == AV_PKT_DATA_SPHERICAL) {
 const AVSphericalMapping *spherical = (AVSphericalMapping 
*)sd->data;
 print_str("projection", 
av_spherical_projection_name(spherical->projection));
diff --git a/tests/ref/fate/matroska-spherical-mono 
b/tests/ref/fate/matroska-spherical-mono
index 08b94e455b..c52ca8e7ee 100644
--- a/tests/ref/fate/matroska-spherical-mono
+++ b/tests/ref/fate/matroska-spherical-mono
@@ -5,6 +5,9 @@ type=2D
 inverted=0
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Spherical Mapping
diff --git a/tests/ref/fate/matroska-spherical-mono-remux 
b/tests/ref/fate/matroska-spherical-mono-remux
index 0ca77c8074..10b92d5f2e 100644
--- a/tests/ref/fate/matroska-spherical-mono-remux
+++ b/tests/ref/fate/matroska-spherical-mono-remux
@@ -29,6 +29,9 @@ type=2D
 inverted=0
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Spherical Mapping
@@ -55,6 +58,9 @@ type=2D
 inverted=0
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Spherical Mapping
diff --git a/tests/ref/fate/matroska-stereo_mode 
b/tests/ref/fate/matroska-stereo_mode
index 13bce13cb8..a1aab1e38e 100644
--- a/tests/ref/fate/matroska-stereo_mode
+++ b/tests/ref/fate/matroska-stereo_mode
@@ -134,6 +134,9 @@ type=side by side
 inverted=0
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
 [STREAM]
@@ -151,6 +154,9 @@ type=top and bottom
 inverted=1
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
 [STREAM]
@@ -166,6 +172,9 @@ type=interleaved lines
 inverted=1
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
 [STREAM]
@@ -182,6 +191,9 @@ type=interleaved columns
 inverted=1
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
 [STREAM]
diff --git a/tests/ref/fate/matroska-vp8-alpha-remux 
b/tests/ref/fate/matroska-vp8-alpha-remux
index e54304cafd..ea8a089cec 100644
--- a/tests/ref/fate/matroska-vp8-alpha-remux
+++ b/tests/ref/fate/matroska-vp8-alpha-remux
@@ -37,5 +37,8 @@ type=2D
 inverted=0
 view=packed
 primary_eye=none
+baseline=0
+horizontal_disparity_adjustment=0/0
+horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
diff --git a/tests/ref/fate/mov-spherical-mono 
b/tests/ref/fate/mov-spherical-mono
index 08b94e455b..c52ca8e7ee 100644
--- a/tests/ref/fate/mov-spherical-mono
+++ b/tests/ref/fate/mov-spherical-mono
@@ -5,6 +5,9 @@ type=2D
 inverted=0
 view=packed
 primary_eye=none
+baseline=0
+horizontal_dispari

[FFmpeg-cvslog] avutil/ambient_viewing_environment: set a sane default value for AVRational fields

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Jun 18 16:12:06 
2024 -0300| [7f1b590480e7519e25ac9fcd99b0f9916fb03462] | committer: James Almer

avutil/ambient_viewing_environment: set a sane default value for AVRational 
fields

Prevent potential divisions by 0 when using them immediately after allocation.

Signed-off-by: James Almer 

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

 libavutil/ambient_viewing_environment.c | 10 ++
 libavutil/version.h |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavutil/ambient_viewing_environment.c 
b/libavutil/ambient_viewing_environment.c
index c47458cfa8..e359727776 100644
--- a/libavutil/ambient_viewing_environment.c
+++ b/libavutil/ambient_viewing_environment.c
@@ -21,6 +21,13 @@
 #include "ambient_viewing_environment.h"
 #include "mem.h"
 
+static void get_defaults(AVAmbientViewingEnvironment *env)
+{
+env->ambient_illuminance =
+env->ambient_light_x =
+env->ambient_light_y = (AVRational) { 0, 1 };
+}
+
 AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size)
 {
 AVAmbientViewingEnvironment *env =
@@ -28,6 +35,8 @@ AVAmbientViewingEnvironment 
*av_ambient_viewing_environment_alloc(size_t *size)
 if (!env)
 return NULL;
 
+get_defaults(env);
+
  if (size)
 *size = sizeof(*env);
 
@@ -44,6 +53,7 @@ AVAmbientViewingEnvironment 
*av_ambient_viewing_environment_create_side_data(AVF
 return NULL;
 
 memset(side_data->data, 0, side_data->size);
+get_defaults((AVAmbientViewingEnvironment *)side_data->data);
 
 return (AVAmbientViewingEnvironment *)side_data->data;
 }
diff --git a/libavutil/version.h b/libavutil/version.h
index 8044fd3935..4f51d441fa 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR  59
 #define LIBAVUTIL_VERSION_MINOR  24
-#define LIBAVUTIL_VERSION_MICRO 100
+#define LIBAVUTIL_VERSION_MICRO 101
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \

___
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/mastering_display_metadata: set a sane default value for AVRational fields

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Jun 18 16:12:23 
2024 -0300| [1044c09ecae478fea33f80c13f94c7381a8f0a24] | committer: James Almer

avutil/mastering_display_metadata: set a sane default value for AVRational 
fields

Prevent potential divisions by 0 when using them immediately after allocation.

Signed-off-by: James Almer 

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

 libavutil/mastering_display_metadata.c | 16 +++-
 libavutil/version.h|  2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libavutil/mastering_display_metadata.c 
b/libavutil/mastering_display_metadata.c
index ea41f13f9d..dd37ed7d0e 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -25,9 +25,20 @@
 #include "mastering_display_metadata.h"
 #include "mem.h"
 
+static void get_defaults(AVMasteringDisplayMetadata *mastering)
+{
+for (int i = 0; i < 3; i++)
+for (int j = 0; j < 2; j++)
+mastering->display_primaries[i][j] = (AVRational) { 0, 1 };
+mastering->white_point[0] =
+mastering->white_point[1] =
+mastering->min_luminance  =
+mastering->max_luminance  = (AVRational) { 0, 1 };
+}
+
 AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void)
 {
-return av_mallocz(sizeof(AVMasteringDisplayMetadata));
+return av_mastering_display_metadata_alloc_size(NULL);
 }
 
 AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t 
*size)
@@ -36,6 +47,8 @@ AVMasteringDisplayMetadata 
*av_mastering_display_metadata_alloc_size(size_t *siz
 if (!mastering)
 return NULL;
 
+get_defaults(mastering);
+
 if (size)
 *size = sizeof(*mastering);
 
@@ -51,6 +64,7 @@ AVMasteringDisplayMetadata 
*av_mastering_display_metadata_create_side_data(AVFra
 return NULL;
 
 memset(side_data->data, 0, sizeof(AVMasteringDisplayMetadata));
+get_defaults((AVMasteringDisplayMetadata *)side_data->data);
 
 return (AVMasteringDisplayMetadata *)side_data->data;
 }
diff --git a/libavutil/version.h b/libavutil/version.h
index 4f51d441fa..9c24b64032 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR  59
 #define LIBAVUTIL_VERSION_MINOR  24
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MICRO 102
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \

___
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/stereo3d: set a sane default value for AVRational fields

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Jun 18 16:20:24 
2024 -0300| [c3606cad9cffded4620af07287606d4d97f29bf1] | committer: James Almer

avutil/stereo3d: set a sane default value for AVRational fields

Prevent potential divisions by 0 when using them immediately after allocation.

Signed-off-by: James Almer 

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

 libavutil/stereo3d.c | 14 +-
 libavutil/version.h  |  2 +-
 tests/ref/fate/matroska-spherical-mono   |  2 +-
 tests/ref/fate/matroska-spherical-mono-remux |  4 ++--
 tests/ref/fate/matroska-stereo_mode  |  8 
 tests/ref/fate/matroska-vp8-alpha-remux  |  2 +-
 tests/ref/fate/mov-spherical-mono|  2 +-
 7 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index a40a9439bb..19e81e4124 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -26,9 +26,20 @@
 #include "mem.h"
 #include "stereo3d.h"
 
+static void get_defaults(AVStereo3D *stereo)
+{
+stereo->horizontal_disparity_adjustment = (AVRational) { 0, 1 };
+}
+
 AVStereo3D *av_stereo3d_alloc(void)
 {
-return av_mallocz(sizeof(AVStereo3D));
+AVStereo3D *stereo = av_mallocz(sizeof(AVStereo3D));
+if (!stereo)
+return NULL;
+
+get_defaults(stereo);
+
+return stereo;
 }
 
 AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
@@ -40,6 +51,7 @@ AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
 return NULL;
 
 memset(side_data->data, 0, sizeof(AVStereo3D));
+get_defaults((AVStereo3D *)side_data->data);
 
 return (AVStereo3D *)side_data->data;
 }
diff --git a/libavutil/version.h b/libavutil/version.h
index 9c24b64032..145fe634b3 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR  59
 #define LIBAVUTIL_VERSION_MINOR  24
-#define LIBAVUTIL_VERSION_MICRO 102
+#define LIBAVUTIL_VERSION_MICRO 103
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
diff --git a/tests/ref/fate/matroska-spherical-mono 
b/tests/ref/fate/matroska-spherical-mono
index c52ca8e7ee..b108596350 100644
--- a/tests/ref/fate/matroska-spherical-mono
+++ b/tests/ref/fate/matroska-spherical-mono
@@ -6,7 +6,7 @@ inverted=0
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [SIDE_DATA]
diff --git a/tests/ref/fate/matroska-spherical-mono-remux 
b/tests/ref/fate/matroska-spherical-mono-remux
index 10b92d5f2e..eec41b77f3 100644
--- a/tests/ref/fate/matroska-spherical-mono-remux
+++ b/tests/ref/fate/matroska-spherical-mono-remux
@@ -30,7 +30,7 @@ inverted=0
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [SIDE_DATA]
@@ -59,7 +59,7 @@ inverted=0
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [SIDE_DATA]
diff --git a/tests/ref/fate/matroska-stereo_mode 
b/tests/ref/fate/matroska-stereo_mode
index a1aab1e38e..26c325b20e 100644
--- a/tests/ref/fate/matroska-stereo_mode
+++ b/tests/ref/fate/matroska-stereo_mode
@@ -135,7 +135,7 @@ inverted=0
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
@@ -155,7 +155,7 @@ inverted=1
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
@@ -173,7 +173,7 @@ inverted=1
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
@@ -192,7 +192,7 @@ inverted=1
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
diff --git a/tests/ref/fate/matroska-vp8-alpha-remux 
b/tests/ref/fate/matroska-vp8-alpha-remux
index ea8a089cec..06bcc4b4ba 100644
--- a/tests/ref/fate/matroska-vp8-alpha-remux
+++ b/tests/ref/fate/matroska-vp8-alpha-remux
@@ -38,7 +38,7 @@ inverted=0
 view=packed
 primary_eye=none
 baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
 horizontal_field_of_view=0
 [/SIDE_DATA]
 [/STREAM]
diff --git a/tests/ref/fate/mov-spherical-mono 
b/tests/ref/fate/mov-spherical-mono
index c52ca8e7ee..b108596350 100644
--- a/tests/ref/fate/mov-spherical-mono
+++ b/tests/ref/fate/mov-spherical-mono
@@ -6,7 +6,7 @@ inverted=0
 view=packed
 primary_eye=none
 baseline=0
-horizontal_d

[FFmpeg-cvslog] avformat/matroskadec: don't use sizeof(AVMasteringDisplayMetadata)

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Jun 19 15:19:49 
2024 -0300| [8a85d3fd39a0ab12c92c130c6e1764336854632f] | committer: James Almer

avformat/matroskadec: don't use sizeof(AVMasteringDisplayMetadata)

It's not part of the libavutil ABI.

Signed-off-by: James Almer 

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

 libavformat/matroskadec.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 328109b354..6bc5fa621e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2324,15 +2324,15 @@ static int mkv_parse_video_color(AVStream *st, const 
MatroskaTrack *track) {
 }
 
 if (has_mastering_primaries || has_mastering_luminance) {
-AVMasteringDisplayMetadata *metadata;
-AVPacketSideData *sd = 
av_packet_side_data_new(&st->codecpar->coded_side_data,
-   
&st->codecpar->nb_coded_side_data,
-   
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
-   
sizeof(AVMasteringDisplayMetadata), 0);
-if (!sd)
+size_t size = 0;
+AVMasteringDisplayMetadata *metadata = 
av_mastering_display_metadata_alloc_size(&size);
+if (!metadata)
+return AVERROR(ENOMEM);
+if (!av_packet_side_data_add(&st->codecpar->coded_side_data, 
&st->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, 
metadata, size, 0)) {
+av_freep(&metadata);
 return AVERROR(ENOMEM);
-metadata = (AVMasteringDisplayMetadata*)sd->data;
-memset(metadata, 0, sizeof(AVMasteringDisplayMetadata));
+}
 if (has_mastering_primaries) {
 metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, 
INT_MAX);
 metadata->display_primaries[0][1] = av_d2q(mastering_meta->r_y, 
INT_MAX);

___
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/mov: don't use sizeof(AVMasteringDisplayMetadata)

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Jun 19 15:19:56 
2024 -0300| [a91f34aad84a1643e8aaadbf8a6204828712731d] | committer: James Almer

avformat/mov: don't use sizeof(AVMasteringDisplayMetadata)

It's not part of the libavutil ABI.

Signed-off-by: James Almer 

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

 libavformat/isom.h | 1 +
 libavformat/mov.c  | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index c0a5788e08..35b767a52c 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -250,6 +250,7 @@ typedef struct MOVStreamContext {
 AVSphericalMapping *spherical;
 size_t spherical_size;
 AVMasteringDisplayMetadata *mastering;
+size_t mastering_size;
 AVContentLightMetadata *coll;
 size_t coll_size;
 AVAmbientViewingEnvironment *ambient;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 367af8478b..2d5b24b9a9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6138,7 +6138,7 @@ static int mov_read_smdm(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 avio_skip(pb, 3); /* flags */
 
-sc->mastering = av_mastering_display_metadata_alloc();
+sc->mastering = 
av_mastering_display_metadata_alloc_size(&sc->mastering_size);
 if (!sc->mastering)
 return AVERROR(ENOMEM);
 
@@ -6181,7 +6181,7 @@ static int mov_read_mdcv(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
-sc->mastering = av_mastering_display_metadata_alloc();
+sc->mastering = 
av_mastering_display_metadata_alloc_size(&sc->mastering_size);
 if (!sc->mastering)
 return AVERROR(ENOMEM);
 
@@ -10043,7 +10043,7 @@ static int mov_read_header(AVFormatContext *s)
 if (sc->mastering) {
 if (!av_packet_side_data_add(&st->codecpar->coded_side_data, 
&st->codecpar->nb_coded_side_data,
  
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
- (uint8_t *)sc->mastering, 
sizeof(*sc->mastering), 0))
+ (uint8_t *)sc->mastering, 
sc->mastering_size, 0))
 return AVERROR(ENOMEM);
 
 sc->mastering = NULL;

___
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/mxfdec: don't use sizeof(AVMasteringDisplayMetadata)

2024-06-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Jun 19 15:20:12 
2024 -0300| [35df214a72685515a5e018a048fbed6f31b459d4] | committer: James Almer

avformat/mxfdec: don't use sizeof(AVMasteringDisplayMetadata)

It's not part of the libavutil ABI.

Signed-off-by: James Almer 

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

 libavformat/mxfdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 852fb7e056..a5863445ab 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -227,6 +227,7 @@ typedef struct MXFDescriptor {
 UID color_trc_ul;
 UID color_space_ul;
 AVMasteringDisplayMetadata *mastering;
+size_t mastering_size;
 AVContentLightMetadata *coll;
 size_t coll_size;
 } MXFDescriptor;
@@ -1424,7 +1425,7 @@ static int mxf_read_generic_descriptor(void *arg, 
AVIOContext *pb, int tag, int
 }
 if (IS_KLV_KEY(uid, mxf_mastering_display_prefix)) {
 if (!descriptor->mastering) {
-descriptor->mastering = av_mastering_display_metadata_alloc();
+descriptor->mastering = 
av_mastering_display_metadata_alloc_size(&descriptor->mastering_size);
 if (!descriptor->mastering)
 return AVERROR(ENOMEM);
 }
@@ -2955,7 +2956,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
 if (descriptor->mastering) {
 if (!av_packet_side_data_add(&st->codecpar->coded_side_data, 
&st->codecpar->nb_coded_side_data,
  
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
- (uint8_t *)descriptor->mastering, 
sizeof(*descriptor->mastering), 0)) {
+ (uint8_t *)descriptor->mastering, 
descriptor->mastering_size, 0)) {
 ret = AVERROR(ENOMEM);
 goto fail_and_free;
 }

___
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".