[vlc-commits] [Git][videolan/vlc][master] 3 commits: hxxx_helper: provide picture left/top crop info

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Sep 13 11:01:29 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
7923ce4e by Francois Cartegnie at 2023-09-13T17:27:41+07:00
hxxx_helper: provide picture left/top crop info

- - - - -
587b9280 by Francois Cartegnie at 2023-09-13T17:27:42+07:00
packetizer: h264: provide picture left/top crop info

- - - - -
8c047bb4 by Francois Cartegnie at 2023-09-13T17:27:42+07:00
packetizer: hevc: provide picture left/top crop info

- - - - -


12 changed files:

- modules/codec/hxxx_helper.c
- modules/codec/hxxx_helper.h
- modules/codec/hxxx_helper_testdec.c
- modules/codec/omxil/mediacodec.c
- modules/codec/videotoolbox/decoder.c
- modules/hw/nvdec/nvdec.c
- modules/packetizer/h264.c
- modules/packetizer/h264_nal.c
- modules/packetizer/h264_nal.h
- modules/packetizer/hevc.c
- modules/packetizer/hevc_nal.c
- modules/packetizer/hevc_nal.h


Changes:

=====================================
modules/codec/hxxx_helper.c
=====================================
@@ -810,19 +810,20 @@ h264_helper_get_current_sps(const struct hxxx_helper *hh)
 
 int
 hxxx_helper_get_current_picture_size(const struct hxxx_helper *hh,
+                                     unsigned *p_ox, unsigned *p_oy,
                                      unsigned *p_w, unsigned *p_h,
                                      unsigned *p_vw, unsigned *p_vh)
 {
     if(hh->i_codec == VLC_CODEC_H264)
     {
         const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
-        if (hsps && h264_get_picture_size(hsps->h264_sps, p_w, p_h, p_vw, p_vh))
+        if (hsps && h264_get_picture_size(hsps->h264_sps, p_ox, p_oy, p_w, p_h, p_vw, p_vh))
                return VLC_SUCCESS;
     }
     else if(hh->i_codec == VLC_CODEC_HEVC)
     {
         const struct hxxx_helper_nal *hsps = &hh->hevc.sps_list[hh->hevc.i_current_sps];
-        if(hsps && hsps->hevc_sps && hevc_get_picture_size(hsps->hevc_sps, p_w, p_h, p_vw, p_vh))
+        if(hsps && hsps->hevc_sps && hevc_get_picture_size(hsps->hevc_sps, p_ox, p_oy, p_w, p_h, p_vw, p_vh))
             return VLC_SUCCESS;
     }
     return VLC_EGENERIC;


=====================================
modules/codec/hxxx_helper.h
=====================================
@@ -112,6 +112,7 @@ block_t * hxxx_helper_get_extradata_chain(const struct hxxx_helper *hh);
 block_t * hxxx_helper_get_extradata_block(const struct hxxx_helper *hh);
 
 int hxxx_helper_get_current_picture_size(const struct hxxx_helper *hh,
+                                         unsigned *p_ox, unsigned *p_oy,
                                          unsigned *p_w, unsigned *p_h,
                                          unsigned *p_vw, unsigned *p_vh);
 


=====================================
modules/codec/hxxx_helper_testdec.c
=====================================
@@ -68,12 +68,15 @@ DecodeBlock(decoder_t *dec, block_t *block)
             dec->fmt_out.video.color_range = full_range;
         }
 
