aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/asvdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-11-21 21:34:46 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:38:30 +0100
commit759001c534287a96dc96d1e274665feb7059145d (patch)
tree6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/asvdec.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
downloadffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/asvdec.c')
-rw-r--r--libavcodec/asvdec.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
index a3adde9356..a1246877a7 100644
--- a/libavcodec/asvdec.c
+++ b/libavcodec/asvdec.c
@@ -183,14 +183,14 @@ static inline int decode_mb(ASV1Context *a, int16_t block[6][64])
return 0;
}
-static inline void idct_put(ASV1Context *a, int mb_x, int mb_y)
+static inline void idct_put(ASV1Context *a, AVFrame *frame, int mb_x, int mb_y)
{
int16_t (*block)[64] = a->block;
- int linesize = a->picture.linesize[0];
+ int linesize = frame->linesize[0];
- uint8_t *dest_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
- uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8;
- uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8;
+ uint8_t *dest_y = frame->data[0] + (mb_y * 16* linesize ) + mb_x * 16;
+ uint8_t *dest_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8;
+ uint8_t *dest_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8;
a->dsp.idct_put(dest_y , linesize, block[0]);
a->dsp.idct_put(dest_y + 8, linesize, block[1]);
@@ -198,8 +198,8 @@ static inline void idct_put(ASV1Context *a, int mb_x, int mb_y)
a->dsp.idct_put(dest_y + 8*linesize + 8, linesize, block[3]);
if (!(a->avctx->flags&CODEC_FLAG_GRAY)) {
- a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]);
- a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]);
+ a->dsp.idct_put(dest_cb, frame->linesize[1], block[4]);
+ a->dsp.idct_put(dest_cr, frame->linesize[2], block[5]);
}
}
@@ -210,15 +210,10 @@ static int decode_frame(AVCodecContext *avctx,
ASV1Context * const a = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- AVFrame *picture = data;
- AVFrame * const p = &a->picture;
+ AVFrame * const p = data;
int mb_x, mb_y, ret;
- if (p->data[0])
- avctx->release_buffer(avctx, p);
-
- p->reference = 0;
- if ((ret = ff_get_buffer(avctx, p)) < 0) {
+ if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
@@ -245,7 +240,7 @@ static int decode_frame(AVCodecContext *avctx,
if ((ret = decode_mb(a, a->block)) < 0)
return ret;
- idct_put(a, mb_x, mb_y);
+ idct_put(a, p, mb_x, mb_y);
}
}
@@ -255,7 +250,7 @@ static int decode_frame(AVCodecContext *avctx,
if ((ret = decode_mb(a, a->block)) < 0)
return ret;
- idct_put(a, mb_x, mb_y);
+ idct_put(a, p, mb_x, mb_y);
}
}
@@ -265,11 +260,10 @@ static int decode_frame(AVCodecContext *avctx,
if ((ret = decode_mb(a, a->block)) < 0)
return ret;
- idct_put(a, mb_x, mb_y);
+ idct_put(a, p, mb_x, mb_y);
}
}
- *picture = a->picture;
*got_frame = 1;
emms_c();
@@ -280,7 +274,6 @@ static int decode_frame(AVCodecContext *avctx,
static av_cold int decode_init(AVCodecContext *avctx)
{
ASV1Context * const a = avctx->priv_data;
- AVFrame *p = &a->picture;
const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
int i;
@@ -304,11 +297,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
a->intra_matrix[i] = 64 * scale * ff_mpeg1_default_intra_matrix[index] / a->inv_qscale;
}
- p->qstride = a->mb_width;
- p->qscale_table = av_malloc(p->qstride * a->mb_height);
- p->quality = (32 * scale + a->inv_qscale / 2) / a->inv_qscale;
- memset(p->qscale_table, p->quality, p->qstride * a->mb_height);
-
return 0;
}
@@ -317,12 +305,8 @@ static av_cold int decode_end(AVCodecContext *avctx)
ASV1Context * const a = avctx->priv_data;
av_freep(&a->bitstream_buffer);
- av_freep(&a->picture.qscale_table);
a->bitstream_buffer_size = 0;
- if (a->picture.data[0])
- avctx->release_buffer(avctx, &a->picture);
-
return 0;
}