[vlc-commits] [Git][videolan/vlc][master] 4 commits: codec/videotoolbox: rebuild avcC after in-band xPS changes

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Nov 27 11:02:44 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
d6a9b7f3 by Felix Paul Kühne at 2026-11-27T11:24:16+01:00
codec/videotoolbox: rebuild avcC after in-band xPS changes

A restart after an in-band SPS change still used the demuxer's avcC
with the old parameter sets, so VideoToolbox rejected the new IDR as
bad data and every frame after it was dropped.

- - - - -
6a5a7df6 by Felix Paul Kühne at 2026-11-27T11:24:16+01:00
codec/videotoolbox: rebuild hvcC after in-band xPS changes

A restart after an in-band VPS/SPS/PPS change still used the demuxer's
hvcC with the old parameter sets, which VideoToolbox rejects as bad
data.

- - - - -
5c4a182e by Felix Paul Kühne at 2026-11-27T11:24:16+01:00
codec/videotoolbox: use the SPS picture size after xPS changes

After a restart for new parameter sets, the size still came from the
demuxer, so VideoToolbox scaled the new resolution down to the old
buffer size.

- - - - -
02d3a0a1 by Felix Paul Kühne at 2026-11-27T11:24:16+01:00
codec/videotoolbox: use the new format description when VT accepts it

When the session could accept the new format description, it was
released and sample buffers kept using the stale one.

- - - - -


2 changed files:

- modules/codec/hxxx_helper.c
- modules/codec/videotoolbox/decoder.c


Changes:

=====================================
modules/codec/hxxx_helper.c
=====================================
@@ -324,6 +324,7 @@ hevc_helper_parse_nal(struct hxxx_helper *hh, const uint8_t *p_nal, size_t i_nal
                  hevc_sequence_parameter_set_t,
                  hevc_decode_sps,
                  hevc_rbsp_release_sps);
+        hh->hevc.i_current_sps = i_id;
         msg_Dbg(hh->p_obj, "new SPS parsed: %u", i_id);
     }
     else if (i_nal_type == HEVC_NAL_PPS)


=====================================
modules/codec/videotoolbox/decoder.c
=====================================
@@ -365,6 +365,8 @@ static block_t *ProcessBlockH264(decoder_t *p_dec, block_t *p_block, bool *pb_co
     struct vt_h264_context *h264ctx = p_sys->p_codec_context;
     p_block = hxxx_helper_process_block(&h264ctx->hh, p_block);
     *pb_config_changed = hxxx_helper_has_new_config(&h264ctx->hh);
+    if (*pb_config_changed)
+        h264ctx->b_extra_has_config = false;
     return p_block;
 }
 
@@ -487,18 +489,16 @@ static bool LateStartH264(decoder_t *p_dec)
     return !hxxx_helper_has_config(&h264ctx->hh);
 }
 
