[FFmpeg-devel] [PATCH 01/10] avcodec/mpegvideo: Move startcodes to mpeg12.h

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Sep 19 05:14:47 EEST 2021


Andreas Rheinhardt:
> And remove the MPEG-4-specific SLICE_START_CODE, which duplicates
> SLICE_STARTCODE.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
> I can add a commit giving these startcodes a proper MPEG12_ prefix later
> if desired.
> (Some of these startcodes are btw duplicated in lavf/mpegvideodec.c.)
> 
>  libavcodec/ituh263dec.c    |  4 ++--
>  libavcodec/mpeg12.h        | 10 ++++++++++
>  libavcodec/mpeg4videodec.c |  2 +-
>  libavcodec/mpegvideo.h     | 12 ------------
>  4 files changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
> index 565a6a1ac8..3f982f414f 100644
> --- a/libavcodec/ituh263dec.c
> +++ b/libavcodec/ituh263dec.c
> @@ -217,11 +217,11 @@ int ff_h263_resync(MpegEncContext *s){
>      if(s->codec_id==AV_CODEC_ID_MPEG4 && s->studio_profile) {
>          align_get_bits(&s->gb);
>  
> -        while (get_bits_left(&s->gb) >= 32 && show_bits_long(&s->gb, 32) != SLICE_START_CODE) {
> +        while (get_bits_left(&s->gb) >= 32 && show_bits_long(&s->gb, 32) != SLICE_STARTCODE) {
>              get_bits(&s->gb, 8);
>          }
>  
> -        if (get_bits_left(&s->gb) >= 32 && show_bits_long(&s->gb, 32) == SLICE_START_CODE)
> +        if (get_bits_left(&s->gb) >= 32 && show_bits_long(&s->gb, 32) == SLICE_STARTCODE)
>              return get_bits_count(&s->gb);
>          else
>              return -1;
> diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h
> index 4cd48b5d20..a7b94c132a 100644
> --- a/libavcodec/mpeg12.h
> +++ b/libavcodec/mpeg12.h
> @@ -25,6 +25,16 @@
>  #include "mpeg12vlc.h"
>  #include "mpegvideo.h"
>  
> +/* Start codes. */
> +#define SEQ_END_CODE            0x000001b7
> +#define SEQ_START_CODE          0x000001b3
> +#define GOP_START_CODE          0x000001b8
> +#define PICTURE_START_CODE      0x00000100
> +#define SLICE_MIN_START_CODE    0x00000101
> +#define SLICE_MAX_START_CODE    0x000001af
> +#define EXT_START_CODE          0x000001b5
> +#define USER_START_CODE         0x000001b2
> +
>  void ff_mpeg12_common_init(MpegEncContext *s);
>  
>  #define INIT_2D_VLC_RL(rl, static_size, flags)\
> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
> index a6ed842ea2..fcab975a9c 100644
> --- a/libavcodec/mpeg4videodec.c
> +++ b/libavcodec/mpeg4videodec.c
> @@ -550,7 +550,7 @@ int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx)
>      unsigned vlc_len;
>      uint16_t mb_num;
>  
> -    if (get_bits_left(gb) >= 32 && get_bits_long(gb, 32) == SLICE_START_CODE) {
> +    if (get_bits_left(gb) >= 32 && get_bits_long(gb, 32) == SLICE_STARTCODE) {
>          vlc_len = av_log2(s->mb_width * s->mb_height) + 1;
>          mb_num = get_bits(gb, vlc_len);
>  
> diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
> index 76b32ea547..9f8d80df3d 100644
> --- a/libavcodec/mpegvideo.h
> +++ b/libavcodec/mpegvideo.h
> @@ -63,18 +63,6 @@
>  
>  #define MAX_B_FRAMES 16
>  
> -/* Start codes. */
> -#define SEQ_END_CODE            0x000001b7
> -#define SEQ_START_CODE          0x000001b3
> -#define GOP_START_CODE          0x000001b8
> -#define PICTURE_START_CODE      0x00000100
> -#define SLICE_MIN_START_CODE    0x00000101
> -#define SLICE_MAX_START_CODE    0x000001af
> -#define EXT_START_CODE          0x000001b5
> -#define USER_START_CODE         0x000001b2
> -#define SLICE_START_CODE        0x000001b7
> -
> -
>  /**
>   * MpegEncContext.
>   */
> 

Will apply this patchset tomorrow unless there are objections.

- Andreas


More information about the ffmpeg-devel mailing list