vc1: export some functions

This is a preparatory step for the MSS2 decoder which needs to use
the WMV9 decoder to decode some kinds of frames.

From the patch by Alberto Delmás <adelmas@gmail.com>
This commit is contained in:
Kostya Shishkov 2012-08-27 19:21:00 +02:00
parent ae43c4c0c0
commit 7627c35a81
2 changed files with 33 additions and 23 deletions

View File

@ -451,4 +451,9 @@ int ff_vc1_parse_frame_header (VC1Context *v, GetBitContext *gb);
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
int ff_vc1_init_common(VC1Context *v);
av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v);
av_cold void ff_vc1_init_transposed_scantables(VC1Context *v);
av_cold int ff_vc1_decode_end(AVCodecContext *avctx);
void ff_vc1_decode_blocks(VC1Context *v);
#endif /* AVCODEC_VC1_H */

View File

@ -4732,7 +4732,7 @@ static void vc1_decode_skip_blocks(VC1Context *v)
s->pict_type = AV_PICTURE_TYPE_P;
}
static void vc1_decode_blocks(VC1Context *v)
void ff_vc1_decode_blocks(VC1Context *v)
{
v->s.esc3_level_length = 0;
@ -5046,7 +5046,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx)
#endif
static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
{
MpegEncContext *s = &v->s;
int i;
@ -5112,6 +5112,21 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
return 0;
}
av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
{
int i;
for (i = 0; i < 64; i++) {
#define transpose(x) ((x >> 3) | ((x & 7) << 3))
v->zz_8x8[0][i] = transpose(ff_wmv1_scantable[0][i]);
v->zz_8x8[1][i] = transpose(ff_wmv1_scantable[1][i]);
v->zz_8x8[2][i] = transpose(ff_wmv1_scantable[2][i]);
v->zz_8x8[3][i] = transpose(ff_wmv1_scantable[3][i]);
v->zzi_8x8[i] = transpose(ff_vc1_adv_interlaced_8x8_zz[i]);
}
v->left_blk_sh = 0;
v->top_blk_sh = 3;
}
/** Initialize a VC1/WMV3 decoder
* @todo TODO: Handle VC-1 IDUs (Transport level?)
* @todo TODO: Decypher remaining bits in extra_data
@ -5121,7 +5136,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
GetBitContext gb;
int i;
/* save the container output size for WMImage */
v->output_width = avctx->width;
@ -5224,16 +5238,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
s->mb_height = (avctx->coded_height + 15) >> 4;
if (v->profile == PROFILE_ADVANCED || v->res_fasttx) {
for (i = 0; i < 64; i++) {
#define transpose(x) ((x >> 3) | ((x & 7) << 3))
v->zz_8x8[0][i] = transpose(ff_wmv1_scantable[0][i]);
v->zz_8x8[1][i] = transpose(ff_wmv1_scantable[1][i]);
v->zz_8x8[2][i] = transpose(ff_wmv1_scantable[2][i]);
v->zz_8x8[3][i] = transpose(ff_wmv1_scantable[3][i]);
v->zzi_8x8[i] = transpose(ff_vc1_adv_interlaced_8x8_zz[i]);
}
v->left_blk_sh = 0;
v->top_blk_sh = 3;
ff_vc1_init_transposed_scantables(v);
} else {
memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64);
v->left_blk_sh = 3;
@ -5259,7 +5264,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
/** Close a VC1/WMV3 decoder
* @warning Initial try at using MpegEncContext stuff
*/
static av_cold int vc1_decode_end(AVCodecContext *avctx)
av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
{
VC1Context *v = avctx->priv_data;
int i;
@ -5448,11 +5453,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (s->context_initialized &&
(s->width != avctx->coded_width ||
s->height != avctx->coded_height)) {
vc1_decode_end(avctx);
ff_vc1_decode_end(avctx);
}
if (!s->context_initialized) {
if (ff_msmpeg4_decode_init(avctx) < 0 || vc1_decode_init_alloc_tables(v) < 0)
if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
return -1;
s->low_delay = !avctx->has_b_frames || v->res_sprite;
@ -5597,7 +5602,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
else
s->end_mb_y = (i <= n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
vc1_decode_blocks(v);
ff_vc1_decode_blocks(v);
if (i != n_slices)
s->gb = slices[i].gb;
}
@ -5675,7 +5680,7 @@ AVCodec ff_vc1_decoder = {
.id = AV_CODEC_ID_VC1,
.priv_data_size = sizeof(VC1Context),
.init = vc1_decode_init,
.close = vc1_decode_end,
.close = ff_vc1_decode_end,
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
@ -5690,7 +5695,7 @@ AVCodec ff_wmv3_decoder = {
.id = AV_CODEC_ID_WMV3,
.priv_data_size = sizeof(VC1Context),
.init = vc1_decode_init,
.close = vc1_decode_end,
.close = ff_vc1_decode_end,
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
@ -5706,7 +5711,7 @@ AVCodec ff_wmv3_vdpau_decoder = {
.id = AV_CODEC_ID_WMV3,
.priv_data_size = sizeof(VC1Context),
.init = vc1_decode_init,
.close = vc1_decode_end,
.close = ff_vc1_decode_end,
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"),
@ -5722,7 +5727,7 @@ AVCodec ff_vc1_vdpau_decoder = {
.id = AV_CODEC_ID_VC1,
.priv_data_size = sizeof(VC1Context),
.init = vc1_decode_init,
.close = vc1_decode_end,
.close = ff_vc1_decode_end,
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"),
@ -5738,7 +5743,7 @@ AVCodec ff_wmv3image_decoder = {
.id = AV_CODEC_ID_WMV3IMAGE,
.priv_data_size = sizeof(VC1Context),
.init = vc1_decode_init,
.close = vc1_decode_end,
.close = ff_vc1_decode_end,
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1,
.flush = vc1_sprite_flush,
@ -5754,7 +5759,7 @@ AVCodec ff_vc1image_decoder = {
.id = AV_CODEC_ID_VC1IMAGE,
.priv_data_size = sizeof(VC1Context),
.init = vc1_decode_init,
.close = vc1_decode_end,
.close = ff_vc1_decode_end,
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1,
.flush = vc1_sprite_flush,