const int st_size = big_mb_num + h->mb_stride;
int x, y;
- FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->intra4x4_pred_mode,
- row_mb_num, 8 * sizeof(uint8_t), fail)
+ if (!FF_ALLOCZ_TYPED_ARRAY(h->intra4x4_pred_mode, row_mb_num * 8) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->non_zero_count, big_mb_num) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->slice_table_base, st_size) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->cbp_table, big_mb_num) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->chroma_pred_mode_table, big_mb_num) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->mvd_table[0], row_mb_num * 8) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->mvd_table[1], row_mb_num * 8) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->direct_table, big_mb_num * 4) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->list_counts, big_mb_num) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->mb2b_xy, big_mb_num) ||
+ !FF_ALLOCZ_TYPED_ARRAY(h->mb2br_xy, big_mb_num))
+ return AVERROR(ENOMEM);
h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
-
- FF_ALLOCZ_OR_GOTO(h->avctx, h->non_zero_count,
- big_mb_num * 48 * sizeof(uint8_t), fail)
- FF_ALLOCZ_OR_GOTO(h->avctx, h->slice_table_base,
- st_size * sizeof(*h->slice_table_base), fail)
- FF_ALLOCZ_OR_GOTO(h->avctx, h->cbp_table,
- big_mb_num * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
- big_mb_num * sizeof(uint8_t), fail)
- FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[0],
- row_mb_num, 16 * sizeof(uint8_t), fail);
- FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[1],
- row_mb_num, 16 * sizeof(uint8_t), fail);
h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
h->slice_ctx[0].mvd_table[1] = h->mvd_table[1];
-
- FF_ALLOCZ_OR_GOTO(h->avctx, h->direct_table,
- 4 * big_mb_num * sizeof(uint8_t), fail);
- FF_ALLOCZ_OR_GOTO(h->avctx, h->list_counts,
- big_mb_num * sizeof(uint8_t), fail)
-
memset(h->slice_table_base, -1,
st_size * sizeof(*h->slice_table_base));
h->slice_table = h->slice_table_base + h->mb_stride * 2 + 1;
-
- FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2b_xy,
- big_mb_num * sizeof(uint32_t), fail);
- FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2br_xy,
- big_mb_num * sizeof(uint32_t), fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++) {
const int mb_xy = x + y * h->mb_stride;
}
return 0;
-
-fail:
- return AVERROR(ENOMEM);
}
/**
er->b8_stride = h->mb_width * 2 + 1;
// error resilience code looks cleaner with this
- FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
- (h->mb_num + 1) * sizeof(int), fail);
+ if (!FF_ALLOCZ_TYPED_ARRAY(er->mb_index2xy, h->mb_num + 1) ||
+ !FF_ALLOCZ_TYPED_ARRAY(er->error_status_table, mb_array_size) ||
+ !FF_ALLOCZ_TYPED_ARRAY(er->er_temp_buffer, er_size) ||
+ !FF_ALLOCZ_TYPED_ARRAY(sl->dc_val_base, yc_size))
+ return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
h->mb_stride + h->mb_width;
-
- FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
- mb_array_size * sizeof(uint8_t), fail);
-
- FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
- er_size * sizeof(uint8_t), fail);
-
- FF_ALLOCZ_OR_GOTO(h->avctx, sl->dc_val_base,
- yc_size * sizeof(int16_t), fail);
er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
}
return 0;
-
-fail:
- return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
}
static int h264_init_context(AVCodecContext *avctx, H264Context *h)
return ret;
}
-static int is_extra(const uint8_t *buf, int buf_size)
+static int is_avcc_extradata(const uint8_t *buf, int buf_size)
{
int cnt= buf[5]&0x1f;
const uint8_t *p= buf+6;
if (buf_size == 0)
return send_next_delayed_frame(h, pict, got_frame, 0);
- if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
- int side_size;
+ if (av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
+ buffer_size_t side_size;
uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
- if (is_extra(side, side_size))
- ff_h264_decode_extradata(side, side_size,
- &h->ps, &h->is_avc, &h->nal_length_size,
- avctx->err_recognition, avctx);
+ ff_h264_decode_extradata(side, side_size,
+ &h->ps, &h->is_avc, &h->nal_length_size,
+ avctx->err_recognition, avctx);
}
if (h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC) {
- if (is_extra(buf, buf_size))
+ if (is_avcc_extradata(buf, buf_size))
return ff_h264_decode_extradata(buf, buf_size,
&h->ps, &h->is_avc, &h->nal_length_size,
avctx->err_recognition, avctx);
#define OFFSET(x) offsetof(H264Context, x)
#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+#define VDX VD | AV_OPT_FLAG_EXPORT
static const AVOption h264_options[] = {
- { "is_avc", "is avc", OFFSET(is_avc), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0 },
- { "nal_length_size", "nal_length_size", OFFSET(nal_length_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, 0 },
+ { "is_avc", "is avc", OFFSET(is_avc), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VDX },
+ { "nal_length_size", "nal_length_size", OFFSET(nal_length_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VDX },
{ "enable_er", "Enable error resilience on damaged frames (unsafe)", OFFSET(enable_er), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD },
{ "x264_build", "Assume this x264 version if no x264 version found in any SEI", OFFSET(x264_build), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VD },
{ NULL },
.capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_FRAME_THREADS,
- .hw_configs = (const AVCodecHWConfigInternal*[]) {
+ .hw_configs = (const AVCodecHWConfigInternal *const []) {
#if CONFIG_H264_DXVA2_HWACCEL
HWACCEL_DXVA2(h264),
#endif
FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP,
.flush = h264_decode_flush,
.update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
+ .update_thread_context_for_user = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context_for_user),
.profiles = NULL_IF_CONFIG_SMALL(ff_h264_profiles),
.priv_class = &h264_class,
};