Commit 84afee34 authored by Michael Niedermayer's avatar Michael Niedermayer

msmpeg4v2 decoding (no encoding yet)

Originally committed as revision 376 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent fcb609f4
...@@ -14,7 +14,9 @@ enum CodecID { ...@@ -14,7 +14,9 @@ enum CodecID {
CODEC_ID_MJPEG, CODEC_ID_MJPEG,
CODEC_ID_MPEG4, CODEC_ID_MPEG4,
CODEC_ID_RAWVIDEO, CODEC_ID_RAWVIDEO,
CODEC_ID_MSMPEG4, CODEC_ID_MSMPEG4V1,
CODEC_ID_MSMPEG4V2,
CODEC_ID_MSMPEG4V3,
CODEC_ID_H263P, CODEC_ID_H263P,
CODEC_ID_H263I, CODEC_ID_H263I,
...@@ -28,6 +30,7 @@ enum CodecID { ...@@ -28,6 +30,7 @@ enum CodecID {
CODEC_ID_PCM_MULAW, CODEC_ID_PCM_MULAW,
CODEC_ID_PCM_ALAW, CODEC_ID_PCM_ALAW,
}; };
#define CODEC_ID_MSMPEG4 CODEC_ID_MSMPEG4V3
enum CodecType { enum CodecType {
CODEC_TYPE_VIDEO, CODEC_TYPE_VIDEO,
...@@ -200,11 +203,15 @@ extern AVCodec h263p_encoder; ...@@ -200,11 +203,15 @@ extern AVCodec h263p_encoder;
extern AVCodec rv10_encoder; extern AVCodec rv10_encoder;
extern AVCodec mjpeg_encoder; extern AVCodec mjpeg_encoder;
extern AVCodec mpeg4_encoder; extern AVCodec mpeg4_encoder;
extern AVCodec msmpeg4_encoder; extern AVCodec msmpeg4v1_encoder;
extern AVCodec msmpeg4v2_encoder;
extern AVCodec msmpeg4v3_encoder;
extern AVCodec h263_decoder; extern AVCodec h263_decoder;
extern AVCodec mpeg4_decoder; extern AVCodec mpeg4_decoder;
extern AVCodec msmpeg4_decoder; extern AVCodec msmpeg4v1_decoder;
extern AVCodec msmpeg4v2_decoder;
extern AVCodec msmpeg4v3_decoder;
extern AVCodec mpeg_decoder; extern AVCodec mpeg_decoder;
extern AVCodec h263i_decoder; extern AVCodec h263i_decoder;
extern AVCodec rv10_decoder; extern AVCodec rv10_decoder;
......
...@@ -40,13 +40,13 @@ static const UINT8 inter_MCBPC_bits[20] = { ...@@ -40,13 +40,13 @@ static const UINT8 inter_MCBPC_bits[20] = {
3, 7, 7, 8, 3, 7, 7, 8,
};*/ };*/
static const UINT8 cbpy_tab[16][2] = const UINT8 cbpy_tab[16][2] =
{ {
{3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4}, {3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4},
{2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2} {2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2}
}; };
static const UINT8 mvtab[33][2] = const UINT8 mvtab[33][2] =
{ {
{1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7}, {1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7},
{11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10}, {11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10},
......
...@@ -47,9 +47,20 @@ static int h263_decode_init(AVCodecContext *avctx) ...@@ -47,9 +47,20 @@ static int h263_decode_init(AVCodecContext *avctx)
s->h263_pred = 1; s->h263_pred = 1;
s->has_b_frames = 1; s->has_b_frames = 1;
break; break;
case CODEC_ID_MSMPEG4: case CODEC_ID_MSMPEG4V1:
s->h263_msmpeg4 = 1; s->h263_msmpeg4 = 1;
s->h263_pred = 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; break;
case CODEC_ID_H263I: case CODEC_ID_H263I:
s->h263_intel = 1; s->h263_intel = 1;
...@@ -269,10 +280,34 @@ AVCodec h263_decoder = { ...@@ -269,10 +280,34 @@ AVCodec h263_decoder = {
CODEC_CAP_DRAW_HORIZ_BAND, CODEC_CAP_DRAW_HORIZ_BAND,
}; };
AVCodec msmpeg4_decoder = { AVCodec msmpeg4v1_decoder = {
"msmpeg4v1",
CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4V1,
sizeof(MpegEncContext),
h263_decode_init,
NULL,
h263_decode_end,
h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND,
};
AVCodec msmpeg4v2_decoder = {
"msmpeg4v2",
CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4V2,
sizeof(MpegEncContext),
h263_decode_init,
NULL,
h263_decode_end,
h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND,
};
AVCodec msmpeg4v3_decoder = {
"msmpeg4", "msmpeg4",
CODEC_TYPE_VIDEO, CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4, CODEC_ID_MSMPEG4V3,
sizeof(MpegEncContext), sizeof(MpegEncContext),
h263_decode_init, h263_decode_init,
NULL, NULL,
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
#define GMC_SPRITE 2 #define GMC_SPRITE 2
/* dc encoding for mpeg4 */ /* dc encoding for mpeg4 */
static const UINT8 DCtab_lum[13][2] = const UINT8 DCtab_lum[13][2] =
{ {
{3,3}, {3,2}, {2,2}, {2,3}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7}, {3,3}, {3,2}, {2,2}, {2,3}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7},
{1,8}, {1,9}, {1,10}, {1,11}, {1,8}, {1,9}, {1,10}, {1,11},
}; };
static const UINT8 DCtab_chrom[13][2] = const UINT8 DCtab_chrom[13][2] =
{ {
{3,2}, {2,2}, {1,2}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7}, {1,8}, {3,2}, {2,2}, {1,2}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7}, {1,8},
{1,9}, {1,10}, {1,11}, {1,12}, {1,9}, {1,10}, {1,11}, {1,12},
...@@ -103,3 +103,22 @@ static const UINT16 sprite_trajectory_tab[15][2] = { ...@@ -103,3 +103,22 @@ static const UINT16 sprite_trajectory_tab[15][2] = {
static const UINT8 mb_type_b_tab[4][2] = { static const UINT8 mb_type_b_tab[4][2] = {
{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 1}, {1, 2}, {1, 3}, {1, 4},
}; };
static const UINT16 pixel_aspect[16][2]={
{0, 0},
{1, 1},
{12, 11},
{10, 11},
{16, 11},
{40, 33},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
};
...@@ -355,11 +355,26 @@ int MPV_encode_init(AVCodecContext *avctx) ...@@ -355,11 +355,26 @@ int MPV_encode_init(AVCodecContext *avctx)
s->h263_pred = 1; s->h263_pred = 1;
s->unrestricted_mv = 1; s->unrestricted_mv = 1;
break; break;
case CODEC_ID_MSMPEG4: case CODEC_ID_MSMPEG4V1:
s->out_format = FMT_H263; s->out_format = FMT_H263;
s->h263_msmpeg4 = 1; s->h263_msmpeg4 = 1;
s->h263_pred = 1; s->h263_pred = 1;
s->unrestricted_mv = 1; s->unrestricted_mv = 1;
s->msmpeg4_version= 1;
break;
case CODEC_ID_MSMPEG4V2:
s->out_format = FMT_H263;
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 2;
break;
case CODEC_ID_MSMPEG4V3:
s->out_format = FMT_H263;
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 3;
break; break;
default: default:
return -1; return -1;
...@@ -2117,10 +2132,30 @@ AVCodec mpeg4_encoder = { ...@@ -2117,10 +2132,30 @@ AVCodec mpeg4_encoder = {
MPV_encode_end, MPV_encode_end,
}; };
AVCodec msmpeg4_encoder = { AVCodec msmpeg4v1_encoder = {
"msmpeg4v1",
CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4V1,
sizeof(MpegEncContext),
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
};
AVCodec msmpeg4v2_encoder = {
"msmpeg4v2",
CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4V2,
sizeof(MpegEncContext),
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
};
AVCodec msmpeg4v3_encoder = {
"msmpeg4", "msmpeg4",
CODEC_TYPE_VIDEO, CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4, CODEC_ID_MSMPEG4V3,
sizeof(MpegEncContext), sizeof(MpegEncContext),
MPV_encode_init, MPV_encode_init,
MPV_encode_picture, MPV_encode_picture,
......
...@@ -267,6 +267,7 @@ typedef struct MpegEncContext { ...@@ -267,6 +267,7 @@ typedef struct MpegEncContext {
int first_slice_line; /* used in mpeg4 too to handle resync markers */ int first_slice_line; /* used in mpeg4 too to handle resync markers */
int flipflop_rounding; int flipflop_rounding;
int bitrate; int bitrate;
int msmpeg4_version; /* 1=mp41, 2=mp42, 3=mp43/divx3 */
/* decompression specific */ /* decompression specific */
GetBitContext gb; GetBitContext gb;
......
This diff is collapsed.
...@@ -569,6 +569,13 @@ extern const UINT16 intra_vlc[103][2]; ...@@ -569,6 +569,13 @@ extern const UINT16 intra_vlc[103][2];
extern const INT8 intra_level[102]; extern const INT8 intra_level[102];
extern const INT8 intra_run[102]; extern const INT8 intra_run[102];
extern const UINT8 DCtab_lum[13][2];
extern const UINT8 DCtab_chrom[13][2];
extern const UINT8 cbpy_tab[16][2];
extern const UINT8 mvtab[33][2];
#define NB_RL_TABLES 6 #define NB_RL_TABLES 6
static RLTable rl_table[NB_RL_TABLES] = { static RLTable rl_table[NB_RL_TABLES] = {
...@@ -1765,3 +1772,12 @@ static MVTable mv_tables[2] = { ...@@ -1765,3 +1772,12 @@ static MVTable mv_tables[2] = {
table1_mvy, table1_mvy,
} }
}; };
static const UINT8 v2_mb_type[8][2] = {
{1, 1}, {0 , 2}, {3 , 3}, {9 , 5},
{5, 4}, {0x21, 7}, {0x20, 7}, {0x11, 6},
};
static const UINT8 v2_intra_cbpc[4][2] = {
{1, 1}, {0, 3}, {1, 3}, {1, 2},
};
...@@ -416,7 +416,9 @@ void avcodec_register_all(void) ...@@ -416,7 +416,9 @@ void avcodec_register_all(void)
register_avcodec(&rv10_encoder); register_avcodec(&rv10_encoder);
register_avcodec(&mjpeg_encoder); register_avcodec(&mjpeg_encoder);
register_avcodec(&mpeg4_encoder); register_avcodec(&mpeg4_encoder);
register_avcodec(&msmpeg4_encoder); register_avcodec(&msmpeg4v1_encoder);
register_avcodec(&msmpeg4v2_encoder);
register_avcodec(&msmpeg4v3_encoder);
#endif /* CONFIG_ENCODERS */ #endif /* CONFIG_ENCODERS */
register_avcodec(&rawvideo_codec); register_avcodec(&rawvideo_codec);
...@@ -424,7 +426,9 @@ void avcodec_register_all(void) ...@@ -424,7 +426,9 @@ void avcodec_register_all(void)
#ifdef CONFIG_DECODERS #ifdef CONFIG_DECODERS
register_avcodec(&h263_decoder); register_avcodec(&h263_decoder);
register_avcodec(&mpeg4_decoder); register_avcodec(&mpeg4_decoder);
register_avcodec(&msmpeg4_decoder); register_avcodec(&msmpeg4v1_decoder);
register_avcodec(&msmpeg4v2_decoder);
register_avcodec(&msmpeg4v3_decoder);
register_avcodec(&mpeg_decoder); register_avcodec(&mpeg_decoder);
register_avcodec(&h263i_decoder); register_avcodec(&h263i_decoder);
register_avcodec(&rv10_decoder); register_avcodec(&rv10_decoder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment