[FFmpeg-cvslog] Merge commit '3c8ea9d4a74fd4d7493d40c818ca64ee492709f3'
Michael Niedermayer
git at videolan.org
Tue Jan 7 03:47:25 CET 2014
ffmpeg | branch: release/2.1 | Michael Niedermayer <michaelni at gmx.at> | Sun Nov 17 02:09:29 2013 +0100| [dcb91e3dfe077c3ac0717b24288834d851312e04] | committer: Michael Niedermayer
Merge commit '3c8ea9d4a74fd4d7493d40c818ca64ee492709f3'
* commit '3c8ea9d4a74fd4d7493d40c818ca64ee492709f3':
vmnc: use the AVFrame API properly.
xan: use the AVFrame API properly.
xxan: use the AVFrame API properly.
zerocodec: use the AVFrame API properly.
Conflicts:
libavcodec/vmnc.c
libavcodec/xan.c
libavcodec/xxan.c
See: cf5ab8b6f71699a48a6384d5e5779630b4be7b56
See: ad438f450b83882a1277a79c1c3d6dfe55573b1c
See: 67607e20e882eb5639a4e9099caecb52a863ab68
Merged-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 8af7774c7aca6f3b595d0417b92f543ce0c7b537)
Author of the merged code: Anton Khirnov
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dcb91e3dfe077c3ac0717b24288834d851312e04
---
libavcodec/vmnc.c | 39 +++++++++++++++++++--------------------
libavcodec/xan.c | 27 +++++++++++++--------------
libavcodec/xxan.c | 24 +++++++++++-------------
libavcodec/zerocodec.c | 16 +++++++++++-----
4 files changed, 54 insertions(+), 52 deletions(-)
diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c
index c1b6d4e..5f91ab1 100644
--- a/libavcodec/vmnc.c
+++ b/libavcodec/vmnc.c
@@ -57,7 +57,7 @@ enum HexTile_Flags {
*/
typedef struct VmncContext {
AVCodecContext *avctx;
- AVFrame *frame;
+ AVFrame *pic;
int bpp;
int bpp2;
@@ -320,15 +320,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
GetByteContext *gb = &c->gb;
uint8_t *outptr;
int dx, dy, w, h, depth, enc, chunks, res, size_left, ret;
- AVFrame *frame = c->frame;
- if ((ret = ff_reget_buffer(avctx, frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
return ret;
bytestream2_init(gb, buf, buf_size);
- frame->key_frame = 0;
- frame->pict_type = AV_PICTURE_TYPE_P;
+ c->pic->key_frame = 0;
+ c->pic->pict_type = AV_PICTURE_TYPE_P;
// restore screen after cursor
if (c->screendta) {
@@ -350,11 +349,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
dy = 0;
}
if ((w > 0) && (h > 0)) {
- outptr = frame->data[0] + dx * c->bpp2 + dy * frame->linesize[0];
+ outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0];
for (i = 0; i < h; i++) {
memcpy(outptr, c->screendta + i * c->cur_w * c->bpp2,
w * c->bpp2);
- outptr += frame->linesize[0];
+ outptr += c->pic->linesize[0];
}
}
}
@@ -370,7 +369,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
w = bytestream2_get_be16(gb);
h = bytestream2_get_be16(gb);
enc = bytestream2_get_be32(gb);
- outptr = frame->data[0] + dx * c->bpp2 + dy * frame->linesize[0];
+ outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0];
size_left = bytestream2_get_bytes_left(gb);
switch (enc) {
case MAGIC_WMVd: // cursor
@@ -424,8 +423,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
bytestream2_skip(gb, 4);
break;
case MAGIC_WMVi: // ServerInitialization struct
- frame->key_frame = 1;
- frame->pict_type = AV_PICTURE_TYPE_I;
+ c->pic->key_frame = 1;
+ c->pic->pict_type = AV_PICTURE_TYPE_I;
depth = bytestream2_get_byte(gb);
if (depth != c->bpp) {
av_log(avctx, AV_LOG_INFO,
@@ -460,7 +459,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return AVERROR_INVALIDDATA;
}
paint_raw(outptr, w, h, gb, c->bpp2, c->bigendian,
- frame->linesize[0]);
+ c->pic->linesize[0]);
break;
case 0x00000005: // HexTile encoded rectangle
if ((dx + w > c->width) || (dy + h > c->height)) {
@@ -469,7 +468,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
w, h, dx, dy, c->width, c->height);
return AVERROR_INVALIDDATA;
}
- res = decode_hextile(c, outptr, gb, w, h, frame->linesize[0]);
+ res = decode_hextile(c, outptr, gb, w, h, c->pic->linesize[0]);
if (res < 0)
return res;
break;
@@ -498,18 +497,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
dy = 0;
}
if ((w > 0) && (h > 0)) {
- outptr = frame->data[0] + dx * c->bpp2 + dy * frame->linesize[0];
+ outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0];
for (i = 0; i < h; i++) {
memcpy(c->screendta + i * c->cur_w * c->bpp2, outptr,
w * c->bpp2);
- outptr += frame->linesize[0];
+ outptr += c->pic->linesize[0];
}
- outptr = frame->data[0];
- put_cursor(outptr, frame->linesize[0], c, c->cur_x, c->cur_y);
+ outptr = c->pic->data[0];
+ put_cursor(outptr, c->pic->linesize[0], c, c->cur_x, c->cur_y);
}
}
*got_frame = 1;
- if ((ret = av_frame_ref(data, frame)) < 0)
+ if ((ret = av_frame_ref(data, c->pic)) < 0)
return ret;
/* always report that the buffer was completely consumed */
@@ -541,8 +540,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- c->frame = av_frame_alloc();
- if (!c->frame)
+ c->pic = av_frame_alloc();
+ if (!c->pic)
return AVERROR(ENOMEM);
return 0;
@@ -552,7 +551,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
{
VmncContext * const c = avctx->priv_data;
- av_frame_free(&c->frame);
+ av_frame_free(&c->pic);
av_freep(&c->curbits);
av_freep(&c->curmask);
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index 1c2e97c..c400f40 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -71,7 +71,18 @@ typedef struct XanContext {
} XanContext;
-static av_cold int xan_decode_end(AVCodecContext *avctx);
+static av_cold int xan_decode_end(AVCodecContext *avctx)
+{
+ XanContext *s = avctx->priv_data;
+
+ av_frame_free(&s->last_frame);
+
+ av_freep(&s->buffer1);
+ av_freep(&s->buffer2);
+ av_freep(&s->palettes);
+
+ return 0;
+}
static av_cold int xan_decode_init(AVCodecContext *avctx)
{
@@ -92,6 +103,7 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
av_freep(&s->buffer1);
return AVERROR(ENOMEM);
}
+
s->last_frame = av_frame_alloc();
if (!s->last_frame) {
xan_decode_end(avctx);
@@ -624,19 +636,6 @@ static int xan_decode_frame(AVCodecContext *avctx,
return buf_size;
}
-static av_cold int xan_decode_end(AVCodecContext *avctx)
-{
- XanContext *s = avctx->priv_data;
-
- av_frame_free(&s->last_frame);
-
- av_freep(&s->buffer1);
- av_freep(&s->buffer2);
- av_freep(&s->palettes);
-
- return 0;
-}
-
AVCodec ff_xan_wc3_decoder = {
.name = "xan_wc3",
.long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"),
diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c
index 56d5f49..b261cdf 100644
--- a/libavcodec/xxan.c
+++ b/libavcodec/xxan.c
@@ -38,7 +38,17 @@ typedef struct XanContext {
GetByteContext gb;
} XanContext;
-static av_cold int xan_decode_end(AVCodecContext *avctx);
+static av_cold int xan_decode_end(AVCodecContext *avctx)
+{
+ XanContext *s = avctx->priv_data;
+
+ av_frame_free(&s->pic);
+
+ av_freep(&s->y_buffer);
+ av_freep(&s->scratch_buffer);
+
+ return 0;
+}
static av_cold int xan_decode_init(AVCodecContext *avctx)
{
@@ -428,18 +438,6 @@ static int xan_decode_frame(AVCodecContext *avctx,
return avpkt->size;
}
-static av_cold int xan_decode_end(AVCodecContext *avctx)
-{
- XanContext *s = avctx->priv_data;
-
- av_frame_free(&s->pic);
-
- av_freep(&s->y_buffer);
- av_freep(&s->scratch_buffer);
-
- return 0;
-}
-
AVCodec ff_xan_wc4_decoder = {
.name = "xan_wc4",
.long_name = NULL_IF_CONFIG_SMALL("Wing Commander IV / Xxan"),
diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c
index 80264b3..9f6c37c 100644
--- a/libavcodec/zerocodec.c
+++ b/libavcodec/zerocodec.c
@@ -23,7 +23,7 @@
#include "libavutil/common.h"
typedef struct {
- AVFrame previous_frame;
+ AVFrame *previous_frame;
z_stream zstream;
} ZeroCodecContext;
@@ -32,7 +32,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data,
{
ZeroCodecContext *zc = avctx->priv_data;
AVFrame *pic = data;
- AVFrame *prev_pic = &zc->previous_frame;
+ AVFrame *prev_pic = zc->previous_frame;
z_stream *zstream = &zc->zstream;
uint8_t *prev = prev_pic->data[0];
uint8_t *dst;
@@ -91,8 +91,8 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data,
dst -= pic->linesize[0];
}
- av_frame_unref(&zc->previous_frame);
- if ((ret = av_frame_ref(&zc->previous_frame, pic)) < 0)
+ av_frame_unref(zc->previous_frame);
+ if ((ret = av_frame_ref(zc->previous_frame, pic)) < 0)
return ret;
*got_frame = 1;
@@ -104,7 +104,7 @@ static av_cold int zerocodec_decode_close(AVCodecContext *avctx)
{
ZeroCodecContext *zc = avctx->priv_data;
- av_frame_unref(&zc->previous_frame);
+ av_frame_free(&zc->previous_frame);
inflateEnd(&zc->zstream);
@@ -130,6 +130,12 @@ static av_cold int zerocodec_decode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
}
+ zc->previous_frame = av_frame_alloc();
+ if (!zc->previous_frame) {
+ zerocodec_decode_close(avctx);
+ return AVERROR(ENOMEM);
+ }
+
return 0;
}
More information about the ffmpeg-cvslog
mailing list