Skip to content

Commit

Permalink
lavc: set defaults in internal codec frames
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Stefano Sabatini committed May 7, 2011
1 parent 2beac7c commit 01042d4
Show file tree
Hide file tree
Showing 67 changed files with 109 additions and 6 deletions.
2 changes: 2 additions & 0 deletions libavcodec/4xm.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions libavcodec/8bps.c
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/aasc.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions libavcodec/anm.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/ansi.c
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions libavcodec/aura.c
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions libavcodec/avs.c
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions libavcodec/bethsoftvideo.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/bfi.c
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions libavcodec/c93.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions libavcodec/cinepak.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/cljr.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions libavcodec/cscd.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/cyuv.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions libavcodec/dnxhddec.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/dsicinav.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/dv.c
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions libavcodec/dxa.c
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions libavcodec/eacmv.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions libavcodec/eatgv.c
Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion libavcodec/escape124.c
Expand Up @@ -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) *
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions libavcodec/flashsv.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/flicvideo.c
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions libavcodec/fraps.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/huffyuv.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/idcinvideo.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/iff.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/indeo2.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/indeo3.c
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions libavcodec/indeo5.c
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions libavcodec/interplayvideo.c
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions libavcodec/kgv1dec.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions libavcodec/kmvc.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/lcldec.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions libavcodec/loco.c
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions libavcodec/mdec.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions libavcodec/mjpegdec.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions libavcodec/mmvideo.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/motionpixels.c
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions libavcodec/msrle.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/msvideo1.c
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion libavcodec/pictordec.c
Expand Up @@ -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)
Expand Down Expand Up @@ -242,7 +250,7 @@ AVCodec ff_pictor_decoder = {
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PICTOR,
sizeof(PicContext),
NULL,
decode_init,
NULL,
decode_end,
decode_frame,
Expand Down
3 changes: 2 additions & 1 deletion libavcodec/qdrw.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions libavcodec/qpeg.c
Expand Up @@ -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;

Expand Down

0 comments on commit 01042d4

Please sign in to comment.