av_cold int ff_h263_decode_init(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; s->avctx = avctx; s->out_format = FMT_H263; s->width = avctx->coded_width; s->height = avctx->coded_height; s->workaround_bugs= avctx->workaround_bugs; // set defaults MPV_decode_defaults(s); s->quant_precision=5; s->decode_mb= ff_h263_decode_mb; s->low_delay= 1; avctx->pix_fmt= avctx->get_format(avctx, avctx->codec->pix_fmts); s->unrestricted_mv= 1; /* select sub codec */ switch(avctx->codec->id) { case CODEC_ID_H263: s->unrestricted_mv= 0; avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; break; case CODEC_ID_MPEG4: s->decode_mb= ff_mpeg4_decode_mb; s->time_increment_bits = 4; /* default value for broken headers */ s->h263_pred = 1; s->low_delay = 0; //default, might be overriden in the vol header during header parsing avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break; case CODEC_ID_MSMPEG4V1: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=1; break; case CODEC_ID_MSMPEG4V2: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=2; break; case CODEC_ID_MSMPEG4V3: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=3; break; case CODEC_ID_WMV1: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=4; break; case CODEC_ID_WMV2: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=5; break; case CODEC_ID_VC1: case CODEC_ID_WMV3: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=6; avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break; case CODEC_ID_H263I: break; case CODEC_ID_FLV1: s->h263_flv = 1; break; default: return -1; } s->codec_id= avctx->codec->id; avctx->hwaccel= ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); /* for h263, we allocate the images after having read the header */ if (avctx->codec->id != CODEC_ID_H263 && avctx->codec->id != CODEC_ID_MPEG4) if (MPV_common_init(s) < 0) return -1; if (CONFIG_MSMPEG4_DECODER && s->h263_msmpeg4) ff_msmpeg4_decode_init(s); else h263_decode_init_vlc(s); return 0; }
int ff_h263_decode_init(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; s->avctx = avctx; s->out_format = FMT_H263; s->width = avctx->width; s->height = avctx->height; s->workaround_bugs= avctx->workaround_bugs; // set defaults MPV_decode_defaults(s); s->quant_precision=5; s->decode_mb= ff_h263_decode_mb; s->low_delay= 1; avctx->pix_fmt= PIX_FMT_YUV420P; s->unrestricted_mv= 1; /* select sub codec */ switch(avctx->codec->id) { case CODEC_ID_H263: s->unrestricted_mv= 0; break; case CODEC_ID_MPEG4: s->decode_mb= ff_mpeg4_decode_mb; s->time_increment_bits = 4; /* default value for broken headers */ s->h263_pred = 1; s->low_delay = 0; //default, might be overriden in the vol header during header parsing break; case CODEC_ID_MSMPEG4V1: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=1; break; case CODEC_ID_MSMPEG4V2: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=2; break; case CODEC_ID_MSMPEG4V3: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=3; break; case CODEC_ID_WMV1: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=4; break; case CODEC_ID_WMV2: s->h263_msmpeg4 = 1; s->h263_pred = 1; s->msmpeg4_version=5; break; case CODEC_ID_H263I: break; case CODEC_ID_FLV1: s->h263_flv = 1; break; default: return -1; } s->codec_id= avctx->codec->id; /* for h263, we allocate the images after having read the header */ if (avctx->codec->id != CODEC_ID_H263 && avctx->codec->id != CODEC_ID_MPEG4) if (MPV_common_init(s) < 0) return -1; if (s->h263_msmpeg4) ff_msmpeg4_decode_init(s); else h263_decode_init_vlc(s); return 0; }