pwt->use_weight = 0;
pwt->use_weight_chroma = 0;
- pwt->luma_log2_weight_denom = get_ue_golomb(gb);
+ pwt->luma_log2_weight_denom = get_ue_golomb_31(gb);
if (pwt->luma_log2_weight_denom > 7U) {
av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", pwt->luma_log2_weight_denom);
pwt->luma_log2_weight_denom = 0;
luma_def = 1 << pwt->luma_log2_weight_denom;
if (sps->chroma_format_idc) {
- pwt->chroma_log2_weight_denom = get_ue_golomb(gb);
+ pwt->chroma_log2_weight_denom = get_ue_golomb_31(gb);
if (pwt->chroma_log2_weight_denom > 7U) {
av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of range\n", pwt->chroma_log2_weight_denom);
pwt->chroma_log2_weight_denom = 0;
pwt->chroma_weight[i][list][j][0] = get_se_golomb(gb);
pwt->chroma_weight[i][list][j][1] = get_se_golomb(gb);
if ((int8_t)pwt->chroma_weight[i][list][j][0] != pwt->chroma_weight[i][list][j][0] ||
- (int8_t)pwt->chroma_weight[i][list][j][1] != pwt->chroma_weight[i][list][j][1])
+ (int8_t)pwt->chroma_weight[i][list][j][1] != pwt->chroma_weight[i][list][j][1]) {
+ pwt->chroma_weight[i][list][j][0] = chroma_def;
+ pwt->chroma_weight[i][list][j][1] = 0;
goto out_range_weight;
+ }
if (pwt->chroma_weight[i][list][j][0] != chroma_def ||
pwt->chroma_weight[i][list][j][1] != 0) {
pwt->use_weight_chroma = 1;
pwt->use_weight = pwt->use_weight || pwt->use_weight_chroma;
return 0;
out_range_weight:
- avpriv_request_sample(logctx, "Out of range weight\n");
+ avpriv_request_sample(logctx, "Out of range weight");
return AVERROR_INVALIDDATA;
}
ref_count[1] = 1;
}
- if (ref_count[0] - 1 > max[0] || ref_count[1] - 1 > max[1]) {
+ if (slice_type_nos == AV_PICTURE_TYPE_B)
+ list_count = 2;
+ else
+ list_count = 1;
+
+ if (ref_count[0] - 1 > max[0] || (list_count == 2 && (ref_count[1] - 1 > max[1]))) {
av_log(logctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n",
ref_count[0] - 1, max[0], ref_count[1] - 1, max[1]);
ref_count[0] = ref_count[1] = 0;
*plist_count = 0;
goto fail;
+ } else if (ref_count[1] - 1 > max[1]) {
+ av_log(logctx, AV_LOG_DEBUG, "reference overflow %u > %u \n",
+ ref_count[1] - 1, max[1]);
+ ref_count[1] = 0;
}
- if (slice_type_nos == AV_PICTURE_TYPE_B)
- list_count = 2;
- else
- list_count = 1;
} else {
list_count = 0;
ref_count[0] = ref_count[1] = 0;
int picture_structure, int nal_ref_idc)
{
const int max_frame_num = 1 << sps->log2_max_frame_num;
- int field_poc[2];
+ int64_t field_poc[2];
pc->frame_num_offset = pc->prev_frame_num_offset;
if (pc->frame_num < pc->prev_frame_num)
if (sps->poc_type == 0) {
const int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
+ if (pc->prev_poc_lsb < 0)
+ pc->prev_poc_lsb = pc->poc_lsb;
if (pc->poc_lsb < pc->prev_poc_lsb &&
pc->prev_poc_lsb - pc->poc_lsb >= max_poc_lsb / 2)
if (picture_structure == PICT_FRAME)
field_poc[1] += pc->delta_poc_bottom;
} else if (sps->poc_type == 1) {
- int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
+ int abs_frame_num;
+ int64_t expected_delta_per_poc_cycle, expectedpoc;
int i;
if (sps->poc_cycle_length != 0)
field_poc[1] = poc;
}
+ if ( field_poc[0] != (int)field_poc[0]
+ || field_poc[1] != (int)field_poc[1])
+ return AVERROR_INVALIDDATA;
+
if (picture_structure != PICT_BOTTOM_FIELD)
pic_field_poc[0] = field_poc[0];
if (picture_structure != PICT_TOP_FIELD)
H2645Packet pkt = { 0 };
int i, ret = 0;
- ret = ff_h2645_packet_split(&pkt, data, size, logctx, is_avc, 2, AV_CODEC_ID_H264, 1);
+ ret = ff_h2645_packet_split(&pkt, data, size, logctx, is_avc, 2, AV_CODEC_ID_H264, 1, 0);
if (ret < 0) {
ret = 0;
goto fail;
for (i = 0; i < pkt.nb_nals; i++) {
H2645NAL *nal = &pkt.nals[i];
switch (nal->type) {
- case H264_NAL_SPS:
- ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0);
+ case H264_NAL_SPS: {
+ GetBitContext tmp_gb = nal->gb;
+ ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0);
+ if (ret >= 0)
+ break;
+ av_log(logctx, AV_LOG_DEBUG,
+ "SPS decoding failure, trying again with the complete NAL\n");
+ init_get_bits8(&tmp_gb, nal->raw_data + 1, nal->raw_size - 1);
+ ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0);
+ if (ret >= 0)
+ break;
+ ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 1);
if (ret < 0)
goto fail;
break;
+ }
case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
nal->size_bits);