PR #24327 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24327
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24327.patch

 
┌─────────────────────────────────────────┬───────────┬───────────┬──────────────────────┐
 │                 sample                  │  master   │ skipframe │            
          │
 
├─────────────────────────────────────────┼───────────┼───────────┼──────────────────────┤
 │ loewe.ts (hevc/TS)                      │ 17.2 ±1.0 │ 4.8 ±0.5  │ 3.56× 
(p=2e-71)      │
 
├─────────────────────────────────────────┼───────────┼───────────┼──────────────────────┤
 │ DELTAQP_A_BRCM_4.bit                    │ 21.7 ±0.7 │ 10.6 ±0.3 │ 2.05× 
(p=3e-78)      │
 
├─────────────────────────────────────────┼───────────┼───────────┼──────────────────────┤
 │ hevc/paramchange                        │ 59.8 ±1.7 │ 4.3 ±0.3  │ 13.93× 
(p=2e-79)     │
 
└─────────────────────────────────────────┴───────────┴───────────┴──────────────────────┘

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



From 0672f52121db8bf32191c9184e2c9a9719be88cc Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Mon, 31 Aug 2026 03:32:50 +0200
Subject: [PATCH] avcodec/hevc: fill the stream parameters when all frames are
 skipped
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 
┌─────────────────────────────────────────┬───────────┬───────────┬──────────────────────┐
 │                 sample                  │  master   │ skipframe │            
          │
 
├─────────────────────────────────────────┼───────────┼───────────┼──────────────────────┤
 │ loewe.ts (hevc/TS)                      │ 17.2 ±1.0 │ 4.8 ±0.5  │ 3.56× 
(p=2e-71)      │
 
├─────────────────────────────────────────┼───────────┼───────────┼──────────────────────┤
 │ DELTAQP_A_BRCM_4.bit                    │ 21.7 ±0.7 │ 10.6 ±0.3 │ 2.05× 
(p=3e-78)      │
 
├─────────────────────────────────────────┼───────────┼───────────┼──────────────────────┤
 │ hevc/paramchange                        │ 59.8 ±1.7 │ 4.3 ±0.3  │ 13.93× 
(p=2e-79)     │
 
└─────────────────────────────────────────┴───────────┴───────────┴──────────────────────┘
---
 libavcodec/hevc/hevcdec.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 475c2738b1..bc8fca0ed6 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3793,8 +3793,18 @@ static int decode_nal_units(HEVCContext *s, const 
uint8_t *buf, int length)
         H2645NAL *nal = &s->pkt.nals[i];
 
         if (s->avctx->skip_frame >= AVDISCARD_ALL ||
-            (s->avctx->skip_frame >= AVDISCARD_NONREF && 
ff_hevc_nal_is_nonref(nal->type)))
-            continue;
+            (s->avctx->skip_frame >= AVDISCARD_NONREF && 
ff_hevc_nal_is_nonref(nal->type))) {
+            switch (nal->type) {
+            case HEVC_NAL_VPS:
+            case HEVC_NAL_SPS:
+            case HEVC_NAL_PPS:
+            case HEVC_NAL_SEI_PREFIX:
+            case HEVC_NAL_SEI_SUFFIX:
+                break;
+            default:
+                continue;
+            }
+        }
 
         ret = decode_nal_unit(s, i);
         if (ret < 0) {
@@ -3804,6 +3814,21 @@ static int decode_nal_units(HEVCContext *s, const 
uint8_t *buf, int length)
         }
     }
 
+    /* All frames were discarded, but the parameter sets were parsed:
+     * export the stream parameters from the first SPS as the extradata
+     * path does, so skip_frame fills the parameters without decoding. */
+    if (s->avctx->skip_frame >= AVDISCARD_ALL &&
+        s->avctx->pix_fmt == AV_PIX_FMT_NONE) {
+        for (int i = 0; i < HEVC_MAX_SPS_COUNT; i++)
+            if (s->ps.sps_list[i]) {
+                export_stream_params(s, s->ps.sps_list[i]);
+                break;
+            }
+        ret = export_stream_params_from_sei(s);
+        if (ret < 0)
+            goto fail;
+    }
+
 fail:
     for (int i = 0; i < FF_ARRAY_ELEMS(s->layers); i++) {
         HEVCLayerContext *l = &s->layers[i];
@@ -4272,6 +4297,7 @@ const FFCodec ff_hevc_decoder = {
     .p.capabilities        = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
                              AV_CODEC_CAP_SLICE_THREADS | 
AV_CODEC_CAP_FRAME_THREADS,
     .caps_internal         = FF_CODEC_CAP_EXPORTS_CROPPING |
+                             FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
                              FF_CODEC_CAP_USES_PROGRESSFRAMES |
                              FF_CODEC_CAP_INIT_CLEANUP,
     .p.profiles            = NULL_IF_CONFIG_SMALL(ff_hevc_profiles),
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to