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

Git pushed a commit to branch master
in repository ffmpeg.

commit cc40f682f28177adfcb1e033707739cac5239a4d
Author:     Romain Beauxis <[email protected]>
AuthorDate: Mon Nov 16 20:51:15 2026 -0600
Commit:     Romain Beauxis <[email protected]>
CommitDate: Sat Nov 21 13:32:34 2026 +0000

    avformat/codecstring: write the HEVC general_profile_space
    
    ISO/IEC 14496-15 prefixes the profile with A, B or C when
    general_profile_space is 1, 2 or 3. It was dropped, which named a
    different profile.
---
 libavformat/codecstring.c       | 18 +++++++++++++-----
 libavformat/tests/codecstring.c |  8 ++++++++
 tests/ref/fate/codecstring      |  1 +
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/libavformat/codecstring.c b/libavformat/codecstring.c
index 325942b118..570a1de99b 100644
--- a/libavformat/codecstring.c
+++ b/libavformat/codecstring.c
@@ -66,7 +66,8 @@ static void set_vp9_codec_str(void *logctx, const 
AVCodecParameters *par,
  * profile_tier_level(). ptl points to the byte holding general_profile_space,
  * and 12 bytes are read.
  */
-static void parse_hevc_profile_tier_level(const uint8_t *ptl, int *profile,
+static void parse_hevc_profile_tier_level(const uint8_t *ptl,
+                                          int *profile_space, int *profile,
                                           uint32_t *profile_compatibility,
                                           char *tier, int *level,
                                           char *constraints,
@@ -78,6 +79,7 @@ static void parse_hevc_profile_tier_level(const uint8_t *ptl, 
int *profile,
     /* TIER represents the general_tier_flag, with 'L' indicating the flag is 
0,
      * and 'H' indicating the flag is 1
      */
+    *profile_space = ptl[0] >> 6;
     *tier = (ptl[0] & 0x20) == 0 ? 'L' : 'H';
     *profile = ptl[0] & 0x1f;
     /* PROFILE_COMPATIBILITY is general_profile_compatibility_flags, but in 
reverse bit order,
@@ -145,6 +147,7 @@ int ff_make_codec_str(void *logctx, const AVCodecParameters 
*par,
     } else if (par->codec_id == AV_CODEC_ID_HEVC) {
         // 3GPP TS 26.244
         uint8_t *data = par->extradata;
+        int profile_space = 0;
         int profile = AV_PROFILE_UNKNOWN;
         uint32_t profile_compatibility = AV_PROFILE_UNKNOWN;
         char tier = 0;
@@ -168,7 +171,7 @@ int ff_make_codec_str(void *logctx, const AVCodecParameters 
*par,
             /* Some muxers write a zeroed record: no profile, no level. */
             if (!(data[1] & 0x1f) || !data[12])
                 return AVERROR(EINVAL);
-            parse_hevc_profile_tier_level(data + 1, &profile,
+            parse_hevc_profile_tier_level(data + 1, &profile_space, &profile,
                                           &profile_compatibility, &tier,
                                           &level, constraints,
                                           sizeof(constraints));
@@ -197,7 +200,8 @@ int ff_make_codec_str(void *logctx, const AVCodecParameters 
*par,
                  *      sps_max_sub_layers_minus1    u(3),
                  *  and sps_temporal_id_nesting_flag u(1)
                  */
-                parse_hevc_profile_tier_level(rbsp_buf + 1, &profile,
+                parse_hevc_profile_tier_level(rbsp_buf + 1, &profile_space,
+                                              &profile,
                                               &profile_compatibility, &tier,
                                               &level, constraints,
                                               sizeof(constraints));
@@ -213,8 +217,12 @@ int ff_make_codec_str(void *logctx, const 
AVCodecParameters *par,
             tier != 0 &&
             level != AV_LEVEL_UNKNOWN &&
             constraints[0] != '\0') {
-            av_bprintf(out, "%s.%d.%x.%c%d.%s",
-                       av_fourcc2str(par->codec_tag), profile,
+            /* general_profile_space 1 to 3 is a letter A to C before
+             * the profile (ISO/IEC 14496-15) */
+            av_bprintf(out, "%s.", av_fourcc2str(par->codec_tag));
+            if (profile_space)
+                av_bprint_chars(out, 'A' + profile_space - 1, 1);
+            av_bprintf(out, "%d.%x.%c%d.%s", profile,
                        profile_compatibility, tier, level, constraints);
         } else
             return AVERROR(EINVAL);
diff --git a/libavformat/tests/codecstring.c b/libavformat/tests/codecstring.c
index 8b193a5d2b..58fc422118 100644
--- a/libavformat/tests/codecstring.c
+++ b/libavformat/tests/codecstring.c
@@ -60,6 +60,11 @@ static const uint8_t hevc_hvcc_zeroed[] = {
     0x00, 0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x00,
 };
 
+static const uint8_t hevc_hvcc_profile_space[] = {
+    0x01, 0x41, 0x60, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x1e, 0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x00,
+};
+
 typedef struct TestCase {
     const char *name;
     enum AVCodecID codec_id;
@@ -90,6 +95,9 @@ static const TestCase cases[] = {
       AV_PROFILE_UNKNOWN, hevc_hvcc_version0, sizeof(hevc_hvcc_version0) },
     { "hevc-hvcc-zeroed",     AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1'),
       AV_PROFILE_HEVC_MAIN, hevc_hvcc_zeroed, sizeof(hevc_hvcc_zeroed) },
+    { "hevc-hvcc-profile-space", AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1'),
+      AV_PROFILE_UNKNOWN, hevc_hvcc_profile_space,
+      sizeof(hevc_hvcc_profile_space) },
     { "aac-lc",              AV_CODEC_ID_AAC,  0,
       AV_PROFILE_AAC_LOW, NULL,        0                   },
 };
diff --git a/tests/ref/fate/codecstring b/tests/ref/fate/codecstring
index 0e0e6dce59..70536e0263 100644
--- a/tests/ref/fate/codecstring
+++ b/tests/ref/fate/codecstring
@@ -8,4 +8,5 @@ hevc-hvcc-hvc1: hvc1.1.6.L30.90
 hevc-hvcc-hev1: hev1.1.6.L30.90
 hevc-hvcc-version0: hvc1.1.6.L30.90
 hevc-hvcc-zeroed: error
+hevc-hvcc-profile-space: hvc1.A1.6.L30.90
 aac-lc: mp4a.40.2

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to