Unified · Split
| @@ -1125,7 +1125,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 1124 unmodified lines | |||
| 1125 | } else { | 1125 | } else { |
| 1126 | s->min_qcoeff = -2047; | 1126 | s->min_qcoeff = -2047; |
| 1127 | s->max_qcoeff = 2047; | 1127 | s->max_qcoeff = 2047; |
| 1128 | s->c.mpeg_quant = 1; | 1128 | s->mpeg_quant = 1; |
| 1129 | } | 1129 | } |
| 1130 | if (s->c.intra_vlc_format) { | 1130 | if (s->c.intra_vlc_format) { |
| 1131 | s->intra_ac_vlc_length = | 1131 | s->intra_ac_vlc_length = |
| @@ -1399,7 +1399,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 1398 unmodified lines | |||
| 1399 | 1399 | ||
| 1400 | scan_table = s->intra_scantable.permutated; | 1400 | scan_table = s->intra_scantable.permutated; |
| 1401 | 1401 | ||
| 1402 | if (s->mpeg_quant) { | 1402 | if (ctx->mpeg_quant) { |
| 1403 | qmul = 1; | 1403 | qmul = 1; |
| 1404 | qadd = 0; | 1404 | qadd = 0; |
| 1405 | if (rvlc) | 1405 | if (rvlc) |
| @@ -2155,7 +2155,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n · 749 unmodified lines | |||
| 2155 | 2155 | ||
| 2156 | s->last_dc[cc] += dct_diff; | 2156 | s->last_dc[cc] += dct_diff; |
| 2157 | 2157 | ||
| 2158 | if (s->mpeg_quant) | 2158 | if (ctx->mpeg_quant) |
| 2159 | block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision); | 2159 | block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision); |
| 2160 | else | 2160 | else |
| 2161 | block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision) * (8 >> s->dct_precision); | 2161 | block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision) * (8 >> s->dct_precision); |
| @@ -2585,7 +2585,7 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 423 unmodified lines | |||
| 2585 | skip_bits(gb, 15); /* latter_half_vbv_occupancy */ | 2585 | skip_bits(gb, 15); /* latter_half_vbv_occupancy */ |
| 2586 | check_marker(s->avctx, gb, "after latter_half_vbv_occupancy"); | 2586 | check_marker(s->avctx, gb, "after latter_half_vbv_occupancy"); |
| 2587 | s->low_delay = get_bits1(gb); | 2587 | s->low_delay = get_bits1(gb); |
| 2588 | s->mpeg_quant = get_bits1(gb); /* mpeg2_stream */ | 2588 | ctx->mpeg_quant = get_bits1(gb); /* mpeg2_stream */ |
| 2589 | 2589 | ||
| 2590 | next_start_code_studio(gb); | 2590 | next_start_code_studio(gb); |
| 2591 | extension_and_user_data(s, gb, 2); | 2591 | extension_and_user_data(s, gb, 2); |
| @@ -2767,7 +2767,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 175 unmodified lines | |||
| 2767 | 2767 | ||
| 2768 | // FIXME a bunch of grayscale shape things | 2768 | // FIXME a bunch of grayscale shape things |
| 2769 | 2769 | ||
| 2770 | if ((s->mpeg_quant = get_bits1(gb))) { /* vol_quant_type */ | 2770 | if ((ctx->mpeg_quant = get_bits1(gb))) { /* vol_quant_type */ |
| 2771 | int i, v; | 2771 | int i, v; |
| 2772 | 2772 | ||
| 2773 | mpeg4_load_default_matrices(s); | 2773 | mpeg4_load_default_matrices(s); |
| @@ -3415,10 +3415,10 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, · 641 unmodified lines | |||
| 3415 | } | 3415 | } |
| 3416 | } | 3416 | } |
| 3417 | 3417 | ||
| 3418 | s->dct_unquantize_intra = s->mpeg_quant ? ctx->dct_unquantize_mpeg2_intra | 3418 | s->dct_unquantize_intra = ctx->mpeg_quant ? ctx->dct_unquantize_mpeg2_intra |
| 3419 | : ctx->dct_unquantize_h263_intra; | 3419 | : ctx->dct_unquantize_h263_intra; |
| 3420 | // The following tells ff_mpv_reconstruct_mb() to unquantize iff mpeg_quant | 3420 | // The following tells ff_mpv_reconstruct_mb() to unquantize iff mpeg_quant |
| 3421 | s->dct_unquantize_inter = s->mpeg_quant ? ctx->dct_unquantize_mpeg2_inter : NULL; | 3421 | s->dct_unquantize_inter = ctx->mpeg_quant ? ctx->dct_unquantize_mpeg2_inter : NULL; |
| 3422 | 3422 | ||
| 3423 | end: | 3423 | end: |
| 3424 | /* detect buggy encoders which don't set the low_delay flag | 3424 | /* detect buggy encoders which don't set the low_delay flag |
| @@ -3857,6 +3857,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, · 432 unmodified lines | |||
| 3857 | s->sprite_warping_accuracy = s1->sprite_warping_accuracy; | 3857 | s->sprite_warping_accuracy = s1->sprite_warping_accuracy; |
| 3858 | s->num_sprite_warping_points = s1->num_sprite_warping_points; | 3858 | s->num_sprite_warping_points = s1->num_sprite_warping_points; |
| 3859 | s->m.data_partitioning = s1->m.data_partitioning; | 3859 | s->m.data_partitioning = s1->m.data_partitioning; |
| 3860 | s->mpeg_quant = s1->mpeg_quant; | ||
| 3860 | s->rvlc = s1->rvlc; | 3861 | s->rvlc = s1->rvlc; |
| 3861 | s->resync_marker = s1->resync_marker; | 3862 | s->resync_marker = s1->resync_marker; |
| 3862 | s->t_frame = s1->t_frame; | 3863 | s->t_frame = s1->t_frame; |
| @@ -52,6 +52,7 @@ typedef struct Mpeg4DecContext { · 51 unmodified lines | |||
| 52 | /// sprite shift [isChroma] | 52 | /// sprite shift [isChroma] |
| 53 | int sprite_shift[2]; | 53 | int sprite_shift[2]; |
| 54 | 54 | ||
| 55 | int mpeg_quant; | ||
| 55 | // reversible vlc | 56 | // reversible vlc |
| 56 | int rvlc; | 57 | int rvlc; |
| 57 | /// could this stream contain resync markers | 58 | /// could this stream contain resync markers |
| @@ -952,9 +952,9 @@ static void mpeg4_encode_vol_header(Mpeg4EncContext *const m4, · 951 unmodified lines | |||
| 952 | put_bits(&s->pb, 2, 0); /* sprite enable */ | 952 | put_bits(&s->pb, 2, 0); /* sprite enable */ |
| 953 | 953 | ||
| 954 | put_bits(&s->pb, 1, 0); /* not 8 bit == false */ | 954 | put_bits(&s->pb, 1, 0); /* not 8 bit == false */ |
| 955 | put_bits(&s->pb, 1, s->c.mpeg_quant); /* quant type = (0 = H.263 style) */ | 955 | put_bits(&s->pb, 1, s->mpeg_quant); /* quant type = (0 = H.263 style) */ |
| 956 | 956 | ||
| 957 | if (s->c.mpeg_quant) { | 957 | if (s->mpeg_quant) { |
| 958 | ff_write_quant_matrix(&s->pb, s->c.avctx->intra_matrix); | 958 | ff_write_quant_matrix(&s->pb, s->c.avctx->intra_matrix); |
| 959 | ff_write_quant_matrix(&s->pb, s->c.avctx->inter_matrix); | 959 | ff_write_quant_matrix(&s->pb, s->c.avctx->inter_matrix); |
| 960 | } | 960 | } |
| @@ -1304,11 +1304,11 @@ void ff_mpeg4_encode_video_packet_header(MPVEncContext *const s) · 343 unmodified lines | |||
| 1304 | put_bits(&s->pb, 1, 0); /* no HEC */ | 1304 | put_bits(&s->pb, 1, 0); /* no HEC */ |
| 1305 | } | 1305 | } |
| 1306 | 1306 | ||
| 1307 | #define OFFSET(x) offsetof(MPVEncContext, c.x) | 1307 | #define OFFSET(x) offsetof(MPVEncContext, x) |
| 1308 | #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | 1308 | #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
| 1309 | static const AVOption options[] = { | 1309 | static const AVOption options[] = { |
| 1310 | { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, | 1310 | { "data_partitioning", "Use data partitioning.", OFFSET(c.data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, |
| 1311 | { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, | 1311 | { "alternate_scan", "Enable alternate scantable.", OFFSET(c.alternate_scan), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, |
| 1312 | { "mpeg_quant", "Use MPEG quantizers instead of H.263", | 1312 | { "mpeg_quant", "Use MPEG quantizers instead of H.263", |
| 1313 | OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE }, | 1313 | OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE }, |
| 1314 | FF_MPV_COMMON_BFRAME_OPTS | 1314 | FF_MPV_COMMON_BFRAME_OPTS |
| @@ -254,7 +254,6 @@ typedef struct MpegEncContext { · 253 unmodified lines | |||
| 254 | int data_partitioning; ///< data partitioning flag from header | 254 | int data_partitioning; ///< data partitioning flag from header |
| 255 | int partitioned_frame; ///< is current frame partitioned | 255 | int partitioned_frame; ///< is current frame partitioned |
| 256 | int low_delay; ///< no reordering needed / has no B-frames | 256 | int low_delay; ///< no reordering needed / has no B-frames |
| 257 | int mpeg_quant; | ||
| 258 | int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4 | 257 | int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4 |
| 259 | 258 | ||
| 260 | /* divx specific, used to workaround (many) bugs in divx5 */ | 259 | /* divx specific, used to workaround (many) bugs in divx5 */ |
| @@ -313,14 +313,15 @@ av_cold void ff_dct_encode_init(MPVEncContext *const s) · 312 unmodified lines | |||
| 313 | s->dct_quantize = dct_quantize_trellis_c; | 313 | s->dct_quantize = dct_quantize_trellis_c; |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | static av_cold void init_unquantize(MpegEncContext *const s, AVCodecContext *avctx) | 316 | static av_cold void init_unquantize(MPVEncContext *const s2, AVCodecContext *avctx) |
| 317 | { | 317 | { |
| 318 | MpegEncContext *const s = &s2->c; | ||
| 318 | MPVUnquantDSPContext unquant_dsp_ctx; | 319 | MPVUnquantDSPContext unquant_dsp_ctx; |
| 319 | 320 | ||
| 320 | ff_mpv_unquantize_init(&unquant_dsp_ctx, | 321 | ff_mpv_unquantize_init(&unquant_dsp_ctx, |
| 321 | avctx->flags & AV_CODEC_FLAG_BITEXACT, s->q_scale_type); | 322 | avctx->flags & AV_CODEC_FLAG_BITEXACT, s->q_scale_type); |
| 322 | 323 | ||
| 323 | if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { | 324 | if (s2->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { |
| 324 | s->dct_unquantize_intra = unquant_dsp_ctx.dct_unquantize_mpeg2_intra; | 325 | s->dct_unquantize_intra = unquant_dsp_ctx.dct_unquantize_mpeg2_intra; |
| 325 | s->dct_unquantize_inter = unquant_dsp_ctx.dct_unquantize_mpeg2_inter; | 326 | s->dct_unquantize_inter = unquant_dsp_ctx.dct_unquantize_mpeg2_inter; |
| 326 | } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { | 327 | } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { |
| @@ -403,7 +404,7 @@ static av_cold int init_matrices(MPVMainEncContext *const m, AVCodecContext *avc · 76 unmodified lines | |||
| 403 | } | 404 | } |
| 404 | 405 | ||
| 405 | if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4 && | 406 | if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4 && |
| 406 | s->c.mpeg_quant) { | 407 | s->mpeg_quant) { |
| 407 | intra_matrix = ff_mpeg4_default_intra_matrix; | 408 | intra_matrix = ff_mpeg4_default_intra_matrix; |
| 408 | inter_matrix = ff_mpeg4_default_non_intra_matrix; | 409 | inter_matrix = ff_mpeg4_default_non_intra_matrix; |
| 409 | } else if (s->c.out_format == FMT_H263 || s->c.out_format == FMT_H261) { | 410 | } else if (s->c.out_format == FMT_H263 || s->c.out_format == FMT_H261) { |
| @@ -839,7 +840,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 429 unmodified lines | |||
| 839 | //return -1; | 840 | //return -1; |
| 840 | } | 841 | } |
| 841 | 842 | ||
| 842 | if (s->c.mpeg_quant || s->c.codec_id == AV_CODEC_ID_MPEG1VIDEO || s->c.codec_id == AV_CODEC_ID_MPEG2VIDEO || s->c.codec_id == AV_CODEC_ID_MJPEG || s->c.codec_id == AV_CODEC_ID_AMV || s->c.codec_id == AV_CODEC_ID_SPEEDHQ) { | 843 | if (s->mpeg_quant || s->c.codec_id == AV_CODEC_ID_MPEG1VIDEO || s->c.codec_id == AV_CODEC_ID_MPEG2VIDEO || s->c.codec_id == AV_CODEC_ID_MJPEG || s->c.codec_id == AV_CODEC_ID_AMV || s->c.codec_id == AV_CODEC_ID_SPEEDHQ) { |
| 843 | // (a + x * 3 / 8) / x | 844 | // (a + x * 3 / 8) / x |
| 844 | s->intra_quant_bias = 3 << (QUANT_BIAS_SHIFT - 3); | 845 | s->intra_quant_bias = 3 << (QUANT_BIAS_SHIFT - 3); |
| 845 | s->inter_quant_bias = 0; | 846 | s->inter_quant_bias = 0; |
| @@ -1027,7 +1028,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 181 unmodified lines | |||
| 1027 | * before calling ff_mpv_common_init(). */ | 1028 | * before calling ff_mpv_common_init(). */ |
| 1028 | s->parent = m; | 1029 | s->parent = m; |
| 1029 | ff_mpv_idct_init(&s->c); | 1030 | ff_mpv_idct_init(&s->c); |
| 1030 | init_unquantize(&s->c, avctx); | 1031 | init_unquantize(s, avctx); |
| 1031 | ff_fdctdsp_init(&s->fdsp, avctx); | 1032 | ff_fdctdsp_init(&s->fdsp, avctx); |
| 1032 | ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); | 1033 | ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); |
| 1033 | ff_pixblockdsp_init(&s->pdsp, avctx); | 1034 | ff_pixblockdsp_init(&s->pdsp, avctx); |
| @@ -4016,7 +4017,7 @@ static int dct_quantize_trellis_c(MPVEncContext *const s, · 2982 unmodified lines | |||
| 4016 | last_non_zero = 0; | 4017 | last_non_zero = 0; |
| 4017 | qmat = n < 4 ? s->q_intra_matrix[qscale] : s->q_chroma_intra_matrix[qscale]; | 4018 | qmat = n < 4 ? s->q_intra_matrix[qscale] : s->q_chroma_intra_matrix[qscale]; |
| 4018 | matrix = n < 4 ? s->c.intra_matrix : s->c.chroma_intra_matrix; | 4019 | matrix = n < 4 ? s->c.intra_matrix : s->c.chroma_intra_matrix; |
| 4019 | if (s->c.mpeg_quant || s->c.out_format == FMT_MPEG1 || s->c.out_format == FMT_MJPEG) | 4020 | if (s->mpeg_quant || s->c.out_format == FMT_MPEG1 || s->c.out_format == FMT_MJPEG) |
| 4020 | bias= 1<<(QMAT_SHIFT-1); | 4021 | bias= 1<<(QMAT_SHIFT-1); |
| 4021 | 4022 | ||
| 4022 | if (n > 3 && s->intra_chroma_ac_vlc_length) { | 4023 | if (n > 3 && s->intra_chroma_ac_vlc_length) { |
| @@ -4331,7 +4332,7 @@ static int dct_quantize_refine(MPVEncContext *const s, //FIXME breaks denoise? · 308 unmodified lines | |||
| 4331 | dc= block[0]*q; | 4332 | dc= block[0]*q; |
| 4332 | // block[0] = (block[0] + (q >> 1)) / q; | 4333 | // block[0] = (block[0] + (q >> 1)) / q; |
| 4333 | start_i = 1; | 4334 | start_i = 1; |
| 4334 | // if (s->c.mpeg_quant || s->c.out_format == FMT_MPEG1) | 4335 | // if (s->mpeg_quant || s->c.out_format == FMT_MPEG1) |
| 4335 | // bias= 1<<(QMAT_SHIFT-1); | 4336 | // bias= 1<<(QMAT_SHIFT-1); |
| 4336 | if (n > 3 && s->intra_chroma_ac_vlc_length) { | 4337 | if (n > 3 && s->intra_chroma_ac_vlc_length) { |
| 4337 | length = s->intra_chroma_ac_vlc_length; | 4338 | length = s->intra_chroma_ac_vlc_length; |
| @@ -147,6 +147,7 @@ typedef struct MPVEncContext { · 146 unmodified lines | |||
| 147 | int last_mv_dir; ///< last mv_dir, used for B-frame encoding | 147 | int last_mv_dir; ///< last mv_dir, used for B-frame encoding |
| 148 | 148 | ||
| 149 | /* MPEG-4 specific */ | 149 | /* MPEG-4 specific */ |
| 150 | int mpeg_quant; | ||
| 150 | PutBitContext tex_pb; ///< used for data partitioned VOPs | 151 | PutBitContext tex_pb; ///< used for data partitioned VOPs |
| 151 | PutBitContext pb2; ///< used for data partitioned VOPs | 152 | PutBitContext pb2; ///< used for data partitioned VOPs |
| 152 | 153 | ||
| @@ -70,7 +70,7 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, · 69 unmodified lines | |||
| 70 | .vop_time_increment_bitcount = m->time_increment_bits, | 70 | .vop_time_increment_bitcount = m->time_increment_bits, |
| 71 | .top_field_first = s->top_field_first, | 71 | .top_field_first = s->top_field_first, |
| 72 | .resync_marker_disable = !m->resync_marker, | 72 | .resync_marker_disable = !m->resync_marker, |
| 73 | .quant_type = s->mpeg_quant, | 73 | .quant_type = m->mpeg_quant, |
| 74 | .quarter_sample = s->quarter_sample, | 74 | .quarter_sample = s->quarter_sample, |
| 75 | .short_video_header = avctx->codec->id == AV_CODEC_ID_H263, | 75 | .short_video_header = avctx->codec->id == AV_CODEC_ID_H263, |
| 76 | .divx_flags = s->divx_packed ? 5 : 0, | 76 | .divx_flags = s->divx_packed ? 5 : 0, |
| @@ -70,7 +70,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, · 69 unmodified lines | |||
| 70 | .obmc_disable = 1, | 70 | .obmc_disable = 1, |
| 71 | .sprite_enable = ctx->vol_sprite_usage, | 71 | .sprite_enable = ctx->vol_sprite_usage, |
| 72 | .sprite_warping_accuracy = ctx->sprite_warping_accuracy, | 72 | .sprite_warping_accuracy = ctx->sprite_warping_accuracy, |
| 73 | .quant_type = s->mpeg_quant, | 73 | .quant_type = ctx->mpeg_quant, |
| 74 | .quarter_sample = s->quarter_sample, | 74 | .quarter_sample = s->quarter_sample, |
| 75 | .data_partitioned = s->data_partitioning, | 75 | .data_partitioned = s->data_partitioning, |
| 76 | .reversible_vlc = ctx->rvlc, | 76 | .reversible_vlc = ctx->rvlc, |
| @@ -68,7 +68,7 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, · 67 unmodified lines | |||
| 68 | info->vop_fcode_backward = ctx->b_code; | 68 | info->vop_fcode_backward = ctx->b_code; |
| 69 | info->resync_marker_disable = !ctx->resync_marker; | 69 | info->resync_marker_disable = !ctx->resync_marker; |
| 70 | info->interlaced = !s->progressive_sequence; | 70 | info->interlaced = !s->progressive_sequence; |
| 71 | info->quant_type = s->mpeg_quant; | 71 | info->quant_type = ctx->mpeg_quant; |
| 72 | info->quarter_sample = s->quarter_sample; | 72 | info->quarter_sample = s->quarter_sample; |
| 73 | info->short_video_header = avctx->codec->id == AV_CODEC_ID_H263; | 73 | info->short_video_header = avctx->codec->id == AV_CODEC_ID_H263; |
| 74 | info->rounding_control = s->no_rounding; | 74 | info->rounding_control = s->no_rounding; |
| @@ -109,7 +109,7 @@ static int RENAME(dct_quantize)(MPVEncContext *const s, · 108 unmodified lines | |||
| 109 | qmat = s->q_inter_matrix16[qscale][0]; | 109 | qmat = s->q_inter_matrix16[qscale][0]; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | if ((s->c.out_format == FMT_H263 || s->c.out_format == FMT_H261) && !s->c.mpeg_quant) { | 112 | if ((s->c.out_format == FMT_H263 || s->c.out_format == FMT_H261) && !s->mpeg_quant) { |
| 113 | __asm__ volatile( | 113 | __asm__ volatile( |
| 114 | "movd %%"FF_REG_a", %%xmm3 \n\t" // last_non_zero_p1 | 114 | "movd %%"FF_REG_a", %%xmm3 \n\t" // last_non_zero_p1 |
| 115 | SPREADW("%%xmm3") | 115 | SPREADW("%%xmm3") |