Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests
@ 2022-10-02 21:14 Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideo_enc: Move SpeedHQ check to speedhqenc.c Andreas Rheinhardt
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 21:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The vsynth3 tests are disabled, because the encoder produces garbage.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 tests/fate/vcodec.mak                     | 9 ++++++++-
 tests/ref/vsynth/vsynth1-speedhq-420p     | 4 ++++
 tests/ref/vsynth/vsynth1-speedhq-422p     | 4 ++++
 tests/ref/vsynth/vsynth1-speedhq-444p     | 4 ++++
 tests/ref/vsynth/vsynth2-speedhq-420p     | 4 ++++
 tests/ref/vsynth/vsynth2-speedhq-422p     | 4 ++++
 tests/ref/vsynth/vsynth2-speedhq-444p     | 4 ++++
 tests/ref/vsynth/vsynth_lena-speedhq-420p | 4 ++++
 tests/ref/vsynth/vsynth_lena-speedhq-422p | 4 ++++
 tests/ref/vsynth/vsynth_lena-speedhq-444p | 4 ++++
 10 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/vsynth/vsynth1-speedhq-420p
 create mode 100644 tests/ref/vsynth/vsynth1-speedhq-422p
 create mode 100644 tests/ref/vsynth/vsynth1-speedhq-444p
 create mode 100644 tests/ref/vsynth/vsynth2-speedhq-420p
 create mode 100644 tests/ref/vsynth/vsynth2-speedhq-422p
 create mode 100644 tests/ref/vsynth/vsynth2-speedhq-444p
 create mode 100644 tests/ref/vsynth/vsynth_lena-speedhq-420p
 create mode 100644 tests/ref/vsynth/vsynth_lena-speedhq-422p
 create mode 100644 tests/ref/vsynth/vsynth_lena-speedhq-444p

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index 8ca17950ea..1a47fc8bf6 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -413,6 +413,12 @@ FATE_VCODEC-$(call ENCDEC, SNOW, AVI) += snow-ll
 fate-vsynth%-snow-ll:            ENCOPTS = -qscale .001 -pred 1 \
                                            -flags +mv4+qpel
 
+FATE_VCODEC-$(call ENCDEC, SPEEDHQ, AVI)      += speedhq-420p
+FATE_VCODEC_SCALE-$(call ENCDEC, SPEEDHQ, AVI) += speedhq-422p speedhq-444p
+fate-vsynth%-speedhq-420p:       ENCOPTS = -pix_fmt yuv420p -b 600k
+fate-vsynth%-speedhq-422p:       ENCOPTS = -pix_fmt yuv422p -noise_reduction 1000
+fate-vsynth%-speedhq-444p:       ENCOPTS = -pix_fmt yuv444p
+
 FATE_VCODEC_SCALE-$(call ENCDEC, SVQ1, MOV)   += svq1
 fate-vsynth%-svq1:               ENCOPTS = -qscale 3 -pix_fmt yuv410p
 fate-vsynth%-svq1:               FMT     = mov
@@ -466,7 +472,8 @@ RESIZE_OFF   = dnxhd-720p dnxhd-720p-rd dnxhd-720p-10bit dnxhd-1080i \
                vc2-444p vc2-444p10 vc2-444p12 vc2-thaar vc2-t5_3
 # Incorrect parameters - usually size or color format restrictions
 INC_PAR_OFF  = cinepak h261 h261-trellis h263 h263p h263-obmc msvideo1 \
-               roqvideo rv10 rv20 y41p qtrlegray
+               roqvideo rv10 rv20 speedhq-420p speedhq-422p speedhq-444p \
+               y41p qtrlegray
 VSYNTH3_OFF  = $(RESIZE_OFF) $(INC_PAR_OFF)
 
 FATE_VCODEC3 = $(filter-out $(VSYNTH3_OFF),$(FATE_VCODEC))
