* [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily
@ 2024-04-05 12:33 Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 02/15] avcodec/mpegutils: Move definitions to better places Andreas Rheinhardt
` (14 more replies)
0 siblings, 15 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:33 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
current_picture is not changed after frame_start() at all
and it therefore does not need to be updated (i.e. copied to the
slice thread contexts) a second time.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_enc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d1b1917824..0e3255c0fb 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -251,7 +251,6 @@ static void update_duplicate_context_after_me(MpegEncContext *dst,
{
#define COPY(a) dst->a= src->a
COPY(pict_type);
- COPY(current_picture);
COPY(f_code);
COPY(b_code);
COPY(qscale);
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 02/15] avcodec/mpegutils: Move definitions to better places
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 03/15] avcodec/mpeg12: Remove always-false check Andreas Rheinhardt
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
FRAME_SKIPPED -> h263dec.h
CANDIDATE_MB_TYPE_* -> mpegvideoenc.h
INPLACE_OFFSET -> mpegvideoenc.h
enum OutputFormat -> mpegvideo.h
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h263dec.c | 1 -
libavcodec/h263dec.h | 5 +++++
libavcodec/intelh263dec.c | 2 --
libavcodec/mpeg4videoenc.c | 1 -
libavcodec/mpegpicture.c | 2 +-
libavcodec/mpegutils.h | 34 ----------------------------------
libavcodec/mpegvideo.h | 12 +++++++++---
libavcodec/mpegvideoenc.h | 19 +++++++++++++++++++
libavcodec/nvdec_mpeg12.c | 1 +
libavcodec/ratecontrol.c | 1 -
libavcodec/rv10.c | 1 -
libavcodec/vc1dec.c | 1 +
12 files changed, 36 insertions(+), 44 deletions(-)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 910df7585f..48bd467f30 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -42,7 +42,6 @@
#include "mpeg4video.h"
#include "mpeg4videodec.h"
#include "mpeg4videodefs.h"
-#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpegvideodec.h"
#include "msmpeg4dec.h"
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index 89c5fcf58f..a01acc0834 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -23,6 +23,11 @@
#include "mpegvideo.h"
#include "vlc.h"
+/**
+ * Return value for header parsers if frame is not coded.
+ * */
+#define FRAME_SKIPPED 100
+
// The defines below define the number of bits that are read at once for
// reading vlc values. Changing these may improve speed and data cache needs
// be aware though that decreasing them may need the number of stages that is
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index f8eeb6b44e..5d34892ef7 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -19,12 +19,10 @@
*/
#include "codec_internal.h"
-#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpegvideodec.h"
#include "h263data.h"
#include "h263dec.h"
-#include "mpegvideodata.h"
/* don't understand why they choose a different header ! */
int ff_intel_h263_decode_picture_header(MpegEncContext *s)
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index f806ad8a74..71dda802e2 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -26,7 +26,6 @@
#include "libavutil/opt.h"
#include "libavutil/thread.h"
#include "codec_internal.h"
-#include "mpegutils.h"
#include "mpegvideo.h"
#include "h263.h"
#include "h263enc.h"
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 5bf85bb7fe..06b6daa01a 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -29,7 +29,7 @@
#include "avcodec.h"
#include "motion_est.h"
#include "mpegpicture.h"
-#include "mpegutils.h"
+#include "mpegvideo.h"
#include "refstruct.h"
#include "threadframe.h"
diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
index 386110bb8c..3da1e7ed38 100644
--- a/libavcodec/mpegutils.h
+++ b/libavcodec/mpegutils.h
@@ -27,11 +27,6 @@
#include "avcodec.h"
-/**
- * Return value for header parsers if frame is not coded.
- * */
-#define FRAME_SKIPPED 100
-
/* picture type */
#define PICT_TOP_FIELD 1
#define PICT_BOTTOM_FIELD 2
@@ -93,35 +88,6 @@
#define HAS_CBP(a) ((a) & MB_TYPE_CBP)
-/* MB types for encoding */
-#define CANDIDATE_MB_TYPE_INTRA (1 << 0)
-#define CANDIDATE_MB_TYPE_INTER (1 << 1)
-#define CANDIDATE_MB_TYPE_INTER4V (1 << 2)
-#define CANDIDATE_MB_TYPE_SKIPPED (1 << 3)
-
-#define CANDIDATE_MB_TYPE_DIRECT (1 << 4)
-#define CANDIDATE_MB_TYPE_FORWARD (1 << 5)
-#define CANDIDATE_MB_TYPE_BACKWARD (1 << 6)
-#define CANDIDATE_MB_TYPE_BIDIR (1 << 7)
-
-#define CANDIDATE_MB_TYPE_INTER_I (1 << 8)
-#define CANDIDATE_MB_TYPE_FORWARD_I (1 << 9)
-#define CANDIDATE_MB_TYPE_BACKWARD_I (1 << 10)
-#define CANDIDATE_MB_TYPE_BIDIR_I (1 << 11)
-
-#define CANDIDATE_MB_TYPE_DIRECT0 (1 << 12)
-
-#define INPLACE_OFFSET 16
-
-enum OutputFormat {
- FMT_MPEG1,
- FMT_H261,
- FMT_H263,
- FMT_MJPEG,
- FMT_SPEEDHQ,
-};
-
-
/**
* Draw a horizontal band if supported.
*
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index d7c2f57682..215df0fd5b 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -28,7 +28,6 @@
#ifndef AVCODEC_MPEGVIDEO_H
#define AVCODEC_MPEGVIDEO_H
-#include "avcodec.h"
#include "blockdsp.h"
#include "error_resilience.h"
#include "fdctdsp.h"
@@ -44,7 +43,6 @@
#include "pixblockdsp.h"
#include "put_bits.h"
#include "ratecontrol.h"
-#include "mpegutils.h"
#include "qpeldsp.h"
#include "videodsp.h"
@@ -61,6 +59,14 @@ typedef struct ScanTable {
uint8_t raster_end[64];
} ScanTable;
+enum OutputFormat {
+ FMT_MPEG1,
+ FMT_H261,
+ FMT_H263,
+ FMT_MJPEG,
+ FMT_SPEEDHQ,
+};
+
/**
* MpegEncContext.
*/
@@ -283,7 +289,7 @@ typedef struct MpegEncContext {
int mb_x, mb_y;
int mb_skip_run;
int mb_intra;
- uint16_t *mb_type; ///< Table for candidate MB types for encoding (defines in mpegutils.h)
+ uint16_t *mb_type; ///< Table for candidate MB types for encoding (defines in mpegvideoenc.h)
int block_index[6]; ///< index to current MB in block based arrays with edges
int block_wrap[6];
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index 1e29782660..c20ea500eb 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -34,6 +34,25 @@
#include "mpegvideo.h"
#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
+#define INPLACE_OFFSET 16
+
+/* MB types for encoding */
+#define CANDIDATE_MB_TYPE_INTRA (1 << 0)
+#define CANDIDATE_MB_TYPE_INTER (1 << 1)
+#define CANDIDATE_MB_TYPE_INTER4V (1 << 2)
+#define CANDIDATE_MB_TYPE_SKIPPED (1 << 3)
+
+#define CANDIDATE_MB_TYPE_DIRECT (1 << 4)
+#define CANDIDATE_MB_TYPE_FORWARD (1 << 5)
+#define CANDIDATE_MB_TYPE_BACKWARD (1 << 6)
+#define CANDIDATE_MB_TYPE_BIDIR (1 << 7)
+
+#define CANDIDATE_MB_TYPE_INTER_I (1 << 8)
+#define CANDIDATE_MB_TYPE_FORWARD_I (1 << 9)
+#define CANDIDATE_MB_TYPE_BACKWARD_I (1 << 10)
+#define CANDIDATE_MB_TYPE_BIDIR_I (1 << 11)
+
+#define CANDIDATE_MB_TYPE_DIRECT0 (1 << 12)
/* mpegvideo_enc common options */
#define FF_MPV_FLAG_SKIP_RD 0x0001
diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
index a4603c7ea7..139f287617 100644
--- a/libavcodec/nvdec_mpeg12.c
+++ b/libavcodec/nvdec_mpeg12.c
@@ -25,6 +25,7 @@
#include "avcodec.h"
#include "hwaccel_internal.h"
#include "internal.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "nvdec.h"
#include "decode.h"
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 1ff209c00b..9ee08ecb88 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -32,7 +32,6 @@
#include "avcodec.h"
#include "ratecontrol.h"
-#include "mpegutils.h"
#include "mpegvideoenc.h"
#include "libavutil/eval.h"
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index d32faa628b..df487b24a9 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -38,7 +38,6 @@
#include "h263data.h"
#include "h263dec.h"
#include "mpeg_er.h"
-#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpegvideodec.h"
#include "mpeg4video.h"
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 2c413e0bf1..3b5b016cf9 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -36,6 +36,7 @@
#include "hwaccel_internal.h"
#include "hwconfig.h"
#include "mpeg_er.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpegvideodec.h"
#include "msmpeg4_vc1_data.h"
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 03/15] avcodec/mpeg12: Remove always-false check
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 ` 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
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Forgotten in 7800cc6e82068c6dfb5af53817f03dfda794c568.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 8d88820c46..62d7fd1814 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -180,8 +180,6 @@ int ff_mpeg1_decode_block_intra(GetBitContext *gb,
component = index <= 3 ? 0 : index - 4 + 1;
diff = decode_dc(gb, component);
- if (diff >= 0xffff)
- return AVERROR_INVALIDDATA;
dc = last_dc[component];
dc += diff;
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 04/15] avcodec/mpegvideo_dec, mpeg12dec: Move MPEG1/2 code to mpeg12dec.c
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 05/15] avcodec/mpeg12dec: Remove redundant check Andreas Rheinhardt
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Up until now, ff_mpv_frame_start() offsets the data of the current
picture and doubles the linesizes of all pictures if the current
picture is field-based so that data and linesize allow to address
the current field only.
This is done based upon the current picture_structure value.
Only two mpegvideo-based decoders ever set this field: mpeg1/2
and VC-1; but the latter only does it after ff_mpv_frame_start()
(when using hardware-acceleration and in order to signal it to
the DXVA2 hwaccel) in which case no offset is applied in
ff_mpv_frame_start(). So only one decoder actually wants this
offset*; therefore move the code performing it to mpeg12dec.c.
*: VC-1 doubles linesize when using field_mode (not only the picture's
linesize, but also uvlinesize and linesize), yet it does not offset
anything. This is further proof that this should not be performed
generically.
Also move MPEG-1/2 specific setting of the top-field-first flag.
(The change here implies that the AVFrame in current_picture
may have different top-field-first flags than the AVFrame
from current_picture_ptr, but this doesn't matter as only
the latter's are used.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 15 +++++++++++++++
libavcodec/mpegvideo_dec.c | 19 -------------------
2 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 4ad1eb6572..fb8bba3287 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1299,6 +1299,21 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
return ret;
+ if (s->picture_structure != PICT_FRAME) {
+ s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
+ ((s->picture_structure == PICT_TOP_FIELD) == s->first_field);
+
+ for (int i = 0; i < 4; i++) {
+ if (s->picture_structure == PICT_BOTTOM_FIELD) {
+ s->current_picture.f->data[i] = FF_PTR_ADD(s->current_picture.f->data[i],
+ s->current_picture.f->linesize[i]);
+ }
+ s->current_picture.f->linesize[i] *= 2;
+ s->last_picture.f->linesize[i] *= 2;
+ s->next_picture.f->linesize[i] *= 2;
+ }
+ }
+
ff_mpeg_er_frame_start(s);
/* first check if we must repeat the frame */
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 88facfc39d..1ced9a52ed 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -348,14 +348,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
return -1;
s->current_picture_ptr = pic;
- // FIXME use only the vars from current_pic
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first;
- if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
- s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (s->picture_structure != PICT_FRAME)
- s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
- ((s->picture_structure == PICT_TOP_FIELD) == s->first_field);
- }
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (!s->progressive_frame &&
!s->progressive_sequence);
s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
@@ -454,18 +447,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
s->last_picture_ptr->f->buf[0]));
- if (s->picture_structure != PICT_FRAME) {
- for (int i = 0; i < 4; i++) {
- if (s->picture_structure == PICT_BOTTOM_FIELD) {
- s->current_picture.f->data[i] = FF_PTR_ADD(s->current_picture.f->data[i],
- s->current_picture.f->linesize[i]);
- }
- s->current_picture.f->linesize[i] *= 2;
- s->last_picture.f->linesize[i] *= 2;
- s->next_picture.f->linesize[i] *= 2;
- }
- }
-
/* set dequantizer, we can't do it during init as
* it might change for MPEG-4 and we can't do it in the header
* decode as init is not called for MPEG-4 there yet */
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 05/15] avcodec/mpeg12dec: Remove redundant check
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (2 preceding siblings ...)
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 ` 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
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This code only gets executed for the first field.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index fb8bba3287..83ff40d237 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1301,7 +1301,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
if (s->picture_structure != PICT_FRAME) {
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
- ((s->picture_structure == PICT_TOP_FIELD) == s->first_field);
+ (s->picture_structure == PICT_TOP_FIELD);
for (int i = 0; i < 4; i++) {
if (s->picture_structure == PICT_BOTTOM_FIELD) {
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 06/15] avcodec/mpeg12dec: Don't pretend MPEG-1/2 to support alpha
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (3 preceding siblings ...)
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 05/15] avcodec/mpeg12dec: Remove redundant check Andreas Rheinhardt
@ 2024-04-05 12:41 ` 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
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
(FF_PTR_ADD has to be kept although MPEG-1/2 only supports
YUV pixel formats because our decoder also supports decoding
to AV_PIX_FMT_GRAY8 depending upon CONFIG_GRAY.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 83ff40d237..337654c88d 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1303,7 +1303,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
(s->picture_structure == PICT_TOP_FIELD);
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < 3; i++) {
if (s->picture_structure == PICT_BOTTOM_FIELD) {
s->current_picture.f->data[i] = FF_PTR_ADD(s->current_picture.f->data[i],
s->current_picture.f->linesize[i]);
@@ -1368,8 +1368,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_finish_setup(avctx);
} else { // second field
- int i;
-
if (!s->current_picture_ptr) {
av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
return AVERROR_INVALIDDATA;
@@ -1383,7 +1381,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
}
}
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 3; i++) {
s->current_picture.f->data[i] = s->current_picture_ptr->f->data[i];
if (s->picture_structure == PICT_BOTTOM_FIELD)
s->current_picture.f->data[i] +=
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 07/15] avcodec/mpegvideo_dec: Don't emit non-keyframe warning for H.261
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (4 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 08/15] avcodec/mpeg12dec: Remove unnecessary FFCodec.close Andreas Rheinhardt
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
H.261 does not have keyframes (or indeed frame types) at all,
so this warning is not warranted.
Also remove an always-true check while at it.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_dec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 1ced9a52ed..1059aa9825 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -380,7 +380,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f->buf[0])
av_log(avctx, AV_LOG_DEBUG,
"allocating dummy last picture for B frame\n");
- else if (s->pict_type != AV_PICTURE_TYPE_I)
+ else if (s->codec_id != AV_CODEC_ID_H261)
av_log(avctx, AV_LOG_ERROR,
"warning: first frame is no keyframe\n");
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 08/15] avcodec/mpeg12dec: Remove unnecessary FFCodec.close
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (5 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 09/15] avcodec/mpegvideo_dec: Remove obsolete current_picture_ptr reuse code Andreas Rheinhardt
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The ipu decoder never calls ff_mpv_common_init() or allocates
anything else that would need to be freed.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 337654c88d..45627e702d 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2868,15 +2868,6 @@ static av_cold int ipu_decode_init(AVCodecContext *avctx)
return 0;
}
-static av_cold int ipu_decode_end(AVCodecContext *avctx)
-{
- IPUContext *s = avctx->priv_data;
-
- ff_mpv_common_end(&s->m);
-
- return 0;
-}
-
const FFCodec ff_ipu_decoder = {
.p.name = "ipu",
CODEC_LONG_NAME("IPU Video"),
@@ -2885,7 +2876,5 @@ const FFCodec ff_ipu_decoder = {
.priv_data_size = sizeof(IPUContext),
.init = ipu_decode_init,
FF_CODEC_DECODE_CB(ipu_decode_frame),
- .close = ipu_decode_end,
.p.capabilities = AV_CODEC_CAP_DR1,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 09/15] avcodec/mpegvideo_dec: Remove obsolete current_picture_ptr reuse code
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (6 preceding siblings ...)
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 08/15] avcodec/mpeg12dec: Remove unnecessary FFCodec.close Andreas Rheinhardt
@ 2024-04-05 12:41 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 10/15] avcodec/mpegvideo_dec: Remove redundant code to reset keyframe flag Andreas Rheinhardt
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Obsolete since at least 74d623914f02aa79447df43a742efd0929dded04.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_dec.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 1059aa9825..9f674488c0 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -325,18 +325,12 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
ff_mpeg_unref_picture(&s->last_picture);
ff_mpeg_unref_picture(&s->next_picture);
- if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) {
- // we already have an unused image
- // (maybe it was set before reading the header)
- pic = s->current_picture_ptr;
- } else {
idx = ff_find_unused_picture(s->avctx, s->picture, 0);
if (idx < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return idx;
}
pic = &s->picture[idx];
- }
pic->reference = 0;
if (!s->droppable) {
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 10/15] avcodec/mpegvideo_dec: Remove redundant code to reset keyframe flag
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (7 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 11/15] avcodec/mpegvideo_dec: Factor allocating dummy frame out Andreas Rheinhardt
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
These AVFrames are blank and therefore the flag is already unset.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_dec.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 9f674488c0..4fa89e4aef 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -387,7 +387,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->last_picture_ptr = &s->picture[idx];
s->last_picture_ptr->reference = 3;
- s->last_picture_ptr->f->flags &= ~AV_FRAME_FLAG_KEY;
s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
if (alloc_picture(s, s->last_picture_ptr) < 0) {
@@ -414,7 +413,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->next_picture_ptr = &s->picture[idx];
s->next_picture_ptr->reference = 3;
- s->next_picture_ptr->f->flags &= ~AV_FRAME_FLAG_KEY;
s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
if (alloc_picture(s, s->next_picture_ptr) < 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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 11/15] avcodec/mpegvideo_dec: Factor allocating dummy frame out
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (8 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 12/15] avcodec/mpegvideo_dec: Move getting Picture slot into alloc_picture() Andreas Rheinhardt
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_dec.c | 64 +++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 4fa89e4aef..b6ef4e5582 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -270,6 +270,32 @@ fail:
return ret;
}
+static int av_cold alloc_dummy_frame(MpegEncContext *s, Picture **picp)
+{
+ int idx = ff_find_unused_picture(s->avctx, s->picture, 0);
+ Picture *pic;
+ int ret;
+
+ if (idx < 0)
+ return idx;
+
+ pic = &s->picture[idx];
+
+ pic->reference = 3;
+ pic->f->pict_type = AV_PICTURE_TYPE_P;
+
+ ret = alloc_picture(s, pic);
+ if (ret < 0)
+ return ret;
+
+ ff_thread_report_progress(&pic->tf, INT_MAX, 0);
+ ff_thread_report_progress(&pic->tf, INT_MAX, 1);
+
+ *picp = pic;
+
+ return 0;
+}
+
static void color_frame(AVFrame *frame, int luma)
{
int h_chroma_shift, v_chroma_shift;
@@ -379,48 +405,22 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
"warning: first frame is no keyframe\n");
/* Allocate a dummy frame */
- idx = ff_find_unused_picture(s->avctx, s->picture, 0);
- if (idx < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return idx;
- }
- s->last_picture_ptr = &s->picture[idx];
-
- s->last_picture_ptr->reference = 3;
- s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
-
- if (alloc_picture(s, s->last_picture_ptr) < 0) {
- s->last_picture_ptr = NULL;
- return -1;
- }
+ ret = alloc_dummy_frame(s, &s->last_picture_ptr);
+ if (ret < 0)
+ return ret;
if (!avctx->hwaccel) {
int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80;
color_frame(s->last_picture_ptr->f, luma_val);
}
- ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);
- ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);
}
if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) &&
s->pict_type == AV_PICTURE_TYPE_B) {
/* Allocate a dummy frame */
- idx = ff_find_unused_picture(s->avctx, s->picture, 0);
- if (idx < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return idx;
- }
- s->next_picture_ptr = &s->picture[idx];
-
- s->next_picture_ptr->reference = 3;
- s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
-
- if (alloc_picture(s, s->next_picture_ptr) < 0) {
- s->next_picture_ptr = NULL;
- return -1;
- }
- ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 0);
- ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1);
+ ret = alloc_dummy_frame(s, &s->next_picture_ptr);
+ if (ret < 0)
+ return ret;
}
if (s->last_picture_ptr) {
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 12/15] avcodec/mpegvideo_dec: Move getting Picture slot into alloc_picture()
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (9 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 13/15] avcodec/mpegvideo: Remove pointless check Andreas Rheinhardt
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_dec.c | 63 ++++++++++++++++----------------------
1 file changed, 26 insertions(+), 37 deletions(-)
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index b6ef4e5582..d337a6565b 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -235,12 +235,20 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s)
return err;
}
-static int alloc_picture(MpegEncContext *s, Picture *pic)
+static int alloc_picture(MpegEncContext *s, Picture **picp, int reference)
{
AVCodecContext *avctx = s->avctx;
+ int idx = ff_find_unused_picture(s->avctx, s->picture, 0);
+ Picture *pic;
int ret;
+ if (idx < 0)
+ return idx;
+
+ pic = &s->picture[idx];
+
pic->tf.f = pic->f;
+ pic->reference = reference;
/* WM Image / Screen codecs allocate internal buffers with different
* dimensions / colorspaces; ignore user-defined callbacks for these. */
@@ -248,7 +256,7 @@ static int alloc_picture(MpegEncContext *s, Picture *pic)
avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
avctx->codec_id != AV_CODEC_ID_MSS2) {
ret = ff_thread_get_ext_buffer(avctx, &pic->tf,
- pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
+ reference ? AV_GET_BUFFER_FLAG_REF : 0);
} else {
pic->f->width = avctx->width;
pic->f->height = avctx->height;
@@ -262,9 +270,14 @@ static int alloc_picture(MpegEncContext *s, Picture *pic)
if (ret < 0)
goto fail;
- return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 0, s->out_format,
- s->mb_stride, s->mb_width, s->mb_height, s->b8_stride,
- &s->linesize, &s->uvlinesize);
+ ret = ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 0, s->out_format,
+ s->mb_stride, s->mb_width, s->mb_height, s->b8_stride,
+ &s->linesize, &s->uvlinesize);
+ if (ret < 0)
+ goto fail;
+ *picp = pic;
+
+ return 0;
fail:
ff_mpeg_unref_picture(pic);
return ret;
@@ -272,27 +285,16 @@ fail:
static int av_cold alloc_dummy_frame(MpegEncContext *s, Picture **picp)
{
- int idx = ff_find_unused_picture(s->avctx, s->picture, 0);
Picture *pic;
- int ret;
-
- if (idx < 0)
- return idx;
-
- pic = &s->picture[idx];
-
- pic->reference = 3;
- pic->f->pict_type = AV_PICTURE_TYPE_P;
-
- ret = alloc_picture(s, pic);
+ int ret = alloc_picture(s, picp, 1);
if (ret < 0)
return ret;
+ pic = *picp;
+
ff_thread_report_progress(&pic->tf, INT_MAX, 0);
ff_thread_report_progress(&pic->tf, INT_MAX, 1);
- *picp = pic;
-
return 0;
}
@@ -320,8 +322,7 @@ static void color_frame(AVFrame *frame, int luma)
*/
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
- Picture *pic;
- int idx, ret;
+ int ret;
s->mb_skipped = 0;
@@ -351,23 +352,11 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
ff_mpeg_unref_picture(&s->last_picture);
ff_mpeg_unref_picture(&s->next_picture);
- idx = ff_find_unused_picture(s->avctx, s->picture, 0);
- if (idx < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return idx;
- }
- pic = &s->picture[idx];
-
- pic->reference = 0;
- if (!s->droppable) {
- if (s->pict_type != AV_PICTURE_TYPE_B)
- pic->reference = 3;
- }
-
- if (alloc_picture(s, pic) < 0)
- return -1;
+ ret = alloc_picture(s, &s->current_picture_ptr,
+ s->pict_type != AV_PICTURE_TYPE_B && !s->droppable);
+ if (ret < 0)
+ return ret;
- s->current_picture_ptr = pic;
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first;
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (!s->progressive_frame &&
!s->progressive_sequence);
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 13/15] avcodec/mpegvideo: Remove pointless check
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (10 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 14/15] avcodec/mpeg12dec: Remove redundant mpeg_enc_ctx_allocated Andreas Rheinhardt
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Possible since 315c956cbd14f021e49dac7fc0b906fad1672aad.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 8a733afdb8..7af823b8bd 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -789,9 +789,6 @@ void ff_mpv_common_end(MpegEncContext *s)
av_freep(&s->bitstream_buffer);
s->allocated_bitstream_buffer_size = 0;
- if (!s->avctx)
- return;
-
if (s->picture) {
for (int i = 0; i < MAX_PICTURE_COUNT; i++)
ff_mpv_picture_free(&s->picture[i]);
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 14/15] avcodec/mpeg12dec: Remove redundant mpeg_enc_ctx_allocated
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (11 preceding siblings ...)
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 13/15] avcodec/mpegvideo: Remove pointless check Andreas Rheinhardt
@ 2024-04-05 12:41 ` Andreas Rheinhardt
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
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 15/15] avcodec/mpegvideo_dec, h264_slice: Return proper error codes
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (12 preceding siblings ...)
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 14/15] avcodec/mpeg12dec: Remove redundant mpeg_enc_ctx_allocated Andreas Rheinhardt
@ 2024-04-05 12:41 ` Andreas Rheinhardt
2024-04-07 22:34 ` [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-05 12:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264_slice.c | 2 +-
libavcodec/mpegvideo_dec.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 4b01c54147..a346839902 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -483,7 +483,7 @@ static int h264_frame_start(H264Context *h)
if (!ff_thread_can_start_frame(h->avctx)) {
av_log(h->avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n");
- return -1;
+ return AVERROR_BUG;
}
release_unused_pictures(h, 1);
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index d337a6565b..4353f1fd68 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -328,7 +328,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
if (!ff_thread_can_start_frame(avctx)) {
av_log(avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n");
- return -1;
+ return AVERROR_BUG;
}
/* mark & release old frames */
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
` (13 preceding siblings ...)
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 ` Andreas Rheinhardt
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2024-04-07 22:34 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> current_picture is not changed after frame_start() at all
> and it therefore does not need to be updated (i.e. copied to the
> slice thread contexts) a second time.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/mpegvideo_enc.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index d1b1917824..0e3255c0fb 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -251,7 +251,6 @@ static void update_duplicate_context_after_me(MpegEncContext *dst,
> {
> #define COPY(a) dst->a= src->a
> COPY(pict_type);
> - COPY(current_picture);
> COPY(f_code);
> COPY(b_code);
> COPY(qscale);
Will apply this patchset tonight unless there are objections.
- Andreas
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-04-07 22:34 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [FFmpeg-devel] [PATCH 14/15] avcodec/mpeg12dec: Remove redundant mpeg_enc_ctx_allocated Andreas Rheinhardt
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
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