[x264-devel] Fix --crop-rect top offset with --interlaced or --fake-interlaced

Anton Mitrofanov git at videolan.org
Mon Mar 11 20:23:59 CET 2019


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Wed Oct 10 19:41:08 2018 +0300| [b048e2658ad6aec55deceb0561db5796cdb64bd2] | committer: Henrik Gramner

Fix --crop-rect top offset with --interlaced or --fake-interlaced

Bug report by Koby Shina.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=b048e2658ad6aec55deceb0561db5796cdb64bd2
---

 encoder/encoder.c | 2 +-
 encoder/set.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 074c4a5c..785d6ed2 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -508,7 +508,7 @@ static int validate_parameters( x264_t *h, int b_open )
     }
 
     int w_mod = 1;
-    int h_mod = 1 << PARAM_INTERLACED;
+    int h_mod = 1 << (PARAM_INTERLACED || h->param.b_fake_interlaced);
     if( i_csp == X264_CSP_I400 )
     {
         h->param.analyse.i_chroma_qp_offset = 0;
diff --git a/encoder/set.c b/encoder/set.c
index 07a1261e..6cfda793 100644
--- a/encoder/set.c
+++ b/encoder/set.c
@@ -250,7 +250,7 @@ void x264_sps_init_reconfigurable( x264_sps_t *sps, x264_param_t *param )
     sps->crop.i_left   = param->crop_rect.i_left;
     sps->crop.i_top    = param->crop_rect.i_top;
     sps->crop.i_right  = param->crop_rect.i_right + sps->i_mb_width*16 - param->i_width;
-    sps->crop.i_bottom = (param->crop_rect.i_bottom + sps->i_mb_height*16 - param->i_height) >> !sps->b_frame_mbs_only;
+    sps->crop.i_bottom = param->crop_rect.i_bottom + sps->i_mb_height*16 - param->i_height;
     sps->b_crop = sps->crop.i_left  || sps->crop.i_top ||
                   sps->crop.i_right || sps->crop.i_bottom;
 
@@ -363,7 +363,7 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps )
     if( sps->b_crop )
     {
         int h_shift = sps->i_chroma_format_idc == CHROMA_420 || sps->i_chroma_format_idc == CHROMA_422;
-        int v_shift = sps->i_chroma_format_idc == CHROMA_420;
+        int v_shift = (sps->i_chroma_format_idc == CHROMA_420) + !sps->b_frame_mbs_only;
         bs_write_ue( s, sps->crop.i_left   >> h_shift );
         bs_write_ue( s, sps->crop.i_right  >> h_shift );
         bs_write_ue( s, sps->crop.i_top    >> v_shift );



More information about the x264-devel mailing list