diff --git a/tests/ref/vsynth/vsynth1-speedhq-420p b/tests/ref/vsynth/vsynth1-speedhq-420p
new file mode 100644
index 0000000000..cd44ef662b
--- /dev/null
+++ b/tests/ref/vsynth/vsynth1-speedhq-420p
@@ -0,0 +1,4 @@
+f905e05eabc8be20438d416722c34ed7 *tests/data/fate/vsynth1-speedhq-420p.avi
+919156 tests/data/fate/vsynth1-speedhq-420p.avi
+31e9b07d5e8ce0c8b7749e53fba05b1c *tests/data/fate/vsynth1-speedhq-420p.out.rawvideo
+stddev:   14.06 PSNR: 25.17 MAXDIFF:  145 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-speedhq-422p b/tests/ref/vsynth/vsynth1-speedhq-422p
new file mode 100644
index 0000000000..adb7aa389f
--- /dev/null
+++ b/tests/ref/vsynth/vsynth1-speedhq-422p
@@ -0,0 +1,4 @@
+8f094b75b93b641c214bfaf743e584ad *tests/data/fate/vsynth1-speedhq-422p.avi
+1028244 tests/data/fate/vsynth1-speedhq-422p.avi
+967315914486c7ea979e4ce9ada04a6c *tests/data/fate/vsynth1-speedhq-422p.out.rawvideo
+stddev:   13.86 PSNR: 25.29 MAXDIFF:  148 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-speedhq-444p b/tests/ref/vsynth/vsynth1-speedhq-444p
new file mode 100644
index 0000000000..8c7abca7f2
--- /dev/null
+++ b/tests/ref/vsynth/vsynth1-speedhq-444p
@@ -0,0 +1,4 @@
+5008149f0dd3d05d05f8f0f9100d39ec *tests/data/fate/vsynth1-speedhq-444p.avi
+1347864 tests/data/fate/vsynth1-speedhq-444p.avi
+23c5db6ca2bdbc52e402cd72ad2fff27 *tests/data/fate/vsynth1-speedhq-444p.out.rawvideo
+stddev:   12.84 PSNR: 25.95 MAXDIFF:  145 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-speedhq-420p b/tests/ref/vsynth/vsynth2-speedhq-420p
new file mode 100644
index 0000000000..6f7d4a2a2e
--- /dev/null
+++ b/tests/ref/vsynth/vsynth2-speedhq-420p
@@ -0,0 +1,4 @@
+41795a070c6a13727cd1de7c65abd121 *tests/data/fate/vsynth2-speedhq-420p.avi
+570618 tests/data/fate/vsynth2-speedhq-420p.avi
+9f76f7f523a1b1efa99e55ebc874b58d *tests/data/fate/vsynth2-speedhq-420p.out.rawvideo
+stddev:    8.67 PSNR: 29.37 MAXDIFF:  142 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-speedhq-422p b/tests/ref/vsynth/vsynth2-speedhq-422p
new file mode 100644
index 0000000000..551047b6ba
--- /dev/null
+++ b/tests/ref/vsynth/vsynth2-speedhq-422p
@@ -0,0 +1,4 @@
+36bfdfdaecbf2938358137a598841377 *tests/data/fate/vsynth2-speedhq-422p.avi
+622790 tests/data/fate/vsynth2-speedhq-422p.avi
+3858c3c1524385150b2cff31cdb72e09 *tests/data/fate/vsynth2-speedhq-422p.out.rawvideo
+stddev:    8.62 PSNR: 29.42 MAXDIFF:  142 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-speedhq-444p b/tests/ref/vsynth/vsynth2-speedhq-444p
new file mode 100644
index 0000000000..0730ee93db
--- /dev/null
+++ b/tests/ref/vsynth/vsynth2-speedhq-444p
@@ -0,0 +1,4 @@
+62e4caac219e2d79d0c7a8b34b66d4ae *tests/data/fate/vsynth2-speedhq-444p.avi
+813586 tests/data/fate/vsynth2-speedhq-444p.avi
+c3fe2a70c17979dbf08100aba9c05934 *tests/data/fate/vsynth2-speedhq-444p.out.rawvideo
+stddev:    8.35 PSNR: 29.69 MAXDIFF:  142 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth_lena-speedhq-420p b/tests/ref/vsynth/vsynth_lena-speedhq-420p
new file mode 100644
index 0000000000..c00b091b28
--- /dev/null
+++ b/tests/ref/vsynth/vsynth_lena-speedhq-420p
@@ -0,0 +1,4 @@
+0669a27deca78e92b998aa5b616f87f2 *tests/data/fate/vsynth_lena-speedhq-420p.avi
+487888 tests/data/fate/vsynth_lena-speedhq-420p.avi
+4dc98e7ffb7c1ade85cf6bed75ee9a68 *tests/data/fate/vsynth_lena-speedhq-420p.out.rawvideo
+stddev:    7.48 PSNR: 30.64 MAXDIFF:  125 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth_lena-speedhq-422p b/tests/ref/vsynth/vsynth_lena-speedhq-422p
new file mode 100644
index 0000000000..5ea8b40011
--- /dev/null
+++ b/tests/ref/vsynth/vsynth_lena-speedhq-422p
@@ -0,0 +1,4 @@
+40a9b249daf3cf5ab3fc99a874907c20 *tests/data/fate/vsynth_lena-speedhq-422p.avi
+536206 tests/data/fate/vsynth_lena-speedhq-422p.avi
+d48a61d173005609e5e06b0027c98a0e *tests/data/fate/vsynth_lena-speedhq-422p.out.rawvideo
+stddev:    7.48 PSNR: 30.65 MAXDIFF:  138 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth_lena-speedhq-444p b/tests/ref/vsynth/vsynth_lena-speedhq-444p
new file mode 100644
index 0000000000..0772d0982f
--- /dev/null
+++ b/tests/ref/vsynth/vsynth_lena-speedhq-444p
@@ -0,0 +1,4 @@
+ce099dfae05cd224ef94c89476176a1c *tests/data/fate/vsynth_lena-speedhq-444p.avi
+702980 tests/data/fate/vsynth_lena-speedhq-444p.avi
+e2661cb41d9f59cd1a62b49b3a058e74 *tests/data/fate/vsynth_lena-speedhq-444p.out.rawvideo
+stddev:    7.23 PSNR: 30.94 MAXDIFF:  125 bytes:  7603200/  7603200
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideo_enc: Move SpeedHQ check to speedhqenc.c
  2022-10-02 21:14 [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
@ 2022-10-02 21:18 ` Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 3/6] avcodec/mpegvideo_enc: Call ff_h261_encode_init() earlier Andreas Rheinhardt
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 21:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Also set this only once and not for every frame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 3 ---
 libavcodec/speedhqenc.c    | 4 ++++
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 0b398c56ab..3af0c1c0f3 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3753,9 +3753,6 @@ static int encode_picture(MpegEncContext *s, int picture_number)
                               s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1);
             s->qscale = 8;
         }
-    } else if (s->out_format == FMT_SPEEDHQ) {
-        s->y_dc_scale_table=
-        s->c_dc_scale_table= ff_mpeg2_dc_scale_table[3];
     }
 
     //FIXME var duplication
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 747ed679bd..b92af2775e 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -36,6 +36,7 @@
 #include "mpeg12data.h"
 #include "mpeg12enc.h"
 #include "mpegvideo.h"
+#include "mpegvideodata.h"
 #include "mpegvideoenc.h"
 #include "speedhqenc.h"
 
@@ -111,6 +112,9 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s)
     s->intra_chroma_ac_vlc_length      =
     s->intra_chroma_ac_vlc_last_length = uni_speedhq_ac_vlc_len;
 
+    s->y_dc_scale_table =
+    s->c_dc_scale_table = ff_mpeg2_dc_scale_table[3];
+
     switch (s->avctx->pix_fmt) {
     case AV_PIX_FMT_YUV420P:
         s->avctx->codec_tag = MKTAG('S','H','Q','0');
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 3/6] avcodec/mpegvideo_enc: Call ff_h261_encode_init() earlier
  2022-10-02 21:14 [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideo_enc: Move SpeedHQ check to speedhqenc.c Andreas Rheinhardt
@ 2022-10-02 21:18 ` Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 4/6] avcodec/mpegvideo_enc: Move H.261 size check to h261enc.c Andreas Rheinhardt
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 21:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It does not require anything that is being set between
the new position where it is called and the old position
where it used to be called; and nothing that it sets
gets overwritten between these two positions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 3af0c1c0f3..e7e2e60a9a 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -689,6 +689,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
                     s->width, s->height);
             return AVERROR(EINVAL);
         }
