[FFmpeg-devel] [PATCH] Encapsulation func to get width and height most of mb's checked oper are defined in mpegutils' marcos, so mb's checked oper about width/height should be put it together with others.

numberwolf porschegt23 at foxmail.com
Sat Mar 14 18:03:01 EET 2020


Reviewed-by: Carl Eugen Hoyos <ceffmpeg at gmail.com>
Signed-off-by: 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
+
 // does this mb use listX, note does not work if subMBs
 #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list))))
 
-- 
2.17.2 (Apple Git-113)



More information about the ffmpeg-devel mailing list