mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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: e999f2339a
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
72df87088c
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
typedef struct TrueMotion1Context {
|
||||
AVCodecContext *avctx;
|
||||
AVFrame frame;
|
||||
AVFrame *frame;
|
||||
|
||||
const uint8_t *buf;
|
||||
int size;
|
||||
@ -400,7 +400,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;
|
||||
|
||||
@ -471,7 +471,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 */
|
||||
@ -614,7 +616,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 */
|
||||
@ -728,7 +730,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];
|
||||
}
|
||||
}
|
||||
|
||||
@ -740,7 +742,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 */
|
||||
@ -854,7 +856,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];
|
||||
}
|
||||
}
|
||||
|
||||
@ -873,7 +875,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) {
|
||||
@ -882,7 +884,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;
|
||||
@ -895,7 +897,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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user