summaryrefslogtreecommitdiff
path: root/libavcodec/crystalhd.c
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2013-03-12 21:53:22 -0700
committerMichael Niedermayer <michaelni@gmx.at>2013-03-13 10:42:34 +0100
commit21dc9b194f68769ea2f549ffe49ac60ded8a796b (patch)
treeecb464376c3cd0c1aacbea7cd267e5a23b6f7d48 /libavcodec/crystalhd.c
parent19c41c6d8ef6cc34cfde6bf877e059689e763bb7 (diff)
downloadffmpeg-21dc9b194f68769ea2f549ffe49ac60ded8a796b.tar.gz
CrystalHD: Port to ref-counted frame API.
Signed-off-by: Philip Langdale <philipl@overt.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/crystalhd.c')
-rw-r--r--libavcodec/crystalhd.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index 3e9b62bf81..5445894a9d 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -122,7 +122,7 @@ typedef struct OpaqueList {
typedef struct {
AVClass *av_class;
AVCodecContext *avctx;
- AVFrame pic;
+ AVFrame *pic;
HANDLE dev;
uint8_t *orig_extradata;
@@ -324,8 +324,7 @@ static void flush(AVCodecContext *avctx)
priv->skip_next_output = 0;
priv->decode_wait = BASE_WAIT;
- if (priv->pic.data[0])
- avctx->release_buffer(avctx, &priv->pic);
+ av_frame_unref (priv->pic);
/* Flush mode 4 flushes all software and hardware buffers. */
DtsFlushInput(priv->dev, 4);
@@ -362,8 +361,7 @@ static av_cold int uninit(AVCodecContext *avctx)
av_free(priv->sps_pps_buf);
- if (priv->pic.data[0])
- avctx->release_buffer(avctx, &priv->pic);
+ av_frame_free (&priv->pic);
if (priv->head) {
OpaqueList *node = priv->head;
@@ -411,6 +409,7 @@ static av_cold int init(AVCodecContext *avctx)
priv->is_nal = avctx->extradata_size > 0 && *(avctx->extradata) == 1;
priv->last_picture = -1;
priv->decode_wait = BASE_WAIT;
+ priv->pic = av_frame_alloc();
subtype = id2subtype(priv, avctx->codec->id);
switch (subtype) {
@@ -635,15 +634,15 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_VERBOSE, "Interlaced state: %d | trust_interlaced %d\n",
interlaced, trust_interlaced);
- if (priv->pic.data[0] && !priv->need_second_field)
- avctx->release_buffer(avctx, &priv->pic);
+ if (priv->pic->data[0] && !priv->need_second_field)
+ av_frame_unref(priv->pic);
priv->need_second_field = interlaced && !priv->need_second_field;
- priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
- FF_BUFFER_HINTS_REUSABLE;
- if (!priv->pic.data[0]) {
- if (ff_get_buffer(avctx, &priv->pic, 0) < 0) {
+ priv->pic->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
+ FF_BUFFER_HINTS_REUSABLE;
+ if (!priv->pic->data[0]) {
+ if (ff_get_buffer(avctx, priv->pic, AV_GET_BUFFER_FLAG_REF) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return RET_ERROR;
}
@@ -663,8 +662,8 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
sStride = bwidth;
}
- dStride = priv->pic.linesize[0];
- dst = priv->pic.data[0];
+ dStride = priv->pic->linesize[0];
+ dst = priv->pic->data[0];
av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
@@ -689,15 +688,17 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height);
}
- priv->pic.interlaced_frame = interlaced;
+ priv->pic->interlaced_frame = interlaced;
if (interlaced)
- priv->pic.top_field_first = !bottom_first;
+ priv->pic->top_field_first = !bottom_first;
- priv->pic.pkt_pts = pkt_pts;
+ priv->pic->pkt_pts = pkt_pts;
if (!priv->need_second_field) {
*got_frame = 1;
- *(AVFrame *)data = priv->pic;
+ if ((ret = av_frame_ref(data, priv->pic)) < 0) {
+ return ret;
+ }
}
/*