]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264_parse.c
h264_parser: remove the remaining dependencies on the h264 decoder
[ffmpeg] / libavcodec / h264_parse.c
index 1fc8f41b31ce2bc7ff8e856518ffff3c57832479..7211c9d34cb598af95a8887b47f0072d3133eb12 100644 (file)
@@ -449,3 +449,30 @@ int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
     }
     return 0;
 }
+
+/**
+ * Compute profile from profile_idc and constraint_set?_flags.
+ *
+ * @param sps SPS
+ *
+ * @return profile as defined by FF_PROFILE_H264_*
+ */
+int ff_h264_get_profile(const SPS *sps)
+{
+    int profile = sps->profile_idc;
+
+    switch (sps->profile_idc) {
+    case FF_PROFILE_H264_BASELINE:
+        // constraint_set1_flag set to 1
+        profile |= (sps->constraint_set_flags & 1 << 1) ? FF_PROFILE_H264_CONSTRAINED : 0;
+        break;
+    case FF_PROFILE_H264_HIGH_10:
+    case FF_PROFILE_H264_HIGH_422:
+    case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
+        // constraint_set3_flag set to 1
+        profile |= (sps->constraint_set_flags & 1 << 3) ? FF_PROFILE_H264_INTRA : 0;
+        break;
+    }
+
+    return profile;
+}