diff mbox

[FFmpeg-devel,2/4] h264_levels: Make get_level intra-profile friendly

Message ID 20181112141815.4472-3-andreas.rheinhardt@googlemail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Nov. 12, 2018, 2:18 p.m. UTC
Currently ff_h264_get_level does not provide the correct level for any
of the High Intra profiles. Now only High Intra profiles with level 1.1
get misdetected.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
---
 libavcodec/h264_levels.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mark Thompson Nov. 13, 2018, 9:21 p.m. UTC | #1
On 12/11/18 14:18, Andreas Rheinhardt wrote:
> Currently ff_h264_get_level does not provide the correct level for any
> of the High Intra profiles. Now only High Intra profiles with level 1.1
> get misdetected.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
> ---
>  libavcodec/h264_levels.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/h264_levels.c b/libavcodec/h264_levels.c
> index 7a55116773..02efaa38dc 100644
> --- a/libavcodec/h264_levels.c
> +++ b/libavcodec/h264_levels.c
> @@ -80,8 +80,8 @@ const H264LevelDescriptor *ff_h264_get_level(int level_idc,
>  {
>      int i;
>      for (i = 0; i < FF_ARRAY_ELEMS(h264_levels); i++) {
> -        if (h264_levels[i].level_idc            == level_idc &&
> -            h264_levels[i].constraint_set3_flag == constraint_set3_flag)
> +        if (h264_levels[i].level_idc == level_idc &&
> +            (constraint_set3_flag || !h264_levels[i].constraint_set3_flag))
>              return &h264_levels[i];
>      }
>      return NULL;
> 

We should be able to make it precisely correct here without that last caveat - if we know the profile is high, then we can ignore the line with cs3f set.

Since it's appearing in a few places, maybe a new function (macro?) identifying the older profiles (constrained baseline, baseline, main, extended - not sure exactly what the right name is...), and then check that here to decide which 1b case to use.

(If you feel like it then a few tests for these High Intra cases in libavcodec/tests/h264_levels.c wouldn't go amiss.  You can run just that test without needing the fate samples with "make fate-h264-levels".)

Thanks,

- Mark
diff mbox

Patch

diff --git a/libavcodec/h264_levels.c b/libavcodec/h264_levels.c
index 7a55116773..02efaa38dc 100644
--- a/libavcodec/h264_levels.c
+++ b/libavcodec/h264_levels.c
@@ -80,8 +80,8 @@  const H264LevelDescriptor *ff_h264_get_level(int level_idc,
 {
     int i;
     for (i = 0; i < FF_ARRAY_ELEMS(h264_levels); i++) {
-        if (h264_levels[i].level_idc            == level_idc &&
-            h264_levels[i].constraint_set3_flag == constraint_set3_flag)
+        if (h264_levels[i].level_idc == level_idc &&
+            (constraint_set3_flag || !h264_levels[i].constraint_set3_flag))
             return &h264_levels[i];
     }
     return NULL;