Patches attached. It's stuff that can be seen as leftover from my last mpegvideo patches+some other trivialities.
- Andreas
From e3e416db815c7512a6f5ecc106cb2259774f7d6b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Fri, 16 May 2025 19:46:40 +0200 Subject: [PATCH 1/5] avcodec/mpegvideo_dec: Move ff_mpv_report_decode_progress() to h263dec.c It is its only user. Also make it static and call it before ff_mpeg_draw_horiz_band(). Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- libavcodec/h263dec.c | 10 ++++++++-- libavcodec/mpegvideo_dec.c | 7 ------- libavcodec/mpegvideodec.h | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 2f8bd73665..150e3e3b42 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -174,6 +174,12 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) return 0; } +static void mpv_report_decode_progress(MpegEncContext *s) +{ + if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) + ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y); +} + static int decode_slice(MpegEncContext *s) { const int part_mask = s->partitioned_frame @@ -278,8 +284,8 @@ static int decode_slice(MpegEncContext *s) if (++s->mb_x >= s->mb_width) { s->mb_x = 0; + mpv_report_decode_progress(s); ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size); - ff_mpv_report_decode_progress(s); s->mb_y++; } return 0; @@ -305,8 +311,8 @@ static int decode_slice(MpegEncContext *s) ff_h263_loop_filter(s); } + mpv_report_decode_progress(s); ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size); - ff_mpv_report_decode_progress(s); s->mb_x = 0; } diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index b8b84ffd8d..4aefe6e047 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -424,13 +424,6 @@ av_cold void ff_mpeg_flush(AVCodecContext *avctx) s->pp_time = 0; } -void ff_mpv_report_decode_progress(MpegEncContext *s) -{ - if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) - ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y); -} - - static inline int hpel_motion_lowres(MpegEncContext *s, uint8_t *dest, const uint8_t *src, int field_based, int field_select, diff --git a/libavcodec/mpegvideodec.h b/libavcodec/mpegvideodec.h index bc4bc90590..8bc70b02c0 100644 --- a/libavcodec/mpegvideodec.h +++ b/libavcodec/mpegvideodec.h @@ -57,7 +57,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); */ int ff_mpv_alloc_dummy_frames(MpegEncContext *s); void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]); -void ff_mpv_report_decode_progress(MpegEncContext *s); void ff_mpv_frame_end(MpegEncContext *s); int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, -- 2.45.2
From 1b5208930d943741757a7825a595fe21543fdd99 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Sat, 17 May 2025 00:04:58 +0200 Subject: [PATCH 2/5] avcodec/mpeg12dec: Set save_chroma_format also for VCR2 Otherwise the MpegEncContext would be unnecessarily reinitialized once (this does not affect the output for an intra-only variant like VCR2) in mpeg_decode_postinit(). Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- libavcodec/mpeg12dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index fc41c548e2..e70261fd14 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1866,6 +1866,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx) s1->save_width = s->width; s1->save_height = s->height; s1->save_progressive_seq = s->progressive_sequence; + s1->save_chroma_format = s->chroma_format; return 0; } -- 2.45.2
From 61d4cd3bd4f8938d7d7ff2691e20e11ddf4dbb8c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Sat, 17 May 2025 00:56:02 +0200 Subject: [PATCH 3/5] avcodec/mpeg12dec: Remove redundant save_width/height These have been added in 29644cb504eee88bd40f95abaa392047946c6066 in 2007 at a time when the MPEG-1/2 parser just set the AVCodecContext's dimensions when encountering a sequence header, so that the checks for the coded dimensions didn't trigger. Yet this is no more and so we can simply remove these redundant checks. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- libavcodec/mpeg12dec.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index e70261fd14..078f0fa999 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -80,7 +80,7 @@ typedef struct Mpeg1Context { int has_afd; int slice_count; unsigned aspect_ratio_info; - int save_width, save_height, save_progressive_seq, save_chroma_format; + int save_progressive_seq, save_chroma_format; AVRational frame_rate_ext; /* MPEG-2 specific framerate modificator */ unsigned frame_rate_index; int sync; /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */ @@ -915,8 +915,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) if (!s->context_initialized || avctx->coded_width != s->width || avctx->coded_height != s->height || - s1->save_width != s->width || - s1->save_height != s->height || s1->save_chroma_format != s->chroma_format || (s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) || 0) { @@ -934,8 +932,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) (s1->bit_rate != 0x3FFFF*400 || s1->vbv_delay != 0xFFFF)) { avctx->bit_rate = s1->bit_rate; } - s1->save_width = s->width; - s1->save_height = s->height; s1->save_progressive_seq = s->progressive_sequence; s1->save_chroma_format = s->chroma_format; @@ -1863,8 +1859,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx) } else { s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; } - s1->save_width = s->width; - s1->save_height = s->height; s1->save_progressive_seq = s->progressive_sequence; s1->save_chroma_format = s->chroma_format; return 0; -- 2.45.2
From 6886688c7e1d719bf7211a4c84e2696ca815fa65 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Sat, 17 May 2025 02:35:43 +0200 Subject: [PATCH 4/5] avcodec/mpeg12dec: Remove nonsense comment Everything in mpeg12dec.c is about decoding. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- libavcodec/mpeg12dec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 078f0fa999..9cf1bb9b28 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -381,9 +381,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, return 0; } -/******************************************/ -/* decoding */ - static inline int get_dmv(MpegEncContext *s) { if (get_bits1(&s->gb)) -- 2.45.2
From f6da02da9cca2a5ac1b2f2bdf5292765901620bf Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Sat, 17 May 2025 02:36:37 +0200 Subject: [PATCH 5/5] avcodec/mpeg12enc: Combine put_bits() This is a 16bit field in the spec, so using a single put_bits() to write it is more natural. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- libavcodec/mpeg12enc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 9d0a8e4170..231740bcc8 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -454,8 +454,7 @@ static int mpeg1_encode_picture_header(MPVMainEncContext *const m) put_bits(&s->pb, 1, 1); // reserved_bit put_bits(&s->pb, 7, fpa_type); // S3D_video_format_type - put_bits(&s->pb, 8, 0x04); // reserved_data[0] - put_bits(&s->pb, 8, 0xFF); // reserved_data[1] + put_bits(&s->pb, 16, 0x04FF); // reserved_data } } -- 2.45.2
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".