Эх сурвалжийг харах

avcodec/mpeg12: Inline ff_mpeg1_clean_buffers() into its callers

This function is extremely small, so inlining it is appropriate (and
actually beneficial size-wise here). It furthermore allows to remove
the mpeg12codecs.h header and the mpeg12-encoders->mpeg12.o dependency.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Andreas Rheinhardt 5 өдөр өмнө
parent
commit
2586763376

+ 2 - 2
libavcodec/Makefile

@@ -566,14 +566,14 @@ OBJS-$(CONFIG_MPC7_DECODER)            += mpc7.o mpc.o
 OBJS-$(CONFIG_MPC8_DECODER)            += mpc8.o mpc.o
 OBJS-$(CONFIG_MPEGVIDEO_DECODER)       += mpeg12dec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_MPEG1VIDEO_DECODER)      += mpeg12dec.o mpeg12.o mpeg12data.o
-OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
+OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o
 OBJS-$(CONFIG_MPEG1_CUVID_DECODER)     += cuviddec.o
 OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER)   += v4l2_m2m_dec.o
 OBJS-$(CONFIG_MPEG2_MMAL_DECODER)      += mmaldec.o
 OBJS-$(CONFIG_MPEG2_QSV_DECODER)       += qsvdec.o
 OBJS-$(CONFIG_MPEG2_QSV_ENCODER)       += qsvenc_mpeg2.o
 OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12dec.o mpeg12.o mpeg12data.o
-OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
+OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o
 OBJS-$(CONFIG_MPEG2_CUVID_DECODER)     += cuviddec.o
 OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER)     += vaapi_encode_mpeg2.o

+ 0 - 10
libavcodec/mpeg12.c

@@ -30,8 +30,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/thread.h"
 
-#include "mpegvideo.h"
-#include "mpeg12codecs.h"
 #include "mpeg12data.h"
 #include "mpeg12dec.h"
 #include "mpegutils.h"
@@ -122,14 +120,6 @@ av_cold void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc
     }
 }
 
-void ff_mpeg1_clean_buffers(MpegEncContext *s)
-{
-    s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
-    s->last_dc[1] = s->last_dc[0];
-    s->last_dc[2] = s->last_dc[0];
-    memset(s->last_mv, 0, sizeof(s->last_mv));
-}
-
 
 /******************************************/
 /* decoding */

+ 0 - 29
libavcodec/mpeg12codecs.h

@@ -1,29 +0,0 @@
-/*
- * MPEG-1/2 codecs common code
- * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_MPEG12CODECS_H
-#define AVCODEC_MPEG12CODECS_H
-
-#include "mpegvideo.h"
-
-void ff_mpeg1_clean_buffers(MpegEncContext *s);
-
-#endif /* AVCODEC_MPEG12CODECS_H */

+ 5 - 2
libavcodec/mpeg12dec.c

@@ -50,7 +50,6 @@
 #include "idctdsp.h"
 #include "mpeg_er.h"
 #include "mpeg12.h"
-#include "mpeg12codecs.h"
 #include "mpeg12data.h"
 #include "mpeg12dec.h"
 #include "mpegutils.h"
@@ -1375,7 +1374,6 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, int mb_y,
     if (s->c.codec_id != AV_CODEC_ID_MPEG1VIDEO && s->c.mb_height > 2800/16)
         skip_bits(&s->gb, 3);
 
-    ff_mpeg1_clean_buffers(&s->c);
     s->c.interlaced_dct = 0;
 
     s->c.qscale = mpeg_get_qscale(&s->gb, s->c.q_scale_type);
@@ -1455,6 +1453,11 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, int mb_y,
         }
     }
 
+    s->c.last_dc[0] = 128 << s->c.intra_dc_precision;
+    s->c.last_dc[1] = s->c.last_dc[0];
+    s->c.last_dc[2] = s->c.last_dc[0];
+    memset(s->c.last_mv, 0, sizeof(s->c.last_mv));
+
     for (int mb_skip_run = 0;;) {
         ret = mpeg_decode_mb(s, &mb_skip_run);
         if (ret < 0)

+ 8 - 0
libavcodec/mpeg12enc.h

@@ -36,4 +36,12 @@ static inline void ff_mpeg1_encode_init(MPVEncContext *s)
     s->c.c_dc_scale_table = ff_mpeg12_dc_scale_table[s->c.intra_dc_precision];
 }
 
+static inline void ff_mpeg1_clean_buffers(MPVEncContext *s)
+{
+    s->c.last_dc[0] = 128 << s->c.intra_dc_precision;
+    s->c.last_dc[1] = s->c.last_dc[0];
+    s->c.last_dc[2] = s->c.last_dc[0];
+    memset(s->c.last_mv, 0, sizeof(s->c.last_mv));
+}
+
 #endif /* AVCODEC_MPEG12ENC_H */

+ 1 - 2
libavcodec/mpegvideo_enc.c

@@ -47,7 +47,6 @@
 #include "avcodec.h"
 #include "encode.h"
 #include "idctdsp.h"
-#include "mpeg12codecs.h"
 #include "mpeg12data.h"
 #include "mpeg12enc.h"
 #include "mpegvideo.h"
@@ -3144,7 +3143,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
                     case AV_CODEC_ID_MPEG2VIDEO:
                         if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
                             ff_mpeg1_encode_slice_header(s);
-                            ff_mpeg1_clean_buffers(&s->c);
+                            ff_mpeg1_clean_buffers(s);
                         }
                     break;
 #if CONFIG_H263P_ENCODER