#include <inttypes.h>
#include "libavutil/imgutils.h"
+
+#include "golomb_legacy.h"
#include "internal.h"
#include "mathops.h"
#include "avcodec.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
sps->color_primaries = get_bits(gb, 8); /* colour_primaries */
sps->color_trc = get_bits(gb, 8); /* transfer_characteristics */
sps->colorspace = get_bits(gb, 8); /* matrix_coefficients */
- if (sps->color_primaries >= AVCOL_PRI_NB)
+
+ // Set invalid values to "unspecified"
+ if (!av_color_primaries_name(sps->color_primaries))
sps->color_primaries = AVCOL_PRI_UNSPECIFIED;
- if (sps->color_trc >= AVCOL_TRC_NB)
+ if (!av_color_transfer_name(sps->color_trc))
sps->color_trc = AVCOL_TRC_UNSPECIFIED;
- if (sps->colorspace >= AVCOL_SPC_NB)
+ if (!av_color_space_name(sps->colorspace))
sps->colorspace = AVCOL_SPC_UNSPECIFIED;
}
}
sps->gaps_in_frame_num_allowed_flag = get_bits1(gb);
sps->mb_width = get_ue_golomb(gb) + 1;
sps->mb_height = get_ue_golomb(gb) + 1;
+
+ sps->frame_mbs_only_flag = get_bits1(gb);
+
+ if (sps->mb_height >= INT_MAX / 2) {
+ av_log(avctx, AV_LOG_ERROR, "height overflow\n");
+ goto fail;
+ }
+ sps->mb_height *= 2 - sps->frame_mbs_only_flag;
+
if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
(unsigned)sps->mb_height >= INT_MAX / 16 ||
av_image_check_size(16 * sps->mb_width,
goto fail;
}
- sps->frame_mbs_only_flag = get_bits1(gb);
if (!sps->frame_mbs_only_flag)
sps->mb_aff = get_bits1(gb);
else
int step_x = 1 << hsub;
int step_y = (2 - sps->frame_mbs_only_flag) << vsub;
- if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) &&
- !(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) {
- crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8));
- av_log(avctx, AV_LOG_WARNING,
- "Reducing left cropping to %d "
- "chroma samples to preserve alignment.\n",
- crop_left);
- }
-
if (INT_MAX / step_x <= crop_left ||
INT_MAX / step_x - crop_left <= crop_right ||
16 * sps->mb_width <= step_x * (crop_left + crop_right) ||
sps = (SPS*)ps->sps_list[pps->sps_id]->data;
if (sps->bit_depth_luma > 10) {
- av_log(avctx, AV_LOG_ERROR,
- "Unimplemented luma bit depth=%d (max=10)\n",
- sps->bit_depth_luma);
+ avpriv_report_missing_feature(avctx, "Luma bit depth=%d (max=10)",
+ sps->bit_depth_luma);
ret = AVERROR_PATCHWELCOME;
goto fail;
}
if (pps->slice_group_count > 1) {
pps->mb_slice_group_map_type = get_ue_golomb(gb);
av_log(avctx, AV_LOG_ERROR, "FMO not supported\n");
- switch (pps->mb_slice_group_map_type) {
- case 0:
-#if 0
- | for (i = 0; i <= num_slice_groups_minus1; i++) | | |
- | run_length[i] |1 |ue(v) |
-#endif
- break;
- case 2:
-#if 0
- | for (i = 0; i < num_slice_groups_minus1; i++) { | | |
- | top_left_mb[i] |1 |ue(v) |
- | bottom_right_mb[i] |1 |ue(v) |
- | } | | |
-#endif
- break;
- case 3:
- case 4:
- case 5:
-#if 0
- | slice_group_change_direction_flag |1 |u(1) |
- | slice_group_change_rate_minus1 |1 |ue(v) |
-#endif
- break;
- case 6:
-#if 0
- | slice_group_id_cnt_minus1 |1 |ue(v) |
- | for (i = 0; i <= slice_group_id_cnt_minus1; i++)| | |
- | slice_group_id[i] |1 |u(v) |
-#endif
- break;
- }
}
pps->ref_count[0] = get_ue_golomb(gb) + 1;
pps->ref_count[1] = get_ue_golomb(gb) + 1;