#include "mpegvideo.h"
#include "msmpeg4.h"
#include "libavutil/x86_cpu.h"
+#include "h263.h"
+#include "mpeg4video.h"
/*
* You can also call this codec : MPEG4 with a twist !
//#define DEBUG
#define DC_VLC_BITS 9
-#define CBPY_VLC_BITS 6
-#define V1_INTRA_CBPC_VLC_BITS 6
-#define V1_INTER_CBPC_VLC_BITS 6
#define V2_INTRA_CBPC_VLC_BITS 3
#define V2_MB_TYPE_VLC_BITS 7
#define MV_VLC_BITS 9
l= level;
/* luminance h263 */
- uni_code= DCtab_lum[size][0];
- uni_len = DCtab_lum[size][1];
+ uni_code= ff_mpeg4_DCtab_lum[size][0];
+ uni_len = ff_mpeg4_DCtab_lum[size][1];
uni_code ^= (1<<uni_len)-1; //M$ does not like compatibility
if (size > 0) {
v2_dc_lum_table[level+256][1]= uni_len;
/* chrominance h263 */
- uni_code= DCtab_chrom[size][0];
- uni_len = DCtab_chrom[size][1];
+ uni_code= ff_mpeg4_DCtab_chrom[size][0];
+ uni_len = ff_mpeg4_DCtab_chrom[size][1];
uni_code ^= (1<<uni_len)-1; //M$ does not like compatibility
if (size > 0) {
else coded_cbp= cbp;
put_bits(&s->pb,
- cbpy_tab[coded_cbp>>2][1],
- cbpy_tab[coded_cbp>>2][0]);
+ ff_h263_cbpy_tab[coded_cbp>>2][1],
+ ff_h263_cbpy_tab[coded_cbp>>2][0]);
s->misc_bits += get_bits_diff(s);
}
put_bits(&s->pb, 1, 0); /* no AC prediction yet */
put_bits(&s->pb,
- cbpy_tab[cbp>>2][1],
- cbpy_tab[cbp>>2][0]);
+ ff_h263_cbpy_tab[cbp>>2][1],
+ ff_h263_cbpy_tab[cbp>>2][0]);
}else{
if (s->pict_type == FF_I_TYPE) {
put_bits(&s->pb,
VLC ff_mb_non_intra_vlc[4];
static VLC v2_dc_lum_vlc;
static VLC v2_dc_chroma_vlc;
-static VLC cbpy_vlc;
static VLC v2_intra_cbpc_vlc;
static VLC v2_mb_type_vlc;
static VLC v2_mv_vlc;
-static VLC v1_intra_cbpc_vlc;
-static VLC v1_inter_cbpc_vlc;
VLC ff_inter_intra_vlc;
/* This is identical to h263 except that its range is multiplied by 2. */
if(s->msmpeg4_version==2)
code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);
else
- code = get_vlc2(&s->gb, v1_inter_cbpc_vlc.table, V1_INTER_CBPC_VLC_BITS, 3);
+ code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
if(code<0 || code>7){
av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
return -1;
if(s->msmpeg4_version==2)
cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);
else
- cbp= get_vlc2(&s->gb, v1_intra_cbpc_vlc.table, V1_INTRA_CBPC_VLC_BITS, 1);
+ cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);
if(cbp<0 || cbp>3){
av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
return -1;
if (!s->mb_intra) {
int mx, my, cbpy;
- cbpy= get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
+ cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
if(cbpy<0){
av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
return -1;
} else {
if(s->msmpeg4_version==2){
s->ac_pred = get_bits1(&s->gb);
- cbp|= get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
+ cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
} else{
s->ac_pred = 0;
- cbp|= get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
+ cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
if(s->pict_type==FF_P_TYPE) cbp^=0x3C;
}
}
}
/* init all vlc decoding tables */
-av_cold int ff_msmpeg4_decode_init(MpegEncContext *s)
+av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
{
+ MpegEncContext *s = avctx->priv_data;
static int done = 0;
int i;
MVTable *mv;
+ ff_h263_decode_init(avctx);
+
common_init(s);
if (!done) {
&v2_dc_chroma_table[0][1], 8, 4,
&v2_dc_chroma_table[0][0], 8, 4, 1506);
- INIT_VLC_STATIC(&cbpy_vlc, CBPY_VLC_BITS, 16,
- &cbpy_tab[0][1], 2, 1,
- &cbpy_tab[0][0], 2, 1, 64);
INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
&v2_intra_cbpc[0][1], 2, 1,
&v2_intra_cbpc[0][0], 2, 1, 8);
&ff_msmp4_mb_i_table[0][1], 4, 2,
&ff_msmp4_mb_i_table[0][0], 4, 2, 536);
- INIT_VLC_STATIC(&v1_intra_cbpc_vlc, V1_INTRA_CBPC_VLC_BITS, 8,
- intra_MCBPC_bits, 1, 1,
- intra_MCBPC_code, 1, 1, 64);
- INIT_VLC_STATIC(&v1_inter_cbpc_vlc, V1_INTER_CBPC_VLC_BITS, 25,
- inter_MCBPC_bits, 1, 1,
- inter_MCBPC_code, 1, 1, 104);
-
INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
&table_inter_intra[0][1], 2, 1,
&table_inter_intra[0][0], 2, 1, 8);
*my_ptr = my;
return 0;
}
+
+AVCodec msmpeg4v1_decoder = {
+ "msmpeg4v1",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MSMPEG4V1,
+ sizeof(MpegEncContext),
+ ff_msmpeg4_decode_init,
+ NULL,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
+ .pix_fmts= ff_pixfmt_list_420,
+};
+
+AVCodec msmpeg4v2_decoder = {
+ "msmpeg4v2",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MSMPEG4V2,
+ sizeof(MpegEncContext),
+ ff_msmpeg4_decode_init,
+ NULL,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
+ .pix_fmts= ff_pixfmt_list_420,
+};
+
+AVCodec msmpeg4v3_decoder = {
+ "msmpeg4",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_MSMPEG4V3,
+ sizeof(MpegEncContext),
+ ff_msmpeg4_decode_init,
+ NULL,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
+ .pix_fmts= ff_pixfmt_list_420,
+};
+
+AVCodec wmv1_decoder = {
+ "wmv1",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_WMV1,
+ sizeof(MpegEncContext),
+ ff_msmpeg4_decode_init,
+ NULL,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ .long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
+ .pix_fmts= ff_pixfmt_list_420,
+};