-static bool ConfigureVoutH264(decoder_t *p_dec)
+static bool ConfigureVoutHxxx(decoder_t *p_dec, const struct hxxx_helper *hh,
+                              bool b_extra_has_config)
 {
-    decoder_sys_t *p_sys = p_dec->p_sys;
-    struct vt_h264_context *h264ctx = p_sys->p_codec_context;
-
     if (p_dec->fmt_in->video.primaries == COLOR_PRIMARIES_UNDEF)
     {
         video_color_primaries_t primaries;
         video_transfer_func_t transfer;
         video_color_space_t colorspace;
         video_color_range_t full_range;
-        if (hxxx_helper_get_colorimetry(&h264ctx->hh,
+        if (hxxx_helper_get_colorimetry(hh,
                                         &primaries,
                                         &transfer,
                                         &colorspace,
@@ -511,11 +511,12 @@ static bool ConfigureVoutH264(decoder_t *p_dec)
         }
     }
 
-    if (!p_dec->fmt_in->video.i_visible_width || !p_dec->fmt_in->video.i_visible_height)
+    if (!b_extra_has_config ||
+        !p_dec->fmt_in->video.i_visible_width || !p_dec->fmt_in->video.i_visible_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,
+           hxxx_helper_get_current_picture_size(hh,
                                                 &i_offset_x, &i_offset_y,
                                                 &i_width, &i_height,
                                                 &i_vis_width, &i_vis_height))
@@ -534,7 +535,7 @@ static bool ConfigureVoutH264(decoder_t *p_dec)
     {
         int i_sar_num, i_sar_den;
         if (VLC_SUCCESS ==
-            hxxx_helper_get_current_sar(&h264ctx->hh, &i_sar_num, &i_sar_den))
+            hxxx_helper_get_current_sar(hh, &i_sar_num, &i_sar_den))
         {
             p_dec->fmt_out.video.i_sar_num = i_sar_num;
             p_dec->fmt_out.video.i_sar_den = i_sar_den;
@@ -544,6 +545,13 @@ static bool ConfigureVoutH264(decoder_t *p_dec)
     return true;
 }
 
+static bool ConfigureVoutH264(decoder_t *p_dec)
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+    struct vt_h264_context *h264ctx = p_sys->p_codec_context;
+    return ConfigureVoutHxxx(p_dec, &h264ctx->hh, h264ctx->b_extra_has_config);
+}
+
 static bool VideoToolboxNeedsToRestartH264(decoder_t *p_dec,
                                            VTDecompressionSessionRef session)
 {
@@ -557,6 +565,10 @@ static bool VideoToolboxNeedsToRestartH264(decoder_t *p_dec,
     if (hxxx_helper_get_current_picture_size(hh, &ox, &oy, &w, &h, &vw, &vh) != VLC_SUCCESS)
         return true;
 
+    if (vw != p_dec->fmt_out.video.i_visible_width ||
+        vh != p_dec->fmt_out.video.i_visible_height)
+        return true;
+
     if (hxxx_helper_get_current_sar(hh, &sarn, &sard) != VLC_SUCCESS)
         return true;
 
@@ -577,7 +589,13 @@ static bool VideoToolboxNeedsToRestartH264(decoder_t *p_dec,
         {
             b_ret = !VTDecompressionSessionCanAcceptFormatDescription(session,
                                                                       newvideoFormatDesc);
-            CFRelease(newvideoFormatDesc);
+            if (b_ret)
+                CFRelease(newvideoFormatDesc);
+            else
+            {
+                CFRelease(p_sys->videoFormatDescription);
+                p_sys->videoFormatDescription = newvideoFormatDesc;
+            }
         }
         CFRelease(decoderConfiguration);
     }
@@ -865,7 +883,7 @@ static bool ConfigureVoutHEVC(decoder_t *p_dec)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     struct vt_hevc_context *hevcctx = p_sys->p_codec_context;
-    if (!ConfigureVoutH264(p_dec))
+    if (!ConfigureVoutHxxx(p_dec, &hevcctx->hh, hevcctx->b_extra_has_config))
         return false;
 
     if (hevcctx->b_dovi)
@@ -879,7 +897,17 @@ static bool ConfigureVoutHEVC(decoder_t *p_dec)
     return true;
 }
 
-#define ProcessBlockHEVC ProcessBlockH264
+static block_t *ProcessBlockHEVC(decoder_t *p_dec, block_t *p_block, bool *pb_config_changed)
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+    struct vt_hevc_context *hevcctx = p_sys->p_codec_context;
+    p_block = hxxx_helper_process_block(&hevcctx->hh, p_block);
+    *pb_config_changed = hxxx_helper_has_new_config(&hevcctx->hh);
+    if (*pb_config_changed)
+        hevcctx->b_extra_has_config = false;
+    return p_block;
+}
+
 #define VideoToolboxNeedsToRestartHEVC VideoToolboxNeedsToRestartH264
 
 static CFDictionaryRef CopyDecoderExtradataMPEG4(decoder_t *p_dec)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d336afd05f480af79576ac8107d86054f2d2de84...02d3a0a1cf60ccd429fb9db5f9e05fef004bb2a8

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d336afd05f480af79576ac8107d86054f2d2de84...02d3a0a1cf60ccd429fb9db5f9e05fef004bb2a8
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list