[FFmpeg-devel] [PATCH 1/2] avcodec/mpeg4video: Split off data in a header of its own

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jan 12 11:51:48 EET 2022


Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/ituh263enc.c     |  1 -
>  libavcodec/mpeg4data.h      |  3 +-
>  libavcodec/mpeg4video.h     | 35 ---------------------
>  libavcodec/mpeg4videodata.h | 61 +++++++++++++++++++++++++++++++++++++
>  libavcodec/mpeg4videodec.c  |  3 ++
>  libavcodec/mpeg4videoenc.c  |  1 +
>  libavcodec/mpegvideo_enc.c  |  1 +
>  libavcodec/msmpeg4.c        |  2 +-
>  libavcodec/msmpeg4data.c    |  2 +-
>  9 files changed, 69 insertions(+), 40 deletions(-)
>  create mode 100644 libavcodec/mpeg4videodata.h
> 
> diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
> index d944c4879f..5a7791111e 100644
> --- a/libavcodec/ituh263enc.c
> +++ b/libavcodec/ituh263enc.c
> @@ -39,7 +39,6 @@
>  #include "mathops.h"
>  #include "mpegutils.h"
>  #include "flv.h"
> -#include "mpeg4video.h"
>  #include "internal.h"
>  
>  /**
> diff --git a/libavcodec/mpeg4data.h b/libavcodec/mpeg4data.h
> index 30179d9801..c5a2b14721 100644
> --- a/libavcodec/mpeg4data.h
> +++ b/libavcodec/mpeg4data.h
> @@ -28,8 +28,7 @@
>  #ifndef AVCODEC_MPEG4DATA_H
>  #define AVCODEC_MPEG4DATA_H
>  
> -#include <stdint.h>
> -#include "mpegvideo.h"
> +#include "mpeg4videodata.h"
>  
>  /* dc encoding for MPEG-4 */
>  const uint8_t ff_mpeg4_DCtab_lum[13][2] =
> diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
> index cec8b30c32..87d9c9996e 100644
> --- a/libavcodec/mpeg4video.h
> +++ b/libavcodec/mpeg4video.h
> @@ -27,7 +27,6 @@
>  
>  #include "get_bits.h"
>  #include "mpegvideo.h"
> -#include "rl.h"
>  
>  // shapes
>  #define RECT_SHAPE       0
> @@ -118,40 +117,6 @@ typedef struct Mpeg4DecContext {
>      int rgb;
>  } Mpeg4DecContext;
>  
> -static const uint8_t mpeg4_block_count[4] = {0, 6, 8, 12};
> -
> -/* dc encoding for MPEG-4 */
> -extern const uint8_t ff_mpeg4_DCtab_lum[13][2];
> -extern const uint8_t ff_mpeg4_DCtab_chrom[13][2];
> -
> -extern const uint16_t ff_mpeg4_intra_vlc[103][2];
> -extern const int8_t ff_mpeg4_intra_level[102];
> -extern const int8_t ff_mpeg4_intra_run[102];
> -
> -extern RLTable ff_mpeg4_rl_intra;
> -void ff_mpeg4_init_rl_intra(void);
> -
> -/* Note this is identical to the intra rvlc except that it is reordered. */
> -extern RLTable ff_rvlc_rl_inter;
> -extern RLTable ff_rvlc_rl_intra;
> -
> -extern const uint8_t ff_sprite_trajectory_lens[15];
> -extern const uint8_t ff_mb_type_b_tab[4][2];
> -
> -/* these matrixes will be permuted for the idct */
> -extern const int16_t ff_mpeg4_default_intra_matrix[64];
> -extern const int16_t ff_mpeg4_default_non_intra_matrix[64];
> -
> -extern const uint8_t ff_mpeg4_y_dc_scale_table[32];
> -extern const uint8_t ff_mpeg4_c_dc_scale_table[32];
> -extern const uint16_t ff_mpeg4_resync_prefix[8];
> -
> -extern const uint8_t ff_mpeg4_dc_threshold[8];
> -
> -extern const uint8_t ff_mpeg4_studio_dc_luma[19][2];
> -extern const uint8_t ff_mpeg4_studio_dc_chroma[19][2];
> -extern const uint8_t ff_mpeg4_studio_intra[12][24][2];
> -
>  void ff_mpeg4_encode_mb(MpegEncContext *s,
>                          int16_t block[6][64],
>                          int motion_x, int motion_y);
> diff --git a/libavcodec/mpeg4videodata.h b/libavcodec/mpeg4videodata.h
> new file mode 100644
> index 0000000000..b20096067a
> --- /dev/null
> +++ b/libavcodec/mpeg4videodata.h
> @@ -0,0 +1,61 @@
> +/*
> + * MPEG-4 encoder/decoder data.
> + * Copyright (c) 2000,2001 Fabrice Bellard
> + * Copyright (c) 2002-2010 Michael Niedermayer <michaelni at gmx.at>
> + *
> + * 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_MPEG4VIDEODATA_H
> +#define AVCODEC_MPEG4VIDEODATA_H
> +
> +#include <stdint.h>
> +#include "rl.h"
> +
> +/* dc encoding for MPEG-4 */
> +extern const uint8_t ff_mpeg4_DCtab_lum[13][2];
> +extern const uint8_t ff_mpeg4_DCtab_chrom[13][2];
> +
> +extern const uint16_t ff_mpeg4_intra_vlc[103][2];
> +extern const int8_t ff_mpeg4_intra_level[102];
> +extern const int8_t ff_mpeg4_intra_run[102];
> +
> +extern RLTable ff_mpeg4_rl_intra;
> +void ff_mpeg4_init_rl_intra(void);
> +
> +/* Note this is identical to the intra rvlc except that it is reordered. */
> +extern RLTable ff_rvlc_rl_inter;
> +extern RLTable ff_rvlc_rl_intra;
> +
> +extern const uint8_t ff_sprite_trajectory_lens[15];
> +extern const uint8_t ff_mb_type_b_tab[4][2];
> +
> +/* these matrixes will be permuted for the idct */
> +extern const int16_t ff_mpeg4_default_intra_matrix[64];
> +extern const int16_t ff_mpeg4_default_non_intra_matrix[64];
> +
> +extern const uint8_t ff_mpeg4_y_dc_scale_table[32];
> +extern const uint8_t ff_mpeg4_c_dc_scale_table[32];
> +extern const uint16_t ff_mpeg4_resync_prefix[8];
> +
> +extern const uint8_t ff_mpeg4_dc_threshold[8];
> +
> +extern const uint8_t ff_mpeg4_studio_dc_luma[19][2];
> +extern const uint8_t ff_mpeg4_studio_dc_chroma[19][2];
> +extern const uint8_t ff_mpeg4_studio_intra[12][24][2];
> +
> +#endif /* AVCODEC_MPEG4VIDEO_H */
> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
> index 325593a795..37088b7a6b 100644
> --- a/libavcodec/mpeg4videodec.c
> +++ b/libavcodec/mpeg4videodec.c
> @@ -34,6 +34,7 @@
>  #include "mpegvideo.h"
>  #include "mpegvideodata.h"
>  #include "mpeg4video.h"
> +#include "mpeg4videodata.h"
>  #include "h263.h"
>  #include "profiles.h"
>  #include "thread.h"
> @@ -56,6 +57,8 @@ static VLC studio_intra_tab[12];
>  static VLC studio_luma_dc;
>  static VLC studio_chroma_dc;
>  
> +static const uint8_t mpeg4_block_count[4] = { 0, 6, 8, 12 };
> +
>  static const int mb_type_b_map[4] = {
>      MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
>      MB_TYPE_L0L1    | MB_TYPE_16x16,
> diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
> index b77653d453..8871d83281 100644
> --- a/libavcodec/mpeg4videoenc.c
> +++ b/libavcodec/mpeg4videoenc.c
> @@ -28,6 +28,7 @@
>  #include "mpegvideo.h"
>  #include "h263.h"
>  #include "mpeg4video.h"
> +#include "mpeg4videodata.h"
>  #include "profiles.h"
>  
>  /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index 15b6669e46..afad9c8be1 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -64,6 +64,7 @@
>  #include "aandcttab.h"
>  #include "flv.h"
>  #include "mpeg4video.h"
> +#include "mpeg4videodata.h"
>  #include "internal.h"
>  #include "bytestream.h"
>  #include "wmv2.h"
> diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
> index e76aec6dfc..f12586dd64 100644
> --- a/libavcodec/msmpeg4.c
> +++ b/libavcodec/msmpeg4.c
> @@ -34,7 +34,7 @@
>  #include "mpegvideo.h"
>  #include "msmpeg4.h"
>  #include "libavutil/x86/asm.h"
> -#include "mpeg4video.h"
> +#include "mpeg4videodata.h"
>  #include "msmpeg4data.h"
>  #include "mpegvideodata.h"
>  #include "vc1data.h"
> diff --git a/libavcodec/msmpeg4data.c b/libavcodec/msmpeg4data.c
> index a3a8144664..63f30ac544 100644
> --- a/libavcodec/msmpeg4data.c
> +++ b/libavcodec/msmpeg4data.c
> @@ -28,7 +28,7 @@
>   */
>  
>  #include "h263data.h"
> -#include "mpeg4video.h"
> +#include "mpeg4videodata.h"
>  #include "msmpeg4data.h"
>  
>  uint32_t ff_v2_dc_lum_table[512][2];
> 

Will apply this patchset tomorrow unless there are objections.

- Andreas


More information about the ffmpeg-devel mailing list