This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 89bdd9e1a5 avcodec/hevc: look for the DOVI RPU in all NALs, not just 
the last one
89bdd9e1a5 is described below

commit 89bdd9e1a50735be7478ab8c07303f3d2fe59d85
Author:     Hendrik Leppkes <[email protected]>
AuthorDate: Wed Jun 3 11:24:26 2026 +0200
Commit:     James Almer <[email protected]>
CommitDate: Fri Jun 5 01:08:08 2026 +0000

    avcodec/hevc: look for the DOVI RPU in all NALs, not just the last one
    
    Some encoders seem to place the SEI suffix NAL at the very end, with the
    RPU before it.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavcodec/hevc/hevcdec.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 6fec59d31e..dfd6203dac 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3740,25 +3740,31 @@ static int decode_nal_units(HEVCContext *s, const 
uint8_t *buf, int length)
      * Dolby Vision RPUs masquerade as unregistered NALs of type 62.
      *
      * We have to do this check here an create the rpu buffer, since RPUs are 
appended
-     * to the end of an AU; they are the last non-EOB/EOS NAL in the AU.
+     * to the end of an AU; they are normally the last non-EOB/EOS NAL in the 
AU.
      */
-    if (s->pkt.nb_nals > 1 && s->pkt.nals[s->pkt.nb_nals - 1].type == 
HEVC_NAL_UNSPEC62 &&
-        s->pkt.nals[s->pkt.nb_nals - 1].size > 2 && 
!s->pkt.nals[s->pkt.nb_nals - 1].nuh_layer_id
-        && !s->pkt.nals[s->pkt.nb_nals - 1].temporal_id) {
-        H2645NAL *nal = &s->pkt.nals[s->pkt.nb_nals - 1];
+    H2645NAL *rpu_nal = NULL;
+    for (int i = s->pkt.nb_nals - 1; i > 0 ; i--) {
+        if (s->pkt.nals[i].type == HEVC_NAL_UNSPEC62 && s->pkt.nals[i].size > 2
+            && !s->pkt.nals[i].nuh_layer_id && !s->pkt.nals[i].temporal_id) {
+                rpu_nal = &s->pkt.nals[i];
+                break;
+        }
+    }
+
+    if (rpu_nal) {
         if (s->rpu_buf) {
             av_buffer_unref(&s->rpu_buf);
             av_log(s->avctx, AV_LOG_WARNING, "Multiple Dolby Vision RPUs found 
in one AU. Skipping previous.\n");
         }
 
-        s->rpu_buf = av_buffer_alloc(nal->raw_size - 2);
+        s->rpu_buf = av_buffer_alloc(rpu_nal->raw_size - 2);
         if (!s->rpu_buf) {
             ret = AVERROR(ENOMEM);
             goto fail;
         }
-        memcpy(s->rpu_buf->data, nal->raw_data + 2, nal->raw_size - 2);
+        memcpy(s->rpu_buf->data, rpu_nal->raw_data + 2, rpu_nal->raw_size - 2);
 
-        ret = ff_dovi_rpu_parse(&s->dovi_ctx, nal->data + 2, nal->size - 2,
+        ret = ff_dovi_rpu_parse(&s->dovi_ctx, rpu_nal->data + 2, rpu_nal->size 
- 2,
                                 s->avctx->err_recognition);
         if (ret < 0) {
             av_buffer_unref(&s->rpu_buf);

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

Reply via email to