From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 14/15] avcodec/mpeg12dec: Remove redundant mpeg_enc_ctx_allocated
Date: Fri, 5 Apr 2024 14:41:37 +0200
Message-ID: <GV1P250MB0737EC1DEF164827CBDE34D08F032@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737AB31294010EE180AF5828F032@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
Use context_initialized from the underlying MpegEncContext
instead. Also don't check before ff_mpv_common_end()
in mpeg_decode_end().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 45627e702d..21a214ef5b 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -71,7 +71,6 @@ enum Mpeg2ClosedCaptionsFormat {
typedef struct Mpeg1Context {
MpegEncContext mpeg_enc_ctx;
- int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
int repeat_field; /* true if we must repeat the field */
AVPanScan pan_scan; /* some temporary storage for the panscan */
AVStereo3D stereo3d;
@@ -803,7 +802,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
ff_mpeg12_init_vlcs();
s2->chroma_format = 1;
- s->mpeg_enc_ctx_allocated = 0;
s->repeat_field = 0;
avctx->color_range = AVCOL_RANGE_MPEG;
return 0;
@@ -817,16 +815,14 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx,
MpegEncContext *s = &ctx->mpeg_enc_ctx, *s1 = &ctx_from->mpeg_enc_ctx;
int err;
- if (avctx == avctx_from ||
- !ctx_from->mpeg_enc_ctx_allocated ||
- !s1->context_initialized)
+ if (avctx == avctx_from || !s1->context_initialized)
return 0;
err = ff_mpeg_update_thread_context(avctx, avctx_from);
if (err)
return err;
- if (!ctx->mpeg_enc_ctx_allocated)
+ if (!s->context_initialized)
memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext));
return 0;
@@ -961,7 +957,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
}
- if ((s1->mpeg_enc_ctx_allocated == 0) ||
+ if (!s->context_initialized ||
avctx->coded_width != s->width ||
avctx->coded_height != s->height ||
s1->save_width != s->width ||
@@ -969,10 +965,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
av_cmp_q(s1->save_aspect, s->avctx->sample_aspect_ratio) ||
(s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) ||
0) {
- if (s1->mpeg_enc_ctx_allocated) {
+ if (s->context_initialized)
ff_mpv_common_end(s);
- s1->mpeg_enc_ctx_allocated = 0;
- }
ret = ff_set_dimensions(avctx, s->width, s->height);
if (ret < 0)
@@ -1029,8 +1023,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
if ((ret = ff_mpv_common_init(s)) < 0)
return ret;
-
- s1->mpeg_enc_ctx_allocated = 1;
}
return 0;
}
@@ -1233,7 +1225,7 @@ static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
s->mpeg_f_code[0][1] += !s->mpeg_f_code[0][1];
s->mpeg_f_code[1][0] += !s->mpeg_f_code[1][0];
s->mpeg_f_code[1][1] += !s->mpeg_f_code[1][1];
- if (!s->pict_type && s1->mpeg_enc_ctx_allocated) {
+ if (!s->pict_type && s->context_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Missing picture start code\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
@@ -1740,7 +1732,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
- if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr)
+ if (!s->context_initialized || !s->current_picture_ptr)
return 0;
if (s->avctx->hwaccel) {
@@ -1881,10 +1873,9 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
/* start new MPEG-1 context decoding */
s->out_format = FMT_MPEG1;
- if (s1->mpeg_enc_ctx_allocated) {
+ if (s->context_initialized)
ff_mpv_common_end(s);
- s1->mpeg_enc_ctx_allocated = 0;
- }
+
s->width = avctx->coded_width;
s->height = avctx->coded_height;
avctx->has_b_frames = 0; // true?
@@ -1894,7 +1885,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
if ((ret = ff_mpv_common_init(s)) < 0)
return ret;
- s1->mpeg_enc_ctx_allocated = 1;
for (i = 0; i < 64; i++) {
int j = s->idsp.idct_permutation[i];
@@ -2448,7 +2438,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
break;
}
- if (!s->mpeg_enc_ctx_allocated)
+ if (!s2->context_initialized)
break;
if (s2->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
@@ -2546,9 +2536,8 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
return buf_size;
}
- if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
- || s2->codec_tag == AV_RL32("BW10")
- ))
+ if (!s2->context_initialized &&
+ (s2->codec_tag == AV_RL32("VCR2") || s2->codec_tag == AV_RL32("BW10")))
vcr2_init_sequence(avctx);
s->slice_count = 0;
@@ -2606,8 +2595,7 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx)
{
Mpeg1Context *s = avctx->priv_data;
- if (s->mpeg_enc_ctx_allocated)
- ff_mpv_common_end(&s->mpeg_enc_ctx);
+ ff_mpv_common_end(&s->mpeg_enc_ctx);
av_buffer_unref(&s->a53_buf_ref);
return 0;
}
--
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-04-05 12:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 02/15] avcodec/mpegutils: Move definitions to better places Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 03/15] avcodec/mpeg12: Remove always-false check Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 04/15] avcodec/mpegvideo_dec, mpeg12dec: Move MPEG1/2 code to mpeg12dec.c Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 05/15] avcodec/mpeg12dec: Remove redundant check Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 06/15] avcodec/mpeg12dec: Don't pretend MPEG-1/2 to support alpha Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 07/15] avcodec/mpegvideo_dec: Don't emit non-keyframe warning for H.261 Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 08/15] avcodec/mpeg12dec: Remove unnecessary FFCodec.close Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 09/15] avcodec/mpegvideo_dec: Remove obsolete current_picture_ptr reuse code Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 10/15] avcodec/mpegvideo_dec: Remove redundant code to reset keyframe flag Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 11/15] avcodec/mpegvideo_dec: Factor allocating dummy frame out Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 12/15] avcodec/mpegvideo_dec: Move getting Picture slot into alloc_picture() Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 13/15] avcodec/mpegvideo: Remove pointless check Andreas Rheinhardt
2024-04-05 12:41 ` Andreas Rheinhardt [this message]
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 15/15] avcodec/mpegvideo_dec, h264_slice: Return proper error codes Andreas Rheinhardt
2024-04-07 22:34 ` [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily 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=GV1P250MB0737EC1DEF164827CBDE34D08F032@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