diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-06 23:48:48 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-01-06 23:48:48 +0100 |
commit | 61904467458b16cf89530e2d0875f3786001dc11 (patch) | |
tree | b87f0d285f00a0f580246dbc0c915d678e1cda49 /libavcodec/4xm.c | |
parent | a2aeaff40f34cb54bef55240f9cb8046385087d7 (diff) | |
parent | e83c1e2d0bedb5d4fa9ab351126b2ecc552f1355 (diff) | |
download | ffmpeg-61904467458b16cf89530e2d0875f3786001dc11.tar.gz |
Merge commit 'e83c1e2d0bedb5d4fa9ab351126b2ecc552f1355'
* commit 'e83c1e2d0bedb5d4fa9ab351126b2ecc552f1355':
avs: return meaningful error codes.
aura: return meaningful error codes.
asvdec: return meaningful error codes.
ansi: return a meaningful error code
anm: return meaningful error codes
aasc: return meaningful error codes.
8bps: return meaningful error codes.
4xm: operate with pointers to AVFrames instead of whole structs.
4xm: eliminate a pointless indirection
Conflicts:
libavcodec/4xm.c
libavcodec/aasc.c
libavcodec/anm.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/4xm.c')
-rw-r--r-- | libavcodec/4xm.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index a2c5ed2897..9d2b4f54c6 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -130,7 +130,7 @@ typedef struct CFrameBuffer { typedef struct FourXContext { AVCodecContext *avctx; DSPContext dsp; - AVFrame current_picture, last_picture; + AVFrame *current_picture, *last_picture; GetBitContext pre_gb; ///< ac/dc prefix GetBitContext gb; GetByteContext g; @@ -261,9 +261,9 @@ static void init_mv(FourXContext *f) for (i = 0; i < 256; i++) { if (f->version > 1) - f->mv[i] = mv[i][0] + mv[i][1] * f->current_picture.linesize[0] / 2; + f->mv[i] = mv[i][0] + mv[i][1] * f->current_picture->linesize[0] / 2; else - f->mv[i] = (i & 15) - 8 + ((i >> 4) - 8) * f->current_picture.linesize[0] / 2; + f->mv[i] = (i & 15) - 8 + ((i >> 4) - 8) * f->current_picture->linesize[0] / 2; } } @@ -340,7 +340,7 @@ static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int code = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table, BLOCK_TYPE_VLC_BITS, 1); - uint16_t *start = (uint16_t *)f->last_picture.data[0]; + uint16_t *start = (uint16_t *)f->last_picture->data[0]; uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w); av_assert2(code >= 0 && code <= 6); @@ -409,9 +409,9 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length) int x, y; const int width = f->avctx->width; const int height = f->avctx->height; - uint16_t *src = (uint16_t *)f->last_picture.data[0]; - uint16_t *dst = (uint16_t *)f->current_picture.data[0]; - const int stride = f->current_picture.linesize[0] >> 1; + uint16_t *src = (uint16_t *)f->last_picture->data[0]; + uint16_t *dst = (uint16_t *)f->current_picture->data[0]; + const int stride = f->current_picture->linesize[0] >> 1; unsigned int bitstream_size, bytestream_size, wordstream_size, extra, bytestream_offset, wordstream_offset; @@ -522,9 +522,9 @@ static int decode_i_block(FourXContext *f, DCTELEM *block) static inline void idct_put(FourXContext *f, int x, int y) { DCTELEM (*block)[64] = f->block; - int stride = f->current_picture.linesize[0] >> 1; + int stride = f->current_picture->linesize[0] >> 1; int i; - uint16_t *dst = ((uint16_t*)f->current_picture.data[0]) + y * stride + x; + uint16_t *dst = ((uint16_t*)f->current_picture->data[0]) + y * stride + x; for (i = 0; i < 4; i++) { block[i][0] += 0x80 * 8 * 8; @@ -681,8 +681,8 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length) const int width = f->avctx->width; const int height = f->avctx->height; const int mbs = (FFALIGN(width, 16) >> 4) * (FFALIGN(height, 16) >> 4); - uint16_t *dst = (uint16_t*)f->current_picture.data[0]; - const int stride = f->current_picture.linesize[0]>>1; + uint16_t *dst = (uint16_t*)f->current_picture->data[0]; + const int stride = f->current_picture->linesize[0]>>1; const uint8_t *buf_end = buf + length; GetByteContext g3; @@ -867,9 +867,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, frame_size = buf_size - 12; } - FFSWAP(AVFrame, f->current_picture, f->last_picture); + FFSWAP(AVFrame*, f->current_picture, f->last_picture); - p = &f->current_picture; + p = f->current_picture; avctx->coded_frame = p; // alternatively we would have to use our own buffer management @@ -894,14 +894,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, return ret; } } else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) { - if (!f->last_picture.data[0]) { - f->last_picture.reference = 3; - if ((ret = ff_get_buffer(avctx, &f->last_picture)) < 0) { + if (!f->last_picture->data[0]) { + f->last_picture->reference = 3; + if ((ret = ff_get_buffer(avctx, f->last_picture)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } for (i=0; i<avctx->height; i++) - memset(f->last_picture.data[0] + i*f->last_picture.linesize[0], 0, 2*avctx->width); + memset(f->last_picture->data[0] + i*f->last_picture->linesize[0], 0, 2*avctx->width); } p->pict_type = AV_PICTURE_TYPE_P; @@ -927,16 +927,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, return buf_size; } - -static av_cold void common_init(AVCodecContext *avctx) -{ - FourXContext * const f = avctx->priv_data; - - ff_dsputil_init(&f->dsp, avctx); - - f->avctx = avctx; -} - static av_cold int decode_init(AVCodecContext *avctx) { FourXContext * const f = avctx->priv_data; @@ -953,7 +943,8 @@ static av_cold int decode_init(AVCodecContext *avctx) avcodec_get_frame_defaults(&f->current_picture); avcodec_get_frame_defaults(&f->last_picture); f->version = AV_RL32(avctx->extradata) >> 16; - common_init(avctx); + ff_dsputil_init(&f->dsp, avctx); + f->avctx = avctx; init_vlcs(f); if (f->version > 2) @@ -961,6 +952,14 @@ static av_cold int decode_init(AVCodecContext *avctx) else avctx->pix_fmt = AV_PIX_FMT_BGR555; + f->current_picture = avcodec_alloc_frame(); + f->last_picture = avcodec_alloc_frame(); + if (!f->current_picture || !f->last_picture) { + avcodec_free_frame(&f->current_picture); + avcodec_free_frame(&f->last_picture); + return AVERROR(ENOMEM); + } + return 0; } @@ -977,10 +976,12 @@ static av_cold int decode_end(AVCodecContext *avctx) f->cfrm[i].allocated_size = 0; } ff_free_vlc(&f->pre_vlc); - if (f->current_picture.data[0]) - avctx->release_buffer(avctx, &f->current_picture); - if (f->last_picture.data[0]) - avctx->release_buffer(avctx, &f->last_picture); + if (f->current_picture->data[0]) + avctx->release_buffer(avctx, f->current_picture); + if (f->last_picture->data[0]) + avctx->release_buffer(avctx, f->last_picture); + avcodec_free_frame(&f->current_picture); + avcodec_free_frame(&f->last_picture); return 0; } |