From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 18/30] avcodec/mpeg12enc: Add custom context, move mpeg2_frame_rate_ext to it
Date: Thu, 23 Dec 2021 10:13:28 +0100
Message-ID: <AM7PR03MB66609362BB774E890DC51FB68F7E9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <AM7PR03MB66606013F665BF849CE7CAD68F7D9@AM7PR03MB6660.eurprd03.prod.outlook.com>
It is only used here.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 26 +++++++++++++++++---------
libavcodec/mpegvideo.h | 1 -
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index abb0a4b29f..97df5523cc 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -62,6 +62,11 @@ static uint8_t uni_mpeg2_ac_vlc_len[64 * 64 * 2];
static uint32_t mpeg1_lum_dc_uni[512];
static uint32_t mpeg1_chr_dc_uni[512];
+typedef struct MPEG12EncContext {
+ MpegEncContext mpeg;
+ AVRational frame_rate_ext;
+} MPEG12EncContext;
+
#define A53_MAX_CC_COUNT 0x1f
#endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
@@ -101,8 +106,9 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len
}
#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
-static int find_frame_rate_index(MpegEncContext *s)
+static int find_frame_rate_index(MPEG12EncContext *mpeg12)
{
+ MpegEncContext *const s = &mpeg12->mpeg;
int i;
AVRational bestq = (AVRational) {0, 0};
AVRational ext;
@@ -127,8 +133,8 @@ static int find_frame_rate_index(MpegEncContext *s)
|| ext.num==1 && ext.den==1 && av_nearer_q(target, bestq, q) == 0) {
bestq = q;
s->frame_rate_index = i;
- s->mpeg2_frame_rate_ext.num = ext.num;
- s->mpeg2_frame_rate_ext.den = ext.den;
+ mpeg12->frame_rate_ext.num = ext.num;
+ mpeg12->frame_rate_ext.den = ext.den;
}
}
}
@@ -142,8 +148,9 @@ static int find_frame_rate_index(MpegEncContext *s)
static av_cold int encode_init(AVCodecContext *avctx)
{
+ MPEG12EncContext *const mpeg12 = avctx->priv_data;
+ MpegEncContext *const s = &mpeg12->mpeg;
int ret;
- MpegEncContext *s = avctx->priv_data;
int max_size = avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 16383 : 4095;
if (avctx->width > max_size || avctx->height > max_size) {
@@ -199,7 +206,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
if ((ret = ff_mpv_encode_init(avctx)) < 0)
return ret;
- if (find_frame_rate_index(s) < 0) {
+ if (find_frame_rate_index(mpeg12) < 0) {
if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d fps\n",
avctx->time_base.den, avctx->time_base.num);
@@ -244,6 +251,7 @@ static void put_header(MpegEncContext *s, int header)
/* put sequence header if needed */
static void mpeg1_encode_sequence_header(MpegEncContext *s)
{
+ MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s;
unsigned int vbv_buffer_size, fps, v;
int i, constraint_parameter_flag;
uint64_t time_code;
@@ -339,8 +347,8 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 1, 1); // marker
put_bits(&s->pb, 8, vbv_buffer_size >> 10); // vbv buffer ext
put_bits(&s->pb, 1, s->low_delay);
- put_bits(&s->pb, 2, s->mpeg2_frame_rate_ext.num-1); // frame_rate_ext_n
- put_bits(&s->pb, 5, s->mpeg2_frame_rate_ext.den-1); // frame_rate_ext_d
+ put_bits(&s->pb, 2, mpeg12->frame_rate_ext.num-1); // frame_rate_ext_n
+ put_bits(&s->pb, 5, mpeg12->frame_rate_ext.den-1); // frame_rate_ext_d
side_data = av_frame_get_side_data(s->current_picture_ptr->f, AV_FRAME_DATA_PANSCAN);
if (side_data) {
@@ -1204,7 +1212,7 @@ const AVCodec ff_mpeg1video_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MPEG1VIDEO,
- .priv_data_size = sizeof(MpegEncContext),
+ .priv_data_size = sizeof(MPEG12EncContext),
.init = encode_init,
.encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end,
@@ -1221,7 +1229,7 @@ const AVCodec ff_mpeg2video_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MPEG2VIDEO,
- .priv_data_size = sizeof(MpegEncContext),
+ .priv_data_size = sizeof(MPEG12EncContext),
.init = encode_init,
.encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end,
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 900b8b1403..2611e7c667 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -203,7 +203,6 @@ typedef struct MpegEncContext {
int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol
int droppable;
int frame_rate_index;
- AVRational mpeg2_frame_rate_ext;
int last_lambda_for[5]; ///< last lambda for a specific pict type
int skipdct; ///< skip dct and code zero residual
--
2.32.0
_______________________________________________
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:[~2021-12-23 9:14 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 3:19 [FFmpeg-devel] [PATCH 01/14] avcodec/mjpegenc: Use custom close function directly Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 02/14] avcodec/mjpegenc: Avoid allocation of MJpegContext Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 03/14] avcodec/mpegvideo_enc: Move MJPEG init checks to mjpegenc.c Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 04/14] avcodec/mpegvideo_enc: Remove redundant checks for multithreading Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 05/14] avcodec/mjpegenc: Add wrapper for ff_mjpeg_encode_picture_header() Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 06/14] avcodec/mjpegenc_common: Move code for MJPEG/AMV to mjpegenc Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 07/14] avcodec/mjpegenc_common: Fix intendation Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 08/14] avcodec/mpegvideo: Move MJPEG/AMV-only fields to MJpegContext Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 09/14] avcodec/mjpegenc: Deprecate unused prediction type Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 10/14] avcodec/mjpegenc_common: Pass MJpegContext for writing picture header Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 11/14] avcodec/mjpegenc_common: Don't call function unnecessarily Andreas Rheinhardt
2021-12-22 3:25 ` [FFmpeg-devel] [PATCH 12/14] avcodec/mjpegenc_common: Use AVCodecContext.codec_id directly Andreas Rheinhardt
2021-12-22 3:30 ` [FFmpeg-devel] [PATCH 13/14] avcodec/mpegvideo: Remove unnecessary headers Andreas Rheinhardt
2021-12-22 3:30 ` [FFmpeg-devel] [PATCH 14/14] avcodec/mpegvideo_enc: Remove impossible branch Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 15/30] avcodec/speedhqenc: Inline constants Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 16/30] avcodec/mpegvideo_enc: Move updating mb_info to its only user Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 17/30] avcodec/mpeg12enc: Simplify check for A53 closed captions Andreas Rheinhardt
2021-12-23 9:13 ` Andreas Rheinhardt [this message]
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 19/30] avcodec/mpeg12enc: Move options-related fields to MPEG12EncContext Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 20/30] avcodec/mpegvideo_enc: Don't merge decoder-only fields Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 21/30] avcodec/mpeg12dec: Use %c to write single char Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 22/30] avcodec/mpegvideo: Don't duplicate identical code Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 23/30] avcodec/mpegvideo: Avoid needlessly calling function Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 24/30] avcodec/wmv2: Move ff_wmv2_add_mb() to the wmv2dec Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 25/30] avcodec/mpegvideo_motion: Don't duplicate identical code Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 26/30] avcodec/mpegvideo: Don't check for > 8 bit MPEG-1/2 Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 27/30] avcodec/mpegvideo: Partially check for being encoder at compile-time Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 28/30] avcodec/mpegvideo: Try to perform check for MPEG-1/2 " Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 29/30] avcodec/mpegvideo: Remove always-true branch Andreas Rheinhardt
2021-12-23 9:13 ` [FFmpeg-devel] [PATCH 30/30] avcodec/mpegvideo: Check for no_rounding at compile-time if possible Andreas Rheinhardt
2021-12-24 3:23 ` [FFmpeg-devel] [PATCH 31/36] avcodec/mpegvideo: Don't initialize error resilience context for encoder Andreas Rheinhardt
2021-12-24 3:23 ` [FFmpeg-devel] [PATCH 32/36] avcodec/mpegvideo: Remove always-false check Andreas Rheinhardt
2021-12-24 3:23 ` [FFmpeg-devel] [PATCH 33/36] avcodec/mpegvideo: Move decoding-only code into a new file Andreas Rheinhardt
2021-12-24 3:23 ` [FFmpeg-devel] [PATCH 34/36] configure: Add new mpegvideodec CONFIG_EXTRA Andreas Rheinhardt
2021-12-25 6:09 ` [FFmpeg-devel] [PATCH v2 34/35] " Andreas Rheinhardt
2021-12-25 6:09 ` [FFmpeg-devel] [PATCH v2 35/35] configure: Remove mpegvideo dependency on me_cmp Andreas Rheinhardt
2021-12-24 3:23 ` [FFmpeg-devel] [PATCH 35/36] avcodec/mpegvideo_enc: Improve inlining of chroma_format Andreas Rheinhardt
2021-12-24 3:23 ` [FFmpeg-devel] [PATCH 36/36] avcodec/mpegvideo_enc: Remove dead code at compile time Andreas Rheinhardt
2021-12-24 17:17 ` Michael Niedermayer
2021-12-24 18:30 ` Andreas Rheinhardt
2021-12-24 18:36 ` Michael Niedermayer
2021-12-25 6:06 ` [FFmpeg-devel] [PATCH 37/39] avcodec/mpeg12enc: Also inline chroma subsampling Andreas Rheinhardt
2021-12-25 6:06 ` [FFmpeg-devel] [PATCH 38/39] avcodec/mpeg12enc: Partially inline whether codec is MPEG-1 Andreas Rheinhardt
2021-12-25 6:06 ` [FFmpeg-devel] [PATCH 39/39] avcodec/mpeg12enc: Inline constants Andreas Rheinhardt
2021-12-31 10:03 ` [FFmpeg-devel] [PATCH 01/14] avcodec/mjpegenc: Use custom close function directly 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=AM7PR03MB66609362BB774E890DC51FB68F7E9@AM7PR03MB6660.eurprd03.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