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

Git pushed a commit to branch master
in repository ffmpeg.

commit fe1ffd63fb09fc8655487046f3ad2b372fef5497
Author:     James Almer <[email protected]>
AuthorDate: Thu Mar 26 17:23:59 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Sat Mar 28 22:07:54 2026 -0300

    avcodec/libdav1d: refactor parsing ITU-T35 metadata
    
    Use a switch case. Will be useful in the following commit.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavcodec/libdav1d.c | 109 ++++++++++++++++++++++++++++----------------------
 1 file changed, 62 insertions(+), 47 deletions(-)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 14ec9842a0..77520744cd 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -370,67 +370,82 @@ static int parse_itut_t35_metadata(Libdav1dContext 
*dav1d, Dav1dPicture *p,
 
     bytestream2_init(&gb, itut_t35->payload, itut_t35->payload_size);
 
-    provider_code = bytestream2_get_be16(&gb);
     country_code = itut_t35->country_code;
-    if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == 
ITU_T_T35_PROVIDER_CODE_ATSC) {
-        uint32_t user_identifier = bytestream2_get_be32(&gb);
-        switch (user_identifier) {
-        case MKBETAG('G', 'A', '9', '4'): { // closed captions
-            AVBufferRef *buf = NULL;
-
-            res = ff_parse_a53_cc(&buf, gb.buffer, 
bytestream2_get_bytes_left(&gb));
-            if (res < 0)
-                return res;
-            if (!res)
-                return 0;  // no cc found, ignore
-
-            res = ff_frame_new_side_data_from_buf(c, frame, 
AV_FRAME_DATA_A53_CC, &buf);
-            if (res < 0)
-                return res;
+    switch (country_code) {
+    case ITU_T_T35_COUNTRY_CODE_US:
+        provider_code = bytestream2_get_be16u(&gb);
+
+        switch (provider_code) {
+        case ITU_T_T35_PROVIDER_CODE_ATSC: {
+            uint32_t user_identifier = bytestream2_get_be32(&gb);
+            switch (user_identifier) {
+            case MKBETAG('G', 'A', '9', '4'): { // closed captions
+                AVBufferRef *buf = NULL;
+
+                res = ff_parse_a53_cc(&buf, gb.buffer, 
bytestream2_get_bytes_left(&gb));
+                if (res < 0)
+                    return res;
+                if (!res)
+                    return 0;  // no cc found, ignore
+
+                res = ff_frame_new_side_data_from_buf(c, frame, 
AV_FRAME_DATA_A53_CC, &buf);
+                if (res < 0)
+                    return res;
 
 #if FF_API_CODEC_PROPS
 FF_DISABLE_DEPRECATION_WARNINGS
-            c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+                c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
+                break;
+            }
+            default: // ignore unsupported identifiers
+                break;
+            }
             break;
         }
-        default: // ignore unsupported identifiers
-            break;
-        }
-    } else if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == 
ITU_T_T35_PROVIDER_CODE_SAMSUNG) {
-        AVDynamicHDRPlus *hdrplus;
-        int provider_oriented_code = bytestream2_get_be16(&gb);
-        int application_identifier = bytestream2_get_byte(&gb);
+        case ITU_T_T35_PROVIDER_CODE_SAMSUNG: {
+            AVDynamicHDRPlus *hdrplus;
+            int provider_oriented_code = bytestream2_get_be16(&gb);
+            int application_identifier = bytestream2_get_byte(&gb);
 
-        if (provider_oriented_code != 1 || application_identifier != 4)
-            return 0; // ignore
+            if (provider_oriented_code != 1 || application_identifier != 4)
+                return 0; // ignore
 
-        hdrplus = av_dynamic_hdr_plus_create_side_data(frame);
-        if (!hdrplus)
-            return AVERROR(ENOMEM);
+            hdrplus = av_dynamic_hdr_plus_create_side_data(frame);
+            if (!hdrplus)
+                return AVERROR(ENOMEM);
 
-        res = av_dynamic_hdr_plus_from_t35(hdrplus, gb.buffer,
-                                            bytestream2_get_bytes_left(&gb));
-        if (res < 0)
-            return res;
-    } else if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == 
ITU_T_T35_PROVIDER_CODE_DOLBY) {
-        int provider_oriented_code = bytestream2_get_be32(&gb);
-        if (provider_oriented_code != 0x800)
-            return 0; // ignore
-
-        res = ff_dovi_rpu_parse(&dav1d->dovi, gb.buffer, 
bytestream2_get_bytes_left(&gb),
-                                c->err_recognition);
-        if (res < 0) {
-            av_log(c, AV_LOG_WARNING, "Error parsing DOVI OBU.\n");
-            return 0; // ignore
+            res = av_dynamic_hdr_plus_from_t35(hdrplus, gb.buffer,
+                                                
bytestream2_get_bytes_left(&gb));
+            if (res < 0)
+                return res;
+            break;
         }
+        case ITU_T_T35_PROVIDER_CODE_DOLBY: {
+            int provider_oriented_code = bytestream2_get_be32(&gb);
+            if (provider_oriented_code != 0x800)
+                return 0; // ignore
 
-        res = ff_dovi_attach_side_data(&dav1d->dovi, frame);
-        if (res < 0)
-            return res;
-    } else {
+            res = ff_dovi_rpu_parse(&dav1d->dovi, gb.buffer, 
bytestream2_get_bytes_left(&gb),
+                                    c->err_recognition);
+            if (res < 0) {
+                av_log(c, AV_LOG_WARNING, "Error parsing DOVI OBU.\n");
+                return 0; // ignore
+            }
+
+            res = ff_dovi_attach_side_data(&dav1d->dovi, frame);
+            if (res < 0)
+                return res;
+            break;
+        }
+        default:
+            break;
+        }
+        break;
+    default:
         // ignore unsupported provider codes
+        break;
     }
     return 0;
 }

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

Reply via email to