+        ff_h261_encode_init(s);
         s->out_format = FMT_H261;
         avctx->delay  = 0;
         s->low_delay  = 1;
@@ -899,9 +900,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     ff_set_cmp(&s->mecc, s->mecc.ildct_cmp,      avctx->ildct_cmp);
     ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
 
-    if (CONFIG_H261_ENCODER && s->out_format == FMT_H261) {
-        ff_h261_encode_init(s);
-    } else if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
+    if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
                && s->out_format == FMT_MPEG1) {
         ff_mpeg1_encode_init(s);
     } else if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 4/6] avcodec/mpegvideo_enc: Move H.261 size check to h261enc.c
  2022-10-02 21:14 [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideo_enc: Move SpeedHQ check to speedhqenc.c Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 3/6] avcodec/mpegvideo_enc: Call ff_h261_encode_init() earlier Andreas Rheinhardt
@ 2022-10-02 21:18 ` Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 5/6] avcodec/h261enc: Store the H.261 format value Andreas Rheinhardt
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 21:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h261enc.c       | 11 ++++++++++-
 libavcodec/h261enc.h       |  2 +-
 libavcodec/mpegvideo_enc.c | 11 +++--------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index b868827160..7aa548c39d 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -382,11 +382,18 @@ static av_cold void h261_encode_init_static(void)
     init_uni_h261_rl_tab(&ff_h261_rl_tcoeff, uni_h261_rl_len);
 }
 
-av_cold void ff_h261_encode_init(MpegEncContext *s)
+av_cold int ff_h261_encode_init(MpegEncContext *s)
 {
     H261EncContext *const h = (H261EncContext*)s;
     static AVOnce init_static_once = AV_ONCE_INIT;
 
+    if (ff_h261_get_picture_format(s->width, s->height) < 0) {
+        av_log(s->avctx, AV_LOG_ERROR,
+                "The specified picture size of %dx%d is not valid for the "
+                "H.261 codec.\nValid sizes are 176x144, 352x288\n",
+                s->width, s->height);
+        return AVERROR(EINVAL);
+    }
     s->private_ctx = &h->common;
 
     s->min_qcoeff       = -127;
@@ -398,6 +405,8 @@ av_cold void ff_h261_encode_init(MpegEncContext *s)
     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;
     ff_thread_once(&init_static_once, h261_encode_init_static);
+
+    return 0;
 }
 
 const FFCodec ff_h261_encoder = {
diff --git a/libavcodec/h261enc.h b/libavcodec/h261enc.h
index 0a01858be5..088cd9f4e0 100644
--- a/libavcodec/h261enc.h
+++ b/libavcodec/h261enc.h
@@ -35,6 +35,6 @@ void ff_h261_reorder_mb_index(MpegEncContext *s);
 void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
                        int motion_x, int motion_y);
 void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number);
-void ff_h261_encode_init(MpegEncContext *s);
+int ff_h261_encode_init(MpegEncContext *s);
 
 #endif
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index e7e2e60a9a..8d74f9e978 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -682,14 +682,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_H261:
         if (!CONFIG_H261_ENCODER)
             return AVERROR_ENCODER_NOT_FOUND;
-        if (ff_h261_get_picture_format(s->width, s->height) < 0) {
-            av_log(avctx, AV_LOG_ERROR,
-                   "The specified picture size of %dx%d is not valid for the "
-                   "H.261 codec.\nValid sizes are 176x144, 352x288\n",
-                    s->width, s->height);
-            return AVERROR(EINVAL);
-        }
-        ff_h261_encode_init(s);
+        ret = ff_h261_encode_init(s);
+        if (ret < 0)
+            return ret;
         s->out_format = FMT_H261;
         avctx->delay  = 0;
         s->low_delay  = 1;
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 5/6] avcodec/h261enc: Store the H.261 format value
  2022-10-02 21:14 [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 4/6] avcodec/mpegvideo_enc: Move H.261 size check to h261enc.c Andreas Rheinhardt
@ 2022-10-02 21:18 ` Andreas Rheinhardt
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 6/6] avcodec/mpegvideo_enc: Call ff_mpeg1_encode_init() earlier Andreas Rheinhardt
  2022-10-05 11:38 ` [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 21:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h261enc.c | 39 +++++++++++++++------------------------
 libavcodec/h261enc.h |  1 -
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 7aa548c39d..e8ea357cbb 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -46,25 +46,16 @@ typedef struct H261EncContext {
     H261Context common;
 
     int gob_number;
+    enum {
+        H261_QCIF = 0,
+        H261_CIF  = 1,
+    } format;
 } H261EncContext;
 
-int ff_h261_get_picture_format(int width, int height)
-{
-    // QCIF
-    if (width == 176 && height == 144)
-        return 0;
-    // CIF
-    else if (width == 352 && height == 288)
-        return 1;
-    // ERROR
-    else
-        return AVERROR(EINVAL);
-}
-
 void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number)
 {
     H261EncContext *const h = (H261EncContext *)s;
-    int format, temp_ref;
+    int temp_ref;
 
     align_put_bits(&s->pb);
 
@@ -81,18 +72,13 @@ void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number)
     put_bits(&s->pb, 1, 0); /* camera  off */
     put_bits(&s->pb, 1, s->pict_type == AV_PICTURE_TYPE_I); /* freeze picture release on/off */
 
-    format = ff_h261_get_picture_format(s->width, s->height);
-
-    put_bits(&s->pb, 1, format); /* 0 == QCIF, 1 == CIF */
+    put_bits(&s->pb, 1, h->format); /* 0 == QCIF, 1 == CIF */
 
     put_bits(&s->pb, 1, 1); /* still image mode */
     put_bits(&s->pb, 1, 1); /* reserved */
 
     put_bits(&s->pb, 1, 0); /* no PEI */
-    if (format == 0)
-        h->gob_number = -1;
-    else
-        h->gob_number = 0;
+    h->gob_number = h->format - 1;
     s->mb_skip_run = 0;
 }
 
@@ -102,7 +88,7 @@ void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number)
 static void h261_encode_gob_header(MpegEncContext *s, int mb_line)
 {
     H261EncContext *const h = (H261EncContext *)s;
-    if (ff_h261_get_picture_format(s->width, s->height) == 0) {
+    if (h->format == H261_QCIF) {
         h->gob_number += 2; // QCIF
     } else {
         h->gob_number++;    // CIF
@@ -118,6 +104,7 @@ static void h261_encode_gob_header(MpegEncContext *s, int mb_line)
 
 void ff_h261_reorder_mb_index(MpegEncContext *s)
 {
+    const H261EncContext *const h = (H261EncContext*)s;
     int index = s->mb_x + s->mb_y * s->mb_width;
 
     if (index % 11 == 0) {
@@ -129,7 +116,7 @@ void ff_h261_reorder_mb_index(MpegEncContext *s)
 
     /* for CIF the GOB's are fragmented in the middle of a scanline
      * that's why we need to adjust the x and y index of the macroblocks */
-    if (ff_h261_get_picture_format(s->width, s->height) == 1) { // CIF
+    if (h->format == H261_CIF) {
         s->mb_x  = index % 11;
         index   /= 11;
         s->mb_y  = index % 3;
@@ -387,7 +374,11 @@ av_cold int ff_h261_encode_init(MpegEncContext *s)
     H261EncContext *const h = (H261EncContext*)s;
     static AVOnce init_static_once = AV_ONCE_INIT;
 
-    if (ff_h261_get_picture_format(s->width, s->height) < 0) {
+    if (s->width == 176 && s->height == 144) {
+        h->format = H261_QCIF;
+    } else if (s->width == 352 && s->height == 288) {
+        h->format = H261_CIF;
+    } else {
         av_log(s->avctx, AV_LOG_ERROR,
                 "The specified picture size of %dx%d is not valid for the "
                 "H.261 codec.\nValid sizes are 176x144, 352x288\n",
diff --git a/libavcodec/h261enc.h b/libavcodec/h261enc.h
index 088cd9f4e0..102e994494 100644
--- a/libavcodec/h261enc.h
+++ b/libavcodec/h261enc.h
@@ -30,7 +30,6 @@
 
 #include "mpegvideo.h"
 
-int ff_h261_get_picture_format(int width, int height);
 void ff_h261_reorder_mb_index(MpegEncContext *s);
 void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
                        int motion_x, int motion_y);
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 6/6] avcodec/mpegvideo_enc: Call ff_mpeg1_encode_init() earlier
  2022-10-02 21:14 [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 5/6] avcodec/h261enc: Store the H.261 format value Andreas Rheinhardt
@ 2022-10-02 21:18 ` Andreas Rheinhardt
  2022-10-05 11:38 ` [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 21:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It does not require anything that is being set between
the new position where it is called and the old position
where it used to be called; and nothing that it sets
gets overwritten between these two positions.
Doing so allows to remove a check lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8d74f9e978..f0fe35d7a3 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -647,17 +647,17 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     s->time_increment_bits = av_log2(avctx->time_base.den - 1) + 1;
 
     switch (avctx->codec->id) {
-    case AV_CODEC_ID_MPEG1VIDEO:
-        s->out_format = FMT_MPEG1;
-        s->low_delay  = !!(avctx->flags & AV_CODEC_FLAG_LOW_DELAY);
-        avctx->delay  = s->low_delay ? 0 : (s->max_b_frames + 1);
-        break;
+#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
     case AV_CODEC_ID_MPEG2VIDEO:
+        s->rtp_mode   = 1;
+        /* fallthrough */
+    case AV_CODEC_ID_MPEG1VIDEO:
         s->out_format = FMT_MPEG1;
         s->low_delay  = !!(avctx->flags & AV_CODEC_FLAG_LOW_DELAY);
         avctx->delay  = s->low_delay ? 0 : (s->max_b_frames + 1);
-        s->rtp_mode   = 1;
+        ff_mpeg1_encode_init(s);
         break;
+#endif
 #if CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER
     case AV_CODEC_ID_MJPEG:
     case AV_CODEC_ID_AMV:
@@ -895,10 +895,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     ff_set_cmp(&s->mecc, s->mecc.ildct_cmp,      avctx->ildct_cmp);
     ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
 
-    if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
-               && s->out_format == FMT_MPEG1) {
-        ff_mpeg1_encode_init(s);
-    } else if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
+    if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
         ff_h263_encode_init(s);
         if (CONFIG_MSMPEG4ENC && s->msmpeg4_version)
             ff_msmpeg4_encode_init(s);
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests
  2022-10-02 21:14 [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
                   ` (4 preceding siblings ...)
  2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 6/6] avcodec/mpegvideo_enc: Call ff_mpeg1_encode_init() earlier Andreas Rheinhardt
