h264_metadata: Avoid integer overflow in bitrate
authorMark Thompson <sw@jkqxz.net>
Mon, 24 Sep 2018 21:45:50 +0000 (22:45 +0100)
committerMark Thompson <sw@jkqxz.net>
Mon, 24 Sep 2018 22:09:32 +0000 (23:09 +0100)
Fixes CID #1439664.

libavcodec/h264_metadata_bsf.c

index 991fcfa..bf37528 100644 (file)
@@ -226,10 +226,10 @@ static int h264_metadata_update_sps(AVBSFContext *bsf,
 
             if (sps->vui.nal_hrd_parameters_present_flag) {
                 bit_rate = (sps->vui.nal_hrd_parameters.bit_rate_value_minus1[0] + 1) *
-                     (1 << (sps->vui.nal_hrd_parameters.bit_rate_scale + 6));
+                    (INT64_C(1) << (sps->vui.nal_hrd_parameters.bit_rate_scale + 6));
             } else if (sps->vui.vcl_hrd_parameters_present_flag) {
                 bit_rate = (sps->vui.vcl_hrd_parameters.bit_rate_value_minus1[0] + 1) *
-                     (1 << (sps->vui.vcl_hrd_parameters.bit_rate_scale + 6));
+                    (INT64_C(1) << (sps->vui.vcl_hrd_parameters.bit_rate_scale + 6));
                 // Adjust for VCL vs. NAL limits.
                 bit_rate = bit_rate * 6 / 5;
             } else {