mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-19 05:40:56 +00:00
avcodec/mpegvideo: Use enum for msmpeg4_version
Improves readability. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
2f6768c761
commit
b2ac792367
@ -113,23 +113,23 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
|
|||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_MSMPEG4V1:
|
case AV_CODEC_ID_MSMPEG4V1:
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->msmpeg4_version = 1;
|
s->msmpeg4_version = MSMP4_V1;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_MSMPEG4V2:
|
case AV_CODEC_ID_MSMPEG4V2:
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->msmpeg4_version = 2;
|
s->msmpeg4_version = MSMP4_V2;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_MSMPEG4V3:
|
case AV_CODEC_ID_MSMPEG4V3:
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->msmpeg4_version = 3;
|
s->msmpeg4_version = MSMP4_V3;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_WMV1:
|
case AV_CODEC_ID_WMV1:
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->msmpeg4_version = 4;
|
s->msmpeg4_version = MSMP4_WMV1;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_WMV2:
|
case AV_CODEC_ID_WMV2:
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->msmpeg4_version = 5;
|
s->msmpeg4_version = MSMP4_WMV2;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_H263I:
|
case AV_CODEC_ID_H263I:
|
||||||
break;
|
break;
|
||||||
@ -227,7 +227,7 @@ static int decode_slice(MpegEncContext *s)
|
|||||||
|
|
||||||
for (; s->mb_y < s->mb_height; s->mb_y++) {
|
for (; s->mb_y < s->mb_height; s->mb_y++) {
|
||||||
/* per-row end of slice checks */
|
/* per-row end of slice checks */
|
||||||
if (s->msmpeg4_version) {
|
if (s->msmpeg4_version != MSMP4_UNUSED) {
|
||||||
if (s->resync_mb_y + s->slice_height == s->mb_y) {
|
if (s->resync_mb_y + s->slice_height == s->mb_y) {
|
||||||
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
|
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
|
||||||
s->mb_x - 1, s->mb_y, ER_MB_END);
|
s->mb_x - 1, s->mb_y, ER_MB_END);
|
||||||
@ -236,7 +236,7 @@ static int decode_slice(MpegEncContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->msmpeg4_version == 1) {
|
if (s->msmpeg4_version == MSMP4_V1) {
|
||||||
s->last_dc[0] =
|
s->last_dc[0] =
|
||||||
s->last_dc[1] =
|
s->last_dc[1] =
|
||||||
s->last_dc[2] = 128;
|
s->last_dc[2] = 128;
|
||||||
@ -375,12 +375,12 @@ static int decode_slice(MpegEncContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle formats which don't have unique end markers
|
// handle formats which don't have unique end markers
|
||||||
if (s->msmpeg4_version || (s->workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly
|
if (s->msmpeg4_version != MSMP4_UNUSED || (s->workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly
|
||||||
int left = get_bits_left(&s->gb);
|
int left = get_bits_left(&s->gb);
|
||||||
int max_extra = 7;
|
int max_extra = 7;
|
||||||
|
|
||||||
/* no markers in M$ crap */
|
/* no markers in M$ crap */
|
||||||
if (s->msmpeg4_version && s->pict_type == AV_PICTURE_TYPE_I)
|
if (s->msmpeg4_version != MSMP4_UNUSED && s->pict_type == AV_PICTURE_TYPE_I)
|
||||||
max_extra += 17;
|
max_extra += 17;
|
||||||
|
|
||||||
/* buggy padding but the frame should still end approximately at
|
/* buggy padding but the frame should still end approximately at
|
||||||
@ -474,10 +474,12 @@ retry:
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* let's go :-) */
|
/* let's go :-) */
|
||||||
if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
|
if (CONFIG_WMV2_DECODER && s->msmpeg4_version == MSMP4_WMV2) {
|
||||||
ret = ff_wmv2_decode_picture_header(s);
|
ret = ff_wmv2_decode_picture_header(s);
|
||||||
} else if (CONFIG_MSMPEG4DEC && s->msmpeg4_version) {
|
#if CONFIG_MSMPEG4DEC
|
||||||
|
} else if (s->msmpeg4_version != MSMP4_UNUSED) {
|
||||||
ret = ff_msmpeg4_decode_picture_header(s);
|
ret = ff_msmpeg4_decode_picture_header(s);
|
||||||
|
#endif
|
||||||
} else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
|
} else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
|
||||||
ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0);
|
ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0);
|
||||||
s->skipped_last_frame = (ret == FRAME_SKIPPED);
|
s->skipped_last_frame = (ret == FRAME_SKIPPED);
|
||||||
@ -583,13 +585,15 @@ retry:
|
|||||||
/* the second part of the wmv2 header contains the MB skip bits which
|
/* the second part of the wmv2 header contains the MB skip bits which
|
||||||
* are stored in current_picture->mb_type which is not available before
|
* are stored in current_picture->mb_type which is not available before
|
||||||
* ff_mpv_frame_start() */
|
* ff_mpv_frame_start() */
|
||||||
if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
|
#if CONFIG_WMV2_DECODER
|
||||||
|
if (s->msmpeg4_version == MSMP4_WMV2) {
|
||||||
ret = ff_wmv2_decode_secondary_picture_header(s);
|
ret = ff_wmv2_decode_secondary_picture_header(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret == 1)
|
if (ret == 1)
|
||||||
goto frame_end;
|
goto frame_end;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* decode each macroblock */
|
/* decode each macroblock */
|
||||||
s->mb_x = 0;
|
s->mb_x = 0;
|
||||||
@ -597,7 +601,7 @@ retry:
|
|||||||
|
|
||||||
slice_ret = decode_slice(s);
|
slice_ret = decode_slice(s);
|
||||||
while (s->mb_y < s->mb_height) {
|
while (s->mb_y < s->mb_height) {
|
||||||
if (s->msmpeg4_version) {
|
if (s->msmpeg4_version != MSMP4_UNUSED) {
|
||||||
if (s->slice_height == 0 || s->mb_x != 0 || slice_ret < 0 ||
|
if (s->slice_height == 0 || s->mb_x != 0 || slice_ret < 0 ||
|
||||||
(s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0)
|
(s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0)
|
||||||
break;
|
break;
|
||||||
@ -609,14 +613,14 @@ retry:
|
|||||||
s->er.error_occurred = 1;
|
s->er.error_occurred = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->msmpeg4_version < 4 && s->h263_pred)
|
if (s->msmpeg4_version < MSMP4_WMV1 && s->h263_pred)
|
||||||
ff_mpeg4_clean_buffers(s);
|
ff_mpeg4_clean_buffers(s);
|
||||||
|
|
||||||
if (decode_slice(s) < 0)
|
if (decode_slice(s) < 0)
|
||||||
slice_ret = AVERROR_INVALIDDATA;
|
slice_ret = AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->msmpeg4_version && s->msmpeg4_version < 4 &&
|
if (s->msmpeg4_version != MSMP4_UNUSED && s->msmpeg4_version < MSMP4_WMV1 &&
|
||||||
s->pict_type == AV_PICTURE_TYPE_I)
|
s->pict_type == AV_PICTURE_TYPE_I)
|
||||||
if (!CONFIG_MSMPEG4DEC ||
|
if (!CONFIG_MSMPEG4DEC ||
|
||||||
ff_msmpeg4_decode_ext_header(s, buf_size) < 0)
|
ff_msmpeg4_decode_ext_header(s, buf_size) < 0)
|
||||||
|
@ -1609,7 +1609,7 @@ int ff_get_best_fcode(MpegEncContext * s, const int16_t (*mv_table)[2], int type
|
|||||||
int best_fcode=-1;
|
int best_fcode=-1;
|
||||||
int best_score=-10000000;
|
int best_score=-10000000;
|
||||||
|
|
||||||
if(s->msmpeg4_version)
|
if (s->msmpeg4_version != MSMP4_UNUSED)
|
||||||
range= FFMIN(range, 16);
|
range= FFMIN(range, 16);
|
||||||
else if(s->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL)
|
else if(s->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL)
|
||||||
range= FFMIN(range, 256);
|
range= FFMIN(range, 256);
|
||||||
@ -1660,9 +1660,9 @@ void ff_fix_long_p_mvs(MpegEncContext * s, int type)
|
|||||||
int y, range;
|
int y, range;
|
||||||
av_assert0(s->pict_type==AV_PICTURE_TYPE_P);
|
av_assert0(s->pict_type==AV_PICTURE_TYPE_P);
|
||||||
|
|
||||||
range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version) ? 8 : 16) << f_code);
|
range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version != MSMP4_UNUSED) ? 8 : 16) << f_code);
|
||||||
|
|
||||||
av_assert0(range <= 16 || !s->msmpeg4_version);
|
av_assert0(range <= 16 || s->msmpeg4_version == MSMP4_UNUSED);
|
||||||
av_assert0(range <=256 || !(s->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL));
|
av_assert0(range <=256 || !(s->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL));
|
||||||
|
|
||||||
if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range;
|
if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range;
|
||||||
@ -1709,7 +1709,7 @@ void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_
|
|||||||
int y, h_range, v_range;
|
int y, h_range, v_range;
|
||||||
|
|
||||||
// RAL: 8 in MPEG-1, 16 in MPEG-4
|
// RAL: 8 in MPEG-1, 16 in MPEG-4
|
||||||
int range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version) ? 8 : 16) << f_code);
|
int range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version != MSMP4_UNUSED) ? 8 : 16) << f_code);
|
||||||
|
|
||||||
if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range;
|
if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range;
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ static int init_duplicate_context(MpegEncContext *s)
|
|||||||
s->block = s->blocks[0];
|
s->block = s->blocks[0];
|
||||||
|
|
||||||
if (s->out_format == FMT_H263) {
|
if (s->out_format == FMT_H263) {
|
||||||
int mb_height = s->msmpeg4_version == 6 /* VC-1 like */ ?
|
int mb_height = s->msmpeg4_version == MSMP4_VC1 ?
|
||||||
FFALIGN(s->mb_height, 2) : s->mb_height;
|
FFALIGN(s->mb_height, 2) : s->mb_height;
|
||||||
int y_size = s->b8_stride * (2 * mb_height + 1);
|
int y_size = s->b8_stride * (2 * mb_height + 1);
|
||||||
int c_size = s->mb_stride * (mb_height + 1);
|
int c_size = s->mb_stride * (mb_height + 1);
|
||||||
@ -535,7 +535,7 @@ int ff_mpv_init_context_frame(MpegEncContext *s)
|
|||||||
/* VC-1 can change from being progressive to interlaced on a per-frame
|
/* VC-1 can change from being progressive to interlaced on a per-frame
|
||||||
* basis. We therefore allocate certain buffers so big that they work
|
* basis. We therefore allocate certain buffers so big that they work
|
||||||
* in both instances. */
|
* in both instances. */
|
||||||
mb_height = s->msmpeg4_version == 6 /* VC-1 like*/ ?
|
mb_height = s->msmpeg4_version == MSMP4_VC1 ?
|
||||||
FFALIGN(s->mb_height, 2) : s->mb_height;
|
FFALIGN(s->mb_height, 2) : s->mb_height;
|
||||||
|
|
||||||
s->mb_width = (s->width + 15) / 16;
|
s->mb_width = (s->width + 15) / 16;
|
||||||
@ -602,7 +602,7 @@ int ff_mpv_init_context_frame(MpegEncContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->msmpeg4_version >= 3) {
|
if (s->msmpeg4_version >= MSMP4_V3) {
|
||||||
s->coded_block_base = av_mallocz(y_size);
|
s->coded_block_base = av_mallocz(y_size);
|
||||||
if (!s->coded_block_base)
|
if (!s->coded_block_base)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
@ -418,7 +418,15 @@ typedef struct MpegEncContext {
|
|||||||
int slice_height; ///< in macroblocks
|
int slice_height; ///< in macroblocks
|
||||||
int first_slice_line; ///< used in MPEG-4 too to handle resync markers
|
int first_slice_line; ///< used in MPEG-4 too to handle resync markers
|
||||||
int flipflop_rounding;
|
int flipflop_rounding;
|
||||||
int msmpeg4_version; ///< 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
|
enum {
|
||||||
|
MSMP4_UNUSED,
|
||||||
|
MSMP4_V1,
|
||||||
|
MSMP4_V2,
|
||||||
|
MSMP4_V3,
|
||||||
|
MSMP4_WMV1,
|
||||||
|
MSMP4_WMV2,
|
||||||
|
MSMP4_VC1, ///< for VC1 (image), WMV3 (image) and MSS2.
|
||||||
|
} msmpeg4_version;
|
||||||
int per_mb_rl_table;
|
int per_mb_rl_table;
|
||||||
int esc3_level_length;
|
int esc3_level_length;
|
||||||
int esc3_run_length;
|
int esc3_run_length;
|
||||||
|
@ -754,7 +754,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
|
|||||||
s->out_format = FMT_H263;
|
s->out_format = FMT_H263;
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->unrestricted_mv = 1;
|
s->unrestricted_mv = 1;
|
||||||
s->msmpeg4_version = 2;
|
s->msmpeg4_version = MSMP4_V2;
|
||||||
avctx->delay = 0;
|
avctx->delay = 0;
|
||||||
s->low_delay = 1;
|
s->low_delay = 1;
|
||||||
break;
|
break;
|
||||||
@ -762,7 +762,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
|
|||||||
s->out_format = FMT_H263;
|
s->out_format = FMT_H263;
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->unrestricted_mv = 1;
|
s->unrestricted_mv = 1;
|
||||||
s->msmpeg4_version = 3;
|
s->msmpeg4_version = MSMP4_V3;
|
||||||
s->flipflop_rounding = 1;
|
s->flipflop_rounding = 1;
|
||||||
avctx->delay = 0;
|
avctx->delay = 0;
|
||||||
s->low_delay = 1;
|
s->low_delay = 1;
|
||||||
@ -771,7 +771,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
|
|||||||
s->out_format = FMT_H263;
|
s->out_format = FMT_H263;
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->unrestricted_mv = 1;
|
s->unrestricted_mv = 1;
|
||||||
s->msmpeg4_version = 4;
|
s->msmpeg4_version = MSMP4_WMV1;
|
||||||
s->flipflop_rounding = 1;
|
s->flipflop_rounding = 1;
|
||||||
avctx->delay = 0;
|
avctx->delay = 0;
|
||||||
s->low_delay = 1;
|
s->low_delay = 1;
|
||||||
@ -780,7 +780,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
|
|||||||
s->out_format = FMT_H263;
|
s->out_format = FMT_H263;
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->unrestricted_mv = 1;
|
s->unrestricted_mv = 1;
|
||||||
s->msmpeg4_version = 5;
|
s->msmpeg4_version = MSMP4_WMV2;
|
||||||
s->flipflop_rounding = 1;
|
s->flipflop_rounding = 1;
|
||||||
avctx->delay = 0;
|
avctx->delay = 0;
|
||||||
s->low_delay = 1;
|
s->low_delay = 1;
|
||||||
@ -916,8 +916,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
|
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
|
||||||
ff_h263_encode_init(s);
|
ff_h263_encode_init(s);
|
||||||
if (CONFIG_MSMPEG4ENC && s->msmpeg4_version)
|
#if CONFIG_MSMPEG4ENC
|
||||||
|
if (s->msmpeg4_version != MSMP4_UNUSED)
|
||||||
ff_msmpeg4_encode_init(s);
|
ff_msmpeg4_encode_init(s);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init q matrix */
|
/* init q matrix */
|
||||||
@ -3456,9 +3458,12 @@ static int encode_thread(AVCodecContext *c, void *arg){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_MSMPEG4ENC
|
||||||
//not beautiful here but we must write it before flushing so it has to be here
|
//not beautiful here but we must write it before flushing so it has to be here
|
||||||
if (CONFIG_MSMPEG4ENC && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I)
|
if (s->msmpeg4_version != MSMP4_UNUSED && s->msmpeg4_version < MSMP4_WMV1 &&
|
||||||
|
s->pict_type == AV_PICTURE_TYPE_I)
|
||||||
ff_msmpeg4_encode_ext_header(s);
|
ff_msmpeg4_encode_ext_header(s);
|
||||||
|
#endif
|
||||||
|
|
||||||
write_slice_end(s);
|
write_slice_end(s);
|
||||||
|
|
||||||
@ -3561,7 +3566,7 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt)
|
|||||||
|
|
||||||
/* we need to initialize some time vars before we can encode B-frames */
|
/* we need to initialize some time vars before we can encode B-frames */
|
||||||
// RAL: Condition added for MPEG1VIDEO
|
// RAL: Condition added for MPEG1VIDEO
|
||||||
if (s->out_format == FMT_MPEG1 || (s->h263_pred && !s->msmpeg4_version))
|
if (s->out_format == FMT_MPEG1 || (s->h263_pred && s->msmpeg4_version == MSMP4_UNUSED))
|
||||||
set_frame_distances(s);
|
set_frame_distances(s);
|
||||||
if(CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4)
|
if(CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4)
|
||||||
ff_set_mpeg4_time(s);
|
ff_set_mpeg4_time(s);
|
||||||
@ -3571,8 +3576,7 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt)
|
|||||||
// s->lambda= s->cur_pic.ptr->quality; //FIXME qscale / ... stuff for ME rate distortion
|
// s->lambda= s->cur_pic.ptr->quality; //FIXME qscale / ... stuff for ME rate distortion
|
||||||
|
|
||||||
if(s->pict_type==AV_PICTURE_TYPE_I){
|
if(s->pict_type==AV_PICTURE_TYPE_I){
|
||||||
if(s->msmpeg4_version >= 3) s->no_rounding=1;
|
s->no_rounding = s->msmpeg4_version >= MSMP4_V3;
|
||||||
else s->no_rounding=0;
|
|
||||||
}else if(s->pict_type!=AV_PICTURE_TYPE_B){
|
}else if(s->pict_type!=AV_PICTURE_TYPE_B){
|
||||||
if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4)
|
if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4)
|
||||||
s->no_rounding ^= 1;
|
s->no_rounding ^= 1;
|
||||||
@ -3654,7 +3658,7 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt)
|
|||||||
s->pict_type= AV_PICTURE_TYPE_I;
|
s->pict_type= AV_PICTURE_TYPE_I;
|
||||||
for(i=0; i<s->mb_stride*s->mb_height; i++)
|
for(i=0; i<s->mb_stride*s->mb_height; i++)
|
||||||
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
|
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
|
||||||
if(s->msmpeg4_version >= 3)
|
if (s->msmpeg4_version >= MSMP4_V3)
|
||||||
s->no_rounding=1;
|
s->no_rounding=1;
|
||||||
ff_dlog(s, "Scene change detected, encoding as I Frame %"PRId64" %"PRId64"\n",
|
ff_dlog(s, "Scene change detected, encoding as I Frame %"PRId64" %"PRId64"\n",
|
||||||
s->mb_var_sum, s->mc_mb_var_sum);
|
s->mb_var_sum, s->mc_mb_var_sum);
|
||||||
@ -3798,8 +3802,10 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt)
|
|||||||
case FMT_H263:
|
case FMT_H263:
|
||||||
if (CONFIG_WMV2_ENCODER && s->codec_id == AV_CODEC_ID_WMV2)
|
if (CONFIG_WMV2_ENCODER && s->codec_id == AV_CODEC_ID_WMV2)
|
||||||
ff_wmv2_encode_picture_header(s);
|
ff_wmv2_encode_picture_header(s);
|
||||||
else if (CONFIG_MSMPEG4ENC && s->msmpeg4_version)
|
#if CONFIG_MSMPEG4ENC
|
||||||
|
else if (s->msmpeg4_version != MSMP4_UNUSED)
|
||||||
ff_msmpeg4_encode_picture_header(s);
|
ff_msmpeg4_encode_picture_header(s);
|
||||||
|
#endif
|
||||||
else if (CONFIG_MPEG4_ENCODER && s->h263_pred) {
|
else if (CONFIG_MPEG4_ENCODER && s->h263_pred) {
|
||||||
ret = ff_mpeg4_encode_picture_header(s);
|
ret = ff_mpeg4_encode_picture_header(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -173,7 +173,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add dct residue */
|
/* add dct residue */
|
||||||
if (!(IS_MPEG12(s) || s->msmpeg4_version ||
|
if (!(IS_MPEG12(s) || s->msmpeg4_version != MSMP4_UNUSED ||
|
||||||
(s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant)))
|
(s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant)))
|
||||||
#endif /* !IS_ENCODER */
|
#endif /* !IS_ENCODER */
|
||||||
{
|
{
|
||||||
|
@ -120,12 +120,12 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
|
|||||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||||
|
|
||||||
switch(s->msmpeg4_version){
|
switch(s->msmpeg4_version){
|
||||||
case 1:
|
case MSMP4_V1:
|
||||||
case 2:
|
case MSMP4_V2:
|
||||||
s->y_dc_scale_table=
|
s->y_dc_scale_table=
|
||||||
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
|
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case MSMP4_V3:
|
||||||
if(s->workaround_bugs){
|
if(s->workaround_bugs){
|
||||||
s->y_dc_scale_table= ff_old_ff_y_dc_scale_table;
|
s->y_dc_scale_table= ff_old_ff_y_dc_scale_table;
|
||||||
s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
|
s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
|
||||||
@ -134,14 +134,14 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
|
|||||||
s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
|
s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case MSMP4_WMV1:
|
||||||
case 5:
|
case MSMP4_WMV2:
|
||||||
s->y_dc_scale_table= ff_wmv1_y_dc_scale_table;
|
s->y_dc_scale_table= ff_wmv1_y_dc_scale_table;
|
||||||
s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
|
s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->msmpeg4_version>=4){
|
if (s->msmpeg4_version >= MSMP4_WMV1) {
|
||||||
ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_wmv1_scantable[1]);
|
ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_wmv1_scantable[1]);
|
||||||
ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_wmv1_scantable[0]);
|
ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_wmv1_scantable[0]);
|
||||||
ff_permute_scantable(s->permutated_intra_h_scantable, ff_wmv1_scantable[2],
|
ff_permute_scantable(s->permutated_intra_h_scantable, ff_wmv1_scantable[2],
|
||||||
@ -218,9 +218,8 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
|
|||||||
b = dc_val[ - 1 - wrap];
|
b = dc_val[ - 1 - wrap];
|
||||||
c = dc_val[ - wrap];
|
c = dc_val[ - wrap];
|
||||||
|
|
||||||
if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){
|
if (s->first_slice_line && !(n & 2) && s->msmpeg4_version < MSMP4_WMV1)
|
||||||
b=c=1024;
|
b=c=1024;
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX: the following solution consumes divisions, but it does not
|
/* XXX: the following solution consumes divisions, but it does not
|
||||||
necessitate to modify mpegvideo.c. The problem comes from the
|
necessitate to modify mpegvideo.c. The problem comes from the
|
||||||
@ -259,7 +258,7 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
|
|||||||
#endif
|
#endif
|
||||||
/* XXX: WARNING: they did not choose the same test as MPEG-4. This
|
/* XXX: WARNING: they did not choose the same test as MPEG-4. This
|
||||||
is very important ! */
|
is very important ! */
|
||||||
if(s->msmpeg4_version>3){
|
if (s->msmpeg4_version > MSMP4_V3) {
|
||||||
if(s->inter_intra_pred){
|
if(s->inter_intra_pred){
|
||||||
uint8_t *dest;
|
uint8_t *dest;
|
||||||
int wrap;
|
int wrap;
|
||||||
|
@ -125,7 +125,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->msmpeg4_version==2)
|
if (s->msmpeg4_version == MSMP4_V2)
|
||||||
code = get_vlc2(&s->gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1);
|
code = get_vlc2(&s->gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1);
|
||||||
else
|
else
|
||||||
code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
|
code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
|
||||||
@ -139,7 +139,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
|||||||
cbp = code & 0x3;
|
cbp = code & 0x3;
|
||||||
} else {
|
} else {
|
||||||
s->mb_intra = 1;
|
s->mb_intra = 1;
|
||||||
if(s->msmpeg4_version==2)
|
if (s->msmpeg4_version == MSMP4_V2)
|
||||||
cbp = get_vlc2(&s->gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1);
|
cbp = get_vlc2(&s->gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1);
|
||||||
else
|
else
|
||||||
cbp = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
|
cbp = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
|
||||||
@ -159,7 +159,8 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cbp|= cbpy<<2;
|
cbp|= cbpy<<2;
|
||||||
if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
|
if (s->msmpeg4_version == MSMP4_V1 || (cbp&3) != 3)
|
||||||
|
cbp ^= 0x3C;
|
||||||
|
|
||||||
ff_h263_pred_motion(s, 0, 0, &mx, &my);
|
ff_h263_pred_motion(s, 0, 0, &mx, &my);
|
||||||
mx= msmpeg4v2_decode_motion(s, mx, 1);
|
mx= msmpeg4v2_decode_motion(s, mx, 1);
|
||||||
@ -172,7 +173,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
|||||||
*mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
|
*mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
|
||||||
} else {
|
} else {
|
||||||
int v;
|
int v;
|
||||||
if(s->msmpeg4_version==2){
|
if (s->msmpeg4_version == MSMP4_V2) {
|
||||||
s->ac_pred = get_bits1(&s->gb);
|
s->ac_pred = get_bits1(&s->gb);
|
||||||
v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
|
v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
|
||||||
if (v < 0) {
|
if (v < 0) {
|
||||||
@ -366,16 +367,16 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
ff_msmpeg4_common_init(s);
|
ff_msmpeg4_common_init(s);
|
||||||
|
|
||||||
switch(s->msmpeg4_version){
|
switch (s->msmpeg4_version) {
|
||||||
case 1:
|
case MSMP4_V1:
|
||||||
case 2:
|
case MSMP4_V2:
|
||||||
s->decode_mb= msmpeg4v12_decode_mb;
|
s->decode_mb= msmpeg4v12_decode_mb;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case MSMP4_V3:
|
||||||
case 4:
|
case MSMP4_WMV1:
|
||||||
s->decode_mb= msmpeg4v34_decode_mb;
|
s->decode_mb= msmpeg4v34_decode_mb;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case MSMP4_WMV2:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +399,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
|
if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if(s->msmpeg4_version==1){
|
if (s->msmpeg4_version == MSMP4_V1) {
|
||||||
int start_code = get_bits_long(&s->gb, 32);
|
int start_code = get_bits_long(&s->gb, 32);
|
||||||
if(start_code!=0x00000100){
|
if(start_code!=0x00000100){
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
|
av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
|
||||||
@ -422,7 +423,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
|
|
||||||
if (s->pict_type == AV_PICTURE_TYPE_I) {
|
if (s->pict_type == AV_PICTURE_TYPE_I) {
|
||||||
code = get_bits(&s->gb, 5);
|
code = get_bits(&s->gb, 5);
|
||||||
if(s->msmpeg4_version==1){
|
if (s->msmpeg4_version == MSMP4_V1) {
|
||||||
if(code==0 || code>s->mb_height){
|
if(code==0 || code>s->mb_height){
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
|
av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
|
||||||
return -1;
|
return -1;
|
||||||
@ -440,20 +441,20 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch(s->msmpeg4_version){
|
switch(s->msmpeg4_version){
|
||||||
case 1:
|
case MSMP4_V1:
|
||||||
case 2:
|
case MSMP4_V2:
|
||||||
s->rl_chroma_table_index = 2;
|
s->rl_chroma_table_index = 2;
|
||||||
s->rl_table_index = 2;
|
s->rl_table_index = 2;
|
||||||
|
|
||||||
s->dc_table_index = 0; //not used
|
s->dc_table_index = 0; //not used
|
||||||
break;
|
break;
|
||||||
case 3:
|
case MSMP4_V3:
|
||||||
s->rl_chroma_table_index = decode012(&s->gb);
|
s->rl_chroma_table_index = decode012(&s->gb);
|
||||||
s->rl_table_index = decode012(&s->gb);
|
s->rl_table_index = decode012(&s->gb);
|
||||||
|
|
||||||
s->dc_table_index = get_bits1(&s->gb);
|
s->dc_table_index = get_bits1(&s->gb);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case MSMP4_WMV1:
|
||||||
ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
|
ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
|
||||||
|
|
||||||
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
|
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
|
||||||
@ -479,9 +480,9 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
s->slice_height);
|
s->slice_height);
|
||||||
} else {
|
} else {
|
||||||
switch(s->msmpeg4_version){
|
switch(s->msmpeg4_version){
|
||||||
case 1:
|
case MSMP4_V1:
|
||||||
case 2:
|
case MSMP4_V2:
|
||||||
if(s->msmpeg4_version==1)
|
if (s->msmpeg4_version == MSMP4_V1)
|
||||||
s->use_skip_mb_code = 1;
|
s->use_skip_mb_code = 1;
|
||||||
else
|
else
|
||||||
s->use_skip_mb_code = get_bits1(&s->gb);
|
s->use_skip_mb_code = get_bits1(&s->gb);
|
||||||
@ -490,7 +491,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
s->dc_table_index = 0; //not used
|
s->dc_table_index = 0; //not used
|
||||||
s->mv_table_index = 0;
|
s->mv_table_index = 0;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case MSMP4_V3:
|
||||||
s->use_skip_mb_code = get_bits1(&s->gb);
|
s->use_skip_mb_code = get_bits1(&s->gb);
|
||||||
s->rl_table_index = decode012(&s->gb);
|
s->rl_table_index = decode012(&s->gb);
|
||||||
s->rl_chroma_table_index = s->rl_table_index;
|
s->rl_chroma_table_index = s->rl_table_index;
|
||||||
@ -499,7 +500,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
|
|
||||||
s->mv_table_index = get_bits1(&s->gb);
|
s->mv_table_index = get_bits1(&s->gb);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case MSMP4_WMV1:
|
||||||
s->use_skip_mb_code = get_bits1(&s->gb);
|
s->use_skip_mb_code = get_bits1(&s->gb);
|
||||||
|
|
||||||
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
|
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
|
||||||
@ -545,13 +546,13 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
|
int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
|
||||||
{
|
{
|
||||||
int left= buf_size*8 - get_bits_count(&s->gb);
|
int left= buf_size*8 - get_bits_count(&s->gb);
|
||||||
int length= s->msmpeg4_version>=3 ? 17 : 16;
|
int length = s->msmpeg4_version >= MSMP4_V3 ? 17 : 16;
|
||||||
/* the alt_bitstream reader could read over the end so we need to check it */
|
/* the alt_bitstream reader could read over the end so we need to check it */
|
||||||
if(left>=length && left<length+8)
|
if(left>=length && left<length+8)
|
||||||
{
|
{
|
||||||
skip_bits(&s->gb, 5); /* fps */
|
skip_bits(&s->gb, 5); /* fps */
|
||||||
s->bit_rate= get_bits(&s->gb, 11)*1024;
|
s->bit_rate= get_bits(&s->gb, 11)*1024;
|
||||||
if(s->msmpeg4_version>=3)
|
if (s->msmpeg4_version >= MSMP4_V3)
|
||||||
s->flipflop_rounding= get_bits1(&s->gb);
|
s->flipflop_rounding= get_bits1(&s->gb);
|
||||||
else
|
else
|
||||||
s->flipflop_rounding= 0;
|
s->flipflop_rounding= 0;
|
||||||
@ -559,7 +560,7 @@ int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
|
|||||||
else if(left<length+8)
|
else if(left<length+8)
|
||||||
{
|
{
|
||||||
s->flipflop_rounding= 0;
|
s->flipflop_rounding= 0;
|
||||||
if(s->msmpeg4_version != 2)
|
if (s->msmpeg4_version != MSMP4_V2)
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
|
av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -574,7 +575,7 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
|
|||||||
{
|
{
|
||||||
int level, pred;
|
int level, pred;
|
||||||
|
|
||||||
if(s->msmpeg4_version<=2){
|
if (s->msmpeg4_version <= MSMP4_V2) {
|
||||||
if (n < 4) {
|
if (n < 4) {
|
||||||
level = get_vlc2(&s->gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3);
|
level = get_vlc2(&s->gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3);
|
||||||
} else {
|
} else {
|
||||||
@ -600,7 +601,7 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->msmpeg4_version==1){
|
if (s->msmpeg4_version == MSMP4_V1) {
|
||||||
int32_t *dc_val;
|
int32_t *dc_val;
|
||||||
pred = msmpeg4v1_pred_dc(s, n, &dc_val);
|
pred = msmpeg4v1_pred_dc(s, n, &dc_val);
|
||||||
level += pred;
|
level += pred;
|
||||||
@ -658,7 +659,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
|
|||||||
}
|
}
|
||||||
block[0] = level;
|
block[0] = level;
|
||||||
|
|
||||||
run_diff = s->msmpeg4_version >= 4;
|
run_diff = s->msmpeg4_version >= MSMP4_WMV1;
|
||||||
i = 0;
|
i = 0;
|
||||||
if (!coded) {
|
if (!coded) {
|
||||||
goto not_coded;
|
goto not_coded;
|
||||||
@ -678,7 +679,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
|
|||||||
i = -1;
|
i = -1;
|
||||||
rl = &ff_rl_table[3 + s->rl_table_index];
|
rl = &ff_rl_table[3 + s->rl_table_index];
|
||||||
|
|
||||||
if(s->msmpeg4_version==2)
|
if (s->msmpeg4_version == MSMP4_V2)
|
||||||
run_diff = 0;
|
run_diff = 0;
|
||||||
else
|
else
|
||||||
run_diff = 1;
|
run_diff = 1;
|
||||||
@ -700,12 +701,13 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
|
|||||||
int cache;
|
int cache;
|
||||||
cache= GET_CACHE(re, &s->gb);
|
cache= GET_CACHE(re, &s->gb);
|
||||||
/* escape */
|
/* escape */
|
||||||
if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
|
if (s->msmpeg4_version == MSMP4_V1 || (cache&0x80000000)==0) {
|
||||||
if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
|
if (s->msmpeg4_version == MSMP4_V1 || (cache&0x40000000)==0) {
|
||||||
/* third escape */
|
/* third escape */
|
||||||
if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
|
if (s->msmpeg4_version != MSMP4_V1)
|
||||||
|
LAST_SKIP_BITS(re, &s->gb, 2);
|
||||||
UPDATE_CACHE(re, &s->gb);
|
UPDATE_CACHE(re, &s->gb);
|
||||||
if(s->msmpeg4_version<=3){
|
if (s->msmpeg4_version <= MSMP4_V3) {
|
||||||
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
|
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
|
||||||
run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
|
run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
|
||||||
level= SHOW_SBITS(re, &s->gb, 8);
|
level= SHOW_SBITS(re, &s->gb, 8);
|
||||||
@ -804,7 +806,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
|
|||||||
i = 63; /* XXX: not optimal */
|
i = 63; /* XXX: not optimal */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
|
if (s->msmpeg4_version >= MSMP4_WMV1 && i > 0) i=63; //FIXME/XXX optimize
|
||||||
s->block_last_index[n] = i;
|
s->block_last_index[n] = i;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -141,7 +141,7 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
|
|||||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||||
|
|
||||||
ff_msmpeg4_common_init(s);
|
ff_msmpeg4_common_init(s);
|
||||||
if (s->msmpeg4_version >= 4) {
|
if (s->msmpeg4_version >= MSMP4_WMV1) {
|
||||||
s->min_qcoeff = -255;
|
s->min_qcoeff = -255;
|
||||||
s->max_qcoeff = 255;
|
s->max_qcoeff = 255;
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s)
|
|||||||
put_bits(&s->pb, 2, s->pict_type - 1);
|
put_bits(&s->pb, 2, s->pict_type - 1);
|
||||||
|
|
||||||
put_bits(&s->pb, 5, s->qscale);
|
put_bits(&s->pb, 5, s->qscale);
|
||||||
if(s->msmpeg4_version<=2){
|
if (s->msmpeg4_version <= MSMP4_V2) {
|
||||||
s->rl_table_index = 2;
|
s->rl_table_index = 2;
|
||||||
s->rl_chroma_table_index = 2;
|
s->rl_chroma_table_index = 2;
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s)
|
|||||||
s->mv_table_index = 1; /* only if P-frame */
|
s->mv_table_index = 1; /* only if P-frame */
|
||||||
s->use_skip_mb_code = 1; /* only if P-frame */
|
s->use_skip_mb_code = 1; /* only if P-frame */
|
||||||
s->per_mb_rl_table = 0;
|
s->per_mb_rl_table = 0;
|
||||||
if(s->msmpeg4_version==4)
|
if (s->msmpeg4_version == MSMP4_WMV1)
|
||||||
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
|
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
|
||||||
ff_dlog(s, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
|
ff_dlog(s, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
|
||||||
s->inter_intra_pred, s->width, s->height);
|
s->inter_intra_pred, s->width, s->height);
|
||||||
@ -244,13 +244,13 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s)
|
|||||||
s->slice_height= s->mb_height/1;
|
s->slice_height= s->mb_height/1;
|
||||||
put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height);
|
put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height);
|
||||||
|
|
||||||
if(s->msmpeg4_version==4){
|
if (s->msmpeg4_version == MSMP4_WMV1) {
|
||||||
ff_msmpeg4_encode_ext_header(s);
|
ff_msmpeg4_encode_ext_header(s);
|
||||||
if(s->bit_rate>MBAC_BITRATE)
|
if(s->bit_rate>MBAC_BITRATE)
|
||||||
put_bits(&s->pb, 1, s->per_mb_rl_table);
|
put_bits(&s->pb, 1, s->per_mb_rl_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->msmpeg4_version>2){
|
if (s->msmpeg4_version > MSMP4_V2) {
|
||||||
if(!s->per_mb_rl_table){
|
if(!s->per_mb_rl_table){
|
||||||
ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index);
|
ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index);
|
||||||
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
|
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
|
||||||
@ -261,10 +261,10 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s)
|
|||||||
} else {
|
} else {
|
||||||
put_bits(&s->pb, 1, s->use_skip_mb_code);
|
put_bits(&s->pb, 1, s->use_skip_mb_code);
|
||||||
|
|
||||||
if(s->msmpeg4_version==4 && s->bit_rate>MBAC_BITRATE)
|
if (s->msmpeg4_version == MSMP4_WMV1 && s->bit_rate > MBAC_BITRATE)
|
||||||
put_bits(&s->pb, 1, s->per_mb_rl_table);
|
put_bits(&s->pb, 1, s->per_mb_rl_table);
|
||||||
|
|
||||||
if(s->msmpeg4_version>2){
|
if (s->msmpeg4_version > MSMP4_V2) {
|
||||||
if(!s->per_mb_rl_table)
|
if(!s->per_mb_rl_table)
|
||||||
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
|
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
|
|
||||||
put_bits(&s->pb, 11, FFMIN(s->bit_rate / 1024, 2047));
|
put_bits(&s->pb, 11, FFMIN(s->bit_rate / 1024, 2047));
|
||||||
|
|
||||||
if (s->msmpeg4_version >= 3)
|
if (s->msmpeg4_version >= MSMP4_V3)
|
||||||
put_bits(&s->pb, 1, s->flipflop_rounding);
|
put_bits(&s->pb, 1, s->flipflop_rounding);
|
||||||
else
|
else
|
||||||
av_assert0(!s->flipflop_rounding);
|
av_assert0(!s->flipflop_rounding);
|
||||||
@ -340,7 +340,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s,
|
|||||||
void ff_msmpeg4_handle_slices(MpegEncContext *s){
|
void ff_msmpeg4_handle_slices(MpegEncContext *s){
|
||||||
if (s->mb_x == 0) {
|
if (s->mb_x == 0) {
|
||||||
if (s->slice_height && (s->mb_y % s->slice_height) == 0) {
|
if (s->slice_height && (s->mb_y % s->slice_height) == 0) {
|
||||||
if(s->msmpeg4_version < 4){
|
if (s->msmpeg4_version < MSMP4_WMV1) {
|
||||||
ff_mpeg4_clean_buffers(s);
|
ff_mpeg4_clean_buffers(s);
|
||||||
}
|
}
|
||||||
s->first_slice_line = 1;
|
s->first_slice_line = 1;
|
||||||
@ -410,7 +410,7 @@ void ff_msmpeg4_encode_mb(MpegEncContext * s,
|
|||||||
if (s->use_skip_mb_code)
|
if (s->use_skip_mb_code)
|
||||||
put_bits(&s->pb, 1, 0); /* mb coded */
|
put_bits(&s->pb, 1, 0); /* mb coded */
|
||||||
|
|
||||||
if(s->msmpeg4_version<=2){
|
if (s->msmpeg4_version <= MSMP4_V2) {
|
||||||
put_bits(&s->pb,
|
put_bits(&s->pb,
|
||||||
ff_v2_mb_type[cbp&3][1],
|
ff_v2_mb_type[cbp&3][1],
|
||||||
ff_v2_mb_type[cbp&3][0]);
|
ff_v2_mb_type[cbp&3][0]);
|
||||||
@ -452,7 +452,7 @@ void ff_msmpeg4_encode_mb(MpegEncContext * s,
|
|||||||
int val = (s->block_last_index[i] >= 1);
|
int val = (s->block_last_index[i] >= 1);
|
||||||
cbp |= val << (5 - i);
|
cbp |= val << (5 - i);
|
||||||
}
|
}
|
||||||
if(s->msmpeg4_version<=2){
|
if (s->msmpeg4_version <= MSMP4_V2) {
|
||||||
if (s->pict_type == AV_PICTURE_TYPE_I) {
|
if (s->pict_type == AV_PICTURE_TYPE_I) {
|
||||||
put_bits(&s->pb,
|
put_bits(&s->pb,
|
||||||
ff_v2_intra_cbpc[cbp&3][1], ff_v2_intra_cbpc[cbp&3][0]);
|
ff_v2_intra_cbpc[cbp&3][1], ff_v2_intra_cbpc[cbp&3][0]);
|
||||||
@ -524,7 +524,7 @@ static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr
|
|||||||
/* do the prediction */
|
/* do the prediction */
|
||||||
level -= pred;
|
level -= pred;
|
||||||
|
|
||||||
if(s->msmpeg4_version<=2){
|
if (s->msmpeg4_version <= MSMP4_V2) {
|
||||||
if (n < 4) {
|
if (n < 4) {
|
||||||
put_bits(&s->pb,
|
put_bits(&s->pb,
|
||||||
ff_v2_dc_lum_table[level + 256][1],
|
ff_v2_dc_lum_table[level + 256][1],
|
||||||
@ -575,20 +575,17 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n)
|
|||||||
} else {
|
} else {
|
||||||
rl = &ff_rl_table[3 + s->rl_chroma_table_index];
|
rl = &ff_rl_table[3 + s->rl_chroma_table_index];
|
||||||
}
|
}
|
||||||
run_diff = s->msmpeg4_version>=4;
|
run_diff = s->msmpeg4_version >= MSMP4_WMV1;
|
||||||
scantable= s->intra_scantable.permutated;
|
scantable= s->intra_scantable.permutated;
|
||||||
} else {
|
} else {
|
||||||
i = 0;
|
i = 0;
|
||||||
rl = &ff_rl_table[3 + s->rl_table_index];
|
rl = &ff_rl_table[3 + s->rl_table_index];
|
||||||
if(s->msmpeg4_version<=2)
|
run_diff = s->msmpeg4_version > MSMP4_V2;
|
||||||
run_diff = 0;
|
|
||||||
else
|
|
||||||
run_diff = 1;
|
|
||||||
scantable= s->inter_scantable.permutated;
|
scantable= s->inter_scantable.permutated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* recalculate block_last_index for M$ wmv1 */
|
/* recalculate block_last_index for M$ wmv1 */
|
||||||
if (s->msmpeg4_version >= 4 && s->block_last_index[n] > 0) {
|
if (s->msmpeg4_version >= MSMP4_WMV1 && s->block_last_index[n] > 0) {
|
||||||
for(last_index=63; last_index>=0; last_index--){
|
for(last_index=63; last_index>=0; last_index--){
|
||||||
if(block[scantable[last_index]]) break;
|
if(block[scantable[last_index]]) break;
|
||||||
}
|
}
|
||||||
@ -634,7 +631,7 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n)
|
|||||||
if (run1 < 0)
|
if (run1 < 0)
|
||||||
goto esc3;
|
goto esc3;
|
||||||
code = get_rl_index(rl, last, run1+1, level);
|
code = get_rl_index(rl, last, run1+1, level);
|
||||||
if (s->msmpeg4_version == 4 && code == rl->n)
|
if (s->msmpeg4_version == MSMP4_WMV1 && code == rl->n)
|
||||||
goto esc3;
|
goto esc3;
|
||||||
code = get_rl_index(rl, last, run1, level);
|
code = get_rl_index(rl, last, run1, level);
|
||||||
if (code == rl->n) {
|
if (code == rl->n) {
|
||||||
@ -642,7 +639,7 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n)
|
|||||||
/* third escape */
|
/* third escape */
|
||||||
put_bits(&s->pb, 1, 0);
|
put_bits(&s->pb, 1, 0);
|
||||||
put_bits(&s->pb, 1, last);
|
put_bits(&s->pb, 1, last);
|
||||||
if(s->msmpeg4_version>=4){
|
if (s->msmpeg4_version >= MSMP4_WMV1) {
|
||||||
if(s->esc3_level_length==0){
|
if(s->esc3_level_length==0){
|
||||||
s->esc3_level_length=8;
|
s->esc3_level_length=8;
|
||||||
s->esc3_run_length= 6;
|
s->esc3_run_length= 6;
|
||||||
|
@ -610,7 +610,7 @@ av_cold void ff_vc1_init_common(VC1Context *v)
|
|||||||
s->out_format = FMT_H263;
|
s->out_format = FMT_H263;
|
||||||
|
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->msmpeg4_version = 6;
|
s->msmpeg4_version = MSMP4_VC1;
|
||||||
|
|
||||||
ff_vc1dsp_init(&v->vc1dsp);
|
ff_vc1dsp_init(&v->vc1dsp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user