[FFmpeg-cvslog] avcodec/h263: Move encoder-only part out of ff_h263_update_motion_val()

Andreas Rheinhardt git at videolan.org
Wed Jun 12 14:15:18 EEST 2024


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri May  3 17:25:12 2024 +0200| [2cbca73975c967eae3e704f432df4bd4c830dd58] | committer: Andreas Rheinhardt

avcodec/h263: Move encoder-only part out of ff_h263_update_motion_val()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavcodec/h263.c          |  9 ---------
 libavcodec/h263enc.h       |  2 +-
 libavcodec/ituh263enc.c    | 14 ++++++++++++++
 libavcodec/mpegvideo_enc.c |  4 ++--
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index b30ffaf878..3edf810bcc 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -91,15 +91,6 @@ void ff_h263_update_motion_val(MpegEncContext * s){
         s->current_picture.motion_val[0][xy + 1 + wrap][0] = motion_x;
         s->current_picture.motion_val[0][xy + 1 + wrap][1] = motion_y;
     }
-
-    if(s->encoding){ //FIXME encoding MUST be cleaned up
-        if (s->mv_type == MV_TYPE_8X8)
-            s->current_picture.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_8x8;
-        else if(s->mb_intra)
-            s->current_picture.mb_type[mb_xy] = MB_TYPE_INTRA;
-        else
-            s->current_picture.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_16x16;
-    }
 }
 
 void ff_h263_loop_filter(MpegEncContext * s){
diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h
index e45475686e..cd5ded1593 100644
--- a/libavcodec/h263enc.h
+++ b/libavcodec/h263enc.h
@@ -36,7 +36,7 @@ void ff_init_qscale_tab(MpegEncContext *s);
 void ff_clean_h263_qscales(MpegEncContext *s);
 
 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code);
-
+void ff_h263_update_mb(MpegEncContext *s);
 
 static inline int h263_get_motion_length(int val, int f_code)
 {
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 4741ada853..87689e5f5b 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -688,6 +688,20 @@ void ff_h263_encode_mb(MpegEncContext * s,
     }
 }
 
+void ff_h263_update_mb(MpegEncContext *s)
+{
+    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
+
+    if (s->mv_type == MV_TYPE_8X8)
+        s->current_picture.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_8x8;
+    else if(s->mb_intra)
+        s->current_picture.mb_type[mb_xy] = MB_TYPE_INTRA;
+    else
+        s->current_picture.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_16x16;
+
+    ff_h263_update_motion_val(s);
+}
+
 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code)
 {
     int range, bit_size, sign, code, bits;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ddacfccf5b..a059da700d 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3314,7 +3314,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
 
                 if (CONFIG_H263_ENCODER &&
                     s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
-                    ff_h263_update_motion_val(s);
+                    ff_h263_update_mb(s);
 
                 if(next_block==0){ //FIXME 16 vs linesize16
                     s->hdsp.put_pixels_tab[0][0](s->dest[0], s->sc.rd_scratchpad                     , s->linesize  ,16);
@@ -3440,7 +3440,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
 
                 if (CONFIG_H263_ENCODER &&
                     s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
-                    ff_h263_update_motion_val(s);
+                    ff_h263_update_mb(s);
 
                 mpv_reconstruct_mb(s, s->block);
             }



More information about the ffmpeg-cvslog mailing list