@ 2022-10-05 11:38 ` Andreas Rheinhardt
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-10-05 11:38 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> The vsynth3 tests are disabled, because the encoder produces garbage.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  tests/fate/vcodec.mak                     | 9 ++++++++-
>  tests/ref/vsynth/vsynth1-speedhq-420p     | 4 ++++
>  tests/ref/vsynth/vsynth1-speedhq-422p     | 4 ++++
>  tests/ref/vsynth/vsynth1-speedhq-444p     | 4 ++++
>  tests/ref/vsynth/vsynth2-speedhq-420p     | 4 ++++
>  tests/ref/vsynth/vsynth2-speedhq-422p     | 4 ++++
>  tests/ref/vsynth/vsynth2-speedhq-444p     | 4 ++++
>  tests/ref/vsynth/vsynth_lena-speedhq-420p | 4 ++++
>  tests/ref/vsynth/vsynth_lena-speedhq-422p | 4 ++++
>  tests/ref/vsynth/vsynth_lena-speedhq-444p | 4 ++++
>  10 files changed, 44 insertions(+), 1 deletion(-)
>  create mode 100644 tests/ref/vsynth/vsynth1-speedhq-420p
>  create mode 100644 tests/ref/vsynth/vsynth1-speedhq-422p
>  create mode 100644 tests/ref/vsynth/vsynth1-speedhq-444p
>  create mode 100644 tests/ref/vsynth/vsynth2-speedhq-420p
>  create mode 100644 tests/ref/vsynth/vsynth2-speedhq-422p
>  create mode 100644 tests/ref/vsynth/vsynth2-speedhq-444p
>  create mode 100644 tests/ref/vsynth/vsynth_lena-speedhq-420p
>  create mode 100644 tests/ref/vsynth/vsynth_lena-speedhq-422p
>  create mode 100644 tests/ref/vsynth/vsynth_lena-speedhq-444p
> 
> diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
> index 8ca17950ea..1a47fc8bf6 100644
> --- a/tests/fate/vcodec.mak
> +++ b/tests/fate/vcodec.mak
> @@ -413,6 +413,12 @@ FATE_VCODEC-$(call ENCDEC, SNOW, AVI) += snow-ll
>  fate-vsynth%-snow-ll:            ENCOPTS = -qscale .001 -pred 1 \
>                                             -flags +mv4+qpel
>  
> +FATE_VCODEC-$(call ENCDEC, SPEEDHQ, AVI)      += speedhq-420p
> +FATE_VCODEC_SCALE-$(call ENCDEC, SPEEDHQ, AVI) += speedhq-422p speedhq-444p
> +fate-vsynth%-speedhq-420p:       ENCOPTS = -pix_fmt yuv420p -b 600k
> +fate-vsynth%-speedhq-422p:       ENCOPTS = -pix_fmt yuv422p -noise_reduction 1000
> +fate-vsynth%-speedhq-444p:       ENCOPTS = -pix_fmt yuv444p
> +
>  FATE_VCODEC_SCALE-$(call ENCDEC, SVQ1, MOV)   += svq1
>  fate-vsynth%-svq1:               ENCOPTS = -qscale 3 -pix_fmt yuv410p
>  fate-vsynth%-svq1:               FMT     = mov
> @@ -466,7 +472,8 @@ RESIZE_OFF   = dnxhd-720p dnxhd-720p-rd dnxhd-720p-10bit dnxhd-1080i \
>                 vc2-444p vc2-444p10 vc2-444p12 vc2-thaar vc2-t5_3
>  # Incorrect parameters - usually size or color format restrictions
>  INC_PAR_OFF  = cinepak h261 h261-trellis h263 h263p h263-obmc msvideo1 \
> -               roqvideo rv10 rv20 y41p qtrlegray
> +               roqvideo rv10 rv20 speedhq-420p speedhq-422p speedhq-444p \
> +               y41p qtrlegray
>  VSYNTH3_OFF  = $(RESIZE_OFF) $(INC_PAR_OFF)
>  
>  FATE_VCODEC3 = $(filter-out $(VSYNTH3_OFF),$(FATE_VCODEC))
> diff --git a/tests/ref/vsynth/vsynth1-speedhq-420p b/tests/ref/vsynth/vsynth1-speedhq-420p
> new file mode 100644
> index 0000000000..cd44ef662b
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth1-speedhq-420p
> @@ -0,0 +1,4 @@
> +f905e05eabc8be20438d416722c34ed7 *tests/data/fate/vsynth1-speedhq-420p.avi
> +919156 tests/data/fate/vsynth1-speedhq-420p.avi
> +31e9b07d5e8ce0c8b7749e53fba05b1c *tests/data/fate/vsynth1-speedhq-420p.out.rawvideo
> +stddev:   14.06 PSNR: 25.17 MAXDIFF:  145 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth1-speedhq-422p b/tests/ref/vsynth/vsynth1-speedhq-422p
> new file mode 100644
> index 0000000000..adb7aa389f
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth1-speedhq-422p
> @@ -0,0 +1,4 @@
> +8f094b75b93b641c214bfaf743e584ad *tests/data/fate/vsynth1-speedhq-422p.avi
> +1028244 tests/data/fate/vsynth1-speedhq-422p.avi
> +967315914486c7ea979e4ce9ada04a6c *tests/data/fate/vsynth1-speedhq-422p.out.rawvideo
> +stddev:   13.86 PSNR: 25.29 MAXDIFF:  148 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth1-speedhq-444p b/tests/ref/vsynth/vsynth1-speedhq-444p
> new file mode 100644
> index 0000000000..8c7abca7f2
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth1-speedhq-444p
> @@ -0,0 +1,4 @@
> +5008149f0dd3d05d05f8f0f9100d39ec *tests/data/fate/vsynth1-speedhq-444p.avi
> +1347864 tests/data/fate/vsynth1-speedhq-444p.avi
> +23c5db6ca2bdbc52e402cd72ad2fff27 *tests/data/fate/vsynth1-speedhq-444p.out.rawvideo
> +stddev:   12.84 PSNR: 25.95 MAXDIFF:  145 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth2-speedhq-420p b/tests/ref/vsynth/vsynth2-speedhq-420p
> new file mode 100644
> index 0000000000..6f7d4a2a2e
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth2-speedhq-420p
> @@ -0,0 +1,4 @@
> +41795a070c6a13727cd1de7c65abd121 *tests/data/fate/vsynth2-speedhq-420p.avi
> +570618 tests/data/fate/vsynth2-speedhq-420p.avi
> +9f76f7f523a1b1efa99e55ebc874b58d *tests/data/fate/vsynth2-speedhq-420p.out.rawvideo
> +stddev:    8.67 PSNR: 29.37 MAXDIFF:  142 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth2-speedhq-422p b/tests/ref/vsynth/vsynth2-speedhq-422p
> new file mode 100644
> index 0000000000..551047b6ba
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth2-speedhq-422p
> @@ -0,0 +1,4 @@
> +36bfdfdaecbf2938358137a598841377 *tests/data/fate/vsynth2-speedhq-422p.avi
> +622790 tests/data/fate/vsynth2-speedhq-422p.avi
> +3858c3c1524385150b2cff31cdb72e09 *tests/data/fate/vsynth2-speedhq-422p.out.rawvideo
> +stddev:    8.62 PSNR: 29.42 MAXDIFF:  142 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth2-speedhq-444p b/tests/ref/vsynth/vsynth2-speedhq-444p
> new file mode 100644
> index 0000000000..0730ee93db
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth2-speedhq-444p
> @@ -0,0 +1,4 @@
> +62e4caac219e2d79d0c7a8b34b66d4ae *tests/data/fate/vsynth2-speedhq-444p.avi
> +813586 tests/data/fate/vsynth2-speedhq-444p.avi
> +c3fe2a70c17979dbf08100aba9c05934 *tests/data/fate/vsynth2-speedhq-444p.out.rawvideo
> +stddev:    8.35 PSNR: 29.69 MAXDIFF:  142 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth_lena-speedhq-420p b/tests/ref/vsynth/vsynth_lena-speedhq-420p
> new file mode 100644
> index 0000000000..c00b091b28
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth_lena-speedhq-420p
> @@ -0,0 +1,4 @@
> +0669a27deca78e92b998aa5b616f87f2 *tests/data/fate/vsynth_lena-speedhq-420p.avi
> +487888 tests/data/fate/vsynth_lena-speedhq-420p.avi
> +4dc98e7ffb7c1ade85cf6bed75ee9a68 *tests/data/fate/vsynth_lena-speedhq-420p.out.rawvideo
> +stddev:    7.48 PSNR: 30.64 MAXDIFF:  125 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth_lena-speedhq-422p b/tests/ref/vsynth/vsynth_lena-speedhq-422p
> new file mode 100644
> index 0000000000..5ea8b40011
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth_lena-speedhq-422p
> @@ -0,0 +1,4 @@
> +40a9b249daf3cf5ab3fc99a874907c20 *tests/data/fate/vsynth_lena-speedhq-422p.avi
> +536206 tests/data/fate/vsynth_lena-speedhq-422p.avi
> +d48a61d173005609e5e06b0027c98a0e *tests/data/fate/vsynth_lena-speedhq-422p.out.rawvideo
> +stddev:    7.48 PSNR: 30.65 MAXDIFF:  138 bytes:  7603200/  7603200
> diff --git a/tests/ref/vsynth/vsynth_lena-speedhq-444p b/tests/ref/vsynth/vsynth_lena-speedhq-444p
> new file mode 100644
> index 0000000000..0772d0982f
> --- /dev/null
> +++ b/tests/ref/vsynth/vsynth_lena-speedhq-444p
> @@ -0,0 +1,4 @@
> +ce099dfae05cd224ef94c89476176a1c *tests/data/fate/vsynth_lena-speedhq-444p.avi
> +702980 tests/data/fate/vsynth_lena-speedhq-444p.avi
> +e2661cb41d9f59cd1a62b49b3a058e74 *tests/data/fate/vsynth_lena-speedhq-444p.out.rawvideo
> +stddev:    7.23 PSNR: 30.94 MAXDIFF:  125 bytes:  7603200/  7603200

Will apply this patchset tomorrow unless there are objections.

- Andreas

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-05 11:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 21:14 [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt
2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideo_enc: Move SpeedHQ check to speedhqenc.c Andreas Rheinhardt
2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 3/6] avcodec/mpegvideo_enc: Call ff_h261_encode_init() earlier Andreas Rheinhardt
2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 4/6] avcodec/mpegvideo_enc: Move H.261 size check to h261enc.c Andreas Rheinhardt
2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 5/6] avcodec/h261enc: Store the H.261 format value Andreas Rheinhardt
2022-10-02 21:18 ` [FFmpeg-devel] [PATCH 6/6] avcodec/mpegvideo_enc: Call ff_mpeg1_encode_init() earlier Andreas Rheinhardt
2022-10-05 11:38 ` [FFmpeg-devel] [PATCH 1/6] fate/vcodec: Add speedhq tests Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git