vc1: use the AVFrame API properly.

pull/46/head
Anton Khirnov 11 years ago
parent 042aec41ae
commit 6792559f8a
  1. 2
      libavcodec/vc1.h
  2. 16
      libavcodec/vc1dec.c

@ -380,7 +380,7 @@ typedef struct VC1Context{
//@{
int new_sprite;
int two_sprites;
AVFrame sprite_output_frame;
AVFrame *sprite_output_frame;
int output_width, output_height, sprite_width, sprite_height;
uint8_t* sr_rows[2][2]; ///< Sprite resizer line cache
//@}

@ -5364,8 +5364,8 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
int width = v->output_width>>!!plane;
for (row = 0; row < v->output_height>>!!plane; row++) {
uint8_t *dst = v->sprite_output_frame.data[plane] +
v->sprite_output_frame.linesize[plane] * row;
uint8_t *dst = v->sprite_output_frame->data[plane] +
v->sprite_output_frame->linesize[plane] * row;
for (sprite = 0; sprite <= v->two_sprites; sprite++) {
uint8_t *iplane = s->current_picture.f.data[plane];
@ -5455,8 +5455,8 @@ static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb)
v->two_sprites = 0;
}
av_frame_unref(&v->sprite_output_frame);
if (ff_get_buffer(avctx, &v->sprite_output_frame, 0) < 0) {
av_frame_unref(v->sprite_output_frame);
if (ff_get_buffer(avctx, v->sprite_output_frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
@ -5673,6 +5673,10 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE);
}
v->sprite_output_frame = av_frame_alloc();
if (!v->sprite_output_frame)
return AVERROR(ENOMEM);
avctx->profile = v->profile;
if (v->profile == PROFILE_ADVANCED)
avctx->level = v->level;
@ -5714,7 +5718,7 @@ av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
VC1Context *v = avctx->priv_data;
int i;
av_frame_unref(&v->sprite_output_frame);
av_frame_free(&v->sprite_output_frame);
for (i = 0; i < 4; i++)
av_freep(&v->sr_rows[i >> 1][i & 1]);
@ -6085,7 +6089,7 @@ image:
if (vc1_decode_sprites(v, &s->gb))
goto err;
#endif
if ((ret = av_frame_ref(pict, &v->sprite_output_frame)) < 0)
if ((ret = av_frame_ref(pict, v->sprite_output_frame)) < 0)
goto err;
*got_frame = 1;
} else {

Loading…
Cancel
Save