From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 65/67] avcodec/mpegvideo: Move quant_precision to Mpeg4DecContext
Date: Fri, 14 Jun 2024 20:25:56 +0200
Message-ID: <GV1P250MB07376CF615D63B72B64AF2B38FC22@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB073785E3B3B4EEEE52B2FC1E8FC02@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
It is an MPEG-4-only value; it is always five for the MPEG-4
encoder, so just hardcode this value and move the MpegEncContext
field to Mpeg4DecContext.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h263dec.c | 1 -
libavcodec/mpeg4video_parser.c | 2 +-
libavcodec/mpeg4videodec.c | 20 ++++++++++----------
libavcodec/mpeg4videodec.h | 2 ++
libavcodec/mpeg4videoenc.c | 2 +-
libavcodec/mpegvideo.h | 1 -
libavcodec/mpegvideo_enc.c | 2 --
libavcodec/vaapi_mpeg4.c | 2 +-
8 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 19a57582ad..a81786479d 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -99,7 +99,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
if (ret < 0)
return ret;
- s->quant_precision = 5;
s->decode_mb = ff_h263_decode_mb;
s->low_delay = 1;
diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c
index 402594e01d..b00b523bde 100644
--- a/libavcodec/mpeg4video_parser.c
+++ b/libavcodec/mpeg4video_parser.c
@@ -122,7 +122,7 @@ static av_cold int mpeg4video_parse_init(AVCodecParserContext *s)
struct Mp4vParseContext *pc = s->priv_data;
pc->first_picture = 1;
- pc->dec_ctx.m.quant_precision = 5;
+ pc->dec_ctx.quant_precision = 5;
pc->dec_ctx.m.slice_context_count = 1;
pc->dec_ctx.showed_packed_warning = 1;
return 0;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 77bd3e9947..debcafc4c0 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -728,7 +728,7 @@ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
s->mb_y = mb_num / s->mb_width;
if (ctx->shape != BIN_ONLY_SHAPE) {
- int qscale = get_bits(&s->gb, s->quant_precision);
+ int qscale = get_bits(&s->gb, ctx->quant_precision);
if (qscale)
s->chroma_qscale = s->qscale = qscale;
}
@@ -2706,17 +2706,16 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
// FIXME sadct disable bit if verid!=1 && shape not rect
if (get_bits1(gb) == 1) { /* not_8_bit */
- s->quant_precision = get_bits(gb, 4); /* quant_precision */
+ ctx->quant_precision = get_bits(gb, 4); /* quant_precision */
if (get_bits(gb, 4) != 8) /* bits_per_pixel */
av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n");
- if (s->quant_precision != 5)
+ if (ctx->quant_precision != 5)
av_log(s->avctx, AV_LOG_ERROR,
- "quant precision %d\n", s->quant_precision);
- if (s->quant_precision<3 || s->quant_precision>9) {
- s->quant_precision = 5;
- }
+ "quant precision %d\n", ctx->quant_precision);
+ if (ctx->quant_precision < 3 || ctx->quant_precision > 9)
+ ctx->quant_precision = 5;
} else {
- s->quant_precision = 5;
+ ctx->quant_precision = 5;
}
// FIXME a bunch of grayscale shape things
@@ -2904,7 +2903,7 @@ no_cplx_est:
av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, low_delay:%d %s%s%s%s\n",
s->avctx->framerate.den, s->avctx->framerate.num,
ctx->time_increment_bits,
- s->quant_precision,
+ ctx->quant_precision,
s->progressive_sequence,
s->low_delay,
ctx->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "",
@@ -3286,7 +3285,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
}
if (ctx->shape != BIN_ONLY_SHAPE) {
- s->chroma_qscale = s->qscale = get_bits(gb, s->quant_precision);
+ s->chroma_qscale = s->qscale = get_bits(gb, ctx->quant_precision);
if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Error, header damaged or not MPEG-4 header (qscale=0)\n");
@@ -3798,6 +3797,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->low_delay = 0; /* default, might be overridden in the vol header during header parsing */
s->decode_mb = mpeg4_decode_mb;
ctx->time_increment_bits = 4; /* default value for broken headers */
+ ctx->quant_precision = 5;
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h
index 4a26d18987..734237b16f 100644
--- a/libavcodec/mpeg4videodec.h
+++ b/libavcodec/mpeg4videodec.h
@@ -60,6 +60,8 @@ typedef struct Mpeg4DecContext {
int enhancement_type;
int scalability;
+ int quant_precision;
+
/// QP above which the ac VLC should be used for intra dc
int intra_dc_threshold;
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 84b603f312..0b18776497 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1358,7 +1358,7 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, mb_num_bits, s->mb_x + s->mb_y * s->mb_width);
- put_bits(&s->pb, s->quant_precision, s->qscale);
+ put_bits(&s->pb, 5 /* quant_precision */, s->qscale);
put_bits(&s->pb, 1, 0); /* no HEC */
}
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 844da6881f..8083299b66 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -384,7 +384,6 @@ typedef struct MpegEncContext {
uint16_t pp_field_time;
uint16_t pb_field_time; ///< like above, just for interlaced
int mcsel;
- int quant_precision;
int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
int data_partitioning; ///< data partitioning flag from header
int partitioned_frame; ///< is current frame partitioned
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d05a93d249..abeb235277 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -951,8 +951,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->h263_slice_structured = 1;
}
- s->quant_precision = 5;
-
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
ff_h263_encode_init(s);
#if CONFIG_MSMPEG4ENC
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index d182f879cb..2c9dfbe42f 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -74,7 +74,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
.resync_marker_disable = !ctx->resync_marker,
},
.no_of_sprite_warping_points = ctx->num_sprite_warping_points,
- .quant_precision = s->quant_precision,
+ .quant_precision = ctx->quant_precision,
.vop_fields.bits = {
.vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I,
.backward_reference_vop_coding_type =
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-06-14 18:27 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 13:16 [FFmpeg-devel] [PATCH 01/57] avcodec/vc1: Combine identical checks Andreas Rheinhardt
2024-06-12 13:47 ` [FFmpeg-devel] [PATCH 02/57] avcodec/mpegvideo_enc: Avoid branches for flipping no_rounding Andreas Rheinhardt
2024-06-12 13:47 ` [FFmpeg-devel] [PATCH 03/57] avcodec/mpegvideo: Don't pretend dct_init can fail Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 04/57] avcodec/mpegvideo: Set dct_unquantize earlier Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 05/57] avcodec/mpegvideo_dec: Set dct_unquantize ptrs only once when possible Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 06/57] configure: Remove obsolete mpeg4_decoder->mpeg4video_parser dependency Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 07/57] avcodec/mpegutils: Remap MB_TYPE_ACPRED, add codec-specific MB_TYPE Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 08/57] avcodec/mpegutils: Remap MB_TYPE_{GMC, SKIP, CBP, QUANT} Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 09/57] avcodec/h261dec: Use VLC symbol table Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 10/57] avcodec/h261dec: Remove nonsense information from error message Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 11/57] avcodec/mpegutils: Remove always-false check Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 12/57] avcodec/mpegutils: Don't use MB_TYPE_L[01] for mpegvideo Andreas Rheinhardt
2024-06-13 8:23 ` Michael Niedermayer
2024-06-13 8:49 ` Andreas Rheinhardt
2024-06-13 9:56 ` Michael Niedermayer
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 13/57] avcodec/mpegutils: Move H.264-only macros to h264dec.h Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 14/57] avcodec/mpeg4videodec: Use VLC symbol table Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 15/57] avcodec/mpeg12dec: " Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 16/57] avcodec/ituh263dec: " Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 17/57] avcodec/mpegvideo_enc: Avoid excessive inlining Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 18/57] avcodec/mpegvideo_enc: Check for existence of ildct cmp functions Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 19/57] avcodec/dvenc: Check for availability of interlaced dct cmp func Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 20/57] avcodec/motion_est: Factor one-time initialization out of ff_init_me Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 21/57] avcodec/me_cmp: Constify ff_set_cmp() Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 22/57] avcodec/me_cmp, motion_est: Move me_(pre_)?_cmp etc. to MotionEstContext Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 23/57] avcodec/me_cmp, mpegvideo: Move frame_skip_cmp to MpegEncContext Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 24/57] avcodec/me_cmp, dvenc, mpegvideo: Move ildct_cmp to its users Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 25/57] avcodec/me_cmp, motion_est: Sanitize permissible cmp_funcs Andreas Rheinhardt
2024-06-13 7:49 ` Michael Niedermayer
2024-06-13 9:37 ` Andreas Rheinhardt
2024-06-13 21:11 ` Michael Niedermayer
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 26/57] avcodec/motion_est: Store remaining required me_cmp_funcs Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 27/57] avcodec/me_cmp: Zero MECmpContext in ff_me_cmp_init() Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 28/57] avcodec/mpegvideo_enc: Avoid branch for sse vs nsse cmp Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 29/57] avcodec/mpegvideo_enc: Only keep what is used from MECmpContext Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 30/57] avcodec/mpegvideo_enc: Initialize qscale tab for all codecs Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 31/57] avcodec/mpegvideo_enc: Don't update qscale unnecessarily Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 32/57] avcodec/mpegutils: Fix ff_draw_horiz_band() Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 33/57] avcodec/mpv_reconstruct_mb_template: Don't unnecessarily copy data Andreas Rheinhardt
2024-06-13 7:36 ` Michael Niedermayer
2024-06-13 8:50 ` Andreas Rheinhardt
2024-06-13 21:19 ` Michael Niedermayer
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 34/57] avcodec/mpeg12dec: Disable allocating scratchpad buffers when possible Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 35/57] avcodec/mpegvideo_dec: Don't alloc framesize-bufs in update_thread_ctx Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 36/57] avcodec/mpegvideo_dec: Don't keep droppable in sync " Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 37/57] avcodec/mpegutils: Don't output wrong mb skip values Andreas Rheinhardt
2024-06-13 7:27 ` Michael Niedermayer
2024-06-17 11:08 ` Andreas Rheinhardt
2024-06-18 22:08 ` Michael Niedermayer
2024-06-19 13:54 ` Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 38/57] avcodec/svq1enc: Stop copying PutBitContext unnecessarily Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 39/57] avcodec/ituh263enc: Inline constants Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 40/57] avcodec/h263enc: Remove no-output code Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 41/57] avcodec/mpeg4videodec: Inline constants Andreas Rheinhardt
2024-06-13 7:16 ` Michael Niedermayer
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 42/57] avcodec/mpeg4videodec: Don't initialize unused stuff Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 43/57] avcodec/vc1_block: Remove unnecessary assignments Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 44/57] avcodec/vc1_block: Simplify resetting coded_block Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 45/57] avcodec/mpeg4videodec: Remove always-false check Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 46/57] avcodec/mpeg12enc: Use AVCodecContext, not priv ctx as logctx Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 47/57] avcodec/mpeg12enc: Pass AVCodecContext* directly Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 48/57] avcodec/msmpeg4enc: Combine writing bits Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 49/57] avcodec/h261dec: Don't reset gob_start_code_skipped in h261_decode_init() Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 50/57] avcodec/h261dec: Fix UB NULL + 0, remove broken resync code Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 51/57] avcodec/h261dec: Simplify decoding GOB header Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 52/57] avcodec/mpv_reconstruct_mb_template: Optimize always-true branch away Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 53/57] avcodec/mpegvideo_dec: Remove unnecessary FFMIN Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 54/57] avcodec/mpegvideo: Join loops when initializing ScanTable Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 55/57] avcodec/mpv_reconstruct_mb_template: Optimize WMV2 code away if possible Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 56/57] avcodec/mpeg4videodec: Don't initialize unused inter_scantable Andreas Rheinhardt
2024-06-12 13:48 ` [FFmpeg-devel] [PATCH 57/57] avcodec/mpeg_er: Don't set block_index unnecessarily Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 58/67] avcodec/h261enc, msmpeg4: Avoid setting dc_scale_tables unnecessarily Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 59/67] avcodec/h261dec: Unquantize coefficients while parsing them Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 60/67] avcodec/h261dec: Simplify decoding motion vectors Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 61/67] avcodec/h261dec: Don't set framerate multiple times Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 62/67] avcodec/rv10: Remove write-only assignments Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 63/67] avcodec/mpeg_er: Simplify disabling IDCT Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 64/67] avcodec/rv10: Use ff_h263_decode_init() Andreas Rheinhardt
2024-06-14 18:25 ` Andreas Rheinhardt [this message]
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 66/67] avcodec/rv10: Avoid indirection Andreas Rheinhardt
2024-06-14 18:25 ` [FFmpeg-devel] [PATCH 67/67] avcodec/mpegvideo_dec: Move setting dct_unquant funcs to h263dec.c Andreas Rheinhardt
2024-06-15 17:16 ` [FFmpeg-devel] [PATCH 68/73] avcodec/h261enc: Inline constants Andreas Rheinhardt
2024-06-15 17:16 ` [FFmpeg-devel] [PATCH 69/73] avcodec/motion_est: Optimize dead code away Andreas Rheinhardt
2024-06-15 17:16 ` [FFmpeg-devel] [PATCH 70/73] avcodec/mpegvideo_enc: Constify pointers to static storage Andreas Rheinhardt
2024-06-15 17:16 ` [FFmpeg-devel] [PATCH 71/73] avcodec/h261data: Make some tables non-static Andreas Rheinhardt
2024-06-15 17:16 ` [FFmpeg-devel] [PATCH 72/73] avcodec/h261enc: Avoid RLTable when writing macroblock Andreas Rheinhardt
2024-06-15 17:16 ` [FFmpeg-devel] [PATCH 73/73] avcodec/h261enc: Fix ac_vlc_length tables Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=GV1P250MB07376CF615D63B72B64AF2B38FC22@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git