diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/qpeg.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/qpeg.c')
| -rw-r--r-- | ffmpeg/libavcodec/qpeg.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/ffmpeg/libavcodec/qpeg.c b/ffmpeg/libavcodec/qpeg.c index 6015b7f..94cb5bd 100644 --- a/ffmpeg/libavcodec/qpeg.c +++ b/ffmpeg/libavcodec/qpeg.c @@ -30,7 +30,7 @@ typedef struct QpegContext{ AVCodecContext *avctx; - AVFrame pic, ref; + AVFrame *pic, *ref; uint32_t pal[256]; GetByteContext buffer; } QpegContext; @@ -110,7 +110,7 @@ static const int qpeg_table_w[16] = { 0x00, 0x20, 0x18, 0x08, 0x18, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x20, 0x08, 0x10, 0x18, 0x04}; /* Decodes delta frames */ -static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst, +static void av_noinline qpeg_decode_inter(QpegContext *qctx, uint8_t *dst, int stride, int width, int height, int delta, const uint8_t *ctable, uint8_t *refdata) @@ -193,7 +193,7 @@ static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst, filled = 0; dst -= stride; height--; - if(height < 0) + if (height < 0) break; } } @@ -209,7 +209,7 @@ static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst, filled = 0; dst -= stride; height--; - if(height < 0) + if (height < 0) break; } } @@ -255,8 +255,8 @@ static int decode_frame(AVCodecContext *avctx, { uint8_t ctable[128]; QpegContext * const a = avctx->priv_data; - AVFrame * p = &a->pic; - AVFrame * ref= &a->ref; + AVFrame * const p = a->pic; + AVFrame * const ref = a->ref; uint8_t* outdata; int delta, ret; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); @@ -273,26 +273,26 @@ static int decode_frame(AVCodecContext *avctx, if ((ret = ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; - outdata = a->pic.data[0]; + outdata = p->data[0]; bytestream2_skip(&a->buffer, 4); bytestream2_get_buffer(&a->buffer, ctable, 128); bytestream2_skip(&a->buffer, 1); delta = bytestream2_get_byte(&a->buffer); if(delta == 0x10) { - qpeg_decode_intra(a, outdata, a->pic.linesize[0], avctx->width, avctx->height); + qpeg_decode_intra(a, outdata, p->linesize[0], avctx->width, avctx->height); } else { - qpeg_decode_inter(a, outdata, a->pic.linesize[0], avctx->width, avctx->height, delta, ctable, a->ref.data[0]); + qpeg_decode_inter(a, outdata, p->linesize[0], avctx->width, avctx->height, delta, ctable, ref->data[0]); } /* make the palette available on the way out */ if (pal) { - a->pic.palette_has_changed = 1; + p->palette_has_changed = 1; memcpy(a->pal, pal, AVPALETTE_SIZE); } - memcpy(a->pic.data[1], a->pal, AVPALETTE_SIZE); + memcpy(p->data[1], a->pal, AVPALETTE_SIZE); - if ((ret = av_frame_ref(data, &a->pic)) < 0) + if ((ret = av_frame_ref(data, p)) < 0) return ret; *got_frame = 1; @@ -312,34 +312,37 @@ static void decode_flush(AVCodecContext *avctx){ a->pal[i] = 0xFFU<<24 | AV_RL32(pal_src+4*i); } -static av_cold int decode_init(AVCodecContext *avctx){ +static av_cold int decode_end(AVCodecContext *avctx) +{ QpegContext * const a = avctx->priv_data; - avcodec_get_frame_defaults(&a->pic); - avcodec_get_frame_defaults(&a->ref); - a->avctx = avctx; - avctx->pix_fmt= AV_PIX_FMT_PAL8; - - decode_flush(avctx); - - avcodec_get_frame_defaults(&a->pic); + av_frame_free(&a->pic); + av_frame_free(&a->ref); return 0; } -static av_cold int decode_end(AVCodecContext *avctx){ +static av_cold int decode_init(AVCodecContext *avctx){ QpegContext * const a = avctx->priv_data; - AVFrame * const p = &a->pic; - AVFrame * const ref= &a->ref; - av_frame_unref(p); - av_frame_unref(ref); + a->avctx = avctx; + avctx->pix_fmt= AV_PIX_FMT_PAL8; + + decode_flush(avctx); + + a->pic = av_frame_alloc(); + a->ref = av_frame_alloc(); + if (!a->pic || !a->ref) { + decode_end(avctx); + return AVERROR(ENOMEM); + } return 0; } AVCodec ff_qpeg_decoder = { .name = "qpeg", + .long_name = NULL_IF_CONFIG_SMALL("Q-team QPEG"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_QPEG, .priv_data_size = sizeof(QpegContext), @@ -348,5 +351,4 @@ AVCodec ff_qpeg_decoder = { .decode = decode_frame, .flush = decode_flush, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("Q-team QPEG"), }; |
