aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-04-29 15:44:21 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-29 16:35:24 +0200
commit36f862e04c2afe37c1fd541e01013c6cef4c6015 (patch)
tree3983371af49a7234d87bf999b35b17875db09a64
parent07a79cf8694ac685ae8f579ccc33d113eb46fe3d (diff)
parenta0f2946068c62e18cb05ac25c0df3d86077251a6 (diff)
downloadffmpeg-36f862e04c2afe37c1fd541e01013c6cef4c6015.tar.gz
Merge commit 'a0f2946068c62e18cb05ac25c0df3d86077251a6'
* commit 'a0f2946068c62e18cb05ac25c0df3d86077251a6': h264: use properly allocated AVFrames Conflicts: libavcodec/h264.c libavcodec/h264.h libavcodec/h264_refs.c libavcodec/h264_slice.c libavcodec/svq3.c libavcodec/vda_h264.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/dxva2_h264.c10
-rw-r--r--libavcodec/h264.c84
-rw-r--r--libavcodec/h264.h3
-rw-r--r--libavcodec/h264_mb_template.c8
-rw-r--r--libavcodec/h264_picture.c18
-rw-r--r--libavcodec/h264_refs.c24
-rw-r--r--libavcodec/h264_slice.c68
-rw-r--r--libavcodec/svq3.c90
-rw-r--r--libavcodec/vaapi_h264.c6
-rw-r--r--libavcodec/vda_h264.c4
-rw-r--r--libavcodec/vdpau.c8
-rw-r--r--libavcodec/vdpau_h264.c6
12 files changed, 175 insertions, 154 deletions
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 62a868b752..8915e47a6c 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -51,7 +51,7 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
memset(pp, 0, sizeof(*pp));
/* Configure current picture */
fill_picture_entry(&pp->CurrPic,
- ff_dxva2_get_surface_index(ctx, &current_picture->f),
+ ff_dxva2_get_surface_index(ctx, current_picture->f),
h->picture_structure == PICT_BOTTOM_FIELD);
/* Configure the set of references */
pp->UsedForReferenceFlags = 0;
@@ -67,7 +67,7 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
}
if (r) {
fill_picture_entry(&pp->RefFrameList[i],
- ff_dxva2_get_surface_index(ctx, &r->f),
+ ff_dxva2_get_surface_index(ctx, r->f),
r->long_ref != 0);
if ((r->reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX)
@@ -244,9 +244,9 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
unsigned plane;
unsigned index;
if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
- index = ff_dxva2_get_surface_index(ctx, &r->f);
+ index = ff_dxva2_get_surface_index(ctx, r->f);
else
- index = get_refpic_index(pp, ff_dxva2_get_surface_index(ctx, &r->f));
+ index = get_refpic_index(pp, ff_dxva2_get_surface_index(ctx, r->f));
fill_picture_entry(&slice->RefPicList[list][i], index,
r->reference == PICT_BOTTOM_FIELD);
for (plane = 0; plane < 3; plane++) {
@@ -454,7 +454,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
- ret = ff_dxva2_common_end_frame(avctx, &h->cur_pic_ptr->f,
+ ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 99b99e7a29..eb9a7d0c97 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -99,7 +99,7 @@ void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl,
int y, int height)
{
AVCodecContext *avctx = h->avctx;
- const AVFrame *src = &h->cur_pic.f;
+ const AVFrame *src = h->cur_pic.f;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int vshift = desc->log2_chroma_h;
const int field_pic = h->picture_structure != PICT_FRAME;
@@ -621,9 +621,19 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
return AVERROR(ENOMEM);
}
- for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
- av_frame_unref(&h->DPB[i].f);
- av_frame_unref(&h->cur_pic.f);
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
+ h->DPB[i].f = av_frame_alloc();
+ if (!h->DPB[i].f)
+ return AVERROR(ENOMEM);
+ }
+
+ h->cur_pic.f = av_frame_alloc();
+ if (!h->cur_pic.f)
+ return AVERROR(ENOMEM);
+
+ h->last_pic_for_ec.f = av_frame_alloc();
+ if (!h->last_pic_for_ec.f)
+ return AVERROR(ENOMEM);
for (i = 0; i < h->nb_slice_ctx; i++)
h->slice_ctx[i].h264 = h;
@@ -721,7 +731,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
H264Picture *cur = h->cur_pic_ptr;
int i, pics, out_of_order, out_idx;
- h->cur_pic_ptr->f.pict_type = h->pict_type;
+ h->cur_pic_ptr->f->pict_type = h->pict_type;
if (h->next_output_pic)
return;
@@ -739,8 +749,8 @@ static void decode_postinit(H264Context *h, int setup_finished)
return;
}
- cur->f.interlaced_frame = 0;
- cur->f.repeat_pict = 0;
+ cur->f->interlaced_frame = 0;
+ cur->f->repeat_pict = 0;
/* Signal interlacing information externally. */
/* Prioritize picture timing SEI information over used
@@ -752,55 +762,55 @@ static void decode_postinit(H264Context *h, int setup_finished)
break;
case SEI_PIC_STRUCT_TOP_FIELD:
case SEI_PIC_STRUCT_BOTTOM_FIELD:
- cur->f.interlaced_frame = 1;
+ cur->f->interlaced_frame = 1;
break;
case SEI_PIC_STRUCT_TOP_BOTTOM:
case SEI_PIC_STRUCT_BOTTOM_TOP:
if (FIELD_OR_MBAFF_PICTURE(h))
- cur->f.interlaced_frame = 1;
+ cur->f->interlaced_frame = 1;
else
// try to flag soft telecine progressive
- cur->f.interlaced_frame = h->prev_interlaced_frame;
+ cur->f->interlaced_frame = h->prev_interlaced_frame;
break;
case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
/* Signal the possibility of telecined film externally
* (pic_struct 5,6). From these hints, let the applications
* decide if they apply deinterlacing. */
- cur->f.repeat_pict = 1;
+ cur->f->repeat_pict = 1;
break;
case SEI_PIC_STRUCT_FRAME_DOUBLING:
- cur->f.repeat_pict = 2;
+ cur->f->repeat_pict = 2;
break;
case SEI_PIC_STRUCT_FRAME_TRIPLING:
- cur->f.repeat_pict = 4;
+ cur->f->repeat_pict = 4;
break;
}
if ((h->sei_ct_type & 3) &&
h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)
- cur->f.interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0;
+ cur->f->interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0;
} else {
/* Derive interlacing flag from used decoding process. */
- cur->f.interlaced_frame = FIELD_OR_MBAFF_PICTURE(h);
+ cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h);
}
- h->prev_interlaced_frame = cur->f.interlaced_frame;
+ h->prev_interlaced_frame = cur->f->interlaced_frame;
if (cur->field_poc[0] != cur->field_poc[1]) {
/* Derive top_field_first from field pocs. */
- cur->f.top_field_first = cur->field_poc[0] < cur->field_poc[1];
+ cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1];
} else {
- if (cur->f.interlaced_frame || h->sps.pic_struct_present_flag) {
+ if (cur->f->interlaced_frame || h->sps.pic_struct_present_flag) {
/* Use picture timing SEI information. Even if it is a
* information of a past frame, better than nothing. */
if (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||
h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
- cur->f.top_field_first = 1;
+ cur->f->top_field_first = 1;
else
- cur->f.top_field_first = 0;
+ cur->f->top_field_first = 0;
} else {
/* Most likely progressive */
- cur->f.top_field_first = 0;
+ cur->f->top_field_first = 0;
}
}
@@ -809,7 +819,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
h->frame_packing_arrangement_type <= 6 &&
h->content_interpretation_type > 0 &&
h->content_interpretation_type < 3) {
- AVStereo3D *stereo = av_stereo3d_create_side_data(&cur->f);
+ AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f);
if (stereo) {
switch (h->frame_packing_arrangement_type) {
case 0:
@@ -846,7 +856,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
if (h->sei_display_orientation_present &&
(h->sei_anticlockwise_rotation || h->sei_hflip || h->sei_vflip)) {
double angle = h->sei_anticlockwise_rotation * 360 / (double) (1 << 16);
- AVFrameSideData *rotation = av_frame_new_side_data(&cur->f,
+ AVFrameSideData *rotation = av_frame_new_side_data(cur->f,
AV_FRAME_DATA_DISPLAYMATRIX,
sizeof(int32_t) * 9);
if (rotation) {
@@ -885,7 +895,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
}
}
out_of_order = MAX_DELAYED_PIC_COUNT - i;
- if( cur->f.pict_type == AV_PICTURE_TYPE_B
+ if( cur->f->pict_type == AV_PICTURE_TYPE_B
|| (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2))
out_of_order = FFMAX(out_of_order, 1);
if (out_of_order == MAX_DELAYED_PIC_COUNT) {
@@ -913,7 +923,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1; h->delayed_pic[i] &&
- !h->delayed_pic[i]->f.key_frame &&
+ !h->delayed_pic[i]->f->key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
@@ -921,7 +931,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
out_idx = i;
}
if (h->avctx->has_b_frames == 0 &&
- (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset))
+ (h->delayed_pic[0]->f->key_frame || h->delayed_pic[0]->mmco_reset))
h->next_outputed_poc = INT_MIN;
out_of_order = out->poc < h->next_outputed_poc;
@@ -934,7 +944,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
}
if (!out_of_order && pics > h->avctx->has_b_frames) {
h->next_output_pic = out;
- if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
+ if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f->key_frame || h->delayed_pic[0]->mmco_reset)) {
h->next_outputed_poc = INT_MIN;
} else
h->next_outputed_poc = out->poc;
@@ -1496,7 +1506,7 @@ again:
}
}
- h->cur_pic_ptr->f.key_frame |=
+ h->cur_pic_ptr->f->key_frame |=
(h->nal_unit_type == NAL_IDR_SLICE);
if (h->nal_unit_type == NAL_IDR_SLICE ||
@@ -1537,10 +1547,10 @@ again:
goto end;
} else if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
- ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
+ ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
start_code,
sizeof(start_code));
- ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
+ ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0],
&buf[buf_index - consumed],
consumed);
} else
@@ -1658,7 +1668,7 @@ static int get_consumed_bytes(int pos, int buf_size)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
{
- AVFrame *src = &srcp->f;
+ AVFrame *src = srcp->f;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src->format);
int i;
int ret = av_frame_ref(dst, src);
@@ -1732,7 +1742,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
- !h->delayed_pic[i]->f.key_frame &&
+ !h->delayed_pic[i]->f->key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
@@ -1793,14 +1803,14 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
if (h->next_output_pic && (
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
- h->next_output_pic->f.flags |= AV_FRAME_FLAG_CORRUPT;
+ h->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT;
if (!h->avctx->hwaccel &&
(h->next_output_pic->field_poc[0] == INT_MAX ||
h->next_output_pic->field_poc[1] == INT_MAX)
) {
int p;
- AVFrame *f = &h->next_output_pic->f;
+ AVFrame *f = h->next_output_pic->f;
int field = h->next_output_pic->field_poc[0] == INT_MAX;
uint8_t *dst_data[4];
int linesizes[4];
@@ -1846,8 +1856,10 @@ av_cold void ff_h264_free_context(H264Context *h)
ff_h264_free_tables(h);
- for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
ff_h264_unref_picture(h, &h->DPB[i]);
+ av_frame_free(&h->DPB[i].f);
+ }
memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
h->cur_pic_ptr = NULL;
@@ -1872,7 +1884,9 @@ static av_cold int h264_decode_end(AVCodecContext *avctx)
ff_h264_free_context(h);
ff_h264_unref_picture(h, &h->cur_pic);
+ av_frame_free(&h->cur_pic.f);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
+ av_frame_free(&h->last_pic_for_ec.f);
return 0;
}
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 7ab1fdfda1..95db912465 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -290,8 +290,7 @@ typedef struct MMCO {
} MMCO;
typedef struct H264Picture {
- struct AVFrame f;
- uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
+ AVFrame *f;
ThreadFrame tf;
AVBufferRef *qscale_table_buf;
diff --git a/libavcodec/h264_mb_template.c b/libavcodec/h264_mb_template.c
index 685535f803..bc68a738b8 100644
--- a/libavcodec/h264_mb_template.c
+++ b/libavcodec/h264_mb_template.c
@@ -57,9 +57,9 @@ static av_noinline void FUNC(hl_decode_mb)(const H264Context *h, H264SliceContex
const int block_h = 16 >> h->chroma_y_shift;
const int chroma422 = CHROMA422(h);
- dest_y = h->cur_pic.f.data[0] + ((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16;
- dest_cb = h->cur_pic.f.data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h;
- dest_cr = h->cur_pic.f.data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h;
+ dest_y = h->cur_pic.f->data[0] + ((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16;
+ dest_cb = h->cur_pic.f->data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h;
+ dest_cr = h->cur_pic.f->data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h;
h->vdsp.prefetch(dest_y + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT), sl->linesize, 4);
h->vdsp.prefetch(dest_cb + (sl->mb_x & 7) * sl->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2);
@@ -283,7 +283,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(const H264Context *h, H264SliceCo
const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) ? 3 : 1;
for (p = 0; p < plane_count; p++) {
- dest[p] = h->cur_pic.f.data[p] +
+ dest[p] = h->cur_pic.f->data[p] +
((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16;
h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT),
sl->linesize, 4);
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index 14a96d0e3d..14d8f19ef8 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -49,7 +49,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
int off = offsetof(H264Picture, tf) + sizeof(pic->tf);
int i;
- if (!pic->f.buf[0])
+ if (!pic->f || !pic->f->buf[0])
return;
ff_thread_release_buffer(h->avctx, &pic->tf);
@@ -69,11 +69,11 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
{
int ret, i;
- av_assert0(!dst->f.buf[0]);
- av_assert0(src->f.buf[0]);
+ av_assert0(!dst->f->buf[0]);
+ av_assert0(src->f->buf[0]);
- src->tf.f = &src->f;
- dst->tf.f = &dst->f;
+ src->tf.f = src->f;
+ dst->tf.f = dst->f;
ret = ff_thread_ref_frame(&dst->tf, &src->tf);
if (ret < 0)
goto fail;
@@ -138,7 +138,7 @@ void ff_h264_set_erpic(ERPicture *dst, H264Picture *src)
if (!src)
return;
- dst->f = &src->f;
+ dst->f = src->f;
dst->tf = &src->tf;
for (i = 0; i < 2; i++) {
@@ -196,15 +196,15 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
* causes problems for the first MB line, too.
*/
if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new && h->enable_er) {
- int use_last_pic = h->last_pic_for_ec.f.buf[0] && !sl->ref_count[0];
+ int use_last_pic = h->last_pic_for_ec.f->buf[0] && !sl->ref_count[0];
ff_h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr);
if (use_last_pic) {
ff_h264_set_erpic(&sl->er.last_pic, &h->last_pic_for_ec);
sl->ref_list[0][0].parent = &h->last_pic_for_ec;
- memcpy(sl->ref_list[0][0].data, h->last_pic_for_ec.f.data, sizeof(sl->ref_list[0][0].data));
- memcpy(sl->ref_list[0][0].linesize, h->last_pic_for_ec.f.linesize, sizeof(sl->ref_list[0][0].linesize));
+ memcpy(sl->ref_list[0][0].data, h->last_pic_for_ec.f->data, sizeof(sl->ref_list[0][0].data));
+ memcpy(sl->ref_list[0][0].linesize, h->last_pic_for_ec.f->linesize, sizeof(sl->ref_list[0][0].linesize));
sl->ref_list[0][0].reference = h->last_pic_for_ec.reference;
} else if (sl->ref_count[0]) {
ff_h264_set_erpic(&sl->er.last_pic, sl->ref_list[0][0].parent);
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 0b2008ac3d..379fb26a1a 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -50,8 +50,8 @@ static void pic_as_field(H264Ref *pic, const int parity)
static void ref_from_h264pic(H264Ref *dst, H264Picture *src)
{
- memcpy(dst->data, src->f.data, sizeof(dst->data));
- memcpy(dst->linesize, src->f.linesize, sizeof(dst->linesize));
+ memcpy(dst->data, src->f->data, sizeof(dst->data));
+ memcpy(dst->linesize, src->f->linesize, sizeof(dst->linesize));
dst->reference = src->reference;
dst->poc = src->poc;
dst->pic_id = src->pic_id;
@@ -155,8 +155,8 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
if (lens[0] == lens[1] && lens[1] > 1) {
for (i = 0; i < lens[0] &&
- h->default_ref_list[0][i].parent->f.buf[0]->buffer ==
- h->default_ref_list[1][i].parent->f.buf[0]->buffer; i++);
+ h->default_ref_list[0][i].parent->f->buf[0]->buffer ==
+ h->default_ref_list[1][i].parent->f->buf[0]->buffer; i++);
if (i == lens[0]) {
FFSWAP(H264Ref, h->default_ref_list[1][0], h->default_ref_list[1][1]);
}
@@ -177,14 +177,14 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
ff_tlog(h->avctx, "List0: %s fn:%d 0x%p\n",
h->default_ref_list[0][i].parent ? (h->default_ref_list[0][i].parent->long_ref ? "LT" : "ST") : "NULL",
h->default_ref_list[0][i].pic_id,
- h->default_ref_list[0][i].parent ? h->default_ref_list[0][i].parent->f.data[0] : 0);
+ h->default_ref_list[0][i].parent ? h->default_ref_list[0][i].parent->f->data[0] : 0);
}
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
for (i = 0; i < sl->ref_count[1]; i++) {
ff_tlog(h->avctx, "List1: %s fn:%d 0x%p\n",
h->default_ref_list[1][i].parent ? (h->default_ref_list[1][i].parent->long_ref ? "LT" : "ST") : "NULL",
h->default_ref_list[1][i].pic_id,
- h->default_ref_list[1][i].parent ? h->default_ref_list[1][i].parent->f.data[0] : 0);
+ h->default_ref_list[1][i].parent ? h->default_ref_list[1][i].parent->f->data[0] : 0);
}
}
#endif
@@ -341,7 +341,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
else
return -1;
}
- av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f.buf[0]) > 0);
+ av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f->buf[0]) > 0);
}
}
@@ -366,7 +366,7 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl)
field[1] = field[0];
for (j = 0; j < 3; j++)
- field[1].data[j] += frame->parent->f.linesize[j];
+ field[1].data[j] += frame->parent->f->linesize[j];
field[1].reference = PICT_BOTTOM_FIELD;
field[1].poc = field[1].parent->field_poc[1];
@@ -497,7 +497,7 @@ void ff_h264_remove_all_refs(H264Context *h)
}
assert(h->long_ref_count == 0);
- if (h->short_ref_count && !h->last_pic_for_ec.f.data[0]) {
+ if (h->short_ref_count && !h->last_pic_for_ec.f->data[0]) {
ff_h264_unref_picture(h, &h->last_pic_for_ec);
ff_h264_ref_picture(h, &h->last_pic_for_ec, h->short_ref[0]);
}
@@ -527,7 +527,7 @@ static void print_short_term(H264Context *h)
for (i = 0; i < h->short_ref_count; i++) {
H264Picture *pic = h->short_ref[i];
av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
- i, pic->frame_num, pic->poc, pic->f.data[0]);
+ i, pic->frame_num, pic->poc, pic->f->data[0]);
}
}
}
@@ -544,7 +544,7 @@ static void print_long_term(H264Context *h)
H264Picture *pic = h->long_ref[i];
if (pic) {
av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
- i, pic->frame_num, pic->poc, pic->f.data[0]);
+ i, pic->frame_num, pic->poc, pic->f->data[0]);
}
}
}
@@ -789,7 +789,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
&& h->long_ref_count==0
&& (h->short_ref_count<=2 || h->pps.ref_count[0] <= 1 && h->pps.ref_count[1] <= 1 && pps_count == 1)
&& h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point)
- && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
+ && h->cur_pic_ptr->f->pict_type == AV_PICTURE_TYPE_I){
h->cur_pic_ptr->recovered |= 1;
if(!h->avctx->has_b_frames)
h->frame_recovered |= FRAME_RECOVERED_SEI;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index db6288d842..9188eb471e 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -154,7 +154,7 @@ static void release_unused_pictures(H264Context *h, int remove_current)
/* release non reference frames */
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
- if (h->DPB[i].f.buf[0] && !h->DPB[i].reference &&
+ if (h->DPB[i].f->buf[0] && !h->DPB[i].reference &&
(remove_current || &h->DPB[i] != h->cur_pic_ptr)) {
ff_h264_unref_picture(h, &h->DPB[i]);
}
@@ -224,9 +224,9 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
{
int i, ret = 0;
- av_assert0(!pic->f.data[0]);
+ av_assert0(!pic->f->data[0]);
- pic->tf.f = &pic->f;
+ pic->tf.f = pic->f;
ret = ff_thread_get_buffer(h->avctx, &pic->tf, pic->reference ?
AV_GET_BUFFER_FLAG_REF : 0);
if (ret < 0)
@@ -246,15 +246,15 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
}
}
- if (CONFIG_GRAY && !h->avctx->hwaccel && h->flags & CODEC_FLAG_GRAY && pic->f.data[2]) {
+ if (CONFIG_GRAY && !h->avctx->hwaccel && h->flags & CODEC_FLAG_GRAY && pic->f->data[2]) {
int h_chroma_shift, v_chroma_shift;
- av_pix_fmt_get_chroma_sub_sample(pic->f.format,
+ av_pix_fmt_get_chroma_sub_sample(pic->f->format,
&h_chroma_shift, &v_chroma_shift);
for(i=0; i<FF_CEIL_RSHIFT(h->avctx->height, v_chroma_shift); i++) {
- memset(pic->f.data[1] + pic->f.linesize[1]*i,
+ memset(pic->f->data[1] + pic->f->linesize[1]*i,
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
- memset(pic->f.data[2] + pic->f.linesize[2]*i,
+ memset(pic->f->data[2] + pic->f->linesize[2]*i,
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
}
}
@@ -291,7 +291,7 @@ fail:
static inline int pic_is_unused(H264Context *h, H264Picture *pic)
{
- if (!pic->f.buf[0])
+ if (!pic->f->buf[0])
return 1;
return 0;
}
@@ -500,14 +500,14 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
ff_h264_unref_picture(h, &h->DPB[i]);
- if (h1->DPB[i].f.buf[0] &&
+ if (h1->DPB[i].f->buf[0] &&
(ret = ff_h264_ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
return ret;
}
h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
ff_h264_unref_picture(h, &h->cur_pic);
- if (h1->cur_pic.f.buf[0]) {
+ if (h1->cur_pic.f->buf[0]) {
ret = ff_h264_ref_picture(h, &h->cur_pic, &h1->cur_pic);
if (ret < 0)
return ret;
@@ -594,7 +594,7 @@ static int h264_frame_start(H264Context *h)
pic = &h->DPB[i];
pic->reference = h->droppable ? 0 : h->picture_structure;
- pic->f.coded_picture_number = h->coded_picture_number++;
+ pic->f->coded_picture_number = h->coded_picture_number++;
pic->field_picture = h->picture_structure != PICT_FRAME;
/*
@@ -602,7 +602,7 @@ static int h264_frame_start(H264Context *h)
* in later.
* See decode_nal_units().
*/
- pic->f.key_frame = 0;
+ pic->f->key_frame = 0;
pic->mmco_reset = 0;
pic->recovered = 0;
pic->invalid_gap = 0;
@@ -612,7 +612,7 @@ static int h264_frame_start(H264Context *h)
return ret;
if(!h->frame_recovered && !h->avctx->hwaccel &&
!(h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU))
- avpriv_color_frame(&pic->f, c);
+ avpriv_color_frame(pic->f, c);
h->cur_pic_ptr = pic;
ff_h264_unref_picture(h, &h->cur_pic);
@@ -624,8 +624,8 @@ static int h264_frame_start(H264Context *h)
return ret;
for (i = 0; i < h->nb_slice_ctx; i++) {
- h->slice_ctx[i].linesize = h->cur_pic_ptr->f.linesize[0];
- h->slice_ctx[i].uvlinesize = h->cur_pic_ptr->f.linesize[1];
+ h->slice_ctx[i].linesize = h->cur_pic_ptr->f->linesize[0];
+ h->slice_ctx[i].uvlinesize = h->cur_pic_ptr->f->linesize[1];
}
if (CONFIG_ERROR_RESILIENCE && h->enable_er) {
@@ -635,14 +635,14 @@ static int h264_frame_start(H264Context *h)
}
for (i = 0; i < 16; i++) {
- h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * pic->f.linesize[0] * ((scan8[i] - scan8[0]) >> 3);
- h->block_offset[48 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * pic->f.linesize[0] * ((scan8[i] - scan8[0]) >> 3);
+ h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * pic->f->linesize[0] * ((scan8[i] - scan8[0]) >> 3);
+ h->block_offset[48 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * pic->f->linesize[0] * ((scan8[i] - scan8[0]) >> 3);
}
for (i = 0; i < 16; i++) {
h->block_offset[16 + i] =
- h->block_offset[32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * pic->f.linesize[1] * ((scan8[i] - scan8[0]) >> 3);
+ h->block_offset[32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * pic->f->linesize[1] * ((scan8[i] - scan8[0]) >> 3);
h->block_offset[48 + 16 + i] =
- h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * pic->f.linesize[1] * ((scan8[i] - scan8[0]) >> 3);
+ h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * pic->f->linesize[1] * ((scan8[i] - scan8[0]) >> 3);
}
/* We mark the current picture as non-reference after allocating it, so
@@ -1460,7 +1460,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
* since that can modify h->cur_pic_ptr. */
if (h->first_field) {
av_assert0(h->cur_pic_ptr);
- av_assert0(h->cur_pic_ptr->f.buf[0]);
+ av_assert0(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* Mark old field/frame as completed */
@@ -1545,10 +1545,10 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
* is not noticeable by comparison, but it should be fixed. */
if (h->short_ref_count) {
if (prev) {
- av_image_copy(h->short_ref[0]->f.data,
- h->short_ref[0]->f.linesize,
- (const uint8_t **)prev->f.data,
- prev->f.linesize,
+ av_image_copy(h->short_ref[0]->f->data,
+ h->short_ref[0]->f->linesize,
+ (const uint8_t **)prev->f->data,
+ prev->f->linesize,
h->avctx->pix_fmt,
h->mb_width * 16,
h->mb_height * 16);
@@ -1563,7 +1563,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
* frame, or to allocate a new one. */
if (h->first_field) {
av_assert0(h->cur_pic_ptr);
- av_assert0(h->cur_pic_ptr->f.buf[0]);
+ av_assert0(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */
@@ -1833,16 +1833,16 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
for (i = 0; i < 16; i++) {
id_list[i] = 60;
if (j < sl->list_count && i < sl->ref_count[j] &&
- sl->ref_list[j][i].parent->f.buf[0]) {
+ sl->ref_list[j][i].parent->f->buf[0]) {
int k;
- AVBuffer *buf = sl->ref_list[j][i].parent->f.buf[0]->buffer;
+ AVBuffer *buf = sl->ref_list[j][i].parent->f->buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
- if (h->short_ref[k]->f.buf[0]->buffer == buf) {
+ if (h->short_ref[k]->f->buf[0]->buffer == buf) {
id_list[i] = k;
break;
}
for (k = 0; k < h->long_ref_count; k++)
- if (h->long_ref[k] && h->long_ref[k]->f.buf[0]->buffer == buf) {
+ if (h->long_ref[k] && h->long_ref[k]->f->buf[0]->buffer == buf) {
id_list[i] = h->short_ref_count + k;
break;
}
@@ -2161,12 +2161,12 @@ static void loop_filter(const H264Context *h, H264SliceContext *sl, int start_x,
sl->mb_x = mb_x;
sl->mb_y = mb_y;
- dest_y = h->cur_pic.f.data[0] +
+ dest_y = h->cur_pic.f->data[0] +
((mb_x << pixel_shift) + mb_y * sl->linesize) * 16;
- dest_cb = h->cur_pic.f.data[1] +
+ dest_cb = h->cur_pic.f->data[1] +
(mb_x << pixel_shift) * (8 << CHROMA444(h)) +
mb_y * sl->uvlinesize * block_h;
- dest_cr = h->cur_pic.f.data[2] +
+ dest_cr = h->cur_pic.f->data[2] +
(mb_x << pixel_shift) * (8 << CHROMA444(h)) +
mb_y * sl->uvlinesize * block_h;
// FIXME simplify above
@@ -2271,8 +2271,8 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
int lf_x_start = sl->mb_x;
int ret;
- sl->linesize = h->cur_pic_ptr->f.linesize[0];
- sl->uvlinesize = h->cur_pic_ptr->f.linesize[1];
+ sl->linesize = h->cur_pic_ptr->f->linesize[0];
+ sl->uvlinesize = h->cur_pic_ptr->f->linesize[1];
ret = alloc_scratch_buffers(sl, sl->linesize);
if (ret < 0)
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 05fc9b723b..a5920fb2fb 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -320,8 +320,8 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
}
/* form component predictions */
- dest = h->cur_pic.f.data[0] + x + y * sl->linesize;
- src = pic->f.data[0] + mx + my * sl->linesize;
+ dest = h->cur_pic.f->data[0] + x + y * sl->linesize;
+ src = pic->f->data[0] + mx + my * sl->linesize;
if (emu) {
h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src,
@@ -347,8 +347,8 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
blocksize++;
for (i = 1; i < 3; i++) {
- dest = h->cur_pic.f.data[i] + (x >> 1) + (y >> 1) * sl->uvlinesize;
- src = pic->f.data[i] + mx + my * sl->uvlinesize;
+ dest = h->cur_pic.f->data[i] + (x >> 1) + (y >> 1) * sl->uvlinesize;
+ src = pic->f->data[i] + mx + my * sl->uvlinesize;
if (emu) {
h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src,
@@ -890,9 +890,18 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
goto fail;
}
+ s->cur_pic->f = av_frame_alloc();
+ s->last_pic->f = av_frame_alloc();
+ s->next_pic->f = av_frame_alloc();
+ if (!s->cur_pic->f || !s->last_pic->f || !s->next_pic->f)
+ return AVERROR(ENOMEM);
+
if ((ret = ff_h264_decode_init(avctx)) < 0)
goto fail;
+ // we will overwrite it later during decoding
+ av_frame_free(&h->cur_pic.f);
+
ff_h264dsp_init(&h->h264dsp, 8, 1);
av_assert0(h->sps.bit_depth_chroma == 0);
ff_h264_pred_init(&h->hpc, AV_CODEC_ID_SVQ3, 8, 1);
@@ -1088,7 +1097,7 @@ static void free_picture(AVCodecContext *avctx, H264Picture *pic)
}
av_buffer_unref(&pic->mb_type_buf);
- av_frame_unref(&pic->f);
+ av_frame_unref(pic->f);
}
static int get_buffer(AVCodecContext *avctx, H264Picture *pic)
@@ -1124,19 +1133,19 @@ static int get_buffer(AVCodecContext *avctx, H264Picture *pic)
}
pic->reference = !(h->pict_type == AV_PICTURE_TYPE_B);
- ret = ff_get_buffer(avctx, &pic->f,
+ ret = ff_get_buffer(avctx, pic->f,
pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
if (ret < 0)
goto fail;
if (!sl->edge_emu_buffer) {
- sl->edge_emu_buffer = av_mallocz_array(pic->f.linesize[0], 17);
+ sl->edge_emu_buffer = av_mallocz_array(pic->f->linesize[0], 17);
if (!sl->edge_emu_buffer)
return AVERROR(ENOMEM);
}
- sl->linesize = pic->f.linesize[0];
- sl->uvlinesize = pic->f.linesize[1];
+ sl->linesize = pic->f->linesize[0];
+ sl->uvlinesize = pic->f->linesize[1];
return 0;
fail:
@@ -1157,8 +1166,8 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
/* special case for last picture */
if (buf_size == 0) {
- if (s->next_pic->f.data[0] && !h->low_delay && !s->last_frame_output) {
- ret = av_frame_ref(data, &s->next_pic->f);
+ if (s->next_pic->f->data[0] && !h->low_delay && !s->last_frame_output) {
+ ret = av_frame_ref(data, s->next_pic->f);
if (ret < 0)
return ret;
s->last_frame_output = 1;
@@ -1189,22 +1198,18 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
if (h->pict_type != AV_PICTURE_TYPE_B)
FFSWAP(H264Picture*, s->next_pic, s->last_pic);
- av_frame_unref(&s->cur_pic->f);
+ av_frame_unref(s->cur_pic->f);
/* for skipping the frame */
- s->cur_pic->f.pict_type = h->pict_type;
- s->cur_pic->f.key_frame = (h->pict_type == AV_PICTURE_TYPE_I);
+ s->cur_pic->f->pict_type = h->pict_type;
+ s->cur_pic->f->key_frame = (h->pict_type == AV_PICTURE_TYPE_I);
ret = get_buffer(avctx, s->cur_pic);
if (ret < 0)
return ret;
h->cur_pic_ptr = s->cur_pic;
- av_frame_unref(&h->cur_pic.f);
- memcpy(&h->cur_pic.tf, &s->cur_pic->tf, sizeof(h->cur_pic) - offsetof(H264Picture, tf));
- ret = av_frame_ref(&h->cur_pic.f, &s->cur_pic->f);
- if (ret < 0)
- return ret;
+ h->cur_pic = *s->cur_pic;
for (i = 0; i < 16; i++) {
h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7)) + 4 * sl->linesize * ((scan8[i] - scan8[0]) >> 3);
@@ -1218,30 +1223,30 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
}
if (h->pict_type != AV_PICTURE_TYPE_I) {
- if (!s->last_pic->f.data[0]) {
+ if (!s->last_pic->f->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
- av_frame_unref(&s->last_pic->f);
+ av_frame_unref(s->last_pic->f);
ret = get_buffer(avctx, s->last_pic);
if (ret < 0)
return ret;
- memset(s->last_pic->f.data[0], 0, avctx->height * s->last_pic->f.linesize[0]);
- memset(s->last_pic->f.data[1], 0x80, (avctx->height / 2) *
- s->last_pic->f.linesize[1]);
- memset(s->last_pic->f.data[2], 0x80, (avctx->height / 2) *
- s->last_pic->f.linesize[2]);
+ memset(s->last_pic->f->data[0], 0, avctx->height * s->last_pic->f->linesize[0]);
+ memset(s->last_pic->f->data[1], 0x80, (avctx->height / 2) *
+ s->last_pic->f->linesize[1]);
+ memset(s->last_pic->f->data[2], 0x80, (avctx->height / 2) *
+ s->last_pic->f->linesize[2]);
}
- if (h->pict_type == AV_PICTURE_TYPE_B && !s->next_pic->f.data[0]) {
+ if (h->pict_type == AV_PICTURE_TYPE_B && !s->next_pic->f->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
- av_frame_unref(&s->next_pic->f);
+ av_frame_unref(s->next_pic->f);
ret = get_buffer(avctx, s->next_pic);
if (ret < 0)
return ret;
- memset(s->next_pic->f.data[0], 0, avctx->height * s->next_pic->f.linesize[0]);
- memset(s->next_pic->f.data[1], 0x80, (avctx->height / 2) *
- s->next_pic->f.linesize[1]);
- memset(s->next_pic->f.data[2], 0x80, (avctx->height / 2) *
- s->next_pic->f.linesize[2]);
+ memset(s->next_pic->f->data[0], 0, avctx->height * s->next_pic->f->linesize[0]);
+ memset(s->next_pic->f->data[1], 0x80, (avctx->height / 2) *
+ s->next_pic->f->linesize[1]);
+ memset(s->next_pic->f->data[2], 0x80, (avctx->height / 2) *
+ s->next_pic->f->linesize[2]);
}
}
@@ -1331,8 +1336,8 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
(h->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
}
- ff_draw_horiz_band(avctx, &s->cur_pic->f,
- s->last_pic->f.data[0] ? &s->last_pic->f : NULL,
+ ff_draw_horiz_band(avctx, s->cur_pic->f,
+ s->last_pic->f->data[0] ? s->last_pic->f : NULL,
16 * sl->mb_y, 16, h->picture_structure, 0,
h->low_delay);
}
@@ -1350,20 +1355,20 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
}
if (h->pict_type == AV_PICTURE_TYPE_B || h->low_delay)
- ret = av_frame_ref(data, &s->cur_pic->f);
- else if (s->last_pic->f.data[0])
- ret = av_frame_ref(data, &s->last_pic->f);
+ ret = av_frame_ref(data, s->cur_pic->f);
+ else if (s->last_pic->f->data[0])
+ ret = av_frame_ref(data, s->last_pic->f);
if (ret < 0)
return ret;
/* Do not output the last pic after seeking. */
- if (s->last_pic->f.data[0] || h->low_delay)
+ if (s->last_pic->f->data[0] || h->low_delay)
*got_frame = 1;
if (h->pict_type != AV_PICTURE_TYPE_B) {
FFSWAP(H264Picture*, s->cur_pic, s->next_pic);
} else {
- av_frame_unref(&s->cur_pic->f);
+ av_frame_unref(s->cur_pic->f);
}
return buf_size;
@@ -1377,11 +1382,14 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx)
free_picture(avctx, s->cur_pic);
free_picture(avctx, s->next_pic);
free_picture(avctx, s->last_pic);
+ av_frame_free(&s->cur_pic->f);
+ av_frame_free(&s->next_pic->f);
+ av_frame_free(&s->last_pic->f);
av_freep(&s->cur_pic);
av_freep(&s->next_pic);
av_freep(&s->last_pic);
- av_frame_unref(&h->cur_pic.f);
+ memset(&h->cur_pic, 0, sizeof(h->cur_pic));
ff_h264_free_context(h);
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index 1a990b3146..eef3c29ab5 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -59,7 +59,7 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic,
pic_structure = pic->reference;
pic_structure &= PICT_FRAME; /* PICT_TOP_FIELD|PICT_BOTTOM_FIELD */
- va_pic->picture_id = ff_vaapi_get_surface_id(&pic->f);
+ va_pic->picture_id = ff_vaapi_get_surface_id(pic->f);
va_pic->frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
va_pic->flags = 0;
@@ -99,7 +99,7 @@ static int dpb_add(DPB *dpb, H264Picture *pic)
for (i = 0; i < dpb->size; i++) {
VAPictureH264 * const va_pic = &dpb->va_pics[i];
- if (va_pic->picture_id == ff_vaapi_get_surface_id(&pic->f)) {
+ if (va_pic->picture_id == ff_vaapi_get_surface_id(pic->f)) {
VAPictureH264 temp_va_pic;
fill_vaapi_pic(&temp_va_pic, pic, 0);
@@ -301,7 +301,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
if (ret < 0)
goto finish;
- ret = ff_vaapi_render_picture(vactx, ff_vaapi_get_surface_id(&h->cur_pic_ptr->f));
+ ret = ff_vaapi_render_picture(vactx, ff_vaapi_get_surface_id(h->cur_pic_ptr->f));
if (ret < 0)
goto finish;
diff --git a/libavcodec/vda_h264.c b/libavcodec/vda_h264.c
index 2a183302d0..8ea81d8d2e 100644
--- a/libavcodec/vda_h264.c
+++ b/libavcodec/vda_h264.c
@@ -143,7 +143,7 @@ static int vda_old_h264_end_frame(AVCodecContext *avctx)
H264Context *h = avctx->priv_data;
VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
- AVFrame *frame = &h->cur_pic_ptr->f;
+ AVFrame *frame = h->cur_pic_ptr->f;
struct vda_buffer *context;
AVBufferRef *buffer;
int status;
@@ -375,7 +375,7 @@ static int vda_h264_end_frame(AVCodecContext *avctx)
H264Context *h = avctx->priv_data;
VDAContext *vda = avctx->internal->hwaccel_priv_data;
AVVDAContext *vda_ctx = avctx->hwaccel_context;
- AVFrame *frame = &h->cur_pic_ptr->f;
+ AVFrame *frame = h->cur_pic_ptr->f;
uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames
CFDataRef coded_frame;
OSStatus status;
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 1656995666..0c3893507e 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -364,7 +364,7 @@ void ff_vdpau_h264_set_reference_frames(H264Context *h)
H264Picture *pic;
int i, list, pic_frame_idx;
- render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
+ render = (struct vdpau_render_state *)h->cur_pic_ptr->f->data[0];
assert(render);
rf = &render->info.h264.referenceFrames[0];
@@ -380,7 +380,7 @@ void ff_vdpau_h264_set_reference_frames(H264Context *h)
continue;
pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
- render_ref = (struct vdpau_render_state *)pic->f.data[0];
+ render_ref = (struct vdpau_render_state *)pic->f->data[0];
assert(render_ref);
rf2 = &render->info.h264.referenceFrames[0];
@@ -448,7 +448,7 @@ void ff_vdpau_h264_picture_start(H264Context *h)
struct vdpau_render_state *render;
int i;
- render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
+ render = (struct vdpau_render_state *)h->cur_pic_ptr->f->data[0];
assert(render);
for (i = 0; i < 2; ++i) {
@@ -465,7 +465,7 @@ void ff_vdpau_h264_picture_complete(H264Context *h)
{
struct vdpau_render_state *render;
- render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
+ render = (struct vdpau_render_state *)h->cur_pic_ptr->f->data[0];
assert(render);
render->info.h264.slice_count = h->current_slice;
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index a9d0c8af9e..10376ac931 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -51,7 +51,7 @@ static void vdpau_h264_clear_rf(VdpReferenceFrameH264 *rf)
static void vdpau_h264_set_rf(VdpReferenceFrameH264 *rf, H264Picture *pic,
int pic_structure)
{
- VdpVideoSurface surface = ff_vdpau_get_surface_id(&pic->f);
+ VdpVideoSurface surface = ff_vdpau_get_surface_id(pic->f);
if (pic_structure == 0)
pic_structure = pic->reference;
@@ -88,7 +88,7 @@ static void vdpau_h264_set_reference_frames(AVCodecContext *avctx)
if (!pic || !pic->reference)
continue;
pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
- surface_ref = ff_vdpau_get_surface_id(&pic->f);
+ surface_ref = ff_vdpau_get_surface_id(pic->f);
rf2 = &info->referenceFrames[0];
while (rf2 != rf) {
@@ -203,7 +203,7 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val;
- val = ff_vdpau_common_end_frame(avctx, &pic->f, pic_ctx);
+ val = ff_vdpau_common_end_frame(avctx, pic->f, pic_ctx);
if (val < 0)
return val;