X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264_ps.c;h=4a5f66e184f228988aed648b4d7a6135035dec7f;hb=1e660fe88d2dd8fdcb0136b4cee3152f61ebc6c5;hp=1e1e793380fc63c965fc28ee126f3c7419a1f905;hpb=f48aea66ddfef3998ee7aaf6c6567577ae481807;p=ffmpeg diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 1e1e793380f..4a5f66e184f 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -31,13 +31,15 @@ #include "internal.h" #include "mathops.h" #include "avcodec.h" -#include "h264.h" #include "h264data.h" +#include "h264_ps.h" #include "golomb.h" #define MAX_LOG2_MAX_FRAME_NUM (12 + 4) #define MIN_LOG2_MAX_FRAME_NUM 4 +#define EXTENDED_SAR 255 + static const uint8_t default_scaling4[2][16] = { { 6, 13, 20, 28, 13, 20, 28, 32, 20, 28, 32, 37, 28, 32, 37, 42 }, @@ -455,8 +457,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, sps->ref_frame_count = get_ue_golomb_31(gb); if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2')) sps->ref_frame_count = FFMAX(2, sps->ref_frame_count); - if (sps->ref_frame_count > H264_MAX_PICTURE_COUNT - 2 || - sps->ref_frame_count > 16U) { + if (sps->ref_frame_count > MAX_DELAYED_PIC_COUNT) { av_log(avctx, AV_LOG_ERROR, "too many reference frames %d\n", sps->ref_frame_count); goto fail; @@ -560,7 +561,8 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, /* if the maximum delay is not stored in the SPS, derive it based on the * level */ - if (!sps->bitstream_restriction_flag) { + if (!sps->bitstream_restriction_flag && + (sps->ref_frame_count || avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)) { sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1; for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) { if (level_max_dpb_mbs[i][0] == sps->level_idc) { @@ -731,7 +733,9 @@ int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avct pps->data_size = gb->buffer_end - gb->buffer; if (pps->data_size > sizeof(pps->data)) { - av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized PPS\n"); + av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized PPS " + "(%"SIZE_SPECIFIER" > %"SIZE_SPECIFIER")\n", + pps->data_size, sizeof(pps->data)); pps->data_size = sizeof(pps->data); } memcpy(pps->data, gb->buffer, pps->data_size);