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/mss2.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/mss2.c')
| -rw-r--r-- | ffmpeg/libavcodec/mss2.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/ffmpeg/libavcodec/mss2.c b/ffmpeg/libavcodec/mss2.c index fcdbbd2..99db046 100644 --- a/ffmpeg/libavcodec/mss2.c +++ b/ffmpeg/libavcodec/mss2.c @@ -34,7 +34,7 @@ typedef struct MSS2Context { VC1Context v; int split_position; - AVFrame last_pic; + AVFrame *last_pic; MSS12Context c; MSS2DSPContext dsp; SliceContext sc[2]; @@ -377,18 +377,12 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, ff_mpeg_flush(avctx); - if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { - int i = ff_find_unused_picture(s, 0); - if (i < 0) - return i; - s->current_picture_ptr = &s->picture[i]; - } - - init_get_bits(&s->gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&s->gb, buf, buf_size)) < 0) + return ret; s->loop_filter = avctx->skip_loop_filter < AVDISCARD_ALL; - if (ff_vc1_parse_frame_header(v, &s->gb) == -1) { + if (ff_vc1_parse_frame_header(v, &s->gb) < 0) { av_log(v->s.avctx, AV_LOG_ERROR, "header error\n"); return AVERROR_INVALIDDATA; } @@ -482,7 +476,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, av_assert0(FF_INPUT_BUFFER_PADDING_SIZE >= ARITH2_PADDING + (MIN_CACHE_BITS + 7) / 8); - init_get_bits(&gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) + return ret; if (keyframe = get_bits1(&gb)) skip_bits(&gb, 7); @@ -523,8 +518,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return AVERROR_INVALIDDATA; avctx->pix_fmt = is_555 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24; - if (ctx->last_pic.format != avctx->pix_fmt) - av_frame_unref(&ctx->last_pic); + if (ctx->last_pic->format != avctx->pix_fmt) + av_frame_unref(ctx->last_pic); if (has_wmv9) { bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); @@ -601,18 +596,18 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; - if (ctx->last_pic.data[0]) { - av_assert0(frame->linesize[0] == ctx->last_pic.linesize[0]); - c->last_rgb_pic = ctx->last_pic.data[0] + - ctx->last_pic.linesize[0] * (avctx->height - 1); + if (ctx->last_pic->data[0]) { + av_assert0(frame->linesize[0] == ctx->last_pic->linesize[0]); + c->last_rgb_pic = ctx->last_pic->data[0] + + ctx->last_pic->linesize[0] * (avctx->height - 1); } else { av_log(avctx, AV_LOG_ERROR, "Missing keyframe\n"); return AVERROR_INVALIDDATA; } } else { - if ((ret = ff_reget_buffer(avctx, &ctx->last_pic)) < 0) + if ((ret = ff_reget_buffer(avctx, ctx->last_pic)) < 0) return ret; - if ((ret = av_frame_ref(frame, &ctx->last_pic)) < 0) + if ((ret = av_frame_ref(frame, ctx->last_pic)) < 0) return ret; c->last_rgb_pic = NULL; @@ -640,7 +635,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ff_mss12_slicecontext_reset(&ctx->sc[1]); } if (is_rle) { - init_get_bits(&gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) + return ret; if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, c->rgb_pic, c->rgb_stride, c->pal, keyframe, ctx->split_position, 0, @@ -726,8 +722,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n"); if (c->mvX < 0 || c->mvY < 0) { - av_frame_unref(&ctx->last_pic); - ret = av_frame_ref(&ctx->last_pic, frame); + av_frame_unref(ctx->last_pic); + ret = av_frame_ref(ctx->last_pic, frame); if (ret < 0) return ret; } @@ -775,7 +771,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx) v->overlap = 0; - v->s.resync_marker = 0; + v->resync_marker = 0; v->rangered = 0; v->s.max_b_frames = avctx->max_b_frames = 0; @@ -802,7 +798,7 @@ static av_cold int mss2_decode_end(AVCodecContext *avctx) { MSS2Context *const ctx = avctx->priv_data; - av_frame_unref(&ctx->last_pic); + av_frame_free(&ctx->last_pic); ff_mss12_decode_end(&ctx->c); av_freep(&ctx->c.pal_pic); @@ -820,10 +816,11 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) c->avctx = avctx; if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1])) return ret; + ctx->last_pic = av_frame_alloc(); c->pal_stride = c->mask_stride; c->pal_pic = av_mallocz(c->pal_stride * avctx->height); c->last_pal_pic = av_mallocz(c->pal_stride * avctx->height); - if (!c->pal_pic || !c->last_pal_pic) { + if (!c->pal_pic || !c->last_pal_pic || !ctx->last_pic) { mss2_decode_end(avctx); return AVERROR(ENOMEM); } @@ -836,11 +833,13 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24; + return 0; } AVCodec ff_mss2_decoder = { .name = "mss2", + .long_name = NULL_IF_CONFIG_SMALL("MS Windows Media Video V9 Screen"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MSS2, .priv_data_size = sizeof(MSS2Context), @@ -848,5 +847,4 @@ AVCodec ff_mss2_decoder = { .close = mss2_decode_end, .decode = mss2_decode_frame, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("MS Windows Media Video V9 Screen"), }; |