-        unsigned width, height, vis_width, vis_height;
+        unsigned offx, offy, width, height, vis_width, vis_height;
         ret = hxxx_helper_get_current_picture_size(&sys->hh,
+                                                   &offx, &offy,
                                                    &width, &height,
                                                    &vis_width, &vis_height);
         if (ret == VLC_SUCCESS)
         {
+            dec->fmt_out.video.i_x_offset = offx;
+            dec->fmt_out.video.i_y_offset = offy;
             dec->fmt_out.video.i_width =
             dec->fmt_out.video.i_visible_width = vis_width;
             dec->fmt_out.video.i_height =


=====================================
modules/codec/omxil/mediacodec.c
=====================================
@@ -131,6 +131,7 @@ typedef struct decoder_sys_t
             struct android_picture_ctx apic_ctxs[MAX_PIC];
             void *p_surface, *p_jsurface;
             unsigned i_angle;
+            unsigned i_input_offset_x, i_input_offset_y;
             unsigned i_input_width, i_input_height;
             unsigned i_input_visible_width, i_input_visible_height;
             unsigned int i_stride, i_slice_height;
@@ -269,14 +270,16 @@ static void HXXXInitSize(decoder_t *p_dec, bool *p_size_changed)
     {
         decoder_sys_t *p_sys = p_dec->p_sys;
         struct hxxx_helper *hh = &p_sys->video.hh;
-        unsigned i_w, i_h, i_vw, i_vh;
-        if(hxxx_helper_get_current_picture_size(hh, &i_w, &i_h, &i_vw, &i_vh)
+        unsigned i_ox, i_oy, i_w, i_h, i_vw, i_vh;
+        if(hxxx_helper_get_current_picture_size(hh, &i_ox, &i_oy, &i_w, &i_h, &i_vw, &i_vh)
            == VLC_SUCCESS)
         {
             *p_size_changed = (i_w != p_sys->video.i_input_width
                             || i_h != p_sys->video.i_input_height
                             || i_vw != p_sys->video.i_input_visible_width
                             || i_vh != p_sys->video.i_input_visible_height);
+            p_sys->video.i_input_offset_x = i_ox;
+            p_sys->video.i_input_offset_y = i_oy;
             p_sys->video.i_input_width = i_w;
             p_sys->video.i_input_height = i_h;
             p_sys->video.i_input_visible_width = i_vw;


=====================================
modules/codec/videotoolbox/decoder.c
=====================================
@@ -561,12 +561,15 @@ static bool ConfigureVoutH264(decoder_t *p_dec)
 
     if (!p_dec->fmt_in->video.i_visible_width || !p_dec->fmt_in->video.i_visible_height)
     {
-        unsigned i_width, i_height, i_vis_width, i_vis_height;
+        unsigned i_offset_x, i_offset_y, i_width, i_height, i_vis_width, i_vis_height;
         if (VLC_SUCCESS ==
            hxxx_helper_get_current_picture_size(&h264ctx->hh,
+                                                &i_offset_x, &i_offset_y,
                                                 &i_width, &i_height,
                                                 &i_vis_width, &i_vis_height))
         {
+            p_dec->fmt_out.video.i_x_offset = i_offset_x;
+            p_dec->fmt_out.video.i_y_offset = i_offset_y;
             p_dec->fmt_out.video.i_visible_width = i_vis_width;
             p_dec->fmt_out.video.i_width = vlc_align(i_width, VT_ALIGNMENT);
             p_dec->fmt_out.video.i_visible_height = i_vis_height;
@@ -596,10 +599,10 @@ static bool VideoToolboxNeedsToRestartH264(decoder_t *p_dec,
     struct vt_h264_context *h264ctx = p_sys->p_codec_context;
     const struct hxxx_helper *hh = &h264ctx->hh;
 
-    unsigned w, h, vw, vh;
+    unsigned ox, oy, w, h, vw, vh;
     int sarn, sard;
 
-    if (hxxx_helper_get_current_picture_size(hh, &w, &h, &vw, &vh) != VLC_SUCCESS)
+    if (hxxx_helper_get_current_picture_size(hh, &ox, &oy, &w, &h, &vw, &vh) != VLC_SUCCESS)
         return true;
 
     if (hxxx_helper_get_current_sar(hh, &sarn, &sard) != VLC_SUCCESS)


=====================================
modules/hw/nvdec/nvdec.c
=====================================
@@ -884,8 +884,8 @@ static int OpenDecoder(vlc_object_t *p_this)
             goto error;
         cudaChroma = MapChomaIDC(i_chroma_idc);
 
-        unsigned i_w, i_h, i_vw, i_vh;
-        result = hxxx_helper_get_current_picture_size(&p_sys->hh, &i_w, &i_h, &i_vw, &i_vh);
+        unsigned i_ox, i_oy, i_w, i_h, i_vw, i_vh;
+        result = hxxx_helper_get_current_picture_size(&p_sys->hh, &i_ox, &i_oy, &i_w, &i_h, &i_vw, &i_vh);
         if (result != VLC_SUCCESS)
             goto error;
 
@@ -911,6 +911,9 @@ static int OpenDecoder(vlc_object_t *p_this)
         p_dec->fmt_out.video.i_width = vlc_align(i_w, OUTPUT_WIDTH_ALIGN);
         p_dec->fmt_out.video.i_height = i_h;
 
+        p_dec->fmt_out.video.i_x_offset = i_ox;
+        p_dec->fmt_out.video.i_y_offset = i_oy;
+
         if (!p_dec->fmt_in->video.i_visible_width || !p_dec->fmt_in->video.i_visible_height)
         {
             p_dec->fmt_out.video.i_visible_width = i_vw;


=====================================
modules/packetizer/h264.c
=====================================
@@ -205,7 +205,10 @@ static void ActivateSets( decoder_t *p_dec, const h264_sequence_parameter_set_t
         p_dec->fmt_out.i_profile = p_sps->i_profile;
         p_dec->fmt_out.i_level = p_sps->i_level;
 
-        (void) h264_get_picture_size( p_sps, &p_dec->fmt_out.video.i_width,
+        (void) h264_get_picture_size( p_sps,
+                                      &p_dec->fmt_out.video.i_x_offset,
+                                      &p_dec->fmt_out.video.i_y_offset,
+                                      &p_dec->fmt_out.video.i_width,
                                       &p_dec->fmt_out.video.i_height,
                                       &p_dec->fmt_out.video.i_visible_width,
                                       &p_dec->fmt_out.video.i_visible_height );


=====================================
modules/packetizer/h264_nal.c
=====================================
@@ -845,7 +845,9 @@ bool h264_get_dpb_values( const h264_sequence_parameter_set_t *p_sps,
     return true;
 }
 
-bool h264_get_picture_size( const h264_sequence_parameter_set_t *p_sps, unsigned *p_w, unsigned *p_h,
+bool h264_get_picture_size( const h264_sequence_parameter_set_t *p_sps,
+                            unsigned *p_ox, unsigned *p_oy,
+                            unsigned *p_w, unsigned *p_h,
                             unsigned *p_vw, unsigned *p_vh )
 {
     unsigned CropUnitX = 1;
@@ -871,6 +873,8 @@ bool h264_get_picture_size( const h264_sequence_parameter_set_t *p_sps, unsigned
     *p_h = 16 * p_sps->pic_height_in_map_units_minus1 + 16;
     *p_h *= ( 2 - p_sps->frame_mbs_only_flag );
 
+    *p_ox = p_sps->frame_crop.left_offset * CropUnitX;
+    *p_oy = p_sps->frame_crop.top_offset * CropUnitY;
     *p_vw = *p_w - ( p_sps->frame_crop.left_offset + p_sps->frame_crop.right_offset ) * CropUnitX;
     *p_vh = *p_h - ( p_sps->frame_crop.bottom_offset + p_sps->frame_crop.top_offset ) * CropUnitY;
 


=====================================
modules/packetizer/h264_nal.h
=====================================
@@ -207,7 +207,9 @@ uint8_t * h264_avcC_to_AnnexB_NAL( const uint8_t *p_buf, size_t i_buf,
 bool h264_get_dpb_values( const h264_sequence_parameter_set_t *,
                           uint8_t *pi_depth, unsigned *pi_delay );
 
-bool h264_get_picture_size( const h264_sequence_parameter_set_t *, unsigned *p_w, unsigned *p_h,
+bool h264_get_picture_size( const h264_sequence_parameter_set_t *,
+                            unsigned *p_ox, unsigned *p_oy,
+                            unsigned *p_w, unsigned *p_h,
                             unsigned *p_vw, unsigned *p_vh );
 bool h264_get_chroma_luma( const h264_sequence_parameter_set_t *, uint8_t *pi_chroma_format,
                            uint8_t *pi_depth_luma, uint8_t *pi_depth_chroma );


=====================================
modules/packetizer/hevc.c
=====================================
@@ -616,16 +616,19 @@ static void ActivateSets(decoder_t *p_dec,
                                          &p_dec->fmt_out.video.color_range);
         }
 
-        unsigned sizes[4];
+        unsigned sizes[6];
         if( hevc_get_picture_size( p_sps, &sizes[0], &sizes[1],
-                                          &sizes[2], &sizes[3] ) )
+                                          &sizes[2], &sizes[3],
+                                          &sizes[4], &sizes[5] ) )
         {
-            p_dec->fmt_out.video.i_width = sizes[0];
-            p_dec->fmt_out.video.i_height = sizes[1];
+            p_dec->fmt_out.video.i_x_offset = sizes[0];
+            p_dec->fmt_out.video.i_y_offset = sizes[1];
+            p_dec->fmt_out.video.i_width = sizes[2];
+            p_dec->fmt_out.video.i_height = sizes[3];
             if(p_dec->fmt_in->video.i_visible_width == 0)
             {
-                p_dec->fmt_out.video.i_visible_width = sizes[2];
-                p_dec->fmt_out.video.i_visible_height = sizes[3];
+                p_dec->fmt_out.video.i_visible_width = sizes[4];
+                p_dec->fmt_out.video.i_visible_height = sizes[5];
             }
         }
 


=====================================
modules/packetizer/hevc_nal.c
=====================================
@@ -1054,7 +1054,9 @@ bool hevc_get_sps_profile_tier_level( const hevc_sequence_parameter_set_t *p_sps
 }
 
 bool hevc_get_picture_size( const hevc_sequence_parameter_set_t *p_sps,
-                            unsigned *p_w, unsigned *p_h, unsigned *p_vw, unsigned *p_vh )
+                            unsigned *p_ox, unsigned *p_oy,
+                            unsigned *p_w, unsigned *p_h,
+                            unsigned *p_vw, unsigned *p_vh )
 {
     *p_w = *p_vw = p_sps->pic_width_in_luma_samples;
     *p_h = *p_vh = p_sps->pic_height_in_luma_samples;
@@ -1078,6 +1080,8 @@ bool hevc_get_picture_size( const hevc_sequence_parameter_set_t *p_sps,
             sub_height_c = 1;
         }
 
+        *p_oy = p_sps->conf_win.top_offset * sub_height_c;
+        *p_ox = p_sps->conf_win.left_offset * sub_width_c;
         *p_vh -= (p_sps->conf_win.bottom_offset + p_sps->conf_win.top_offset) * sub_height_c;
         *p_vw -= (p_sps->conf_win.left_offset +  p_sps->conf_win.right_offset) * sub_width_c;
     }


=====================================
modules/packetizer/hevc_nal.h
=====================================
@@ -283,7 +283,9 @@ bool hevc_get_sps_profile_tier_level( const hevc_sequence_parameter_set_t *,
                                       uint8_t *pi_profile, uint8_t *pi_level );
 enum vlc_hevc_profile_e
      hevc_get_vlc_profile( const hevc_sequence_parameter_set_t * );
-bool hevc_get_picture_size( const hevc_sequence_parameter_set_t *, unsigned *p_w, unsigned *p_h,
+bool hevc_get_picture_size( const hevc_sequence_parameter_set_t *,
+                            unsigned *p_ox, unsigned *p_oy,
+                            unsigned *p_w, unsigned *p_h,
                             unsigned *p_vw, unsigned *p_vh );
 bool hevc_get_frame_rate( const hevc_sequence_parameter_set_t *,
                           const hevc_video_parameter_set_t * /* can be NULL */,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3b4d89ac00f15681cb49368f051f666c6cdd0296...8c047bb483c2d9ad08cfc04a085fbbe690e6fd1d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3b4d89ac00f15681cb49368f051f666c6cdd0296...8c047bb483c2d9ad08cfc04a085fbbe690e6fd1d
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list