[FFmpeg-devel] [ffmpeg-devel][PATCH] Encapsulation func to get width and height

Carl Eugen Hoyos ceffmpeg at gmail.com
Sat Mar 14 12:57:24 EET 2020


Am Sa., 14. März 2020 um 10:57 Uhr schrieb numberwolf <porschegt23 at foxmail.com>:
>
> ---
>  libavcodec/mpegutils.c | 4 ++--
>  libavcodec/mpegutils.h | 3 +++
>  2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
> index c0ee3aa..819293c 100644
> --- a/libavcodec/mpegutils.c
> +++ b/libavcodec/mpegutils.c
> @@ -34,8 +34,8 @@ static int add_mb(AVMotionVector *mb, uint32_t mb_type,
>                    int motion_x, int motion_y, int motion_scale,
>                    int direction)
>  {
> -    mb->w = IS_8X8(mb_type) || IS_8X16(mb_type) ? 8 : 16;
> -    mb->h = IS_8X8(mb_type) || IS_16X8(mb_type) ? 8 : 16;
> +    mb->w = MB_SIZE_WIDTH(mb_type);
> +    mb->h = MB_SIZE_HEIGHT(mb_type);
>      mb->motion_x = motion_x;
>      mb->motion_y = motion_y;
>      mb->motion_scale = motion_scale;
> diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
> index 1ed21c1..ed59716 100644
> --- a/libavcodec/mpegutils.h
> +++ b/libavcodec/mpegutils.h
> @@ -95,6 +95,9 @@
>  #define IS_QUANT(a)      ((a) & MB_TYPE_QUANT)
>  #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list))))
>
> +#define MB_SIZE_WIDTH(a)      (((a) & MB_TYPE_8x8) || ((a) & MB_TYPE_8x16)) ? 8 : 16
> +#define MB_SIZE_HEIGHT(a)     (((a) & MB_TYPE_8x8) || ((a) & MB_TYPE_16x8)) ? 8 : 16

Doesn't this patch make the code less readable / isn't the existing macro
enough to easily understand above assignment?

Carl Eugen


More information about the ffmpeg-devel mailing list