]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264_parse.c
qsvdec: only access hwaccel_context is the pixel format is QSV
[ffmpeg] / libavcodec / h264_parse.c
index 1fc8f41b31ce2bc7ff8e856518ffff3c57832479..d694558ecc53a9a4b876d0f48a4cbc89819a7986 100644 (file)
 #include "get_bits.h"
 #include "golomb.h"
 #include "h264.h"
+#include "h264dec.h"
 #include "h264_parse.h"
+#include "h264_ps.h"
 
 int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
                               const int *ref_count, int slice_type_nos,
                               H264PredWeightTable *pwt)
 {
-    int list, i;
+    int list, i, j;
     int luma_def, chroma_def;
 
     pwt->use_weight             = 0;
@@ -78,6 +80,14 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
                     }
                 }
             }
+
+            // for MBAFF
+            pwt->luma_weight[16 + 2 * i][list][0] = pwt->luma_weight[16 + 2 * i + 1][list][0] = pwt->luma_weight[i][list][0];
+            pwt->luma_weight[16 + 2 * i][list][1] = pwt->luma_weight[16 + 2 * i + 1][list][1] = pwt->luma_weight[i][list][1];
+            for (j = 0; j < 2; j++) {
+                pwt->chroma_weight[16 + 2 * i][list][j][0] = pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = pwt->chroma_weight[i][list][j][0];
+                pwt->chroma_weight[16 + 2 * i][list][j][1] = pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = pwt->chroma_weight[i][list][j][1];
+            }
         }
         if (slice_type_nos != AV_PICTURE_TYPE_B)
             break;
@@ -320,12 +330,12 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
     for (i = 0; i < pkt.nb_nals; i++) {
         H2645NAL *nal = &pkt.nals[i];
         switch (nal->type) {
-        case NAL_SPS:
+        case H264_NAL_SPS:
             ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps);
             if (ret < 0)
                 goto fail;
             break;
-        case NAL_PPS:
+        case H264_NAL_PPS:
             ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
                                                        nal->size_bits);
             if (ret < 0)
@@ -449,3 +459,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;
+}