[FFmpeg-cvslog] mpegvideo: convert mpegvideo_common.h to a .c file

Mans Rullgard git at videolan.org
Thu Aug 9 19:34:53 CEST 2012


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Sat Aug  4 00:50:21 2012 +0100| [7a851153d3fe1a9e0d60bf11053870d1ea8241e6] | committer: Mans Rullgard

mpegvideo: convert mpegvideo_common.h to a .c file

This file defines a single, huge function, MPV_motion(), which
although being declared inline is not actually inlined by the
compiler (for good reason).  There is thus no sense in defining
this function in a header file, resulting in multiple copies of
it in the final library.

Signed-off-by: Mans Rullgard <mans at mansr.com>

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

 libavcodec/Makefile                                |    2 +-
 libavcodec/dnxhdenc.c                              |    1 -
 libavcodec/mpegvideo.c                             |    5 ++--
 libavcodec/mpegvideo.h                             |   15 ++++++++++
 libavcodec/mpegvideo_enc.c                         |   11 +++----
 .../{mpegvideo_common.h => mpegvideo_motion.c}     |   30 ++++----------------
 6 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6dde8a6..655e828 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -50,7 +50,7 @@ OBJS-$(CONFIG_MDCT)                    += mdct_fixed.o mdct_float.o
 OBJS-$(CONFIG_MPEGAUDIODSP)            += mpegaudiodsp.o                \
                                           mpegaudiodsp_fixed.o          \
                                           mpegaudiodsp_float.o
-OBJS-$(CONFIG_MPEGVIDEO)               += mpegvideo.o
+OBJS-$(CONFIG_MPEGVIDEO)               += mpegvideo.o mpegvideo_motion.o
 RDFT-OBJS-$(CONFIG_HARDCODED_TABLES)   += sin_tables.o
 OBJS-$(CONFIG_RDFT)                    += rdft.o $(RDFT-OBJS-yes)
 OBJS-$(CONFIG_SINEWIN)                 += sinewin.o
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index aca5497..523d1c0 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -31,7 +31,6 @@
 #include "dsputil.h"
 #include "internal.h"
 #include "mpegvideo.h"
-#include "mpegvideo_common.h"
 #include "dnxhdenc.h"
 
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 4fb5949..8f3544f 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -33,7 +33,6 @@
 #include "dsputil.h"
 #include "internal.h"
 #include "mpegvideo.h"
-#include "mpegvideo_common.h"
 #include "mjpegenc.h"
 #include "msmpeg4.h"
 #include "xvmc_internal.h"
@@ -2035,12 +2034,12 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
                     op_pix = s->dsp.put_no_rnd_pixels_tab;
                 }
                 if (s->mv_dir & MV_DIR_FORWARD) {
-                    MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix);
+                    ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix);
                     op_pix = s->dsp.avg_pixels_tab;
                     op_qpix= s->me.qpel_avg;
                 }
                 if (s->mv_dir & MV_DIR_BACKWARD) {
-                    MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix);
+                    ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix);
                 }
             }
 
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 5c537da..80fa0fa 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -739,6 +739,13 @@ static const AVClass name ## _class = {\
     .version    = LIBAVUTIL_VERSION_INT,\
 };
 
+/**
+ * Set the given MpegEncContext to common defaults (same for encoding
+ * and decoding).  The changed fields will not depend upon the prior
+ * state of the MpegEncContext.
+ */
+void ff_MPV_common_defaults(MpegEncContext *s);
+
 void ff_MPV_decode_defaults(MpegEncContext *s);
 int ff_MPV_common_init(MpegEncContext *s);
 void ff_MPV_common_end(MpegEncContext *s);
@@ -777,10 +784,18 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int en
 int ff_dct_common_init(MpegEncContext *s);
 void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],
                        const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra);
+int ff_dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
 
 void ff_init_block_index(MpegEncContext *s);
 void ff_copy_picture(Picture *dst, Picture *src);
 
+void ff_MPV_motion(MpegEncContext *s,
+                   uint8_t *dest_y, uint8_t *dest_cb,
+                   uint8_t *dest_cr, int dir,
+                   uint8_t **ref_picture,
+                   op_pixels_func (*pix_op)[4],
+                   qpel_mc_func (*qpix_op)[16]);
+
 /**
  * Allocate a Picture.
  * The pixels are allocated/set by calling get_buffer() if shared = 0.
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index e84b0da..d527ace 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -33,7 +33,6 @@
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
-#include "mpegvideo_common.h"
 #include "h263.h"
 #include "mjpegenc.h"
 #include "msmpeg4.h"
@@ -1850,14 +1849,16 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
         }
 
         if (s->mv_dir & MV_DIR_FORWARD) {
-            MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data,
-                       op_pix, op_qpix);
+            ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0,
+                          s->last_picture.f.data,
+                          op_pix, op_qpix);
             op_pix  = s->dsp.avg_pixels_tab;
             op_qpix = s->dsp.avg_qpel_pixels_tab;
         }
         if (s->mv_dir & MV_DIR_BACKWARD) {
-            MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data,
-                       op_pix, op_qpix);
+            ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1,
+                          s->next_picture.f.data,
+                          op_pix, op_qpix);
         }
 
         if (s->flags & CODEC_FLAG_INTERLACED_DCT) {
diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_motion.c
similarity index 97%
rename from libavcodec/mpegvideo_common.h
rename to libavcodec/mpegvideo_motion.c
index 224ec98..ea06953 100644
--- a/libavcodec/mpegvideo_common.h
+++ b/libavcodec/mpegvideo_motion.c
@@ -1,5 +1,4 @@
 /*
- * The simplest mpeg encoder (well, it was the simplest!)
  * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
@@ -22,14 +21,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/**
- * @file
- * The simplest mpeg encoder (well, it was the simplest!).
- */
-
-#ifndef AVCODEC_MPEGVIDEO_COMMON_H
-#define AVCODEC_MPEGVIDEO_COMMON_H
-
 #include <string.h>
 #include "avcodec.h"
 #include "dsputil.h"
@@ -38,14 +29,6 @@
 #include "msmpeg4.h"
 #include <limits.h>
 
-int ff_dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
-
-/**
- * Set the given MpegEncContext to common defaults (same for encoding and decoding).
- * The changed fields will not depend upon the prior state of the MpegEncContext.
- */
-void ff_MPV_common_defaults(MpegEncContext *s);
-
 static inline void gmc1_motion(MpegEncContext *s,
                                uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
                                uint8_t **ref_picture)
@@ -874,12 +857,12 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
     }
 }
 
-static inline void MPV_motion(MpegEncContext *s,
-                              uint8_t *dest_y, uint8_t *dest_cb,
-                              uint8_t *dest_cr, int dir,
-                              uint8_t **ref_picture,
-                              op_pixels_func (*pix_op)[4],
-                              qpel_mc_func (*qpix_op)[16])
+void ff_MPV_motion(MpegEncContext *s,
+                   uint8_t *dest_y, uint8_t *dest_cb,
+                   uint8_t *dest_cr, int dir,
+                   uint8_t **ref_picture,
+                   op_pixels_func (*pix_op)[4],
+                   qpel_mc_func (*qpix_op)[16])
 {
 #if !CONFIG_SMALL
     if(s->out_format == FMT_MPEG1)
@@ -890,4 +873,3 @@ static inline void MPV_motion(MpegEncContext *s,
         MPV_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
                             ref_picture, pix_op, qpix_op, 0);
 }
-#endif /* AVCODEC_MPEGVIDEO_COMMON_H */



More information about the ffmpeg-cvslog mailing list