---
Patch squashed and modified according to comments.
Vittorio

 libavcodec/h264_ps.c |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 54b735d..fc97769 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -131,6 +131,7 @@ static inline int decode_hrd_parameters(H264Context *h, SPS 
*sps)
 static inline int decode_vui_parameters(H264Context *h, SPS *sps)
 {
     int aspect_ratio_info_present_flag;
+    int chroma_loc_info_present_flag;
     unsigned int aspect_ratio_idc;
 
     aspect_ratio_info_present_flag = get_bits1(&h->gb);
@@ -173,11 +174,17 @@ static inline int decode_vui_parameters(H264Context *h, 
SPS *sps)
         }
     }
 
-    /* chroma_location_info_present_flag */
-    if (get_bits1(&h->gb)) {
-        /* chroma_sample_location_type_top_field */
-        h->avctx->chroma_sample_location = get_ue_golomb(&h->gb) + 1;
-        get_ue_golomb(&h->gb);  /* chroma_sample_location_type_bottom_field */
+    chroma_loc_info_present_flag = get_bits1(&h->gb);
+    if (chroma_loc_info_present_flag) {
+        int chroma_sample_loc_type_top_field    = get_ue_golomb(&h->gb);
+        int chroma_sample_loc_type_bottom_field = get_ue_golomb(&h->gb);
+
+        if (chroma_sample_loc_type_top_field != 
chroma_sample_loc_type_bottom_field) {
+            av_log(h->avctx, AV_LOG_WARNING, "Different chroma location for 
top and bottom fields is not supported.");
+            if (h->avctx->err_recognition & AV_EF_EXPLODE)
+                return AVERROR_PATCHWELCOME;
+        }
+        h->avctx->chroma_sample_location = chroma_sample_loc_type_top_field + 
1;
     }
 
     sps->timing_info_present_flag = get_bits1(&h->gb);
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to