s->uvlinesize != pic->f->linesize[1])) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
- ff_mpeg_unref_picture(s, pic);
+ ff_mpeg_unref_picture(s->avctx, pic);
return -1;
}
if (pic->f->linesize[1] != pic->f->linesize[2]) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
- ff_mpeg_unref_picture(s, pic);
+ ff_mpeg_unref_picture(s->avctx, pic);
return -1;
}
(ret = frame_size_alloc(s, pic->f->linesize[0])) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed to allocate context scratch buffers.\n");
- ff_mpeg_unref_picture(s, pic);
+ ff_mpeg_unref_picture(s->avctx, pic);
return ret;
}
return 0;
fail:
av_log(s->avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
- ff_mpeg_unref_picture(s, pic);
+ ff_mpeg_unref_picture(s->avctx, pic);
ff_free_picture_tables(pic);
return AVERROR(ENOMEM);
}
/**
* Deallocate a picture.
*/
-void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
+void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
{
- int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean);
-
pic->tf.f = pic->f;
/* WM Image / Screen codecs allocate internal buffers with different
* dimensions / colorspaces; ignore user-defined callbacks for these. */
- if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
- s->codec_id != AV_CODEC_ID_VC1IMAGE &&
- s->codec_id != AV_CODEC_ID_MSS2)
- ff_thread_release_buffer(s->avctx, &pic->tf);
+ if (avctx->codec->id != AV_CODEC_ID_WMV3IMAGE &&
+ avctx->codec->id != AV_CODEC_ID_VC1IMAGE &&
+ avctx->codec->id != AV_CODEC_ID_MSS2)
+ ff_thread_release_buffer(avctx, &pic->tf);
else if (pic->f)
av_frame_unref(pic->f);
if (pic->needs_realloc)
ff_free_picture_tables(pic);
-
- memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
}
static int update_picture_tables(Picture *dst, Picture *src)
return 0;
fail:
- ff_mpeg_unref_picture(s, dst);
+ ff_mpeg_unref_picture(s->avctx, dst);
return ret;
}
s->picture_number = s1->picture_number;
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- ff_mpeg_unref_picture(s, &s->picture[i]);
+ ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
if (s1->picture[i].f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->picture[i], &s1->picture[i])) < 0)
return ret;
#define UPDATE_PICTURE(pic)\
do {\
- ff_mpeg_unref_picture(s, &s->pic);\
+ ff_mpeg_unref_picture(s->avctx, &s->pic);\
if (s1->pic.f->buf[0])\
ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
else\
if (s->picture) {
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
ff_free_picture_tables(&s->picture[i]);
- ff_mpeg_unref_picture(s, &s->picture[i]);
+ ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
av_frame_free(&s->picture[i].f);
}
}
av_freep(&s->picture);
ff_free_picture_tables(&s->last_picture);
- ff_mpeg_unref_picture(s, &s->last_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->last_picture);
av_frame_free(&s->last_picture.f);
ff_free_picture_tables(&s->current_picture);
- ff_mpeg_unref_picture(s, &s->current_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->current_picture);
av_frame_free(&s->current_picture.f);
ff_free_picture_tables(&s->next_picture);
- ff_mpeg_unref_picture(s, &s->next_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->next_picture);
av_frame_free(&s->next_picture.f);
ff_free_picture_tables(&s->new_picture);
- ff_mpeg_unref_picture(s, &s->new_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->new_picture);
av_frame_free(&s->new_picture.f);
free_context_frame(s);
/* release non reference frames */
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (!s->picture[i].reference)
- ff_mpeg_unref_picture(s, &s->picture[i]);
+ ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
}
if (s->picture[ret].needs_realloc) {
s->picture[ret].needs_realloc = 0;
ff_free_picture_tables(&s->picture[ret]);
- ff_mpeg_unref_picture(s, &s->picture[ret]);
+ ff_mpeg_unref_picture(s->avctx, &s->picture[ret]);
}
}
return ret;
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
s->last_picture_ptr != s->next_picture_ptr &&
s->last_picture_ptr->f->buf[0]) {
- ff_mpeg_unref_picture(s, s->last_picture_ptr);
+ ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr);
}
/* release forgotten pictures */
if (!(avctx->active_thread_type & FF_THREAD_FRAME))
av_log(avctx, AV_LOG_ERROR,
"releasing zombie picture\n");
- ff_mpeg_unref_picture(s, &s->picture[i]);
+ ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
}
- ff_mpeg_unref_picture(s, &s->current_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->current_picture);
release_unused_pictures(s);
}
if (s->last_picture_ptr) {
- ff_mpeg_unref_picture(s, &s->last_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->last_picture);
if (s->last_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->last_picture,
s->last_picture_ptr)) < 0)
return ret;
}
if (s->next_picture_ptr) {
- ff_mpeg_unref_picture(s, &s->next_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->next_picture);
if (s->next_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->next_picture,
s->next_picture_ptr)) < 0)
return;
for (i = 0; i < MAX_PICTURE_COUNT; i++)
- ff_mpeg_unref_picture(s, &s->picture[i]);
+ ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
- ff_mpeg_unref_picture(s, &s->current_picture);
- ff_mpeg_unref_picture(s, &s->last_picture);
- ff_mpeg_unref_picture(s, &s->next_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->current_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->last_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->next_picture);
s->mb_x= s->mb_y= 0;
av_frame_free(&s->tmp_frames[i]);
ff_free_picture_tables(&s->new_picture);
- ff_mpeg_unref_picture(s, &s->new_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->new_picture);
av_freep(&s->avctx->stats_out);
av_freep(&s->ac_stats);
s->reordered_input_picture[0]->f->pict_type !=
AV_PICTURE_TYPE_B ? 3 : 0;
- ff_mpeg_unref_picture(s, &s->new_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->new_picture);
if ((ret = ff_mpeg_ref_picture(s, &s->new_picture, s->reordered_input_picture[0])))
return ret;
s->new_picture.f->data[i] += INPLACE_OFFSET;
}
}
- ff_mpeg_unref_picture(s, &s->current_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->current_picture);
if ((ret = ff_mpeg_ref_picture(s, &s->current_picture,
s->current_picture_ptr)) < 0)
return ret;
s->picture_number = s->new_picture.f->display_picture_number;
} else {
- ff_mpeg_unref_picture(s, &s->new_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->new_picture);
}
return 0;
}
/* release non-reference frames */
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (!s->picture[i].reference)
- ff_mpeg_unref_picture(s, &s->picture[i]);
+ ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
}
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
s->last_picture_ptr != s->next_picture_ptr &&
s->last_picture_ptr->f->buf[0]) {
- ff_mpeg_unref_picture(s, s->last_picture_ptr);
+ ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr);
}
s->current_picture_ptr->f->pict_type = s->pict_type;
s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
- ff_mpeg_unref_picture(s, &s->current_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->current_picture);
if ((ret = ff_mpeg_ref_picture(s, &s->current_picture,
s->current_picture_ptr)) < 0)
return ret;
}
if (s->last_picture_ptr) {
- ff_mpeg_unref_picture(s, &s->last_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->last_picture);
if (s->last_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->last_picture,
s->last_picture_ptr)) < 0)
return ret;
}
if (s->next_picture_ptr) {
- ff_mpeg_unref_picture(s, &s->next_picture);
+ ff_mpeg_unref_picture(s->avctx, &s->next_picture);
if (s->next_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->next_picture,
s->next_picture_ptr)) < 0)