diff mbox series

[FFmpeg-devel,36/36] avcodec/mpegvideo_enc: Remove dead code at compile time

Message ID AM7PR03MB6660B6F5BD2E56420C60E4008F7F9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 58f6d1e758b0617cbd30a3ccef647ec655a50ea9
Headers show
Series [FFmpeg-devel,01/14] avcodec/mjpegenc: Use custom close function directly | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Andreas Rheinhardt Dec. 24, 2021, 3:23 a.m. UTC
There are no encoders for interlaced dct that support 4:4:4.

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

Comments

Michael Niedermayer Dec. 24, 2021, 5:17 p.m. UTC | #1
On Fri, Dec 24, 2021 at 04:23:32AM +0100, Andreas Rheinhardt wrote:
> There are no encoders for interlaced dct that support 4:4:4.

i dont remember why its not supported but
why not add 4:4:4 interlaced dct support ?

just thinking as you already work on the code, that would seem to me
the "more interresting" route than to optimize that out

nothing againt this patch of course, thats fine too

thx
[...]
Andreas Rheinhardt Dec. 24, 2021, 6:30 p.m. UTC | #2
Michael Niedermayer:
> On Fri, Dec 24, 2021 at 04:23:32AM +0100, Andreas Rheinhardt wrote:
>> There are no encoders for interlaced dct that support 4:4:4.
> 
> i dont remember why its not supported but
> why not add 4:4:4 interlaced dct support ?
> 
> just thinking as you already work on the code, that would seem to me
> the "more interresting" route than to optimize that out
> 
> nothing againt this patch of course, thats fine too
> 
> thx
> [...]
> 

There are two encoders that support interlaced DCT: mpeg2video and
mpeg4. Our encoder for the former supports 420 and 422; the format also
allows 444. I don't really know how much is missing for supporting this
(it's probably more than just hardcoding a third chroma format in
ff_mpeg1_encode_mb()). And honestly, I don't really want to reread the
mpeg-2 spec to find out, because it is nearly 2022 and MPEG-2 is
obsolete and legacy.

- Andreas
Michael Niedermayer Dec. 24, 2021, 6:36 p.m. UTC | #3
On Fri, Dec 24, 2021 at 07:30:11PM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Fri, Dec 24, 2021 at 04:23:32AM +0100, Andreas Rheinhardt wrote:
> >> There are no encoders for interlaced dct that support 4:4:4.
> > 
> > i dont remember why its not supported but
> > why not add 4:4:4 interlaced dct support ?
> > 
> > just thinking as you already work on the code, that would seem to me
> > the "more interresting" route than to optimize that out
> > 
> > nothing againt this patch of course, thats fine too
> > 
> > thx
> > [...]
> > 
> 
> There are two encoders that support interlaced DCT: mpeg2video and
> mpeg4. Our encoder for the former supports 420 and 422; the format also
> allows 444. I don't really know how much is missing for supporting this
> (it's probably more than just hardcoding a third chroma format in
> ff_mpeg1_encode_mb()). And honestly, I don't really want to reread the
> mpeg-2 spec to find out, because it is nearly 2022 and MPEG-2 is
> obsolete and legacy.

our decoder should support 444 i dont remember anything special
but i agree, it makes little sense for a old format unless one
enjoys doing it

thx


[...]
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 0ac8886246..15b6669e46 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2035,6 +2035,10 @@  static av_always_inline void encode_mb_internal(MpegEncContext *s,
                                                 int chroma_y_shift,
                                                 int chroma_format)
 {
+/* Interlaced DCT is only possible with MPEG-2 and MPEG-4
+ * and neither of these encoders currently supports 444. */
+#define INTERLACED_DCT(s) ((chroma_format == CHROMA_420 || chroma_format == CHROMA_422) && \
+                           (s)->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT)
     int16_t weight[12][64];
     int16_t orig[12][64];
     const int mb_x = s->mb_x;
@@ -2112,7 +2116,7 @@  static av_always_inline void encode_mb_internal(MpegEncContext *s,
     }
 
     if (s->mb_intra) {
-        if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+        if (INTERLACED_DCT(s)) {
             int progressive_score, interlaced_score;
 
             s->interlaced_dct = 0;
@@ -2191,7 +2195,7 @@  static av_always_inline void encode_mb_internal(MpegEncContext *s,
                           op_pix, op_qpix);
         }
 
-        if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+        if (INTERLACED_DCT(s)) {
             int progressive_score, interlaced_score;
 
             s->interlaced_dct = 0;