aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-17 00:40:59 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-07 03:31:14 +0100
commit2d7f20d2bbb1c30686c6a55cca8e3d71832a3a2e (patch)
tree4203a3256294a0686d717e2fa2705ba105ac7cef
parent3976c50fc1ff2fe4e7c224791cecc0faacbe8274 (diff)
downloadffmpeg-2d7f20d2bbb1c30686c6a55cca8e3d71832a3a2e.tar.gz
Merge commit 'a639ea7f4bc44bf6bfa452675558a342924a66a9'
* commit 'a639ea7f4bc44bf6bfa452675558a342924a66a9': escape124: use the AVFrame API properly. qtrle: use the AVFrame API properly. cljr: use the AVFrame API properly. cinepak: use the AVFrame API properly. Conflicts: libavcodec/cinepak.c libavcodec/cljr.c libavcodec/qtrle.c See: 80e9e63c libavcodec/cinepak.c See: 71c378984b0bd5470f67c424a79a4750f84d2d3e Merged-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit bfb1f44d246f4ed97d5cad9c1eace8a20951ff76) Author of the merged code: Anton Khirnov Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/cljr.c12
-rw-r--r--libavcodec/escape124.c21
2 files changed, 21 insertions, 12 deletions
diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c
index 51ac10662a..7e0773b6be 100644
--- a/libavcodec/cljr.c
+++ b/libavcodec/cljr.c
@@ -99,16 +99,21 @@ AVCodec ff_cljr_decoder = {
#if CONFIG_CLJR_ENCODER
typedef struct CLJRContext {
AVClass *avclass;
- AVFrame picture;
int dither_type;
} CLJRContext;
static av_cold int encode_init(AVCodecContext *avctx)
{
- CLJRContext * const a = avctx->priv_data;
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame)
+ return AVERROR(ENOMEM);
- avctx->coded_frame = &a->picture;
+ return 0;
+}
+static av_cold int encode_close(AVCodecContext *avctx)
+{
+ av_frame_free(&avctx->coded_frame);
return 0;
}
@@ -183,6 +188,7 @@ AVCodec ff_cljr_encoder = {
.priv_data_size = sizeof(CLJRContext),
.init = encode_init,
.encode2 = encode_frame,
+ .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P,
AV_PIX_FMT_NONE },
.priv_class = &cljr_class,
diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c
index a050fcb4e9..bed1efb5c8 100644
--- a/libavcodec/escape124.c
+++ b/libavcodec/escape124.c
@@ -42,7 +42,7 @@ typedef struct CodeBook {
} CodeBook;
typedef struct Escape124Context {
- AVFrame frame;
+ AVFrame *frame;
unsigned num_superblocks;
@@ -58,12 +58,15 @@ static av_cold int escape124_decode_init(AVCodecContext *avctx)
{
Escape124Context *s = avctx->priv_data;
- avcodec_get_frame_defaults(&s->frame);
avctx->pix_fmt = AV_PIX_FMT_RGB555;
s->num_superblocks = ((unsigned)avctx->width / 8) *
((unsigned)avctx->height / 8);
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
+
return 0;
}
@@ -75,7 +78,7 @@ static av_cold int escape124_decode_close(AVCodecContext *avctx)
for (i = 0; i < 3; i++)
av_free(s->codebooks[i].blocks);
- av_frame_unref(&s->frame);
+ av_frame_free(&s->frame);
return 0;
}
@@ -227,13 +230,13 @@ static int escape124_decode_frame(AVCodecContext *avctx,
// Leave last frame unchanged
// FIXME: Is this necessary? I haven't seen it in any real samples
if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
- if (!s->frame.data[0])
+ if (!s->frame->data[0])
return AVERROR_INVALIDDATA;
av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n");
*got_frame = 1;
- if ((ret = av_frame_ref(frame, &s->frame)) < 0)
+ if ((ret = av_frame_ref(frame, s->frame)) < 0)
return ret;
return frame_size;
@@ -272,8 +275,8 @@ static int escape124_decode_frame(AVCodecContext *avctx,
new_frame_data = (uint16_t*)frame->data[0];
new_stride = frame->linesize[0] / 2;
- old_frame_data = (uint16_t*)s->frame.data[0];
- old_stride = s->frame.linesize[0] / 2;
+ old_frame_data = (uint16_t*)s->frame->data[0];
+ old_stride = s->frame->linesize[0] / 2;
for (superblock_index = 0; superblock_index < s->num_superblocks;
superblock_index++) {
@@ -350,8 +353,8 @@ static int escape124_decode_frame(AVCodecContext *avctx,
"Escape sizes: %i, %i, %i\n",
frame_size, buf_size, get_bits_count(&gb) / 8);
- av_frame_unref(&s->frame);
- if ((ret = av_frame_ref(&s->frame, frame)) < 0)
+ av_frame_unref(s->frame);
+ if ((ret = av_frame_ref(s->frame, frame)) < 0)
return ret;
*got_frame = 1;