From 01042d4123b6e0a4c15d6828f835bd648eb03d38 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 2 May 2011 02:15:15 +0200 Subject: [PATCH] lavc: set defaults in internal codec frames This is required specifically for setting frame->format to -1, otherwise it will be set to 0 = PIX_FMT_YUV420P and code reading the format from the output decoded frame will get misled. In particular fix regressions occurring with the pending vsrc_buffer patch. --- libavcodec/4xm.c | 2 ++ libavcodec/8bps.c | 1 + libavcodec/aasc.c | 2 +- libavcodec/anm.c | 1 + libavcodec/ansi.c | 1 + libavcodec/aura.c | 1 + libavcodec/avs.c | 2 ++ libavcodec/bethsoftvideo.c | 1 + libavcodec/bfi.c | 1 + libavcodec/c93.c | 4 ++++ libavcodec/cinepak.c | 1 + libavcodec/cljr.c | 1 + libavcodec/cscd.c | 1 + libavcodec/cyuv.c | 1 + libavcodec/dnxhddec.c | 1 + libavcodec/dsicinav.c | 1 + libavcodec/dv.c | 1 + libavcodec/dxa.c | 3 +++ libavcodec/eacmv.c | 4 ++++ libavcodec/eatgv.c | 2 ++ libavcodec/escape124.c | 4 +++- libavcodec/flashsv.c | 1 + libavcodec/flicvideo.c | 1 + libavcodec/fraps.c | 1 + libavcodec/huffyuv.c | 1 + libavcodec/idcinvideo.c | 1 + libavcodec/iff.c | 1 + libavcodec/indeo2.c | 1 + libavcodec/indeo3.c | 1 + libavcodec/indeo5.c | 2 ++ libavcodec/interplayvideo.c | 3 +++ libavcodec/kgv1dec.c | 1 + libavcodec/kmvc.c | 1 + libavcodec/lcldec.c | 1 + libavcodec/loco.c | 2 ++ libavcodec/mdec.c | 1 + libavcodec/mjpegdec.c | 1 + libavcodec/mmvideo.c | 1 + libavcodec/motionpixels.c | 1 + libavcodec/msrle.c | 1 + libavcodec/msvideo1.c | 1 + libavcodec/pictordec.c | 10 +++++++++- libavcodec/qdrw.c | 3 ++- libavcodec/qpeg.c | 2 ++ libavcodec/qtrle.c | 1 + libavcodec/rl2.c | 1 + libavcodec/roqvideodec.c | 2 ++ libavcodec/rpza.c | 1 + libavcodec/smacker.c | 1 + libavcodec/smc.c | 1 + libavcodec/tiertexseqv.c | 1 + libavcodec/tmv.c | 9 +++++++++ libavcodec/truemotion1.c | 1 + libavcodec/truemotion2.c | 1 + libavcodec/tscc.c | 1 + libavcodec/ulti.c | 1 + libavcodec/vb.c | 1 + libavcodec/vcr1.c | 1 + libavcodec/vmdav.c | 3 +++ libavcodec/vmnc.c | 1 + libavcodec/vp56.c | 4 +++- libavcodec/vqavideo.c | 1 + libavcodec/wnv1.c | 1 + libavcodec/xan.c | 2 ++ libavcodec/xl.c | 3 ++- libavcodec/yop.c | 1 + libavcodec/zmbv.c | 1 + 67 files changed, 109 insertions(+), 6 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index bd348211f0455..d89b494b09309 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -832,6 +832,8 @@ static av_cold int decode_init(AVCodecContext *avctx){ return 1; } + avcodec_get_frame_defaults(&f->current_picture); + avcodec_get_frame_defaults(&f->last_picture); f->version= AV_RL32(avctx->extradata)>>16; common_init(avctx); init_vlcs(f); diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index d5f550ffd7f4a..832298b98e629 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -162,6 +162,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; + avcodec_get_frame_defaults(&c->pic); c->pic.data[0] = NULL; switch (avctx->bits_per_coded_sample) { diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c index 44bdcb0b6352a..e6f363de4c4ba 100644 --- a/libavcodec/aasc.c +++ b/libavcodec/aasc.c @@ -50,8 +50,8 @@ static av_cold int aasc_decode_init(AVCodecContext *avctx) AascContext *s = avctx->priv_data; s->avctx = avctx; - avctx->pix_fmt = PIX_FMT_BGR24; + avcodec_get_frame_defaults(&s->frame); return 0; } diff --git a/libavcodec/anm.c b/libavcodec/anm.c index e216c08441ad5..02244f70e1c0d 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -44,6 +44,7 @@ static av_cold int decode_init(AVCodecContext *avctx) if (avctx->extradata_size != 16*8 + 4*256) return -1; + avcodec_get_frame_defaults(&s->frame); s->frame.reference = 1; buf = avctx->extradata + 16*8; diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index fdd1d321f7d68..7043b7c9d9af4 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -81,6 +81,7 @@ static av_cold int decode_init(AVCodecContext *avctx) s->fg = DEFAULT_FG_COLOR; s->bg = DEFAULT_BG_COLOR; + avcodec_get_frame_defaults(&s->frame); if (!avctx->width || !avctx->height) avcodec_set_dimensions(avctx, 80<<3, 25<<4); diff --git a/libavcodec/aura.c b/libavcodec/aura.c index 9041c7cb68a9d..18024f1c08d56 100644 --- a/libavcodec/aura.c +++ b/libavcodec/aura.c @@ -39,6 +39,7 @@ static av_cold int aura_decode_init(AVCodecContext *avctx) if (avctx->width & 0x3) return -1; avctx->pix_fmt = PIX_FMT_YUV422P; + avcodec_get_frame_defaults(&s->frame); return 0; } diff --git a/libavcodec/avs.c b/libavcodec/avs.c index 5aebe35533d20..06fcd5cd0e851 100644 --- a/libavcodec/avs.c +++ b/libavcodec/avs.c @@ -146,7 +146,9 @@ avs_decode_frame(AVCodecContext * avctx, static av_cold int avs_decode_init(AVCodecContext * avctx) { + AvsContext *const avs = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&avs->picture); return 0; } diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index 5b06e5f12e25e..3869b87aa2d99 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -39,6 +39,7 @@ typedef struct BethsoftvidContext { static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx) { BethsoftvidContext *vid = avctx->priv_data; + avcodec_get_frame_defaults(&vid->frame); vid->frame.reference = 1; vid->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c index e0b0c68e8bfda..9e40b86e50d36 100644 --- a/libavcodec/bfi.c +++ b/libavcodec/bfi.c @@ -41,6 +41,7 @@ static av_cold int bfi_decode_init(AVCodecContext * avctx) { BFIContext *bfi = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&bfi->frame); bfi->dst = av_mallocz(avctx->width * avctx->height); return 0; } diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 8eecf4788c6f0..31296395f7edb 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -47,6 +47,10 @@ typedef enum { static av_cold int decode_init(AVCodecContext *avctx) { + C93DecoderContext * const c93 = avctx->priv_data; + + avcodec_get_frame_defaults(&c93->pictures[0]); + avcodec_get_frame_defaults(&c93->pictures[1]); avctx->pix_fmt = PIX_FMT_PAL8; return 0; } diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index bbff22b62bf29..57657afaa48f6 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -404,6 +404,7 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index ebe5c99d3bd19..c9b09116745bd 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -118,6 +118,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, static av_cold void common_init(AVCodecContext *avctx){ CLJRContext * const a = avctx->priv_data; + avcodec_get_frame_defaults(&a->picture); avctx->coded_frame= (AVFrame*)&a->picture; a->avctx= avctx; } diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c index a3f6fbf022c8b..9255503e05d42 100644 --- a/libavcodec/cscd.c +++ b/libavcodec/cscd.c @@ -231,6 +231,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { return 1; } c->bpp = avctx->bits_per_coded_sample; + avcodec_get_frame_defaults(&c->pic); c->pic.data[0] = NULL; c->linelen = avctx->width * avctx->bits_per_coded_sample / 8; c->height = avctx->height; diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c index 79a84412e7eb4..1c665aefc882b 100644 --- a/libavcodec/cyuv.c +++ b/libavcodec/cyuv.c @@ -53,6 +53,7 @@ static av_cold int cyuv_decode_init(AVCodecContext *avctx) return -1; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV411P; + avcodec_get_frame_defaults(&s->frame); return 0; } diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index fb7bb8f8fd66f..8cbe1a8111e3e 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -55,6 +55,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx) ctx->avctx = avctx; dsputil_init(&ctx->dsp, avctx); avctx->coded_frame = &ctx->picture; + avcodec_get_frame_defaults(&ctx->picture); ctx->picture.type = AV_PICTURE_TYPE_I; ctx->picture.key_frame = 1; return 0; diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c index b4e0579a7b3b3..f12560714a2db 100644 --- a/libavcodec/dsicinav.c +++ b/libavcodec/dsicinav.c @@ -94,6 +94,7 @@ static av_cold int cinvideo_decode_init(AVCodecContext *avctx) cin->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&cin->frame); cin->frame.data[0] = NULL; cin->bitmap_size = avctx->width * avctx->height; diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 27d0daa4f5be2..9b24d13967965 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -1093,6 +1093,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, if (s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); + avcodec_get_frame_defaults(&s->picture); s->picture.reference = 0; s->picture.key_frame = 1; s->picture.pict_type = AV_PICTURE_TYPE_I; diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c index 759cc907b5ce3..807ecd85ee227 100644 --- a/libavcodec/dxa.c +++ b/libavcodec/dxa.c @@ -295,6 +295,9 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&c->pic); + avcodec_get_frame_defaults(&c->prev); + c->dsize = avctx->width * avctx->height * 2; if((c->decomp_buf = av_malloc(c->dsize)) == NULL) { av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index 7904a686db0c2..408d94881288e 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -43,6 +43,10 @@ typedef struct CmvContext { static av_cold int cmv_decode_init(AVCodecContext *avctx){ CmvContext *s = avctx->priv_data; + avcodec_get_frame_defaults(&s->frame); + avcodec_get_frame_defaults(&s->last_frame); + avcodec_get_frame_defaults(&s->last2_frame); + s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; return 0; diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index 0f6557f77ea43..0855f104178fb 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -55,6 +55,8 @@ static av_cold int tgv_decode_init(AVCodecContext *avctx){ s->avctx = avctx; avctx->time_base = (AVRational){1, 15}; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); + avcodec_get_frame_defaults(&s->last_frame); return 0; } diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index 5a6769d34265d..12e478fe19ade 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -61,6 +61,7 @@ static av_cold int escape124_decode_init(AVCodecContext *avctx) { Escape124Context *s = avctx->priv_data; + avcodec_get_frame_defaults(&s->frame); avctx->pix_fmt = PIX_FMT_RGB555; s->num_superblocks = ((unsigned)avctx->width / 8) * @@ -214,7 +215,8 @@ static int escape124_decode_frame(AVCodecContext *avctx, uint16_t* old_frame_data, *new_frame_data; unsigned old_stride, new_stride; - AVFrame new_frame = { { 0 } }; + AVFrame new_frame; + avcodec_get_frame_defaults(&new_frame); init_get_bits(&gb, buf, buf_size * 8); diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 18327ad462a53..a57e8510789d0 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -92,6 +92,7 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) return 1; } avctx->pix_fmt = PIX_FMT_BGR24; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index 7d2fd87647e5c..8cc72e241e5bc 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -118,6 +118,7 @@ static av_cold int flic_decode_init(AVCodecContext *avctx) return -1; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; s->new_palette = 0; diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index fc7392ae54390..7e96b0d3120f2 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -60,6 +60,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { FrapsContext * const s = avctx->priv_data; + avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = (AVFrame*)&s->frame; s->avctx = avctx; diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 87c5b3e36ade6..0f59421bb7cb8 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -433,6 +433,7 @@ static av_cold int decode_init(AVCodecContext *avctx) memset(s->vlc, 0, 3*sizeof(VLC)); avctx->coded_frame= &s->picture; + avcodec_get_frame_defaults(&s->picture); s->interlaced= s->height > 288; s->bgr32=1; diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c index ab0697252b378..362ba3bde9f19 100644 --- a/libavcodec/idcinvideo.c +++ b/libavcodec/idcinvideo.c @@ -166,6 +166,7 @@ static av_cold int idcin_decode_init(AVCodecContext *avctx) huff_build_tree(s, i); } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 2467781537c83..85a190f49c10d 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -339,6 +339,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); s->bpp = avctx->bits_per_coded_sample; + avcodec_get_frame_defaults(&s->frame); if ((err = extract_header(avctx, NULL)) < 0) return err; diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index c4d410faf5123..f58804bab3104 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -192,6 +192,7 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){ Ir2Context * const ic = avctx->priv_data; static VLC_TYPE vlc_tables[1 << CODE_VLC_BITS][2]; + avcodec_get_frame_defaults(&ic->picture); ic->avctx = avctx; avctx->pix_fmt= PIX_FMT_YUV410P; diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 14526a239ca5c..588a5b4cac6c1 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -967,6 +967,7 @@ static av_cold int indeo3_decode_init(AVCodecContext *avctx) s->width = avctx->width; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV410P; + avcodec_get_frame_defaults(&s->frame); if (!(ret = build_modpred(s))) ret = iv_alloc_frames(s); diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c index d96b31032f88a..5135c46bc71a9 100644 --- a/libavcodec/indeo5.c +++ b/libavcodec/indeo5.c @@ -713,6 +713,8 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->pic_conf.tile_height = avctx->height; ctx->pic_conf.luma_bands = ctx->pic_conf.chroma_bands = 1; + avcodec_get_frame_defaults(&ctx->frame); + result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n"); diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index d2b834560724d..d539cfc207440 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -1030,6 +1030,9 @@ static av_cold int ipvideo_decode_init(AVCodecContext *avctx) /* decoding map contains 4 bits of information per 8x8 block */ s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2); + avcodec_get_frame_defaults(&s->second_last_frame); + avcodec_get_frame_defaults(&s->last_frame); + avcodec_get_frame_defaults(&s->current_frame); s->current_frame.data[0] = s->last_frame.data[0] = s->second_last_frame.data[0] = NULL; diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 2f6a80c2c6a63..c364cfc5936d8 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -150,6 +150,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&c->pic); return 0; } diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 0bc7e944c6d94..aa2aaace6c882 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -375,6 +375,7 @@ static av_cold int decode_init(AVCodecContext * avctx) c->setpal = 1; } + avcodec_get_frame_defaults(&c->pic); avctx->pix_fmt = PIX_FMT_PAL8; return 0; diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index f2e5bb0c80d51..57735ac6ff050 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -453,6 +453,7 @@ static av_cold int decode_init(AVCodecContext *avctx) unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) + AV_LZO_OUTPUT_PADDING; unsigned int max_decomp_size; + avcodec_get_frame_defaults(&c->pic); if (avctx->extradata_size < 8) { av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n"); return 1; diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 8f2b8ff325a44..f5807b8f0a166 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -272,6 +272,8 @@ static av_cold int decode_init(AVCodecContext *avctx){ if(avctx->debug & FF_DEBUG_PICT_INFO) av_log(avctx, AV_LOG_INFO, "lossy:%i, version:%i, mode: %i\n", l->lossy, version, l->mode); + avcodec_get_frame_defaults(&l->pic); + return 0; } diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 246ec2108cdb8..30cd3ab17652a 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -218,6 +218,7 @@ static av_cold void mdec_common_init(AVCodecContext *avctx){ a->mb_width = (avctx->coded_width + 15) / 16; a->mb_height = (avctx->coded_height + 15) / 16; + avcodec_get_frame_defaults(&a->picture); avctx->coded_frame= &a->picture; a->avctx= avctx; } diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 3adc16ece7016..3b1a8abbee34d 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -84,6 +84,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) if (!s->picture_ptr) s->picture_ptr = &s->picture; + avcodec_get_frame_defaults(&s->picture); s->avctx = avctx; dsputil_init(&s->dsp, avctx); diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index 92420b1d25994..707ddc5f7eaa0 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -58,6 +58,7 @@ static av_cold int mm_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); s->frame.reference = 1; return 0; diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index ed0af4d90e302..01558ab95b3db 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -61,6 +61,7 @@ static av_cold int mp_decode_init(AVCodecContext *avctx) mp->vpt = av_mallocz(avctx->height * sizeof(YuvPixel)); mp->hpt = av_mallocz(avctx->height * avctx->width / 16 * sizeof(YuvPixel)); avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&mp->frame); return 0; } diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index a263318512ef2..6d6a2a35020e4 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -65,6 +65,7 @@ static av_cold int msrle_decode_init(AVCodecContext *avctx) return -1; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index f7434a3a888d5..c1c7d4808000c 100644 --- a/libavcodec/msvideo1.c +++ b/libavcodec/msvideo1.c @@ -70,6 +70,7 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_RGB555; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index 8981dbc7596f7..b87c8643d068c 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -94,6 +94,14 @@ static const uint8_t cga_mode45_index[6][4] = { [5] = { 0, 11, 12, 15 }, // mode5, high intensity }; +static av_cold int decode_init(AVCodecContext *avctx) +{ + PicContext *s = avctx->priv_data; + + avcodec_get_frame_defaults(&s->frame); + return 0; +} + static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) @@ -242,7 +250,7 @@ AVCodec ff_pictor_decoder = { AVMEDIA_TYPE_VIDEO, CODEC_ID_PICTOR, sizeof(PicContext), - NULL, + decode_init, NULL, decode_end, decode_frame, diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index 8123d8db344d3..cd3146388e05b 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -133,8 +133,9 @@ static int decode_frame(AVCodecContext *avctx, } static av_cold int decode_init(AVCodecContext *avctx){ -// QdrawContext * const a = avctx->priv_data; + QdrawContext * const a = avctx->priv_data; + avcodec_get_frame_defaults(&a->pic); avctx->pix_fmt= PIX_FMT_PAL8; return 0; diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 55a65405f3e87..68232e28e36a6 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -295,6 +295,8 @@ static int decode_frame(AVCodecContext *avctx, static av_cold int decode_init(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= PIX_FMT_PAL8; diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index 8b0c72641c294..2cc2de2e23f87 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -417,6 +417,7 @@ static av_cold int qtrle_decode_init(AVCodecContext *avctx) break; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 19104144a237c..8a553539ab6fe 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -134,6 +134,7 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx) int i; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); /** parse extra data */ if(!avctx->extradata || avctx->extradata_size < EXTRADATA1_SIZE){ diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index 4959239ba7f68..f0977f649146a 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -159,6 +159,8 @@ static av_cold int roq_decode_init(AVCodecContext *avctx) s->avctx = avctx; s->width = avctx->width; s->height = avctx->height; + avcodec_get_frame_defaults(&s->frames[0]); + avcodec_get_frame_defaults(&s->frames[1]); s->last_frame = &s->frames[0]; s->current_frame = &s->frames[1]; avctx->pix_fmt = PIX_FMT_YUV444P; diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index 6a79d97e86975..12558563c662c 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -233,6 +233,7 @@ static av_cold int rpza_decode_init(AVCodecContext *avctx) s->avctx = avctx; avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index bef44b89b510f..b8eab837ff166 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -515,6 +515,7 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&c->pic); /* decode huffman trees from extradata */ if(avctx->extradata_size < 16){ diff --git a/libavcodec/smc.c b/libavcodec/smc.c index 3f1b9742b8fb6..ce5b72a2a30dd 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -425,6 +425,7 @@ static av_cold int smc_decode_init(AVCodecContext *avctx) s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index c8aa38cca93f2..f3a044882e299 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -180,6 +180,7 @@ static av_cold int seqvideo_decode_init(AVCodecContext *avctx) seq->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&seq->frame); seq->frame.data[0] = NULL; return 0; diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c index ee5d060525184..b1083fe682192 100644 --- a/libavcodec/tmv.c +++ b/libavcodec/tmv.c @@ -34,6 +34,14 @@ typedef struct TMVContext { AVFrame pic; } TMVContext; +static av_cold int tmv_decode_init(AVCodecContext *avctx) +{ + TMVContext *tmv = avctx->priv_data; + + avcodec_get_frame_defaults(&tmv->pic); + return 0; +} + static int tmv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { @@ -97,6 +105,7 @@ AVCodec ff_tmv_decoder = { .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_TMV, .priv_data_size = sizeof(TMVContext), + .init = tmv_decode_init, .close = tmv_decode_close, .decode = tmv_decode_frame, .capabilities = CODEC_CAP_DR1, diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index b1b14319c5c12..284dbd8e122c7 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -474,6 +474,7 @@ static av_cold int truemotion1_decode_init(AVCodecContext *avctx) // else // avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; /* there is a vertical predictor for each pixel in a line; each vertical diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index b254bcce4178e..122049c9579ca 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -831,6 +831,7 @@ static av_cold int decode_init(AVCodecContext *avctx){ l->avctx = avctx; l->pic.data[0]=NULL; avctx->pix_fmt = PIX_FMT_BGR24; + avcodec_get_frame_defaults(&l->pic); dsputil_init(&l->dsp, avctx); diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index dc344a100a90d..e12b9a31fccc6 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -145,6 +145,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->height = avctx->height; + avcodec_get_frame_defaults(&c->pic); // Needed if zlib unused or init aborted before inflateInit memset(&(c->zstream), 0, sizeof(z_stream)); switch(avctx->bits_per_coded_sample){ diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index 83a66ab85ebf7..9033cee98f553 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -49,6 +49,7 @@ static av_cold int ulti_decode_init(AVCodecContext *avctx) s->height = avctx->height; s->blocks = (s->width / 8) * (s->height / 8); avctx->pix_fmt = PIX_FMT_YUV410P; + avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = (AVFrame*) &s->frame; s->ulti_codebook = ulti_codebook; diff --git a/libavcodec/vb.c b/libavcodec/vb.c index fc79f5d58681a..3fb59cf377429 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -268,6 +268,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&c->pic); c->frame = av_mallocz(avctx->width * avctx->height); c->prev_frame = av_mallocz(avctx->width * avctx->height); diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index 0bedba0f1fbd8..0d59b7e7ecf0a 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -146,6 +146,7 @@ static av_cold void common_init(AVCodecContext *avctx){ VCR1Context * const a = avctx->priv_data; avctx->coded_frame= (AVFrame*)&a->picture; + avcodec_get_frame_defaults(&a->picture); a->avctx= avctx; } diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 86e368372567f..8d8bc61e421ef 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -358,6 +358,9 @@ static av_cold int vmdvideo_decode_init(AVCodecContext *avctx) palette32[i] = (r << 16) | (g << 8) | (b); } + avcodec_get_frame_defaults(&s->frame); + avcodec_get_frame_defaults(&s->prev_frame); + return 0; } diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c index 68ec3fc18c86c..6455d86f77958 100644 --- a/libavcodec/vmnc.c +++ b/libavcodec/vmnc.c @@ -470,6 +470,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->bpp = avctx->bits_per_coded_sample; c->bpp2 = c->bpp/8; + avcodec_get_frame_defaults(&c->pic); switch(c->bpp){ case 8: diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 27f56a78aade7..ad451c251f811 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -653,8 +653,10 @@ av_cold void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha) ff_vp56dsp_init(&s->vp56dsp, avctx->codec->id); ff_init_scantable(s->dsp.idct_permutation, &s->scantable,ff_zigzag_direct); - for (i=0; i<4; i++) + for (i=0; i<4; i++) { s->framep[i] = &s->frames[i]; + avcodec_get_frame_defaults(&s->frames[i]); + } s->framep[VP56_FRAME_UNUSED] = s->framep[VP56_FRAME_GOLDEN]; s->framep[VP56_FRAME_UNUSED2] = s->framep[VP56_FRAME_GOLDEN2]; s->edge_emu_buffer_alloc = NULL; diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index 109faab4fb9dd..272d80906e929 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -187,6 +187,7 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) (s->height / s->vector_height) * 2; s->decode_buffer = av_malloc(s->decode_buffer_size); + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index 15d90c1a89728..197cf7985d8b5 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -136,6 +136,7 @@ static av_cold int decode_init(AVCodecContext *avctx){ l->avctx = avctx; avctx->pix_fmt = PIX_FMT_YUV422P; + avcodec_get_frame_defaults(&l->pic); code_vlc.table = code_table; code_vlc.table_allocated = 1 << CODE_VLC_BITS; diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 520331634c3ff..f5d1812aec31b 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -91,6 +91,8 @@ static av_cold int xan_decode_init(AVCodecContext *avctx) av_freep(&s->buffer1); return AVERROR(ENOMEM); } + avcodec_get_frame_defaults(&s->last_frame); + avcodec_get_frame_defaults(&s->current_frame); return 0; } diff --git a/libavcodec/xl.c b/libavcodec/xl.c index 5f19cae3bbf6e..7f3b0775c0a5e 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -121,8 +121,9 @@ static int decode_frame(AVCodecContext *avctx, } static av_cold int decode_init(AVCodecContext *avctx){ -// VideoXLContext * const a = avctx->priv_data; + VideoXLContext * const a = avctx->priv_data; + avcodec_get_frame_defaults(&a->pic); avctx->pix_fmt= PIX_FMT_YUV411P; return 0; diff --git a/libavcodec/yop.c b/libavcodec/yop.c index a117e2d791221..45a3344b9eb2b 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -92,6 +92,7 @@ static av_cold int yop_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); s->num_pal_colors = avctx->extradata[0]; s->first_color[0] = avctx->extradata[1]; s->first_color[1] = avctx->extradata[2]; diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index 3edbe921a1db8..4bd159cc447d9 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -599,6 +599,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->width = avctx->width; c->height = avctx->height; + avcodec_get_frame_defaults(&c->pic); c->bpp = avctx->bits_per_coded_sample;