[FFmpeg-cvslog] Merge commit '508b37557bf36eae83c18e64d42f27b44a321d81'
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:33:49 2013 +0100| [dbb4ff685135a39f37224fd9e85bbf59c215c6d1] | committer: Michael Niedermayer
Merge commit '508b37557bf36eae83c18e64d42f27b44a321d81'
* commit '508b37557bf36eae83c18e64d42f27b44a321d81':
tiertexseqv: use the AVFrame API properly.
smc: use the AVFrame API properly.
truemotion2: use the AVFrame API properly.
truemotion1: use the AVFrame API properly.
Conflicts:
libavcodec/smc.c
libavcodec/tiertexseqv.c
libavcodec/truemotion1.c
libavcodec/truemotion2.c
See: e999f2339ab0200039ee7123b75d79a52aaac5d1
Merged-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 72df87088c8a6593d66b207140edd32b4d2fb6ee)
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=dbb4ff685135a39f37224fd9e85bbf59c215c6d1
---
libavcodec/smc.c | 22 ++++++++++++----------
libavcodec/tiertexseqv.c | 28 +++++++++++++++-------------
libavcodec/truemotion1.c | 22 ++++++++++++----------
libavcodec/truemotion2.c | 1 +
4 files changed, 40 insertions(+), 33 deletions(-)
diff --git a/libavcodec/smc.c b/libavcodec/smc.c
index 3b836e7..31e6c88 100644
--- a/libavcodec/smc.c
+++ b/libavcodec/smc.c
@@ -46,7 +46,7 @@
typedef struct SmcContext {
AVCodecContext *avctx;
- AVFrame frame;
+ AVFrame *frame;
GetByteContext gb;
@@ -81,7 +81,7 @@ static void smc_decode_stream(SmcContext *s)
{
int width = s->avctx->width;
int height = s->avctx->height;
- int stride = s->frame.linesize[0];
+ int stride = s->frame->linesize[0];
int i;
int chunk_size;
int buf_size = bytestream2_size(&s->gb);
@@ -92,9 +92,9 @@ static void smc_decode_stream(SmcContext *s)
unsigned int color_flags_b;
unsigned int flag_mask;
- unsigned char *pixels = s->frame.data[0];
+ unsigned char *pixels = s->frame->data[0];
- int image_size = height * s->frame.linesize[0];
+ int image_size = height * s->frame->linesize[0];
int row_ptr = 0;
int pixel_ptr = 0;
int pixel_x, pixel_y;
@@ -112,7 +112,7 @@ static void smc_decode_stream(SmcContext *s)
int color_octet_index = 0;
/* make the palette available */
- memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
+ memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);
bytestream2_skip(&s->gb, 1);
chunk_size = bytestream2_get_be24(&s->gb);
@@ -417,7 +417,9 @@ static av_cold int smc_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
- avcodec_get_frame_defaults(&s->frame);
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
return 0;
}
@@ -434,18 +436,18 @@ static int smc_decode_frame(AVCodecContext *avctx,
bytestream2_init(&s->gb, buf, buf_size);
- if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (pal) {
- s->frame.palette_has_changed = 1;
+ s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
smc_decode_stream(s);
*got_frame = 1;
- if ((ret = av_frame_ref(data, &s->frame)) < 0)
+ if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
/* always report that the buffer was completely consumed */
@@ -456,7 +458,7 @@ static av_cold int smc_decode_end(AVCodecContext *avctx)
{
SmcContext *s = avctx->priv_data;
- av_frame_unref(&s->frame);
+ av_frame_free(&s->frame);
return 0;
}
diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c
index 0da9afd..7c62208 100644
--- a/libavcodec/tiertexseqv.c
+++ b/libavcodec/tiertexseqv.c
@@ -32,7 +32,7 @@
typedef struct SeqVideoContext {
AVCodecContext *avctx;
- AVFrame frame;
+ AVFrame *frame;
} SeqVideoContext;
@@ -93,14 +93,14 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
for (b = 0; b < 8; b++) {
memcpy(dst, &block[b * 8], 8);
- dst += seq->frame.linesize[0];
+ dst += seq->frame->linesize[0];
}
break;
case 2:
src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
for (i = 0; i < 8; i++) {
for (b = 0; b < 8; b++)
- dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
+ dst[b * seq->frame->linesize[0]] = block[i * 8 + b];
++dst;
}
break;
@@ -117,7 +117,7 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
for (b = 0; b < 8; b++) {
for (i = 0; i < 8; i++)
dst[i] = color_table[get_bits(&gb, bits)];
- dst += seq->frame.linesize[0];
+ dst += seq->frame->linesize[0];
}
}
@@ -137,7 +137,7 @@ static const unsigned char *seq_decode_op2(SeqVideoContext *seq,
for (i = 0; i < 8; i++) {
memcpy(dst, src, 8);
src += 8;
- dst += seq->frame.linesize[0];
+ dst += seq->frame->linesize[0];
}
return src;
@@ -154,7 +154,7 @@ static const unsigned char *seq_decode_op3(SeqVideoContext *seq,
if (src_end - src < 2)
return NULL;
pos = *src++;
- offset = ((pos >> 3) & 7) * seq->frame.linesize[0] + (pos & 7);
+ offset = ((pos >> 3) & 7) * seq->frame->linesize[0] + (pos & 7);
dst[offset] = *src++;
} while (!(pos & 0x80));
@@ -173,7 +173,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
flags = *data++;
if (flags & 1) {
- palette = (uint32_t *)seq->frame.data[1];
+ palette = (uint32_t *)seq->frame->data[1];
if (data_end - data < 256 * 3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
@@ -181,7 +181,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
c[j] = (*data << 2) | (*data >> 4);
palette[i] = 0xFFU << 24 | AV_RB24(c);
}
- seq->frame.palette_has_changed = 1;
+ seq->frame->palette_has_changed = 1;
}
if (flags & 2) {
@@ -190,7 +190,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
init_get_bits(&gb, data, 128 * 8); data += 128;
for (y = 0; y < 128; y += 8)
for (x = 0; x < 256; x += 8) {
- dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x];
+ dst = &seq->frame->data[0][y * seq->frame->linesize[0] + x];
op = get_bits(&gb, 2);
switch (op) {
case 1:
@@ -217,7 +217,9 @@ static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
seq->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
- avcodec_get_frame_defaults(&seq->frame);
+ seq->frame = av_frame_alloc();
+ if (!seq->frame)
+ return AVERROR(ENOMEM);
return 0;
}
@@ -232,13 +234,13 @@ static int seqvideo_decode_frame(AVCodecContext *avctx,
SeqVideoContext *seq = avctx->priv_data;
- if ((ret = ff_reget_buffer(avctx, &seq->frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, seq->frame)) < 0)
return ret;
if (seqvideo_decode(seq, buf, buf_size))
return AVERROR_INVALIDDATA;
- if ((ret = av_frame_ref(data, &seq->frame)) < 0)
+ if ((ret = av_frame_ref(data, seq->frame)) < 0)
return ret;
*got_frame = 1;
@@ -249,7 +251,7 @@ static av_cold int seqvideo_decode_end(AVCodecContext *avctx)
{
SeqVideoContext *seq = avctx->priv_data;
- av_frame_unref(&seq->frame);
+ av_frame_free(&seq->frame);
return 0;
}
diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index d72cee8..db49080 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -44,7 +44,7 @@
typedef struct TrueMotion1Context {
AVCodecContext *avctx;
- AVFrame frame;
+ AVFrame *frame;
const uint8_t *buf;
int size;
@@ -402,7 +402,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
if (s->w != s->avctx->width || s->h != s->avctx->height ||
new_pix_fmt != s->avctx->pix_fmt) {
- av_frame_unref(&s->frame);
+ av_frame_unref(s->frame);
s->avctx->sample_aspect_ratio = (AVRational){ 1 << width_shift, 1 };
s->avctx->pix_fmt = new_pix_fmt;
avcodec_set_dimensions(s->avctx, s->w, s->h);
@@ -470,7 +470,9 @@ static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
// else
// avctx->pix_fmt = AV_PIX_FMT_RGB555;
- avcodec_get_frame_defaults(&s->frame);
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
/* there is a vertical predictor for each pixel in a line; each vertical
* predictor is 0 to start with */
@@ -613,7 +615,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s)
unsigned int horiz_pred;
unsigned int *vert_pred;
unsigned int *current_pixel_pair;
- unsigned char *current_line = s->frame.data[0];
+ unsigned char *current_line = s->frame->data[0];
int keyframe = s->flags & FLAG_KEYFRAME;
/* these variables are for managing the stream of macroblock change bits */
@@ -727,7 +729,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s)
if (((y + 1) & 3) == 0)
mb_change_bits += s->mb_change_bits_row_size;
- current_line += s->frame.linesize[0];
+ current_line += s->frame->linesize[0];
}
}
@@ -739,7 +741,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
unsigned int horiz_pred;
unsigned int *vert_pred;
unsigned int *current_pixel_pair;
- unsigned char *current_line = s->frame.data[0];
+ unsigned char *current_line = s->frame->data[0];
int keyframe = s->flags & FLAG_KEYFRAME;
/* these variables are for managing the stream of macroblock change bits */
@@ -853,7 +855,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
if (((y + 1) & 3) == 0)
mb_change_bits += s->mb_change_bits_row_size;
- current_line += s->frame.linesize[0];
+ current_line += s->frame->linesize[0];
}
}
@@ -872,7 +874,7 @@ static int truemotion1_decode_frame(AVCodecContext *avctx,
if ((ret = truemotion1_decode_header(s)) < 0)
return ret;
- if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (compression_types[s->compression].algorithm == ALGO_RGB24H) {
@@ -881,7 +883,7 @@ static int truemotion1_decode_frame(AVCodecContext *avctx,
truemotion1_decode_16bit(s);
}
- if ((ret = av_frame_ref(data, &s->frame)) < 0)
+ if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
@@ -894,7 +896,7 @@ static av_cold int truemotion1_decode_end(AVCodecContext *avctx)
{
TrueMotion1Context *s = avctx->priv_data;
- av_frame_unref(&s->frame);
+ av_frame_free(&s->frame);
av_freep(&s->vert_pred);
return 0;
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 42badcb..a1683f5 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -931,6 +931,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
l->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_BGR24;
+
l->pic = av_frame_alloc();
if (!l->pic)
return AVERROR(ENOMEM);
More information about the ffmpeg-cvslog
mailing list