* [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function
@ 2022-01-25 17:36 Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 02/21] avcodec/h263: Move decoding-only stuff to a new header h263dec.h Andreas Rheinhardt
` (14 more replies)
0 siblings, 15 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h263.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 982e545491..31836ebb95 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -68,7 +68,6 @@ void ff_h263_encode_init(MpegEncContext *s);
void ff_h263_decode_init_vlc(void);
void ff_h263_init_rl_inter(void);
int ff_h263_decode_picture_header(MpegEncContext *s);
-int ff_h263_decode_gob_header(MpegEncContext *s);
void ff_h263_update_motion_val(MpegEncContext * s);
void ff_h263_loop_filter(MpegEncContext * s);
int ff_h263_decode_mba(MpegEncContext *s);
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 02/21] avcodec/h263: Move decoding-only stuff to a new header h263dec.h
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (13 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Soon to be followed by a H263DecContext.
libavcodec/flvdec.c | 2 +-
libavcodec/h263.h | 40 -----------------------
libavcodec/h263dec.c | 1 +
libavcodec/h263dec.h | 65 ++++++++++++++++++++++++++++++++++++++
libavcodec/intelh263dec.c | 3 +-
libavcodec/ituh263dec.c | 1 +
libavcodec/mpeg4videodec.c | 1 +
libavcodec/msmpeg4dec.c | 1 +
libavcodec/rv10.c | 1 +
libavcodec/wmv2dec.c | 2 +-
10 files changed, 74 insertions(+), 43 deletions(-)
create mode 100644 libavcodec/h263dec.h
diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 2ddcf021fd..2bd86b5b47 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -21,7 +21,7 @@
#include "libavutil/imgutils.h"
#include "flv.h"
-#include "h263.h"
+#include "h263dec.h"
#include "mpegvideo.h"
#include "mpegvideodata.h"
diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 31836ebb95..6dd5d2295a 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -22,41 +22,14 @@
#include <stdint.h>
#include "libavutil/rational.h"
-#include "get_bits.h"
#include "mpegvideo.h"
#include "h263data.h"
-#include "rl.h"
#define FF_ASPECT_EXTENDED 15
-#define INT_BIT (CHAR_BIT * sizeof(int))
-
-// 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
-// passed to get_vlc* to be increased.
-#define H263_MV_VLC_BITS 9
-#define INTRA_MCBPC_VLC_BITS 6
-#define INTER_MCBPC_VLC_BITS 7
-#define CBPY_VLC_BITS 6
-#define TEX_VLC_BITS 9
#define H263_GOB_HEIGHT(h) ((h) <= 400 ? 1 : (h) <= 800 ? 2 : 4)
-extern VLC ff_h263_intra_MCBPC_vlc;
-extern VLC ff_h263_inter_MCBPC_vlc;
-extern VLC ff_h263_cbpy_vlc;
-extern VLC ff_h263_mv_vlc;
-
-extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[];
-
-
-int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code);
av_const int ff_h263_aspect_to_info(AVRational aspect);
-int ff_h263_decode_init(AVCodecContext *avctx);
-int ff_h263_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt);
-int ff_h263_decode_end(AVCodecContext *avctx);
void ff_h263_encode_mb(MpegEncContext *s,
int16_t block[6][64],
int motion_x, int motion_y);
@@ -65,27 +38,14 @@ void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line);
int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,
int *px, int *py);
void ff_h263_encode_init(MpegEncContext *s);
-void ff_h263_decode_init_vlc(void);
void ff_h263_init_rl_inter(void);
-int ff_h263_decode_picture_header(MpegEncContext *s);
void ff_h263_update_motion_val(MpegEncContext * s);
void ff_h263_loop_filter(MpegEncContext * s);
-int ff_h263_decode_mba(MpegEncContext *s);
void ff_h263_encode_mba(MpegEncContext *s);
void ff_init_qscale_tab(MpegEncContext *s);
-/**
- * Print picture info if FF_DEBUG_PICT_INFO is set.
- */
-void ff_h263_show_pict_info(MpegEncContext *s);
-
-int ff_intel_h263_decode_picture_header(MpegEncContext *s);
-int ff_h263_decode_mb(MpegEncContext *s,
- int16_t block[6][64]);
-
void ff_clean_h263_qscales(MpegEncContext *s);
-int ff_h263_resync(MpegEncContext *s);
void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code);
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index ac48acf47a..3466027286 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -33,6 +33,7 @@
#include "error_resilience.h"
#include "flv.h"
#include "h263.h"
+#include "h263dec.h"
#if FF_API_FLAG_TRUNCATED
#include "h263_parser.h"
#endif
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
new file mode 100644
index 0000000000..8d5f9a7add
--- /dev/null
+++ b/libavcodec/h263dec.h
@@ -0,0 +1,65 @@
+/*
+ * H.263 decoder internal header
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef AVCODEC_H263DEC_H
+#define AVCODEC_H263DEC_H
+
+#include "mpegvideo.h"
+#include "vlc.h"
+
+// 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
+// passed to get_vlc* to be increased.
+#define H263_MV_VLC_BITS 9
+#define INTRA_MCBPC_VLC_BITS 6
+#define INTER_MCBPC_VLC_BITS 7
+#define CBPY_VLC_BITS 6
+#define TEX_VLC_BITS 9
+
+extern VLC ff_h263_intra_MCBPC_vlc;
+extern VLC ff_h263_inter_MCBPC_vlc;
+extern VLC ff_h263_cbpy_vlc;
+extern VLC ff_h263_mv_vlc;
+
+extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[];
+
+int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code);
+int ff_h263_decode_init(AVCodecContext *avctx);
+int ff_h263_decode_frame(AVCodecContext *avctx,
+ void *data, int *got_frame,
+ AVPacket *avpkt);
+int ff_h263_decode_end(AVCodecContext *avctx);
+void ff_h263_decode_init_vlc(void);
+int ff_h263_decode_picture_header(MpegEncContext *s);
+int ff_h263_decode_gob_header(MpegEncContext *s);
+int ff_h263_decode_mba(MpegEncContext *s);
+
+/**
+ * Print picture info if FF_DEBUG_PICT_INFO is set.
+ */
+void ff_h263_show_pict_info(MpegEncContext *s);
+
+int ff_intel_h263_decode_picture_header(MpegEncContext *s);
+int ff_h263_decode_mb(MpegEncContext *s,
+ int16_t block[6][64]);
+
+int ff_h263_resync(MpegEncContext *s);
+
+#endif
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index 58c1b63c0a..9dde247298 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -20,7 +20,8 @@
#include "mpegutils.h"
#include "mpegvideo.h"
-#include "h263.h"
+#include "h263data.h"
+#include "h263dec.h"
#include "mpegvideodata.h"
/* don't understand why they choose a different header ! */
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 5329e62a5e..0a032ea54c 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -39,6 +39,7 @@
#include "mpegvideo.h"
#include "h263.h"
#include "h263data.h"
+#include "h263dec.h"
#include "internal.h"
#include "mathops.h"
#include "mpegutils.h"
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 737689b35b..162048b604 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -36,6 +36,7 @@
#include "mpeg4video.h"
#include "mpeg4videodata.h"
#include "h263.h"
+#include "h263dec.h"
#include "profiles.h"
#include "thread.h"
#include "xvididct.h"
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index f302509589..3d2dcb9429 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -29,6 +29,7 @@
#include "msmpeg4.h"
#include "libavutil/imgutils.h"
#include "h263.h"
+#include "h263dec.h"
#include "mpeg4video.h"
#include "msmpeg4data.h"
#include "vc1data.h"
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 0dc2c87335..4dfaa3460d 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -34,6 +34,7 @@
#include "error_resilience.h"
#include "h263.h"
#include "h263data.h"
+#include "h263dec.h"
#include "internal.h"
#include "mpeg_er.h"
#include "mpegutils.h"
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index f7745c5a83..7518088b6a 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -19,7 +19,7 @@
*/
#include "avcodec.h"
-#include "h263.h"
+#include "h263dec.h"
#include "internal.h"
#include "intrax8.h"
#include "mathops.h"
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 03/21] avcodec/mpeg4videoenc: Use stack variable for vo_type
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 04/21] avcodec/mpeg4videodec: Keep vo_type in sync between threads Andreas Rheinhardt
` (17 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4videoenc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 8871d83281..b3e697daf7 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -961,14 +961,14 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
int vo_number,
int vol_number)
{
- int vo_ver_id;
+ int vo_ver_id, vo_type;
if (s->max_b_frames || s->quarter_sample) {
vo_ver_id = 5;
- s->vo_type = ADV_SIMPLE_VO_TYPE;
+ vo_type = ADV_SIMPLE_VO_TYPE;
} else {
vo_ver_id = 1;
- s->vo_type = SIMPLE_VO_TYPE;
+ vo_type = SIMPLE_VO_TYPE;
}
put_bits(&s->pb, 16, 0);
@@ -977,7 +977,7 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
put_bits(&s->pb, 16, 0x120 + vol_number); /* video obj layer */
put_bits(&s->pb, 1, 0); /* random access vol */
- put_bits(&s->pb, 8, s->vo_type); /* video obj type indication */
+ put_bits(&s->pb, 8, vo_type); /* video obj type indication */
if (s->workaround_bugs & FF_BUG_MS) {
put_bits(&s->pb, 1, 0); /* is obj layer id= no */
} else {
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 04/21] avcodec/mpeg4videodec: Keep vo_type in sync between threads
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 03/21] avcodec/mpeg4videoenc: Use stack variable for vo_type Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 05/21] avcodec/mpeg4?video: Move vo_type to Mpeg4DecContext Andreas Rheinhardt
` (16 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Otherwise one can get outdated values when setting FF_DEBUG_PICT_INFO.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4videodec.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 162048b604..33a0c97ba8 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3471,6 +3471,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
s->divx_build = s1->divx_build;
s->xvid_build = s1->xvid_build;
s->lavc_build = s1->lavc_build;
+ s->m.vo_type = s1->m.vo_type;
s->showed_packed_warning = s1->showed_packed_warning;
s->vol_control_parameters = s1->vol_control_parameters;
s->cplx_estimation_trash_i = s1->cplx_estimation_trash_i;
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 05/21] avcodec/mpeg4?video: Move vo_type to Mpeg4DecContext
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 03/21] avcodec/mpeg4videoenc: Use stack variable for vo_type Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 04/21] avcodec/mpeg4videodec: Keep vo_type in sync between threads Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 06/21] avcodec/ituh263enc: Use stack variable for custom_pcf Andreas Rheinhardt
` (15 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4video.h | 2 ++
libavcodec/mpeg4videodec.c | 16 ++++++++--------
libavcodec/mpegvideo.h | 1 -
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 87d9c9996e..fd6b6f2863 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -105,6 +105,8 @@ typedef struct Mpeg4DecContext {
int xvid_build;
int lavc_build;
+ int vo_type;
+
/// flag for having shown the warning about invalid Divx B-frames
int showed_packed_warning;
/** does the stream contain the low_delay flag,
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 33a0c97ba8..00bf7b6c4a 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2305,15 +2305,15 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
/* vol header */
skip_bits(gb, 1); /* random access */
- s->vo_type = get_bits(gb, 8);
+ ctx->vo_type = get_bits(gb, 8);
/* If we are in studio profile (per vo_type), check if its all consistent
* and if so continue pass control to decode_studio_vol_header().
* elIf something is inconsistent, error out
* else continue with (non studio) vol header decpoding.
*/
- if (s->vo_type == CORE_STUDIO_VO_TYPE ||
- s->vo_type == SIMPLE_STUDIO_VO_TYPE) {
+ if (ctx->vo_type == CORE_STUDIO_VO_TYPE ||
+ ctx->vo_type == SIMPLE_STUDIO_VO_TYPE) {
if (s->avctx->profile != FF_PROFILE_UNKNOWN && s->avctx->profile != FF_PROFILE_MPEG4_SIMPLE_STUDIO)
return AVERROR_INVALIDDATA;
s->studio_profile = 1;
@@ -2360,7 +2360,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
/* is setting low delay flag only once the smartest thing to do?
* low delay detection will not be overridden. */
if (s->picture_number == 0) {
- switch(s->vo_type) {
+ switch (ctx->vo_type) {
case SIMPLE_VO_TYPE:
case ADV_SIMPLE_VO_TYPE:
s->low_delay = 1;
@@ -2745,7 +2745,7 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
}
if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1)
- if (s->codec_tag == AV_RL32("DIVX") && s->vo_type == 0 &&
+ if (s->codec_tag == AV_RL32("DIVX") && ctx->vo_type == 0 &&
ctx->vol_control_parameters == 0)
ctx->divx_version = 400; // divx 4
@@ -3084,7 +3084,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
s->top_field_first, s->quarter_sample ? 'q' : 'h',
s->data_partitioning, ctx->resync_marker,
ctx->num_sprite_warping_points, s->sprite_warping_accuracy,
- 1 - s->no_rounding, s->vo_type,
+ 1 - s->no_rounding, ctx->vo_type,
ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold,
ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p,
ctx->cplx_estimation_trash_b,
@@ -3111,7 +3111,7 @@ end:
/* detect buggy encoders which don't set the low_delay flag
* (divx4/xvid/opendivx). Note we cannot detect divx5 without B-frames
* easily (although it's buggy too) */
- if (s->vo_type == 0 && ctx->vol_control_parameters == 0 &&
+ if (ctx->vo_type == 0 && ctx->vol_control_parameters == 0 &&
ctx->divx_version == -1 && s->picture_number == 0) {
av_log(s->avctx, AV_LOG_WARNING,
"looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
@@ -3471,7 +3471,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
s->divx_build = s1->divx_build;
s->xvid_build = s1->xvid_build;
s->lavc_build = s1->lavc_build;
- s->m.vo_type = s1->m.vo_type;
+ s->vo_type = s1->vo_type;
s->showed_packed_warning = s1->showed_packed_warning;
s->vol_control_parameters = s1->vol_control_parameters;
s->cplx_estimation_trash_i = s1->cplx_estimation_trash_i;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 448fe2cedc..e0aec532a6 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -389,7 +389,6 @@ typedef struct MpegEncContext {
int data_partitioning; ///< data partitioning flag from header
int partitioned_frame; ///< is current frame partitioned
int low_delay; ///< no reordering needed / has no B-frames
- int vo_type;
PutBitContext tex_pb; ///< used for data partitioned VOPs
PutBitContext pb2; ///< used for data partitioned VOPs
int mpeg_quant;
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 06/21] avcodec/ituh263enc: Use stack variable for custom_pcf
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (2 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 05/21] avcodec/mpeg4?video: Move vo_type to Mpeg4DecContext Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 07/21] avcodec/mpeg12enc: Use stack variable for aspect_ratio_info Andreas Rheinhardt
` (14 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/ituh263enc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 5a7791111e..069c6a9acf 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -106,6 +106,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
int best_clock_code=1;
int best_divisor=60;
int best_error= INT_MAX;
+ int custom_pcf;
if(s->h263_plus){
for(i=0; i<2; i++){
@@ -120,7 +121,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
}
}
}
- s->custom_pcf= best_clock_code!=1 || best_divisor!=60;
+ custom_pcf = best_clock_code != 1 || best_divisor != 60;
coded_frame_rate= 1800000;
coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
@@ -165,7 +166,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
else
put_bits(&s->pb, 3, format);
- put_bits(&s->pb,1, s->custom_pcf);
+ put_bits(&s->pb,1, custom_pcf);
put_bits(&s->pb,1, s->umvplus); /* Unrestricted Motion Vector */
put_bits(&s->pb,1,0); /* SAC: off */
put_bits(&s->pb,1,s->obmc); /* Advanced Prediction Mode */
@@ -203,7 +204,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
}
}
- if(s->custom_pcf){
+ if (custom_pcf) {
if(ufep){
put_bits(&s->pb, 1, best_clock_code);
put_bits(&s->pb, 7, best_divisor);
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 07/21] avcodec/mpeg12enc: Use stack variable for aspect_ratio_info
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (3 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 06/21] avcodec/ituh263enc: Use stack variable for custom_pcf Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 08/21] avcodec/mpeg12enc: Return early if no Sequence Header is written Andreas Rheinhardt
` (13 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index e28aa809d2..a19100a42d 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -273,6 +273,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
if (s->current_picture.f->key_frame) {
AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
+ int aspect_ratio_info;
/* MPEG-1 header repeated every GOP */
put_header(s, SEQ_START_CODE);
@@ -291,11 +292,11 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
if (error - 2 <= best_aspect_error) {
best_aspect_error = error;
- s->aspect_ratio_info = i;
+ aspect_ratio_info = i;
}
}
- put_bits(&s->pb, 4, s->aspect_ratio_info);
+ put_bits(&s->pb, 4, aspect_ratio_info);
put_bits(&s->pb, 4, s->frame_rate_index);
if (s->avctx->rc_max_rate) {
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 08/21] avcodec/mpeg12enc: Return early if no Sequence Header is written
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (4 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 07/21] avcodec/mpeg12enc: Use stack variable for aspect_ratio_info Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 09/21] avcodec/mpeg12enc: Reindent after the previous commit Andreas Rheinhardt
` (12 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Allows to avoid one level of indentation.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index a19100a42d..e30e41027c 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -264,16 +264,18 @@ 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;
+ AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
uint64_t time_code;
int64_t best_aspect_error = INT64_MAX;
AVRational aspect_ratio = s->avctx->sample_aspect_ratio;
+ int aspect_ratio_info;
+
+ if (!s->current_picture.f->key_frame)
+ return;
if (aspect_ratio.num == 0 || aspect_ratio.den == 0)
aspect_ratio = (AVRational){1,1}; // pixel aspect 1.1 (VGA)
- if (s->current_picture.f->key_frame) {
- AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
- int aspect_ratio_info;
/* MPEG-1 header repeated every GOP */
put_header(s, SEQ_START_CODE);
@@ -414,7 +416,6 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number);
put_bits(&s->pb, 1, 0); // broken link
- }
}
static inline void encode_mb_skip_run(MpegEncContext *s, int run)
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 09/21] avcodec/mpeg12enc: Reindent after the previous commit
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (5 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 08/21] avcodec/mpeg12enc: Return early if no Sequence Header is written Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 10/21] avcodec/mpeg4videoenc: Use stack variable for aspect_ratio_info Andreas Rheinhardt
` (11 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 255 ++++++++++++++++++++---------------------
1 file changed, 127 insertions(+), 128 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index e30e41027c..bec522d8e7 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -263,7 +263,7 @@ 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;
+ int constraint_parameter_flag;
AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
uint64_t time_code;
int64_t best_aspect_error = INT64_MAX;
@@ -276,146 +276,145 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
if (aspect_ratio.num == 0 || aspect_ratio.den == 0)
aspect_ratio = (AVRational){1,1}; // pixel aspect 1.1 (VGA)
+ /* MPEG-1 header repeated every GOP */
+ put_header(s, SEQ_START_CODE);
- /* MPEG-1 header repeated every GOP */
- put_header(s, SEQ_START_CODE);
+ put_sbits(&s->pb, 12, s->width & 0xFFF);
+ put_sbits(&s->pb, 12, s->height & 0xFFF);
- put_sbits(&s->pb, 12, s->width & 0xFFF);
- put_sbits(&s->pb, 12, s->height & 0xFFF);
-
- for (i = 1; i < 15; i++) {
- int64_t error = aspect_ratio.num * (1LL<<32) / aspect_ratio.den;
- if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || i <= 1)
- error -= (1LL<<32) / ff_mpeg1_aspect[i];
- else
- error -= (1LL<<32)*ff_mpeg2_aspect[i].num * s->height / s->width / ff_mpeg2_aspect[i].den;
+ for (int i = 1; i < 15; i++) {
+ int64_t error = aspect_ratio.num * (1LL<<32) / aspect_ratio.den;
+ if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || i <= 1)
+ error -= (1LL<<32) / ff_mpeg1_aspect[i];
+ else
+ error -= (1LL<<32)*ff_mpeg2_aspect[i].num * s->height / s->width / ff_mpeg2_aspect[i].den;
- error = FFABS(error);
+ error = FFABS(error);
- if (error - 2 <= best_aspect_error) {
- best_aspect_error = error;
- aspect_ratio_info = i;
- }
+ if (error - 2 <= best_aspect_error) {
+ best_aspect_error = error;
+ aspect_ratio_info = i;
}
+ }
- put_bits(&s->pb, 4, aspect_ratio_info);
- put_bits(&s->pb, 4, s->frame_rate_index);
+ put_bits(&s->pb, 4, aspect_ratio_info);
+ put_bits(&s->pb, 4, s->frame_rate_index);
- if (s->avctx->rc_max_rate) {
- v = (s->avctx->rc_max_rate + 399) / 400;
- if (v > 0x3ffff && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)
- v = 0x3ffff;
- } else {
- v = 0x3FFFF;
- }
+ if (s->avctx->rc_max_rate) {
+ v = (s->avctx->rc_max_rate + 399) / 400;
+ if (v > 0x3ffff && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)
+ v = 0x3ffff;
+ } else {
+ v = 0x3FFFF;
+ }
- if (s->avctx->rc_buffer_size)
- vbv_buffer_size = s->avctx->rc_buffer_size;
- else
- /* VBV calculation: Scaled so that a VCD has the proper
- * VBV size of 40 kilobytes */
- vbv_buffer_size = ((20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
- vbv_buffer_size = (vbv_buffer_size + 16383) / 16384;
-
- put_sbits(&s->pb, 18, v);
- put_bits(&s->pb, 1, 1); // marker
- put_sbits(&s->pb, 10, vbv_buffer_size);
-
- constraint_parameter_flag =
- s->width <= 768 &&
- s->height <= 576 &&
- s->mb_width * s->mb_height <= 396 &&
- s->mb_width * s->mb_height * framerate.num <= 396 * 25 * framerate.den &&
- framerate.num <= framerate.den * 30 &&
- s->avctx->me_range &&
- s->avctx->me_range < 128 &&
- vbv_buffer_size <= 20 &&
- v <= 1856000 / 400 &&
- s->codec_id == AV_CODEC_ID_MPEG1VIDEO;
-
- put_bits(&s->pb, 1, constraint_parameter_flag);
-
- ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
- ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
-
- if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- AVFrameSideData *side_data;
- int width = s->width;
- int height = s->height;
- int use_seq_disp_ext;
+ if (s->avctx->rc_buffer_size)
+ vbv_buffer_size = s->avctx->rc_buffer_size;
+ else
+ /* VBV calculation: Scaled so that a VCD has the proper
+ * VBV size of 40 kilobytes */
+ vbv_buffer_size = ((20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
+ vbv_buffer_size = (vbv_buffer_size + 16383) / 16384;
+
+ put_sbits(&s->pb, 18, v);
+ put_bits(&s->pb, 1, 1); // marker
+ put_sbits(&s->pb, 10, vbv_buffer_size);
+
+ constraint_parameter_flag =
+ s->width <= 768 &&
+ s->height <= 576 &&
+ s->mb_width * s->mb_height <= 396 &&
+ s->mb_width * s->mb_height * framerate.num <= 396 * 25 * framerate.den &&
+ framerate.num <= framerate.den * 30 &&
+ s->avctx->me_range &&
+ s->avctx->me_range < 128 &&
+ vbv_buffer_size <= 20 &&
+ v <= 1856000 / 400 &&
+ s->codec_id == AV_CODEC_ID_MPEG1VIDEO;
+
+ put_bits(&s->pb, 1, constraint_parameter_flag);
+
+ ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
+ ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
- put_header(s, EXT_START_CODE);
- put_bits(&s->pb, 4, 1); // seq ext
-
- put_bits(&s->pb, 1, s->avctx->profile == FF_PROFILE_MPEG2_422); // escx 1 for 4:2:2 profile
-
- put_bits(&s->pb, 3, s->avctx->profile); // profile
- put_bits(&s->pb, 4, s->avctx->level); // level
-
- put_bits(&s->pb, 1, s->progressive_sequence);
- put_bits(&s->pb, 2, s->chroma_format);
- put_bits(&s->pb, 2, s->width >> 12);
- put_bits(&s->pb, 2, s->height >> 12);
- put_bits(&s->pb, 12, v >> 18); // bitrate ext
- 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, 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) {
- AVPanScan *pan_scan = (AVPanScan *)side_data->data;
- if (pan_scan->width && pan_scan->height) {
- width = pan_scan->width >> 4;
- height = pan_scan->height >> 4;
- }
- }
+ if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ const AVFrameSideData *side_data;
+ int width = s->width;
+ int height = s->height;
+ int use_seq_disp_ext;
- use_seq_disp_ext = (width != s->width ||
- height != s->height ||
- s->avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
- s->avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
- s->avctx->colorspace != AVCOL_SPC_UNSPECIFIED ||
- mpeg12->video_format != VIDEO_FORMAT_UNSPECIFIED);
-
- if (mpeg12->seq_disp_ext == 1 ||
- (mpeg12->seq_disp_ext == -1 && use_seq_disp_ext)) {
- put_header(s, EXT_START_CODE);
- put_bits(&s->pb, 4, 2); // sequence display extension
- put_bits(&s->pb, 3, mpeg12->video_format); // video_format
- put_bits(&s->pb, 1, 1); // colour_description
- put_bits(&s->pb, 8, s->avctx->color_primaries); // colour_primaries
- put_bits(&s->pb, 8, s->avctx->color_trc); // transfer_characteristics
- put_bits(&s->pb, 8, s->avctx->colorspace); // matrix_coefficients
- put_bits(&s->pb, 14, width); // display_horizontal_size
- put_bits(&s->pb, 1, 1); // marker_bit
- put_bits(&s->pb, 14, height); // display_vertical_size
- put_bits(&s->pb, 3, 0); // remaining 3 bits are zero padding
+ put_header(s, EXT_START_CODE);
+ put_bits(&s->pb, 4, 1); // seq ext
+
+ put_bits(&s->pb, 1, s->avctx->profile == FF_PROFILE_MPEG2_422); // escx 1 for 4:2:2 profile
+
+ put_bits(&s->pb, 3, s->avctx->profile); // profile
+ put_bits(&s->pb, 4, s->avctx->level); // level
+
+ put_bits(&s->pb, 1, s->progressive_sequence);
+ put_bits(&s->pb, 2, s->chroma_format);
+ put_bits(&s->pb, 2, s->width >> 12);
+ put_bits(&s->pb, 2, s->height >> 12);
+ put_bits(&s->pb, 12, v >> 18); // bitrate ext
+ 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, 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) {
+ const AVPanScan *pan_scan = (AVPanScan *)side_data->data;
+ if (pan_scan->width && pan_scan->height) {
+ width = pan_scan->width >> 4;
+ height = pan_scan->height >> 4;
}
}
- put_header(s, GOP_START_CODE);
- put_bits(&s->pb, 1, mpeg12->drop_frame_timecode); // drop frame flag
- /* time code: we must convert from the real frame rate to a
- * fake MPEG frame rate in case of low frame rate */
- fps = (framerate.num + framerate.den / 2) / framerate.den;
- time_code = s->current_picture_ptr->f->coded_picture_number +
- mpeg12->timecode_frame_start;
-
- s->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
-
- av_assert0(mpeg12->drop_frame_timecode == !!(mpeg12->tc.flags & AV_TIMECODE_FLAG_DROPFRAME));
- if (mpeg12->drop_frame_timecode)
- time_code = av_timecode_adjust_ntsc_framenum2(time_code, fps);
-
- put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
- put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
- put_bits(&s->pb, 1, 1);
- put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
- put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
- put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number);
- put_bits(&s->pb, 1, 0); // broken link
+ use_seq_disp_ext = (width != s->width ||
+ height != s->height ||
+ s->avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
+ s->avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
+ s->avctx->colorspace != AVCOL_SPC_UNSPECIFIED ||
+ mpeg12->video_format != VIDEO_FORMAT_UNSPECIFIED);
+
+ if (mpeg12->seq_disp_ext == 1 ||
+ (mpeg12->seq_disp_ext == -1 && use_seq_disp_ext)) {
+ put_header(s, EXT_START_CODE);
+ put_bits(&s->pb, 4, 2); // sequence display extension
+ put_bits(&s->pb, 3, mpeg12->video_format); // video_format
+ put_bits(&s->pb, 1, 1); // colour_description
+ put_bits(&s->pb, 8, s->avctx->color_primaries); // colour_primaries
+ put_bits(&s->pb, 8, s->avctx->color_trc); // transfer_characteristics
+ put_bits(&s->pb, 8, s->avctx->colorspace); // matrix_coefficients
+ put_bits(&s->pb, 14, width); // display_horizontal_size
+ put_bits(&s->pb, 1, 1); // marker_bit
+ put_bits(&s->pb, 14, height); // display_vertical_size
+ put_bits(&s->pb, 3, 0); // remaining 3 bits are zero padding
+ }
+ }
+
+ put_header(s, GOP_START_CODE);
+ put_bits(&s->pb, 1, mpeg12->drop_frame_timecode); // drop frame flag
+ /* time code: we must convert from the real frame rate to a
+ * fake MPEG frame rate in case of low frame rate */
+ fps = (framerate.num + framerate.den / 2) / framerate.den;
+ time_code = s->current_picture_ptr->f->coded_picture_number +
+ mpeg12->timecode_frame_start;
+
+ s->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
+
+ av_assert0(mpeg12->drop_frame_timecode == !!(mpeg12->tc.flags & AV_TIMECODE_FLAG_DROPFRAME));
+ if (mpeg12->drop_frame_timecode)
+ time_code = av_timecode_adjust_ntsc_framenum2(time_code, fps);
+
+ put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
+ put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
+ put_bits(&s->pb, 1, 1);
+ put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
+ put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
+ put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number);
+ put_bits(&s->pb, 1, 0); // broken link
}
static inline void encode_mb_skip_run(MpegEncContext *s, int run)
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 10/21] avcodec/mpeg4videoenc: Use stack variable for aspect_ratio_info
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (6 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 09/21] avcodec/mpeg12enc: Reindent after the previous commit Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 11/21] avcodec/ituh263enc: " Andreas Rheinhardt
` (10 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4videoenc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index b3e697daf7..27e16c3b72 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -961,7 +961,7 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
int vo_number,
int vol_number)
{
- int vo_ver_id, vo_type;
+ int vo_ver_id, vo_type, aspect_ratio_info;
if (s->max_b_frames || s->quarter_sample) {
vo_ver_id = 5;
@@ -986,10 +986,10 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
put_bits(&s->pb, 3, 1); /* is obj layer priority */
}
- s->aspect_ratio_info = ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
+ aspect_ratio_info = ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
- put_bits(&s->pb, 4, s->aspect_ratio_info); /* aspect ratio info */
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
+ put_bits(&s->pb, 4, aspect_ratio_info); /* aspect ratio info */
+ if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
av_reduce(&s->avctx->sample_aspect_ratio.num, &s->avctx->sample_aspect_ratio.den,
s->avctx->sample_aspect_ratio.num, s->avctx->sample_aspect_ratio.den, 255);
put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 11/21] avcodec/ituh263enc: Use stack variable for aspect_ratio_info
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (7 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 10/21] avcodec/mpeg4videoenc: Use stack variable for aspect_ratio_info Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 12/21] avcodec/ituh263dec: " Andreas Rheinhardt
` (9 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/ituh263enc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 069c6a9acf..bd2deba210 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -193,13 +193,13 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
if (format == 8) {
/* Custom Picture Format (CPFMT) */
- s->aspect_ratio_info= ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
+ unsigned aspect_ratio_info = ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
- put_bits(&s->pb,4,s->aspect_ratio_info);
+ put_bits(&s->pb,4, aspect_ratio_info);
put_bits(&s->pb,9,(s->width >> 2) - 1);
put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
put_bits(&s->pb,9,(s->height >> 2));
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
+ if (aspect_ratio_info == FF_ASPECT_EXTENDED){
put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
}
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 12/21] avcodec/ituh263dec: Use stack variable for aspect_ratio_info
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (8 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 11/21] avcodec/ituh263enc: " Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 13/21] avcodec/mpeg4videodec: " Andreas Rheinhardt
` (8 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/ituh263dec.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 0a032ea54c..7d7a1f01a2 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -1222,8 +1222,8 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
if (ufep) {
if (format == 6) {
/* Custom Picture Format (CPFMT) */
- s->aspect_ratio_info = get_bits(&s->gb, 4);
- ff_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info);
+ int aspect_ratio_info = get_bits(&s->gb, 4);
+ ff_dlog(s->avctx, "aspect: %d\n", aspect_ratio_info);
/* aspect ratios:
0 - forbidden
1 - 1:1
@@ -1237,12 +1237,12 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
check_marker(s->avctx, &s->gb, "in dimensions");
height = get_bits(&s->gb, 9) * 4;
ff_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
+ if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
/* expected dimensions */
s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
}else{
- s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info];
+ s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[aspect_ratio_info];
}
} else {
width = ff_h263_format[format][0];
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 13/21] avcodec/mpeg4videodec: Use stack variable for aspect_ratio_info
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (9 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 12/21] avcodec/ituh263dec: " Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 14/21] avcodec/mpegvideo: Move aspect_ratio_info to Mpeg1Context Andreas Rheinhardt
` (7 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4videodec.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 00bf7b6c4a..bdd320b1df 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2215,7 +2215,7 @@ static void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id
static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
- int width, height;
+ int width, height, aspect_ratio_info;
int bits_per_raw_sample;
int rgb, chroma_format;
@@ -2270,12 +2270,12 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
s->height = height;
}
}
- s->aspect_ratio_info = get_bits(gb, 4);
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
+ aspect_ratio_info = get_bits(gb, 4);
+ if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
s->avctx->sample_aspect_ratio.num = get_bits(gb, 8); // par_width
s->avctx->sample_aspect_ratio.den = get_bits(gb, 8); // par_height
} else {
- s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
+ s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[aspect_ratio_info];
}
skip_bits(gb, 4); /* frame_rate_code */
skip_bits(gb, 15); /* first_half_bit_rate */
@@ -2301,7 +2301,7 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
- int width, height, vo_ver_id;
+ int width, height, vo_ver_id, aspect_ratio_info;
/* vol header */
skip_bits(gb, 1); /* random access */
@@ -2329,12 +2329,12 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
} else {
vo_ver_id = 1;
}
- s->aspect_ratio_info = get_bits(gb, 4);
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
+ aspect_ratio_info = get_bits(gb, 4);
+ if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
s->avctx->sample_aspect_ratio.num = get_bits(gb, 8); // par_width
s->avctx->sample_aspect_ratio.den = get_bits(gb, 8); // par_height
} else {
- s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
+ s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[aspect_ratio_info];
}
if ((ctx->vol_control_parameters = get_bits1(gb))) { /* vol control parameter */
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 14/21] avcodec/mpegvideo: Move aspect_ratio_info to Mpeg1Context
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (10 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 13/21] avcodec/mpeg4videodec: " Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 15/21] avcodec/mpegvideo: Move timecode_frame_start " Andreas Rheinhardt
` (6 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Only used there and only by the main thread.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 23 ++++++++++++-----------
libavcodec/mpegvideo.h | 1 -
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 6ad9fb245c..dbbf9bd819 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -65,6 +65,7 @@ typedef struct Mpeg1Context {
uint8_t afd;
int has_afd;
int slice_count;
+ unsigned aspect_ratio_info;
AVRational save_aspect;
int save_width, save_height, save_progressive_seq;
int rc_buffer_size;
@@ -1205,13 +1206,13 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
// MPEG-1 aspect
- AVRational aspect_inv = av_d2q(ff_mpeg1_aspect[s->aspect_ratio_info], 255);
+ AVRational aspect_inv = av_d2q(ff_mpeg1_aspect[s1->aspect_ratio_info], 255);
avctx->sample_aspect_ratio = (AVRational) { aspect_inv.den, aspect_inv.num };
} else { // MPEG-2
// MPEG-2 aspect
- if (s->aspect_ratio_info > 1) {
+ if (s1->aspect_ratio_info > 1) {
AVRational dar =
- av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
+ av_mul_q(av_div_q(ff_mpeg2_aspect[s1->aspect_ratio_info],
(AVRational) { s1->pan_scan.width,
s1->pan_scan.height }),
(AVRational) { s->width, s->height });
@@ -1224,25 +1225,25 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
(av_cmp_q(dar, (AVRational) { 4, 3 }) &&
av_cmp_q(dar, (AVRational) { 16, 9 }))) {
s->avctx->sample_aspect_ratio =
- av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
+ av_div_q(ff_mpeg2_aspect[s1->aspect_ratio_info],
(AVRational) { s->width, s->height });
} else {
s->avctx->sample_aspect_ratio =
- av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
+ av_div_q(ff_mpeg2_aspect[s1->aspect_ratio_info],
(AVRational) { s1->pan_scan.width, s1->pan_scan.height });
// issue1613 4/3 16/9 -> 16/9
// res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3
// widescreen-issue562.mpg 4/3 16/9 -> 16/9
// s->avctx->sample_aspect_ratio = av_mul_q(s->avctx->sample_aspect_ratio, (AVRational) {s->width, s->height});
ff_dlog(avctx, "aspect A %d/%d\n",
- ff_mpeg2_aspect[s->aspect_ratio_info].num,
- ff_mpeg2_aspect[s->aspect_ratio_info].den);
+ ff_mpeg2_aspect[s1->aspect_ratio_info].num,
+ ff_mpeg2_aspect[s1->aspect_ratio_info].den);
ff_dlog(avctx, "aspect B %d/%d\n", s->avctx->sample_aspect_ratio.num,
s->avctx->sample_aspect_ratio.den);
}
} else {
s->avctx->sample_aspect_ratio =
- ff_mpeg2_aspect[s->aspect_ratio_info];
+ ff_mpeg2_aspect[s1->aspect_ratio_info];
}
} // MPEG-2
@@ -2102,8 +2103,8 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
return AVERROR_INVALIDDATA;
}
- s->aspect_ratio_info = get_bits(&s->gb, 4);
- if (s->aspect_ratio_info == 0) {
+ s1->aspect_ratio_info = get_bits(&s->gb, 4);
+ if (s1->aspect_ratio_info == 0) {
av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n");
if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
return AVERROR_INVALIDDATA;
@@ -2168,7 +2169,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%"PRId64", aspect_ratio_info: %d \n",
- s1->rc_buffer_size, s->bit_rate, s->aspect_ratio_info);
+ s1->rc_buffer_size, s->bit_rate, s1->aspect_ratio_info);
return 0;
}
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index e0aec532a6..e093e8c04a 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -384,7 +384,6 @@ typedef struct MpegEncContext {
int mcsel;
int quant_precision;
int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
- int aspect_ratio_info; //FIXME remove
int sprite_warping_accuracy;
int data_partitioning; ///< data partitioning flag from header
int partitioned_frame; ///< is current frame partitioned
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 15/21] avcodec/mpegvideo: Move timecode_frame_start to Mpeg1Context
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (11 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 14/21] avcodec/mpegvideo: Move aspect_ratio_info to Mpeg1Context Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 16/21] avcodec/mpegvideo_enc: Don't sync gop_picture_number among slice threads Andreas Rheinhardt
` (5 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is only used there and only by the main thread.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 11 ++++++-----
libavcodec/mpegvideo.h | 1 -
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index dbbf9bd819..0c5eddb7f1 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -75,6 +75,7 @@ typedef struct Mpeg1Context {
int tmpgexs;
int first_slice;
int extradata_decoded;
+ int64_t timecode_frame_start; /*< GOP timecode frame start number, in non drop frame format */
} Mpeg1Context;
#define MB_TYPE_ZERO_MV 0x20000000
@@ -2443,7 +2444,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
init_get_bits(&s->gb, buf, buf_size * 8);
- tc = s-> timecode_frame_start = get_bits(&s->gb, 25);
+ tc = s1->timecode_frame_start = get_bits(&s->gb, 25);
s1->closed_gop = get_bits1(&s->gb);
/* broken_link indicates that after editing the
@@ -2854,19 +2855,19 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data,
if (ret<0 || *got_output) {
s2->current_picture_ptr = NULL;
- if (s2->timecode_frame_start != -1 && *got_output) {
+ if (s->timecode_frame_start != -1 && *got_output) {
char tcbuf[AV_TIMECODE_STR_SIZE];
AVFrameSideData *tcside = av_frame_new_side_data(picture,
AV_FRAME_DATA_GOP_TIMECODE,
sizeof(int64_t));
if (!tcside)
return AVERROR(ENOMEM);
- memcpy(tcside->data, &s2->timecode_frame_start, sizeof(int64_t));
+ memcpy(tcside->data, &s->timecode_frame_start, sizeof(int64_t));
- av_timecode_make_mpeg_tc_string(tcbuf, s2->timecode_frame_start);
+ av_timecode_make_mpeg_tc_string(tcbuf, s->timecode_frame_start);
av_dict_set(&picture->metadata, "timecode", tcbuf, 0);
- s2->timecode_frame_start = -1;
+ s->timecode_frame_start = -1;
}
}
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index e093e8c04a..fd9d60b03e 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -443,7 +443,6 @@ typedef struct MpegEncContext {
// picture structure defines are loaded from mpegutils.h
int picture_structure;
- int64_t timecode_frame_start; ///< GOP timecode frame start number, in non drop frame format
int intra_dc_precision;
int frame_pred_frame_dct;
int top_field_first;
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 16/21] avcodec/mpegvideo_enc: Don't sync gop_picture_number among slice threads
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (12 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 15/21] avcodec/mpegvideo: Move timecode_frame_start " Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 17/21] avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContext Andreas Rheinhardt
` (4 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is only used by the main thread.
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 35f0f79d4e..93deded66c 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -258,7 +258,6 @@ static void update_duplicate_context_after_me(MpegEncContext *dst,
COPY(lambda);
COPY(lambda2);
COPY(picture_in_gop_number);
- COPY(gop_picture_number);
COPY(frame_pred_frame_dct); // FIXME don't set in encode_header
COPY(progressive_frame); // FIXME don't set in encode_header
COPY(partitioned_frame); // FIXME don't set in encode_header
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 17/21] avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContext
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (13 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 16/21] avcodec/mpegvideo_enc: Don't sync gop_picture_number among slice threads Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 18/21] avcodec/mpegvideo_enc: Move msmpeg4/wmv1 encoders to msmpeg4enc.c Andreas Rheinhardt
` (3 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 9 ++++++---
libavcodec/mpegvideo.h | 1 -
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index bec522d8e7..eaab968425 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -66,6 +66,8 @@ typedef struct MPEG12EncContext {
MpegEncContext mpeg;
AVRational frame_rate_ext;
+ int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num
+
int64_t timecode_frame_start; ///< GOP timecode frame start number, in non drop frame format
AVTimecode tc; ///< timecode context
char *tc_opt_str; ///< timecode option string
@@ -402,7 +404,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
time_code = s->current_picture_ptr->f->coded_picture_number +
mpeg12->timecode_frame_start;
- s->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
+ mpeg12->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
av_assert0(mpeg12->drop_frame_timecode == !!(mpeg12->tc.flags & AV_TIMECODE_FLAG_DROPFRAME));
if (mpeg12->drop_frame_timecode)
@@ -413,7 +415,8 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
- put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number);
+ put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) ||
+ s->intra_only || !mpeg12->gop_picture_number);
put_bits(&s->pb, 1, 0); // broken link
}
@@ -458,7 +461,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
// RAL: s->picture_number instead of s->fake_picture_number
put_bits(&s->pb, 10,
- (s->picture_number - s->gop_picture_number) & 0x3ff);
+ (s->picture_number - mpeg12->gop_picture_number) & 0x3ff);
put_bits(&s->pb, 3, s->pict_type);
s->vbv_delay_ptr = s->pb.buf + put_bytes_count(&s->pb, 0);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index fd9d60b03e..e5a4cc9b81 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -432,7 +432,6 @@ typedef struct MpegEncContext {
GetBitContext gb;
/* MPEG-1 specific */
- int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num & MPEG-1 specific
int last_mv_dir; ///< last mv_dir, used for B-frame encoding
uint8_t *vbv_delay_ptr; ///< pointer to vbv_delay in the bitstream
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 18/21] avcodec/mpegvideo_enc: Move msmpeg4/wmv1 encoders to msmpeg4enc.c
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (14 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 17/21] avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContext Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 19/21] avcodec/mpegvideo_enc: Move H.263p? encoders to ituh263enc.c Andreas Rheinhardt
` (2 subsequent siblings)
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_enc.c | 42 --------------------------------------
libavcodec/msmpeg4enc.c | 42 ++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 93deded66c..4c3c870013 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -4628,45 +4628,3 @@ const AVCodec ff_h263p_encoder = {
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
.priv_class = &h263p_class,
};
-
-const AVCodec ff_msmpeg4v2_encoder = {
- .name = "msmpeg4v2",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MSMPEG4V2,
- .priv_class = &ff_mpv_enc_class,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_mpv_encode_init,
- .encode2 = ff_mpv_encode_picture,
- .close = ff_mpv_encode_end,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-};
-
-const AVCodec ff_msmpeg4v3_encoder = {
- .name = "msmpeg4",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MSMPEG4V3,
- .priv_class = &ff_mpv_enc_class,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_mpv_encode_init,
- .encode2 = ff_mpv_encode_picture,
- .close = ff_mpv_encode_end,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-};
-
-const AVCodec ff_wmv1_encoder = {
- .name = "wmv1",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_WMV1,
- .priv_class = &ff_mpv_enc_class,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_mpv_encode_init,
- .encode2 = ff_mpv_encode_picture,
- .close = ff_mpv_encode_end,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-};
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index a4efbd34e6..2c619e1210 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -669,3 +669,45 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n)
}
}
}
+
+const AVCodec ff_msmpeg4v2_encoder = {
+ .name = "msmpeg4v2",
+ .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_MSMPEG4V2,
+ .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
+ .priv_class = &ff_mpv_enc_class,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+ .priv_data_size = sizeof(MpegEncContext),
+ .init = ff_mpv_encode_init,
+ .encode2 = ff_mpv_encode_picture,
+ .close = ff_mpv_encode_end,
+};
+
+const AVCodec ff_msmpeg4v3_encoder = {
+ .name = "msmpeg4",
+ .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_MSMPEG4V3,
+ .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
+ .priv_class = &ff_mpv_enc_class,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+ .priv_data_size = sizeof(MpegEncContext),
+ .init = ff_mpv_encode_init,
+ .encode2 = ff_mpv_encode_picture,
+ .close = ff_mpv_encode_end,
+};
+
+const AVCodec ff_wmv1_encoder = {
+ .name = "wmv1",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_WMV1,
+ .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
+ .priv_class = &ff_mpv_enc_class,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+ .priv_data_size = sizeof(MpegEncContext),
+ .init = ff_mpv_encode_init,
+ .encode2 = ff_mpv_encode_picture,
+ .close = ff_mpv_encode_end,
+};
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 19/21] avcodec/mpegvideo_enc: Move H.263p? encoders to ituh263enc.c
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (15 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 18/21] avcodec/mpegvideo_enc: Move msmpeg4/wmv1 encoders to msmpeg4enc.c Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 20/21] avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 21/21] avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)Context Andreas Rheinhardt
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/ituh263enc.c | 72 ++++++++++++++++++++++++++++++++++++++
libavcodec/mpegvideo_enc.c | 72 --------------------------------------
2 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index bd2deba210..9253d60a16 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -874,3 +874,75 @@ void ff_h263_encode_mba(MpegEncContext *s)
mb_pos= s->mb_x + s->mb_width*s->mb_y;
put_bits(&s->pb, ff_mba_length[i], mb_pos);
}
+
+#define OFFSET(x) offsetof(MpegEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption h263_options[] = {
+ { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "mb_info", "emit macroblock info for RFC 2190 packetization, the parameter value is the maximum payload size", OFFSET(mb_info), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
+ FF_MPV_COMMON_OPTS
+#if FF_API_MPEGVIDEO_OPTS
+ FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+ FF_MPV_DEPRECATED_A53_CC_OPT
+ FF_MPV_DEPRECATED_MATRIX_OPT
+ FF_MPV_DEPRECATED_BFRAME_OPTS
+#endif
+ { NULL },
+};
+
+static const AVClass h263_class = {
+ .class_name = "H.263 encoder",
+ .item_name = av_default_item_name,
+ .option = h263_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+const AVCodec ff_h263_encoder = {
+ .name = "h263",
+ .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_H263,
+ .pix_fmts= (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE},
+ .priv_class = &h263_class,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+ .priv_data_size = sizeof(MpegEncContext),
+ .init = ff_mpv_encode_init,
+ .encode2 = ff_mpv_encode_picture,
+ .close = ff_mpv_encode_end,
+};
+
+static const AVOption h263p_options[] = {
+ { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
+ FF_MPV_COMMON_OPTS
+#if FF_API_MPEGVIDEO_OPTS
+ FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+ FF_MPV_DEPRECATED_A53_CC_OPT
+ FF_MPV_DEPRECATED_MATRIX_OPT
+ FF_MPV_DEPRECATED_BFRAME_OPTS
+#endif
+ { NULL },
+};
+static const AVClass h263p_class = {
+ .class_name = "H.263p encoder",
+ .item_name = av_default_item_name,
+ .option = h263p_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+const AVCodec ff_h263p_encoder = {
+ .name = "h263p",
+ .long_name = NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_H263P,
+ .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
+ .priv_class = &h263p_class,
+ .capabilities = AV_CODEC_CAP_SLICE_THREADS,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+ .priv_data_size = sizeof(MpegEncContext),
+ .init = ff_mpv_encode_init,
+ .encode2 = ff_mpv_encode_picture,
+ .close = ff_mpv_encode_end,
+};
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 4c3c870013..044c675014 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -4556,75 +4556,3 @@ int ff_dct_quantize_c(MpegEncContext *s,
return last_non_zero;
}
-
-#define OFFSET(x) offsetof(MpegEncContext, x)
-#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
-static const AVOption h263_options[] = {
- { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
- { "mb_info", "emit macroblock info for RFC 2190 packetization, the parameter value is the maximum payload size", OFFSET(mb_info), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
- FF_MPV_COMMON_OPTS
-#if FF_API_MPEGVIDEO_OPTS
- FF_MPV_DEPRECATED_MPEG_QUANT_OPT
- FF_MPV_DEPRECATED_A53_CC_OPT
- FF_MPV_DEPRECATED_MATRIX_OPT
- FF_MPV_DEPRECATED_BFRAME_OPTS
-#endif
- { NULL },
-};
-
-static const AVClass h263_class = {
- .class_name = "H.263 encoder",
- .item_name = av_default_item_name,
- .option = h263_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-const AVCodec ff_h263_encoder = {
- .name = "h263",
- .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_H263,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_mpv_encode_init,
- .encode2 = ff_mpv_encode_picture,
- .close = ff_mpv_encode_end,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
- .pix_fmts= (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE},
- .priv_class = &h263_class,
-};
-
-static const AVOption h263p_options[] = {
- { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
- { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
- { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
- { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
- FF_MPV_COMMON_OPTS
-#if FF_API_MPEGVIDEO_OPTS
- FF_MPV_DEPRECATED_MPEG_QUANT_OPT
- FF_MPV_DEPRECATED_A53_CC_OPT
- FF_MPV_DEPRECATED_MATRIX_OPT
- FF_MPV_DEPRECATED_BFRAME_OPTS
-#endif
- { NULL },
-};
-static const AVClass h263p_class = {
- .class_name = "H.263p encoder",
- .item_name = av_default_item_name,
- .option = h263p_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-const AVCodec ff_h263p_encoder = {
- .name = "h263p",
- .long_name = NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_H263P,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_mpv_encode_init,
- .encode2 = ff_mpv_encode_picture,
- .close = ff_mpv_encode_end,
- .capabilities = AV_CODEC_CAP_SLICE_THREADS,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
- .priv_class = &h263p_class,
-};
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 20/21] avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (16 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 19/21] avcodec/mpegvideo_enc: Move H.263p? encoders to ituh263enc.c Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 21/21] avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)Context Andreas Rheinhardt
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo.h | 3 ---
libavcodec/speedhqenc.c | 19 ++++++++++++++-----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index e5a4cc9b81..9243edefce 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -425,9 +425,6 @@ typedef struct MpegEncContext {
int inter_intra_pred;
int mspel;
- /* SpeedHQ specific */
- int slice_start;
-
/* decompression specific */
GetBitContext gb;
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 967774931c..9a03876fbf 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -54,6 +54,12 @@ static uint32_t speedhq_chr_dc_uni[512];
static uint8_t uni_speedhq_ac_vlc_len[64 * 64 * 2];
+typedef struct SpeedHQEncContext {
+ MpegEncContext m;
+
+ int slice_start;
+} SpeedHQEncContext;
+
static av_cold void speedhq_init_static_data(void)
{
ff_rl_init(&ff_rl_speedhq, speedhq_static_rl_table_store);
@@ -123,24 +129,27 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s)
void ff_speedhq_encode_picture_header(MpegEncContext *s)
{
+ SpeedHQEncContext *ctx = (SpeedHQEncContext*)s;
+
put_bits_le(&s->pb, 8, 100 - s->qscale * 2); /* FIXME why doubled */
put_bits_le(&s->pb, 24, 4); /* no second field */
+ ctx->slice_start = 4;
/* length of first slice, will be filled out later */
- s->slice_start = 4;
put_bits_le(&s->pb, 24, 0);
}
void ff_speedhq_end_slice(MpegEncContext *s)
{
+ SpeedHQEncContext *ctx = (SpeedHQEncContext*)s;
int slice_len;
flush_put_bits_le(&s->pb);
- slice_len = s->pb.buf_ptr - (s->pb.buf + s->slice_start);
- AV_WL24(s->pb.buf + s->slice_start, slice_len);
+ slice_len = put_bytes_output(&s->pb) - ctx->slice_start;
+ AV_WL24(s->pb.buf + ctx->slice_start, slice_len);
/* length of next slice, will be filled out later */
- s->slice_start = s->pb.buf_ptr - s->pb.buf;
+ ctx->slice_start = put_bytes_output(&s->pb);
put_bits_le(&s->pb, 24, 0);
}
@@ -273,7 +282,7 @@ const AVCodec ff_speedhq_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_SPEEDHQ,
.priv_class = &ff_mpv_enc_class,
- .priv_data_size = sizeof(MpegEncContext),
+ .priv_data_size = sizeof(SpeedHQEncContext),
.init = ff_mpv_encode_init,
.encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end,
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 21/21] avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)Context
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
` (17 preceding siblings ...)
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 20/21] avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it Andreas Rheinhardt
@ 2022-01-25 17:41 ` Andreas Rheinhardt
18 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-25 17:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12dec.c | 15 ++++++++-------
libavcodec/mpeg12enc.c | 11 ++++++-----
libavcodec/mpegvideo.h | 1 -
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 0c5eddb7f1..4a7bd6d466 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -70,6 +70,7 @@ typedef struct Mpeg1Context {
int save_width, save_height, save_progressive_seq;
int rc_buffer_size;
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? */
int closed_gop;
int tmpgexs;
@@ -1297,7 +1298,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
// MPEG-1 fps
- avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
+ avctx->framerate = ff_mpeg12_frame_rate_tab[s1->frame_rate_index];
avctx->ticks_per_frame = 1;
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
@@ -1305,8 +1306,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
// MPEG-2 fps
av_reduce(&s->avctx->framerate.num,
&s->avctx->framerate.den,
- ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
- ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
+ ff_mpeg12_frame_rate_tab[s1->frame_rate_index].num * s1->frame_rate_ext.num,
+ ff_mpeg12_frame_rate_tab[s1->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
avctx->ticks_per_frame = 2;
@@ -2110,11 +2111,11 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
return AVERROR_INVALIDDATA;
}
- s->frame_rate_index = get_bits(&s->gb, 4);
- if (s->frame_rate_index == 0 || s->frame_rate_index > 13) {
+ s1->frame_rate_index = get_bits(&s->gb, 4);
+ if (s1->frame_rate_index == 0 || s1->frame_rate_index > 13) {
av_log(avctx, AV_LOG_WARNING,
- "frame_rate_index %d is invalid\n", s->frame_rate_index);
- s->frame_rate_index = 1;
+ "frame_rate_index %d is invalid\n", s1->frame_rate_index);
+ s1->frame_rate_index = 1;
}
s->bit_rate = get_bits(&s->gb, 18) * 400LL;
if (check_marker(s->avctx, &s->gb, "in sequence header") == 0) {
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index eaab968425..ecb90d1a41 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -65,6 +65,7 @@ static uint32_t mpeg1_chr_dc_uni[512];
typedef struct MPEG12EncContext {
MpegEncContext mpeg;
AVRational frame_rate_ext;
+ unsigned frame_rate_index;
int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num
@@ -144,7 +145,7 @@ static int find_frame_rate_index(MPEG12EncContext *mpeg12)
|| av_nearer_q(target, bestq, q) < 0
|| ext.num==1 && ext.den==1 && av_nearer_q(target, bestq, q) == 0) {
bestq = q;
- s->frame_rate_index = i;
+ mpeg12->frame_rate_index = i;
mpeg12->frame_rate_ext.num = ext.num;
mpeg12->frame_rate_ext.den = ext.den;
}
@@ -233,14 +234,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
mpeg12->drop_frame_timecode = mpeg12->drop_frame_timecode || !!(avctx->flags2 & AV_CODEC_FLAG2_DROP_FRAME_TIMECODE);
if (mpeg12->drop_frame_timecode)
mpeg12->tc.flags |= AV_TIMECODE_FLAG_DROPFRAME;
- if (mpeg12->drop_frame_timecode && s->frame_rate_index != 4) {
+ if (mpeg12->drop_frame_timecode && mpeg12->frame_rate_index != 4) {
av_log(avctx, AV_LOG_ERROR,
"Drop frame time code only allowed with 1001/30000 fps\n");
return AVERROR(EINVAL);
}
if (mpeg12->tc_opt_str) {
- AVRational rate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
+ AVRational rate = ff_mpeg12_frame_rate_tab[mpeg12->frame_rate_index];
int ret = av_timecode_init_from_string(&mpeg12->tc, rate, mpeg12->tc_opt_str, s);
if (ret < 0)
return ret;
@@ -266,7 +267,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s;
unsigned int vbv_buffer_size, fps, v;
int constraint_parameter_flag;
- AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
+ AVRational framerate = ff_mpeg12_frame_rate_tab[mpeg12->frame_rate_index];
uint64_t time_code;
int64_t best_aspect_error = INT64_MAX;
AVRational aspect_ratio = s->avctx->sample_aspect_ratio;
@@ -300,7 +301,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
}
put_bits(&s->pb, 4, aspect_ratio_info);
- put_bits(&s->pb, 4, s->frame_rate_index);
+ put_bits(&s->pb, 4, mpeg12->frame_rate_index);
if (s->avctx->rc_max_rate) {
v = (s->avctx->rc_max_rate + 399) / 400;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 9243edefce..0b76a460c9 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -201,7 +201,6 @@ typedef struct MpegEncContext {
int last_pict_type; //FIXME removes
int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol
int droppable;
- int frame_rate_index;
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 22/33] avcodec/mpegvideo_enc: Localize check for invalid number of b-frames
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 02/21] avcodec/h263: Move decoding-only stuff to a new header h263dec.h Andreas Rheinhardt
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 23/33] avcodec/mpegvideo_enc: Don't hardcode list of codecs supporting bframes Andreas Rheinhardt
` (11 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_enc.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 044c675014..920cb337a1 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -350,9 +350,21 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum "
"is %d.\n", MAX_B_FRAMES);
avctx->max_b_frames = MAX_B_FRAMES;
+ } else if (avctx->max_b_frames < 0) {
+ av_log(avctx, AV_LOG_ERROR,
+ "max b frames must be 0 or positive for mpegvideo based encoders\n");
+ return AVERROR(EINVAL);
}
s->max_b_frames = avctx->max_b_frames;
s->codec_id = avctx->codec->id;
+ if (s->max_b_frames &&
+ s->codec_id != AV_CODEC_ID_MPEG4 &&
+ s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
+ s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
+ av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n");
+ return AVERROR(EINVAL);
+ }
+
s->strict_std_compliance = avctx->strict_std_compliance;
s->quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0;
s->rtp_mode = !!s->rtp_payload_size;
@@ -499,19 +511,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- if (s->max_b_frames &&
- s->codec_id != AV_CODEC_ID_MPEG4 &&
- s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
- s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
- av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n");
- return AVERROR(EINVAL);
- }
- if (s->max_b_frames < 0) {
- av_log(avctx, AV_LOG_ERROR,
- "max b frames must be 0 or positive for mpegvideo based encoders\n");
- return AVERROR(EINVAL);
- }
-
if ((s->codec_id == AV_CODEC_ID_MPEG4 ||
s->codec_id == AV_CODEC_ID_H263 ||
s->codec_id == AV_CODEC_ID_H263P) &&
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 23/33] avcodec/mpegvideo_enc: Don't hardcode list of codecs supporting bframes
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (2 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 22/33] avcodec/mpegvideo_enc: Localize check for invalid number of b-frames Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 24/33] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4 Andreas Rheinhardt
` (10 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Check for the encoder's AV_CODEC_CAP_DELAY instead.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_enc.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 920cb337a1..9a5634c505 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -357,10 +357,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
}
s->max_b_frames = avctx->max_b_frames;
s->codec_id = avctx->codec->id;
- if (s->max_b_frames &&
- s->codec_id != AV_CODEC_ID_MPEG4 &&
- s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
- s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
+ if (s->max_b_frames && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n");
return AVERROR(EINVAL);
}
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 24/33] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (3 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 23/33] avcodec/mpegvideo_enc: Don't hardcode list of codecs supporting bframes Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-27 10:13 ` Kieran Kunhya
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 25/33] avcodec/mpegvideo: Fix crash when using lowres with 10bit MPEG-4 Andreas Rheinhardt
` (9 subsequent siblings)
14 siblings, 1 reply; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Fixes visual corruptions on two macroblocks from two frames from
https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4447/A003C003_SR_422_23.98p.mxf
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index e9f2fb212a..47603c2991 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1648,8 +1648,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
int vsub = i ? s->chroma_y_shift : 0;
int hsub = i ? s->chroma_x_shift : 0;
dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub) - 1);
- for(h = (16 >> vsub)-1; h >= 1; h--){
- for(w = (16 >> hsub)-1; w >= 1; w--)
+ for (h = (16 >> vsub) - 1; h >= 0; h--) {
+ for (w = (16 >> hsub) - 1; w >= 0; w--)
dest_pcm[i][w] = (*s->dpcm_macroblock)[i][idx++];
dest_pcm[i] -= linesize[i] / 2;
}
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 25/33] avcodec/mpegvideo: Fix crash when using lowres with 10bit MPEG-4
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (4 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 24/33] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4 Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 26/33] fate/mpeg4: Add test for MPEG-4 Simple Studio Profile Andreas Rheinhardt
` (8 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
In this case the macroblocks written to are smaller, yet
the MPEG-4 Simple Studio Profile code for 10bit DPCM ignored this;
e.g. in case of lowres = 2 or = 3, the sample mpeg4_sstp_dpcm.m4v
from the FATE-suite reads beyond the end of the buffer.
This commit fixes this by taking lowres into account.
The DPCM macroblocks of the aforementioned sample look
as good as can be expected after this patch; yet the non-DPCM
coded macroblocks are simply corrupt.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 47603c2991..40494fe115 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1629,13 +1629,17 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
for(i = 0; i < 3; i++) {
+ const int16_t *src = (*s->dpcm_macroblock)[i];
int idx = 0;
int vsub = i ? s->chroma_y_shift : 0;
int hsub = i ? s->chroma_x_shift : 0;
- for(h = 0; h < (16 >> vsub); h++){
- for(w = 0; w < (16 >> hsub); w++)
- dest_pcm[i][w] = (*s->dpcm_macroblock)[i][idx++];
+ int lowres = lowres_flag ? s->avctx->lowres : 0;
+ int step = 1 << lowres;
+ for (h = 0; h < (16 >> (vsub + lowres)); h++){
+ for (w = 0, idx = 0; w < (16 >> (hsub + lowres)); w++, idx += step)
+ dest_pcm[i][w] = src[idx];
dest_pcm[i] += linesize[i] / 2;
+ src += (16 >> hsub) * step;
}
}
} else {
@@ -1644,13 +1648,17 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
av_assert2(s->dpcm_direction == -1);
for(i = 0; i < 3; i++) {
+ const int16_t *src = (*s->dpcm_macroblock)[i];
int idx = 0;
int vsub = i ? s->chroma_y_shift : 0;
int hsub = i ? s->chroma_x_shift : 0;
+ int lowres = lowres_flag ? s->avctx->lowres : 0;
+ int step = 1 << lowres;
dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub) - 1);
- for (h = (16 >> vsub) - 1; h >= 0; h--) {
- for (w = (16 >> hsub) - 1; w >= 0; w--)
- dest_pcm[i][w] = (*s->dpcm_macroblock)[i][idx++];
+ for (h = (16 >> (vsub + lowres)) - 1; h >= 0; h--){
+ for (w = (16 >> (hsub + lowres)) - 1, idx = 0; w >= 0; w--, idx += step)
+ dest_pcm[i][w] = src[idx];
+ src += step * (16 >> hsub);
dest_pcm[i] -= linesize[i] / 2;
}
}
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 26/33] fate/mpeg4: Add test for MPEG-4 Simple Studio Profile
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (5 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 25/33] avcodec/mpegvideo: Fix crash when using lowres with 10bit MPEG-4 Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 27/33] avcodec/mpegvideo: Move handling Simple Studio Profile to mpeg4videodec Andreas Rheinhardt
` (7 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The sample mpeg4/mpeg4_sstp_dpcm.m4v existed in the FATE-suite,
but it was surprisingly unused.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Will hopefully work on all arches.
tests/fate/mpeg4.mak | 5 +++++
tests/ref/fate/mpeg4-simple-studio-profile | 6 ++++++
2 files changed, 11 insertions(+)
create mode 100644 tests/ref/fate/mpeg4-simple-studio-profile
diff --git a/tests/fate/mpeg4.mak b/tests/fate/mpeg4.mak
index 26007f82f0..05c26b9be5 100644
--- a/tests/fate/mpeg4.mak
+++ b/tests/fate/mpeg4.mak
@@ -11,6 +11,11 @@ FATE_MPEG4-$(call ALLYES, AVI_DEMUXER MPEG4_UNPACK_BFRAMES_BSF AVI_MUXER) += fat
fate-mpeg4-packed: CMD = framecrc -flags +bitexact -idct simple -i $(TARGET_SAMPLES)/mpeg4/packed_bframes.avi -flags +bitexact -fflags +bitexact -vsync cfr
FATE_MPEG4-$(call ALLYES, AVI_DEMUXER MPEG4_DECODER) += fate-mpeg4-packed
+FATE_MPEG4-$(call ALLYES, FILE_PROTOCOL M4V_DEMUXER MPEG4_DECODER SCALE_FILTER \
+ RAWVIDEO_ENCODER FRAMECRC_MUXER PIPE_PROTOCOL) \
+ += fate-mpeg4-simple-studio-profile
+fate-mpeg4-simple-studio-profile: CMD = framecrc -bitexact -idct simple -i $(TARGET_SAMPLES)/mpeg4/mpeg4_sstp_dpcm.m4v -sws_flags +accurate_rnd+bitexact -pix_fmt yuv422p10le -vf scale
+
FATE_MPEG4-$(call DEMDEC, M4V, MPEG4) += fate-m4v fate-m4v-cfr
fate-m4v: CMD = framecrc -flags +bitexact -idct simple -i $(TARGET_SAMPLES)/mpeg4/demo.m4v
fate-m4v-cfr: CMD = framecrc -flags +bitexact -idct simple -i $(TARGET_SAMPLES)/mpeg4/demo.m4v -vf fps=5
diff --git a/tests/ref/fate/mpeg4-simple-studio-profile b/tests/ref/fate/mpeg4-simple-studio-profile
new file mode 100644
index 0000000000..303265ae1a
--- /dev/null
+++ b/tests/ref/fate/mpeg4-simple-studio-profile
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 720x480
+#sar 0: 1/1
+0, 0, 0, 1, 1382400, 0x3d252879
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 27/33] avcodec/mpegvideo: Move handling Simple Studio Profile to mpeg4videodec
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (6 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 26/33] fate/mpeg4: Add test for MPEG-4 Simple Studio Profile Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 28/33] avcodec/mpegvideo: Move MPEG-4 Simple Studio Profile fields to mpeg4video Andreas Rheinhardt
` (6 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This is its only user.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4video.h | 4 +++
libavcodec/mpeg4videodec.c | 62 +++++++++++++++++++++++++++++++++++
libavcodec/mpegvideo.c | 66 +++-----------------------------------
3 files changed, 71 insertions(+), 61 deletions(-)
diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index fd6b6f2863..08beb7f29f 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -119,6 +119,10 @@ typedef struct Mpeg4DecContext {
int rgb;
} Mpeg4DecContext;
+
+void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb,
+ uint8_t *dest_cr, int block_size, int uvlinesize,
+ int dct_linesize, int dct_offset);
void ff_mpeg4_encode_mb(MpegEncContext *s,
int16_t block[6][64],
int motion_x, int motion_y);
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index bdd320b1df..fb43ad2d17 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -67,6 +67,68 @@ static const int mb_type_b_map[4] = {
MB_TYPE_L0 | MB_TYPE_16x16,
};
+void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb,
+ uint8_t *dest_cr, int block_size, int uvlinesize,
+ int dct_linesize, int dct_offset)
+{
+ const int act_block_size = block_size * 2;
+
+ if (s->dpcm_direction == 0) {
+ s->idsp.idct_put(dest_y, dct_linesize, (int16_t*)(*s->block32)[0]);
+ s->idsp.idct_put(dest_y + act_block_size, dct_linesize, (int16_t*)(*s->block32)[1]);
+ s->idsp.idct_put(dest_y + dct_offset, dct_linesize, (int16_t*)(*s->block32)[2]);
+ s->idsp.idct_put(dest_y + dct_offset + act_block_size, dct_linesize, (int16_t*)(*s->block32)[3]);
+
+ dct_linesize = uvlinesize << s->interlaced_dct;
+ dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
+
+ s->idsp.idct_put(dest_cb, dct_linesize, (int16_t*)(*s->block32)[4]);
+ s->idsp.idct_put(dest_cr, dct_linesize, (int16_t*)(*s->block32)[5]);
+ s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, (int16_t*)(*s->block32)[6]);
+ s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, (int16_t*)(*s->block32)[7]);
+ if (!s->chroma_x_shift){ //Chroma444
+ s->idsp.idct_put(dest_cb + act_block_size, dct_linesize, (int16_t*)(*s->block32)[8]);
+ s->idsp.idct_put(dest_cr + act_block_size, dct_linesize, (int16_t*)(*s->block32)[9]);
+ s->idsp.idct_put(dest_cb + act_block_size + dct_offset, dct_linesize, (int16_t*)(*s->block32)[10]);
+ s->idsp.idct_put(dest_cr + act_block_size + dct_offset, dct_linesize, (int16_t*)(*s->block32)[11]);
+ }
+ } else if(s->dpcm_direction == 1) {
+ uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
+ int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
+ for (int i = 0; i < 3; i++) {
+ const uint16_t *src = (*s->dpcm_macroblock)[i];
+ int vsub = i ? s->chroma_y_shift : 0;
+ int hsub = i ? s->chroma_x_shift : 0;
+ int lowres = s->avctx->lowres;
+ int step = 1 << lowres;
+ for (int h = 0; h < (16 >> (vsub + lowres)); h++){
+ for (int w = 0, idx = 0; w < (16 >> (hsub + lowres)); w++, idx += step)
+ dest_pcm[i][w] = src[idx];
+ dest_pcm[i] += linesize[i] / 2;
+ src += (16 >> hsub) * step;
+ }
+ }
+ } else {
+ uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
+ int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
+ av_assert2(s->dpcm_direction == -1);
+ for (int i = 0; i < 3; i++) {
+ const uint16_t *src = (*s->dpcm_macroblock)[i];
+ int vsub = i ? s->chroma_y_shift : 0;
+ int hsub = i ? s->chroma_x_shift : 0;
+ int lowres = s->avctx->lowres;
+ int step = 1 << lowres;
+ dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub) - 1);
+ for (int h = (16 >> (vsub + lowres)) - 1; h >= 0; h--){
+ for (int w = (16 >> (hsub + lowres)) - 1, idx = 0; w >= 0; w--, idx += step)
+ dest_pcm[i][w] = src[idx];
+ src += step * (16 >> hsub);
+ dest_pcm[i] -= linesize[i] / 2;
+ }
+ }
+ }
+}
+
/**
* Predict the ac.
* @param n block index (0-3 are luma, 4-5 are chroma)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 40494fe115..a231ee52b7 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -40,6 +40,7 @@
#include "mpeg_er.h"
#include "mpegutils.h"
#include "mpegvideo.h"
+#include "mpeg4video.h"
#include "mpegvideodata.h"
#include "qpeldsp.h"
#include "thread.h"
@@ -1602,67 +1603,10 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
} else {
/* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */
- if (!is_mpeg12 && s->avctx->bits_per_raw_sample > 8) {
- const int act_block_size = block_size * 2;
-
- if(s->dpcm_direction == 0) {
- s->idsp.idct_put(dest_y, dct_linesize, (int16_t*)(*s->block32)[0]);
- s->idsp.idct_put(dest_y + act_block_size, dct_linesize, (int16_t*)(*s->block32)[1]);
- s->idsp.idct_put(dest_y + dct_offset, dct_linesize, (int16_t*)(*s->block32)[2]);
- s->idsp.idct_put(dest_y + dct_offset + act_block_size, dct_linesize, (int16_t*)(*s->block32)[3]);
-
- dct_linesize = uvlinesize << s->interlaced_dct;
- dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
-
- s->idsp.idct_put(dest_cb, dct_linesize, (int16_t*)(*s->block32)[4]);
- s->idsp.idct_put(dest_cr, dct_linesize, (int16_t*)(*s->block32)[5]);
- s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, (int16_t*)(*s->block32)[6]);
- s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, (int16_t*)(*s->block32)[7]);
- if(!s->chroma_x_shift){//Chroma444
- s->idsp.idct_put(dest_cb + act_block_size, dct_linesize, (int16_t*)(*s->block32)[8]);
- s->idsp.idct_put(dest_cr + act_block_size, dct_linesize, (int16_t*)(*s->block32)[9]);
- s->idsp.idct_put(dest_cb + act_block_size + dct_offset, dct_linesize, (int16_t*)(*s->block32)[10]);
- s->idsp.idct_put(dest_cr + act_block_size + dct_offset, dct_linesize, (int16_t*)(*s->block32)[11]);
- }
- } else if(s->dpcm_direction == 1) {
- int i, w, h;
- uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
- int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
- for(i = 0; i < 3; i++) {
- const int16_t *src = (*s->dpcm_macroblock)[i];
- int idx = 0;
- int vsub = i ? s->chroma_y_shift : 0;
- int hsub = i ? s->chroma_x_shift : 0;
- int lowres = lowres_flag ? s->avctx->lowres : 0;
- int step = 1 << lowres;
- for (h = 0; h < (16 >> (vsub + lowres)); h++){
- for (w = 0, idx = 0; w < (16 >> (hsub + lowres)); w++, idx += step)
- dest_pcm[i][w] = src[idx];
- dest_pcm[i] += linesize[i] / 2;
- src += (16 >> hsub) * step;
- }
- }
- } else {
- int i, w, h;
- uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
- int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
- av_assert2(s->dpcm_direction == -1);
- for(i = 0; i < 3; i++) {
- const int16_t *src = (*s->dpcm_macroblock)[i];
- int idx = 0;
- int vsub = i ? s->chroma_y_shift : 0;
- int hsub = i ? s->chroma_x_shift : 0;
- int lowres = lowres_flag ? s->avctx->lowres : 0;
- int step = 1 << lowres;
- dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub) - 1);
- for (h = (16 >> (vsub + lowres)) - 1; h >= 0; h--){
- for (w = (16 >> (hsub + lowres)) - 1, idx = 0; w >= 0; w--, idx += step)
- dest_pcm[i][w] = src[idx];
- src += step * (16 >> hsub);
- dest_pcm[i] -= linesize[i] / 2;
- }
- }
- }
+ if (!is_mpeg12 && CONFIG_MPEG4_DECODER && /* s->codec_id == AV_CODEC_ID_MPEG4 && */
+ s->avctx->bits_per_raw_sample > 8) {
+ ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
+ uvlinesize, dct_linesize, dct_offset);
}
/* dct only in intra block */
else if (IS_ENCODER(s) || !IS_MPEG12(s)) {
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 28/33] avcodec/mpegvideo: Move MPEG-4 Simple Studio Profile fields to mpeg4video
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (7 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 27/33] avcodec/mpegvideo: Move handling Simple Studio Profile to mpeg4videodec Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 29/33] avcodec/mpegpicture: Let ff_mpeg_unref_picture() free picture tables Andreas Rheinhardt
` (5 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This is possible now that dealing with the Simple Studio Profile
has been moved to mpeg4videodec.c. It also allows to avoid
allocations, because one can simply put the required buffers
on the context (if one made these buffers part of MpegEncContext,
the memory would be wasted for every codec other than MPEG-4).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4video.h | 5 +++++
libavcodec/mpeg4videodec.c | 44 ++++++++++++++++++++------------------
libavcodec/mpegvideo.c | 13 -----------
libavcodec/mpegvideo.h | 4 ----
4 files changed, 28 insertions(+), 38 deletions(-)
diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 08beb7f29f..9fc79b1a22 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -117,6 +117,11 @@ typedef struct Mpeg4DecContext {
int cplx_estimation_trash_b;
int rgb;
+
+ int32_t block32[12][64];
+ // 0 = DCT, 1 = DPCM top to bottom scan, -1 = DPCM bottom to top scan
+ int dpcm_direction;
+ int16_t dpcm_macroblock[3][256];
} Mpeg4DecContext;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index fb43ad2d17..b8118ff2d2 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -71,32 +71,33 @@ void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb
uint8_t *dest_cr, int block_size, int uvlinesize,
int dct_linesize, int dct_offset)
{
+ Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
const int act_block_size = block_size * 2;
- if (s->dpcm_direction == 0) {
- s->idsp.idct_put(dest_y, dct_linesize, (int16_t*)(*s->block32)[0]);
- s->idsp.idct_put(dest_y + act_block_size, dct_linesize, (int16_t*)(*s->block32)[1]);
- s->idsp.idct_put(dest_y + dct_offset, dct_linesize, (int16_t*)(*s->block32)[2]);
- s->idsp.idct_put(dest_y + dct_offset + act_block_size, dct_linesize, (int16_t*)(*s->block32)[3]);
+ if (ctx->dpcm_direction == 0) {
+ s->idsp.idct_put(dest_y, dct_linesize, (int16_t*)ctx->block32[0]);
+ s->idsp.idct_put(dest_y + act_block_size, dct_linesize, (int16_t*)ctx->block32[1]);
+ s->idsp.idct_put(dest_y + dct_offset, dct_linesize, (int16_t*)ctx->block32[2]);
+ s->idsp.idct_put(dest_y + dct_offset + act_block_size, dct_linesize, (int16_t*)ctx->block32[3]);
dct_linesize = uvlinesize << s->interlaced_dct;
dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
- s->idsp.idct_put(dest_cb, dct_linesize, (int16_t*)(*s->block32)[4]);
- s->idsp.idct_put(dest_cr, dct_linesize, (int16_t*)(*s->block32)[5]);
- s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, (int16_t*)(*s->block32)[6]);
- s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, (int16_t*)(*s->block32)[7]);
+ s->idsp.idct_put(dest_cb, dct_linesize, (int16_t*)ctx->block32[4]);
+ s->idsp.idct_put(dest_cr, dct_linesize, (int16_t*)ctx->block32[5]);
+ s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, (int16_t*)ctx->block32[6]);
+ s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, (int16_t*)ctx->block32[7]);
if (!s->chroma_x_shift){ //Chroma444
- s->idsp.idct_put(dest_cb + act_block_size, dct_linesize, (int16_t*)(*s->block32)[8]);
- s->idsp.idct_put(dest_cr + act_block_size, dct_linesize, (int16_t*)(*s->block32)[9]);
- s->idsp.idct_put(dest_cb + act_block_size + dct_offset, dct_linesize, (int16_t*)(*s->block32)[10]);
- s->idsp.idct_put(dest_cr + act_block_size + dct_offset, dct_linesize, (int16_t*)(*s->block32)[11]);
+ s->idsp.idct_put(dest_cb + act_block_size, dct_linesize, (int16_t*)ctx->block32[8]);
+ s->idsp.idct_put(dest_cr + act_block_size, dct_linesize, (int16_t*)ctx->block32[9]);
+ s->idsp.idct_put(dest_cb + act_block_size + dct_offset, dct_linesize, (int16_t*)ctx->block32[10]);
+ s->idsp.idct_put(dest_cr + act_block_size + dct_offset, dct_linesize, (int16_t*)ctx->block32[11]);
}
- } else if(s->dpcm_direction == 1) {
+ } else if (ctx->dpcm_direction == 1) {
uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
for (int i = 0; i < 3; i++) {
- const uint16_t *src = (*s->dpcm_macroblock)[i];
+ const uint16_t *src = ctx->dpcm_macroblock[i];
int vsub = i ? s->chroma_y_shift : 0;
int hsub = i ? s->chroma_x_shift : 0;
int lowres = s->avctx->lowres;
@@ -111,9 +112,9 @@ void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb
} else {
uint16_t *dest_pcm[3] = {(uint16_t*)dest_y, (uint16_t*)dest_cb, (uint16_t*)dest_cr};
int linesize[3] = {dct_linesize, uvlinesize, uvlinesize};
- av_assert2(s->dpcm_direction == -1);
+ av_assert2(ctx->dpcm_direction == -1);
for (int i = 0; i < 3; i++) {
- const uint16_t *src = (*s->dpcm_macroblock)[i];
+ const uint16_t *src = ctx->dpcm_macroblock[i];
int vsub = i ? s->chroma_y_shift : 0;
int hsub = i ? s->chroma_x_shift : 0;
int lowres = s->avctx->lowres;
@@ -2078,9 +2079,10 @@ static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[25
static int mpeg4_decode_studio_mb(MpegEncContext *s, int16_t block_[12][64])
{
+ Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
int i;
- s->dpcm_direction = 0;
+ ctx->dpcm_direction = 0;
/* StudioMacroblock */
/* Assumes I-VOP */
@@ -2094,15 +2096,15 @@ static int mpeg4_decode_studio_mb(MpegEncContext *s, int16_t block_[12][64])
}
for (i = 0; i < mpeg4_block_count[s->chroma_format]; i++) {
- if (mpeg4_decode_studio_block(s, (*s->block32)[i], i) < 0)
+ if (mpeg4_decode_studio_block(s, ctx->block32[i], i) < 0)
return AVERROR_INVALIDDATA;
}
} else {
/* DPCM */
check_marker(s->avctx, &s->gb, "DPCM block start");
- s->dpcm_direction = get_bits1(&s->gb) ? -1 : 1;
+ ctx->dpcm_direction = get_bits1(&s->gb) ? -1 : 1;
for (i = 0; i < 3; i++) {
- if (mpeg4_decode_dpcm_macroblock(s, (*s->dpcm_macroblock)[i], i) < 0)
+ if (mpeg4_decode_dpcm_macroblock(s, ctx->dpcm_macroblock[i], i) < 0)
return AVERROR_INVALIDDATA;
}
}
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index a231ee52b7..3b889e0791 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -378,11 +378,6 @@ static int init_duplicate_context(MpegEncContext *s)
}
if (s->out_format == FMT_H263) {
- if (!(s->block32 = av_mallocz(sizeof(*s->block32))) ||
- !(s->dpcm_macroblock = av_mallocz(sizeof(*s->dpcm_macroblock))))
- return AVERROR(ENOMEM);
- s->dpcm_direction = 0;
-
/* ac values */
if (!FF_ALLOCZ_TYPED_ARRAY(s->ac_val_base, yc_size))
return AVERROR(ENOMEM);
@@ -434,8 +429,6 @@ static void free_duplicate_context(MpegEncContext *s)
av_freep(&s->me.map);
av_freep(&s->me.score_map);
av_freep(&s->blocks);
- av_freep(&s->block32);
- av_freep(&s->dpcm_macroblock);
av_freep(&s->ac_val_base);
s->block = NULL;
}
@@ -462,9 +455,6 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src)
COPY(me.score_map);
COPY(blocks);
COPY(block);
- COPY(block32);
- COPY(dpcm_macroblock);
- COPY(dpcm_direction);
COPY(start_mb_y);
COPY(end_mb_y);
COPY(me.map_generation);
@@ -678,10 +668,7 @@ static void clear_context(MpegEncContext *s)
s->dct_error_sum = NULL;
s->block = NULL;
s->blocks = NULL;
- s->block32 = NULL;
memset(s->pblocks, 0, sizeof(s->pblocks));
- s->dpcm_direction = 0;
- s->dpcm_macroblock = NULL;
s->ac_val_base = NULL;
s->ac_val[0] =
s->ac_val[1] =
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 0b76a460c9..325f62e01f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -479,10 +479,6 @@ typedef struct MpegEncContext {
int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block
int (*decode_mb)(struct MpegEncContext *s, int16_t block[12][64]); // used by some codecs to avoid a switch()
- int32_t (*block32)[12][64];
- int dpcm_direction; // 0 = DCT, 1 = DPCM top to bottom scan, -1 = DPCM bottom to top scan
- int16_t (*dpcm_macroblock)[3][256];
-
#define SLICE_OK 0
#define SLICE_ERROR -1
#define SLICE_END -2 ///<end marker found
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 29/33] avcodec/mpegpicture: Let ff_mpeg_unref_picture() free picture tables
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (8 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 28/33] avcodec/mpegvideo: Move MPEG-4 Simple Studio Profile fields to mpeg4video Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 30/33] avcodec/mpegpicture: Add function to completely free MPEG-Picture Andreas Rheinhardt
` (4 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegpicture.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 0652b7c879..f78a3c23e3 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -290,7 +290,8 @@ fail:
}
/**
- * Deallocate a picture.
+ * Deallocate a picture; frees the picture tables in case they
+ * need to be reallocated anyway.
*/
void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
{
@@ -443,8 +444,6 @@ int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
if (ret >= 0 && ret < MAX_PICTURE_COUNT) {
if (picture[ret].needs_realloc) {
- picture[ret].needs_realloc = 0;
- ff_free_picture_tables(&picture[ret]);
ff_mpeg_unref_picture(avctx, &picture[ret]);
}
}
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 30/33] avcodec/mpegpicture: Add function to completely free MPEG-Picture
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (9 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 29/33] avcodec/mpegpicture: Let ff_mpeg_unref_picture() free picture tables Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-27 14:21 ` James Almer
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 31/33] avcodec/h264data: Add missing rational.h inclusion Andreas Rheinhardt
` (3 subsequent siblings)
14 siblings, 1 reply; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Also use said function in mpegvideo.c and mpegvideo_enc.c;
and make ff_free_picture_tables() static as it isn't needed anymore
outside of mpegpicture.c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
The new_picture is actually only used by encoders;
if it were not for svq1enc (which relies on ff_mpv_common_init()
and ff_mpv_common_end() to allocate and free it), I'd have moved
everything related to it to mpegvideo_enc.c. I probably do it later
anyway.
(And yes, I am aware of the fact that freeing this frame in
ff_mpv_encode_end() is redundant.)
libavcodec/mpegpicture.c | 47 +++++++++++++++++++++-----------------
libavcodec/mpegpicture.h | 2 +-
libavcodec/mpegvideo.c | 25 +++++---------------
libavcodec/mpegvideo_enc.c | 3 +--
4 files changed, 34 insertions(+), 43 deletions(-)
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index f78a3c23e3..349ab81055 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -30,6 +30,24 @@
#include "mpegpicture.h"
#include "mpegutils.h"
+static void av_noinline free_picture_tables(Picture *pic)
+{
+ pic->alloc_mb_width =
+ pic->alloc_mb_height = 0;
+
+ av_buffer_unref(&pic->mb_var_buf);
+ av_buffer_unref(&pic->mc_mb_var_buf);
+ av_buffer_unref(&pic->mb_mean_buf);
+ av_buffer_unref(&pic->mbskip_table_buf);
+ av_buffer_unref(&pic->qscale_table_buf);
+ av_buffer_unref(&pic->mb_type_buf);
+
+ for (int i = 0; i < 2; i++) {
+ av_buffer_unref(&pic->motion_val_buf[i]);
+ av_buffer_unref(&pic->ref_index_buf[i]);
+ }
+}
+
static int make_tables_writable(Picture *pic)
{
int ret, i;
@@ -240,7 +258,7 @@ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
if (pic->qscale_table_buf)
if ( pic->alloc_mb_width != mb_width
|| pic->alloc_mb_height != mb_height)
- ff_free_picture_tables(pic);
+ free_picture_tables(pic);
if (shared) {
av_assert0(pic->f->data[0]);
@@ -285,7 +303,7 @@ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
fail:
av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
ff_mpeg_unref_picture(avctx, pic);
- ff_free_picture_tables(pic);
+ free_picture_tables(pic);
return AVERROR(ENOMEM);
}
@@ -310,7 +328,7 @@ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
av_buffer_unref(&pic->hwaccel_priv_buf);
if (pic->needs_realloc)
- ff_free_picture_tables(pic);
+ free_picture_tables(pic);
memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
}
@@ -331,7 +349,7 @@ int ff_update_picture_tables(Picture *dst, Picture *src)
}
if (ret < 0) {
- ff_free_picture_tables(dst);
+ free_picture_tables(dst);
return ret;
}
@@ -450,22 +468,9 @@ int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
return ret;
}
-void ff_free_picture_tables(Picture *pic)
+void av_cold ff_free_picture(AVCodecContext *avctx, Picture *pic)
{
- int i;
-
- pic->alloc_mb_width =
- pic->alloc_mb_height = 0;
-
- av_buffer_unref(&pic->mb_var_buf);
- av_buffer_unref(&pic->mc_mb_var_buf);
- av_buffer_unref(&pic->mb_mean_buf);
- av_buffer_unref(&pic->mbskip_table_buf);
- av_buffer_unref(&pic->qscale_table_buf);
- av_buffer_unref(&pic->mb_type_buf);
-
- for (i = 0; i < 2; i++) {
- av_buffer_unref(&pic->motion_val_buf[i]);
- av_buffer_unref(&pic->ref_index_buf[i]);
- }
+ free_picture_tables(pic);
+ ff_mpeg_unref_picture(avctx, pic);
+ av_frame_free(&pic->f);
}
diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index a354c2a83c..cee16c07d3 100644
--- a/libavcodec/mpegpicture.h
+++ b/libavcodec/mpegpicture.h
@@ -108,7 +108,7 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src);
void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture);
-void ff_free_picture_tables(Picture *pic);
+void ff_free_picture(AVCodecContext *avctx, Picture *pic);
int ff_update_picture_tables(Picture *dst, Picture *src);
int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared);
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 3b889e0791..7c63c738f3 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -874,8 +874,6 @@ void ff_mpv_free_context_frame(MpegEncContext *s)
/* init common structure for both encoder and decoder */
void ff_mpv_common_end(MpegEncContext *s)
{
- int i;
-
if (!s)
return;
@@ -895,25 +893,14 @@ void ff_mpv_common_end(MpegEncContext *s)
return;
if (s->picture) {
- for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- ff_free_picture_tables(&s->picture[i]);
- ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
- av_frame_free(&s->picture[i].f);
- }
+ for (int i = 0; i < MAX_PICTURE_COUNT; i++)
+ ff_free_picture(s->avctx, &s->picture[i]);
}
av_freep(&s->picture);
- ff_free_picture_tables(&s->last_picture);
- ff_mpeg_unref_picture(s->avctx, &s->last_picture);
- av_frame_free(&s->last_picture.f);
- ff_free_picture_tables(&s->current_picture);
- ff_mpeg_unref_picture(s->avctx, &s->current_picture);
- av_frame_free(&s->current_picture.f);
- ff_free_picture_tables(&s->next_picture);
- ff_mpeg_unref_picture(s->avctx, &s->next_picture);
- av_frame_free(&s->next_picture.f);
- ff_free_picture_tables(&s->new_picture);
- ff_mpeg_unref_picture(s->avctx, &s->new_picture);
- av_frame_free(&s->new_picture.f);
+ ff_free_picture(s->avctx, &s->last_picture);
+ ff_free_picture(s->avctx, &s->current_picture);
+ ff_free_picture(s->avctx, &s->next_picture);
+ ff_free_picture(s->avctx, &s->new_picture);
s->context_initialized = 0;
s->context_reinit = 0;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 9a5634c505..baa45d20ab 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -941,8 +941,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++)
av_frame_free(&s->tmp_frames[i]);
- ff_free_picture_tables(&s->new_picture);
- ff_mpeg_unref_picture(avctx, &s->new_picture);
+ ff_free_picture(avctx, &s->new_picture);
av_freep(&avctx->stats_out);
av_freep(&s->ac_stats);
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 31/33] avcodec/h264data: Add missing rational.h inclusion
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (10 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 30/33] avcodec/mpegpicture: Add function to completely free MPEG-Picture Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 32/33] avcodec/mpegvideo: Use offset instead of pointer for vbv_delay Andreas Rheinhardt
` (2 subsequent siblings)
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Fixes checkheaders.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264data.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h
index 988352aa9a..4efe76a34d 100644
--- a/libavcodec/h264data.h
+++ b/libavcodec/h264data.h
@@ -21,6 +21,7 @@
#include <stdint.h>
+#include "libavutil/rational.h"
#include "h264.h"
extern const uint8_t ff_h264_golomb_to_pict_type[5];
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 32/33] avcodec/mpegvideo: Use offset instead of pointer for vbv_delay
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (11 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 31/33] avcodec/h264data: Add missing rational.h inclusion Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 33/33] avcodec/mpeg4videodec: Move use_intra_dc_vlc to stack, fix data race Andreas Rheinhardt
2022-01-28 11:36 ` [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
An offset has the advantage of not needing to be updated
when the buffer is reallocated. Furthermore, the way the pointer
is currently updated is undefined behaviour in case the pointer
is not already set (i.e. when not encoding MPEG-1/2), because
it calculates the nonsense NULL - s->pb.buf.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 2 +-
libavcodec/mpegvideo.h | 2 +-
libavcodec/mpegvideo_enc.c | 15 +++++++--------
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index ecb90d1a41..9c0be69ded 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -465,7 +465,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
(s->picture_number - mpeg12->gop_picture_number) & 0x3ff);
put_bits(&s->pb, 3, s->pict_type);
- s->vbv_delay_ptr = s->pb.buf + put_bytes_count(&s->pb, 0);
+ s->vbv_delay_pos = put_bytes_count(&s->pb, 0);
put_bits(&s->pb, 16, 0xFFFF); /* vbv_delay */
// RAL: Forward f_code also needed for B-frames
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 325f62e01f..fa0ea51046 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -429,7 +429,7 @@ typedef struct MpegEncContext {
/* MPEG-1 specific */
int last_mv_dir; ///< last mv_dir, used for B-frame encoding
- uint8_t *vbv_delay_ptr; ///< pointer to vbv_delay in the bitstream
+ int vbv_delay_pos; ///< offset of vbv_delay in the bitstream
/* MPEG-2-specific - I wished not to have to support this mess. */
int progressive_sequence;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index baa45d20ab..d27a74f9e0 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1840,8 +1840,9 @@ vbv_retry:
double inbits = avctx->rc_max_rate *
av_q2d(avctx->time_base);
int minbits = s->frame_bits - 8 *
- (s->vbv_delay_ptr - s->pb.buf - 1);
+ (s->vbv_delay_pos - 1);
double bits = s->rc_context.buffer_index + minbits - inbits;
+ uint8_t *const vbv_delay_ptr = s->pb.buf + s->vbv_delay_pos;
if (bits < 0)
av_log(avctx, AV_LOG_ERROR,
@@ -1857,11 +1858,11 @@ vbv_retry:
av_assert0(vbv_delay < 0xFFFF);
- s->vbv_delay_ptr[0] &= 0xF8;
- s->vbv_delay_ptr[0] |= vbv_delay >> 13;
- s->vbv_delay_ptr[1] = vbv_delay >> 5;
- s->vbv_delay_ptr[2] &= 0x07;
- s->vbv_delay_ptr[2] |= vbv_delay << 3;
+ vbv_delay_ptr[0] &= 0xF8;
+ vbv_delay_ptr[0] |= vbv_delay >> 13;
+ vbv_delay_ptr[1] = vbv_delay >> 5;
+ vbv_delay_ptr[2] &= 0x07;
+ vbv_delay_ptr[2] |= vbv_delay << 3;
props = av_cpb_properties_alloc(&props_size);
if (!props)
@@ -2721,7 +2722,6 @@ int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t s
&& s->slice_context_count == 1
&& s->pb.buf == s->avctx->internal->byte_buffer) {
int lastgob_pos = s->ptr_lastgob - s->pb.buf;
- int vbv_pos = s->vbv_delay_ptr - s->pb.buf;
uint8_t *new_buffer = NULL;
int new_buffer_size = 0;
@@ -2744,7 +2744,6 @@ int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t s
s->avctx->internal->byte_buffer_size = new_buffer_size;
rebase_put_bits(&s->pb, new_buffer, new_buffer_size);
s->ptr_lastgob = s->pb.buf + lastgob_pos;
- s->vbv_delay_ptr = s->pb.buf + vbv_pos;
}
if (put_bytes_left(&s->pb, 0) < threshold)
return AVERROR(EINVAL);
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* [FFmpeg-devel] [PATCH 33/33] avcodec/mpeg4videodec: Move use_intra_dc_vlc to stack, fix data race
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (12 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 32/33] avcodec/mpegvideo: Use offset instead of pointer for vbv_delay Andreas Rheinhardt
@ 2022-01-26 21:34 ` Andreas Rheinhardt
2022-01-28 11:36 ` [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-26 21:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
use_intra_dc_vlc is currently kept in sync between frame threads
in mpeg4_update_thread_context(), yet it is set when decoding
blocks, i.e. after ff_thread_finish_setup(). This is a data race
and therefore undefined behaviour.
This race can be fixed easily by moving the variable from the context
to the stack: use_intra_dc_vlc is only read in
mpeg4_decode_block() and only if one is decoding an intra block.
There are three callsites for this function: One in
mpeg4_decode_partitioned_mb() which always sets use_intra_dc_vlc
before the call and two in mpeg4_decode_mb(). One of these callsites
is for intra blocks and use_intra_dc_vlc is set before it;
the last callsite is for non-intra blocks, where use_intra_dc_vlc
is ignored. So if it is used, it always uses a new value and can
therefore be moved to the stack.
The above also explains why this data race did not lead to
FATE-test failures.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg4video.h | 1 -
libavcodec/mpeg4videodec.c | 24 ++++++++++++++----------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 9fc79b1a22..14fc5e1396 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -94,7 +94,6 @@ typedef struct Mpeg4DecContext {
int new_pred;
int enhancement_type;
int scalability;
- int use_intra_dc_vlc;
/// QP above which the ac VLC should be used for intra dc
int intra_dc_threshold;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index b8118ff2d2..2aea845580 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1105,7 +1105,8 @@ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
* @return <0 if an error occurred
*/
static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
- int n, int coded, int intra, int rvlc)
+ int n, int coded, int intra,
+ int use_intra_dc_vlc, int rvlc)
{
MpegEncContext *s = &ctx->m;
int level, i, last, run, qmul, qadd;
@@ -1117,7 +1118,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
// Note intra & rvlc should be optimized away if this is inlined
if (intra) {
- if (ctx->use_intra_dc_vlc) {
+ if (use_intra_dc_vlc) {
/* DC coef */
if (s->partitioned_frame) {
level = s->dc_val[0][s->block_index[n]];
@@ -1357,7 +1358,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
not_coded:
if (intra) {
- if (!ctx->use_intra_dc_vlc) {
+ if (!use_intra_dc_vlc) {
block[0] = ff_mpeg4_pred_dc(s, n, block[0], &dc_pred_dir, 0);
i -= i >> 31; // if (i == -1) i = 0;
@@ -1378,7 +1379,7 @@ not_coded:
static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
{
Mpeg4DecContext *ctx = s->avctx->priv_data;
- int cbp, mb_type;
+ int cbp, mb_type, use_intra_dc_vlc;
const int xy = s->mb_x + s->mb_y * s->mb_stride;
av_assert2(s == (void*)ctx);
@@ -1386,7 +1387,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
mb_type = s->current_picture.mb_type[xy];
cbp = s->cbp_table[xy];
- ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
+ use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
if (s->current_picture.qscale_table[xy] != s->qscale)
ff_set_qscale(s, s->current_picture.qscale_table[xy]);
@@ -1436,7 +1437,8 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
s->bdsp.clear_blocks(s->block[0]);
/* decode each block */
for (i = 0; i < 6; i++) {
- if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, s->mb_intra, ctx->rvlc) < 0) {
+ if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, s->mb_intra,
+ use_intra_dc_vlc, ctx->rvlc) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"texture corrupted at %d %d %d\n",
s->mb_x, s->mb_y, s->mb_intra);
@@ -1763,6 +1765,8 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
}
s->current_picture.mb_type[xy] = mb_type;
} else { /* I-Frame */
+ int use_intra_dc_vlc;
+
do {
cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
if (cbpc < 0) {
@@ -1790,7 +1794,7 @@ intra:
}
cbp = (cbpc & 3) | (cbpy << 2);
- ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
+ use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
if (dquant)
ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
@@ -1801,7 +1805,8 @@ intra:
s->bdsp.clear_blocks(s->block[0]);
/* decode each block */
for (i = 0; i < 6; i++) {
- if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 1, 0) < 0)
+ if (mpeg4_decode_block(ctx, block[i], i, cbp & 32,
+ 1, use_intra_dc_vlc, 0) < 0)
return AVERROR_INVALIDDATA;
cbp += cbp;
}
@@ -1810,7 +1815,7 @@ intra:
/* decode each block */
for (i = 0; i < 6; i++) {
- if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 0, 0) < 0)
+ if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 0, 0, 0) < 0)
return AVERROR_INVALIDDATA;
cbp += cbp;
}
@@ -3529,7 +3534,6 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
s->new_pred = s1->new_pred;
s->enhancement_type = s1->enhancement_type;
s->scalability = s1->scalability;
- s->use_intra_dc_vlc = s1->use_intra_dc_vlc;
s->intra_dc_threshold = s1->intra_dc_threshold;
s->divx_version = s1->divx_version;
s->divx_build = s1->divx_build;
--
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".
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [FFmpeg-devel] [PATCH 24/33] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 24/33] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4 Andreas Rheinhardt
@ 2022-01-27 10:13 ` Kieran Kunhya
0 siblings, 0 replies; 37+ messages in thread
From: Kieran Kunhya @ 2022-01-27 10:13 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt
On Wed, 26 Jan 2022 at 21:35, Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:
> Fixes visual corruptions on two macroblocks from two frames from
>
> https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4447/A003C003_SR_422_23.98p.mxf
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/mpegvideo.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index e9f2fb212a..47603c2991 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -1648,8 +1648,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s,
> int16_t block[12][64],
> int vsub = i ? s->chroma_y_shift : 0;
> int hsub = i ? s->chroma_x_shift : 0;
> dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub)
> - 1);
> - for(h = (16 >> vsub)-1; h >= 1; h--){
> - for(w = (16 >> hsub)-1; w >= 1; w--)
> + for (h = (16 >> vsub) - 1; h >= 0; h--) {
> + for (w = (16 >> hsub) - 1; w >= 0; w--)
> dest_pcm[i][w] =
> (*s->dpcm_macroblock)[i][idx++];
> dest_pcm[i] -= linesize[i] / 2;
> }
> --
> 2.32.0
>
Seems fine
Kieran
_______________________________________________
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] 37+ messages in thread
* Re: [FFmpeg-devel] [PATCH 30/33] avcodec/mpegpicture: Add function to completely free MPEG-Picture
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 30/33] avcodec/mpegpicture: Add function to completely free MPEG-Picture Andreas Rheinhardt
@ 2022-01-27 14:21 ` James Almer
2022-01-27 14:35 ` Andreas Rheinhardt
0 siblings, 1 reply; 37+ messages in thread
From: James Almer @ 2022-01-27 14:21 UTC (permalink / raw)
To: ffmpeg-devel
On 1/26/2022 6:34 PM, Andreas Rheinhardt wrote:
> Also use said function in mpegvideo.c and mpegvideo_enc.c;
> and make ff_free_picture_tables() static as it isn't needed anymore
> outside of mpegpicture.c.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> The new_picture is actually only used by encoders;
> if it were not for svq1enc (which relies on ff_mpv_common_init()
> and ff_mpv_common_end() to allocate and free it), I'd have moved
> everything related to it to mpegvideo_enc.c. I probably do it later
> anyway.
> (And yes, I am aware of the fact that freeing this frame in
> ff_mpv_encode_end() is redundant.)
>
> libavcodec/mpegpicture.c | 47 +++++++++++++++++++++-----------------
> libavcodec/mpegpicture.h | 2 +-
> libavcodec/mpegvideo.c | 25 +++++---------------
> libavcodec/mpegvideo_enc.c | 3 +--
> 4 files changed, 34 insertions(+), 43 deletions(-)
>
> diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
> index f78a3c23e3..349ab81055 100644
> --- a/libavcodec/mpegpicture.c
> +++ b/libavcodec/mpegpicture.c
> @@ -30,6 +30,24 @@
> #include "mpegpicture.h"
> #include "mpegutils.h"
>
> +static void av_noinline free_picture_tables(Picture *pic)
> +{
> + pic->alloc_mb_width =
> + pic->alloc_mb_height = 0;
> +
> + av_buffer_unref(&pic->mb_var_buf);
> + av_buffer_unref(&pic->mc_mb_var_buf);
> + av_buffer_unref(&pic->mb_mean_buf);
> + av_buffer_unref(&pic->mbskip_table_buf);
> + av_buffer_unref(&pic->qscale_table_buf);
> + av_buffer_unref(&pic->mb_type_buf);
> +
> + for (int i = 0; i < 2; i++) {
> + av_buffer_unref(&pic->motion_val_buf[i]);
> + av_buffer_unref(&pic->ref_index_buf[i]);
> + }
> +}
> +
> static int make_tables_writable(Picture *pic)
> {
> int ret, i;
> @@ -240,7 +258,7 @@ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
> if (pic->qscale_table_buf)
> if ( pic->alloc_mb_width != mb_width
> || pic->alloc_mb_height != mb_height)
> - ff_free_picture_tables(pic);
> + free_picture_tables(pic);
>
> if (shared) {
> av_assert0(pic->f->data[0]);
> @@ -285,7 +303,7 @@ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
> fail:
> av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
> ff_mpeg_unref_picture(avctx, pic);
> - ff_free_picture_tables(pic);
> + free_picture_tables(pic);
> return AVERROR(ENOMEM);
> }
>
> @@ -310,7 +328,7 @@ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
> av_buffer_unref(&pic->hwaccel_priv_buf);
>
> if (pic->needs_realloc)
> - ff_free_picture_tables(pic);
> + free_picture_tables(pic);
>
> memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
> }
> @@ -331,7 +349,7 @@ int ff_update_picture_tables(Picture *dst, Picture *src)
> }
>
> if (ret < 0) {
> - ff_free_picture_tables(dst);
> + free_picture_tables(dst);
> return ret;
> }
>
> @@ -450,22 +468,9 @@ int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
> return ret;
> }
>
> -void ff_free_picture_tables(Picture *pic)
> +void av_cold ff_free_picture(AVCodecContext *avctx, Picture *pic)
> {
> - int i;
> -
> - pic->alloc_mb_width =
> - pic->alloc_mb_height = 0;
> -
> - av_buffer_unref(&pic->mb_var_buf);
> - av_buffer_unref(&pic->mc_mb_var_buf);
> - av_buffer_unref(&pic->mb_mean_buf);
> - av_buffer_unref(&pic->mbskip_table_buf);
> - av_buffer_unref(&pic->qscale_table_buf);
> - av_buffer_unref(&pic->mb_type_buf);
> -
> - for (i = 0; i < 2; i++) {
> - av_buffer_unref(&pic->motion_val_buf[i]);
> - av_buffer_unref(&pic->ref_index_buf[i]);
> - }
> + free_picture_tables(pic);
> + ff_mpeg_unref_picture(avctx, pic);
> + av_frame_free(&pic->f);
> }
> diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
> index a354c2a83c..cee16c07d3 100644
> --- a/libavcodec/mpegpicture.h
> +++ b/libavcodec/mpegpicture.h
> @@ -108,7 +108,7 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
> int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src);
> void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture);
>
> -void ff_free_picture_tables(Picture *pic);
> +void ff_free_picture(AVCodecContext *avctx, Picture *pic);
> int ff_update_picture_tables(Picture *dst, Picture *src);
>
> int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared);
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index 3b889e0791..7c63c738f3 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -874,8 +874,6 @@ void ff_mpv_free_context_frame(MpegEncContext *s)
> /* init common structure for both encoder and decoder */
> void ff_mpv_common_end(MpegEncContext *s)
> {
> - int i;
> -
> if (!s)
> return;
>
> @@ -895,25 +893,14 @@ void ff_mpv_common_end(MpegEncContext *s)
> return;
>
> if (s->picture) {
> - for (i = 0; i < MAX_PICTURE_COUNT; i++) {
> - ff_free_picture_tables(&s->picture[i]);
> - ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
> - av_frame_free(&s->picture[i].f);
> - }
> + for (int i = 0; i < MAX_PICTURE_COUNT; i++)
> + ff_free_picture(s->avctx, &s->picture[i]);
> }
> av_freep(&s->picture);
> - ff_free_picture_tables(&s->last_picture);
> - ff_mpeg_unref_picture(s->avctx, &s->last_picture);
> - av_frame_free(&s->last_picture.f);
> - ff_free_picture_tables(&s->current_picture);
> - ff_mpeg_unref_picture(s->avctx, &s->current_picture);
> - av_frame_free(&s->current_picture.f);
> - ff_free_picture_tables(&s->next_picture);
> - ff_mpeg_unref_picture(s->avctx, &s->next_picture);
> - av_frame_free(&s->next_picture.f);
> - ff_free_picture_tables(&s->new_picture);
> - ff_mpeg_unref_picture(s->avctx, &s->new_picture);
> - av_frame_free(&s->new_picture.f);
> + ff_free_picture(s->avctx, &s->last_picture);
> + ff_free_picture(s->avctx, &s->current_picture);
> + ff_free_picture(s->avctx, &s->next_picture);
> + ff_free_picture(s->avctx, &s->new_picture);
>
> s->context_initialized = 0;
> s->context_reinit = 0;
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index 9a5634c505..baa45d20ab 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -941,8 +941,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
> for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++)
> av_frame_free(&s->tmp_frames[i]);
>
> - ff_free_picture_tables(&s->new_picture);
> - ff_mpeg_unref_picture(avctx, &s->new_picture);
> + ff_free_picture(avctx, &s->new_picture);
These names are too generic for what's apparently specific to mpeg.
ff_free_picture (And the struct being called Picture) could apply to
anything.
Maybe the functions should all use the ff_mpeg_ namespace, and the
struct be renamed to MPEGPicture, following decoders like h264 and hevc.
I'm not telling you to do it if you don't want to, just throwing the
idea out there. But IMO at least call the new function
ff_mpeg_free_picture().
>
> av_freep(&avctx->stats_out);
> av_freep(&s->ac_stats);
_______________________________________________
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] 37+ messages in thread
* Re: [FFmpeg-devel] [PATCH 30/33] avcodec/mpegpicture: Add function to completely free MPEG-Picture
2022-01-27 14:21 ` James Almer
@ 2022-01-27 14:35 ` Andreas Rheinhardt
0 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-27 14:35 UTC (permalink / raw)
To: ffmpeg-devel
James Almer:
>
>
> On 1/26/2022 6:34 PM, Andreas Rheinhardt wrote:
>> Also use said function in mpegvideo.c and mpegvideo_enc.c;
>> and make ff_free_picture_tables() static as it isn't needed anymore
>> outside of mpegpicture.c.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>> The new_picture is actually only used by encoders;
>> if it were not for svq1enc (which relies on ff_mpv_common_init()
>> and ff_mpv_common_end() to allocate and free it), I'd have moved
>> everything related to it to mpegvideo_enc.c. I probably do it later
>> anyway.
>> (And yes, I am aware of the fact that freeing this frame in
>> ff_mpv_encode_end() is redundant.)
>>
>> libavcodec/mpegpicture.c | 47 +++++++++++++++++++++-----------------
>> libavcodec/mpegpicture.h | 2 +-
>> libavcodec/mpegvideo.c | 25 +++++---------------
>> libavcodec/mpegvideo_enc.c | 3 +--
>> 4 files changed, 34 insertions(+), 43 deletions(-)
>>
>> diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
>> index f78a3c23e3..349ab81055 100644
>> --- a/libavcodec/mpegpicture.c
>> +++ b/libavcodec/mpegpicture.c
>> @@ -30,6 +30,24 @@
>> #include "mpegpicture.h"
>> #include "mpegutils.h"
>> +static void av_noinline free_picture_tables(Picture *pic)
>> +{
>> + pic->alloc_mb_width =
>> + pic->alloc_mb_height = 0;
>> +
>> + av_buffer_unref(&pic->mb_var_buf);
>> + av_buffer_unref(&pic->mc_mb_var_buf);
>> + av_buffer_unref(&pic->mb_mean_buf);
>> + av_buffer_unref(&pic->mbskip_table_buf);
>> + av_buffer_unref(&pic->qscale_table_buf);
>> + av_buffer_unref(&pic->mb_type_buf);
>> +
>> + for (int i = 0; i < 2; i++) {
>> + av_buffer_unref(&pic->motion_val_buf[i]);
>> + av_buffer_unref(&pic->ref_index_buf[i]);
>> + }
>> +}
>> +
>> static int make_tables_writable(Picture *pic)
>> {
>> int ret, i;
>> @@ -240,7 +258,7 @@ int ff_alloc_picture(AVCodecContext *avctx,
>> Picture *pic, MotionEstContext *me,
>> if (pic->qscale_table_buf)
>> if ( pic->alloc_mb_width != mb_width
>> || pic->alloc_mb_height != mb_height)
>> - ff_free_picture_tables(pic);
>> + free_picture_tables(pic);
>> if (shared) {
>> av_assert0(pic->f->data[0]);
>> @@ -285,7 +303,7 @@ int ff_alloc_picture(AVCodecContext *avctx,
>> Picture *pic, MotionEstContext *me,
>> fail:
>> av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
>> ff_mpeg_unref_picture(avctx, pic);
>> - ff_free_picture_tables(pic);
>> + free_picture_tables(pic);
>> return AVERROR(ENOMEM);
>> }
>> @@ -310,7 +328,7 @@ void ff_mpeg_unref_picture(AVCodecContext
>> *avctx, Picture *pic)
>> av_buffer_unref(&pic->hwaccel_priv_buf);
>> if (pic->needs_realloc)
>> - ff_free_picture_tables(pic);
>> + free_picture_tables(pic);
>> memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
>> }
>> @@ -331,7 +349,7 @@ int ff_update_picture_tables(Picture *dst, Picture
>> *src)
>> }
>> if (ret < 0) {
>> - ff_free_picture_tables(dst);
>> + free_picture_tables(dst);
>> return ret;
>> }
>> @@ -450,22 +468,9 @@ int ff_find_unused_picture(AVCodecContext
>> *avctx, Picture *picture, int shared)
>> return ret;
>> }
>> -void ff_free_picture_tables(Picture *pic)
>> +void av_cold ff_free_picture(AVCodecContext *avctx, Picture *pic)
>> {
>> - int i;
>> -
>> - pic->alloc_mb_width =
>> - pic->alloc_mb_height = 0;
>> -
>> - av_buffer_unref(&pic->mb_var_buf);
>> - av_buffer_unref(&pic->mc_mb_var_buf);
>> - av_buffer_unref(&pic->mb_mean_buf);
>> - av_buffer_unref(&pic->mbskip_table_buf);
>> - av_buffer_unref(&pic->qscale_table_buf);
>> - av_buffer_unref(&pic->mb_type_buf);
>> -
>> - for (i = 0; i < 2; i++) {
>> - av_buffer_unref(&pic->motion_val_buf[i]);
>> - av_buffer_unref(&pic->ref_index_buf[i]);
>> - }
>> + free_picture_tables(pic);
>> + ff_mpeg_unref_picture(avctx, pic);
>> + av_frame_free(&pic->f);
>> }
>> diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
>> index a354c2a83c..cee16c07d3 100644
>> --- a/libavcodec/mpegpicture.h
>> +++ b/libavcodec/mpegpicture.h
>> @@ -108,7 +108,7 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx,
>> MotionEstContext *me,
>> int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture
>> *src);
>> void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture);
>> -void ff_free_picture_tables(Picture *pic);
>> +void ff_free_picture(AVCodecContext *avctx, Picture *pic);
>> int ff_update_picture_tables(Picture *dst, Picture *src);
>> int ff_find_unused_picture(AVCodecContext *avctx, Picture
>> *picture, int shared);
>> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
>> index 3b889e0791..7c63c738f3 100644
>> --- a/libavcodec/mpegvideo.c
>> +++ b/libavcodec/mpegvideo.c
>> @@ -874,8 +874,6 @@ void ff_mpv_free_context_frame(MpegEncContext *s)
>> /* init common structure for both encoder and decoder */
>> void ff_mpv_common_end(MpegEncContext *s)
>> {
>> - int i;
>> -
>> if (!s)
>> return;
>> @@ -895,25 +893,14 @@ void ff_mpv_common_end(MpegEncContext *s)
>> return;
>> if (s->picture) {
>> - for (i = 0; i < MAX_PICTURE_COUNT; i++) {
>> - ff_free_picture_tables(&s->picture[i]);
>> - ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
>> - av_frame_free(&s->picture[i].f);
>> - }
>> + for (int i = 0; i < MAX_PICTURE_COUNT; i++)
>> + ff_free_picture(s->avctx, &s->picture[i]);
>> }
>> av_freep(&s->picture);
>> - ff_free_picture_tables(&s->last_picture);
>> - ff_mpeg_unref_picture(s->avctx, &s->last_picture);
>> - av_frame_free(&s->last_picture.f);
>> - ff_free_picture_tables(&s->current_picture);
>> - ff_mpeg_unref_picture(s->avctx, &s->current_picture);
>> - av_frame_free(&s->current_picture.f);
>> - ff_free_picture_tables(&s->next_picture);
>> - ff_mpeg_unref_picture(s->avctx, &s->next_picture);
>> - av_frame_free(&s->next_picture.f);
>> - ff_free_picture_tables(&s->new_picture);
>> - ff_mpeg_unref_picture(s->avctx, &s->new_picture);
>> - av_frame_free(&s->new_picture.f);
>> + ff_free_picture(s->avctx, &s->last_picture);
>> + ff_free_picture(s->avctx, &s->current_picture);
>> + ff_free_picture(s->avctx, &s->next_picture);
>> + ff_free_picture(s->avctx, &s->new_picture);
>> s->context_initialized = 0;
>> s->context_reinit = 0;
>> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
>> index 9a5634c505..baa45d20ab 100644
>> --- a/libavcodec/mpegvideo_enc.c
>> +++ b/libavcodec/mpegvideo_enc.c
>> @@ -941,8 +941,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
>> for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++)
>> av_frame_free(&s->tmp_frames[i]);
>> - ff_free_picture_tables(&s->new_picture);
>> - ff_mpeg_unref_picture(avctx, &s->new_picture);
>> + ff_free_picture(avctx, &s->new_picture);
>
> These names are too generic for what's apparently specific to mpeg.
> ff_free_picture (And the struct being called Picture) could apply to
> anything.
>
> Maybe the functions should all use the ff_mpeg_ namespace, and the
> struct be renamed to MPEGPicture, following decoders like h264 and hevc.
> I'm not telling you to do it if you don't want to, just throwing the
> idea out there. But IMO at least call the new function
> ff_mpeg_free_picture().
>
I pondered using an ff_mpv prefix as lots of other mpegvideo functions
already do, but somehow didn't do it. I'll change it now.
- 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] 37+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
` (13 preceding siblings ...)
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 33/33] avcodec/mpeg4videodec: Move use_intra_dc_vlc to stack, fix data race Andreas Rheinhardt
@ 2022-01-28 11:36 ` Andreas Rheinhardt
14 siblings, 0 replies; 37+ messages in thread
From: Andreas Rheinhardt @ 2022-01-28 11:36 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/h263.h | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/libavcodec/h263.h b/libavcodec/h263.h
> index 982e545491..31836ebb95 100644
> --- a/libavcodec/h263.h
> +++ b/libavcodec/h263.h
> @@ -68,7 +68,6 @@ void ff_h263_encode_init(MpegEncContext *s);
> void ff_h263_decode_init_vlc(void);
> void ff_h263_init_rl_inter(void);
> int ff_h263_decode_picture_header(MpegEncContext *s);
> -int ff_h263_decode_gob_header(MpegEncContext *s);
> void ff_h263_update_motion_val(MpegEncContext * s);
> void ff_h263_loop_filter(MpegEncContext * s);
> int ff_h263_decode_mba(MpegEncContext *s);
Will apply this patchset (with the ff_free_picture() renamed) tomorrow
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] 37+ messages in thread
end of thread, other threads:[~2022-01-28 11:37 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 17:36 [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 02/21] avcodec/h263: Move decoding-only stuff to a new header h263dec.h Andreas Rheinhardt
[not found] ` <20220125174148.994967-1-andreas.rheinhardt@outlook.com>
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 03/21] avcodec/mpeg4videoenc: Use stack variable for vo_type Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 04/21] avcodec/mpeg4videodec: Keep vo_type in sync between threads Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 05/21] avcodec/mpeg4?video: Move vo_type to Mpeg4DecContext Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 06/21] avcodec/ituh263enc: Use stack variable for custom_pcf Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 07/21] avcodec/mpeg12enc: Use stack variable for aspect_ratio_info Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 08/21] avcodec/mpeg12enc: Return early if no Sequence Header is written Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 09/21] avcodec/mpeg12enc: Reindent after the previous commit Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 10/21] avcodec/mpeg4videoenc: Use stack variable for aspect_ratio_info Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 11/21] avcodec/ituh263enc: " Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 12/21] avcodec/ituh263dec: " Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 13/21] avcodec/mpeg4videodec: " Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 14/21] avcodec/mpegvideo: Move aspect_ratio_info to Mpeg1Context Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 15/21] avcodec/mpegvideo: Move timecode_frame_start " Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 16/21] avcodec/mpegvideo_enc: Don't sync gop_picture_number among slice threads Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 17/21] avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContext Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 18/21] avcodec/mpegvideo_enc: Move msmpeg4/wmv1 encoders to msmpeg4enc.c Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 19/21] avcodec/mpegvideo_enc: Move H.263p? encoders to ituh263enc.c Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 20/21] avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it Andreas Rheinhardt
2022-01-25 17:41 ` [FFmpeg-devel] [PATCH 21/21] avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)Context Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 22/33] avcodec/mpegvideo_enc: Localize check for invalid number of b-frames Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 23/33] avcodec/mpegvideo_enc: Don't hardcode list of codecs supporting bframes Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 24/33] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4 Andreas Rheinhardt
2022-01-27 10:13 ` Kieran Kunhya
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 25/33] avcodec/mpegvideo: Fix crash when using lowres with 10bit MPEG-4 Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 26/33] fate/mpeg4: Add test for MPEG-4 Simple Studio Profile Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 27/33] avcodec/mpegvideo: Move handling Simple Studio Profile to mpeg4videodec Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 28/33] avcodec/mpegvideo: Move MPEG-4 Simple Studio Profile fields to mpeg4video Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 29/33] avcodec/mpegpicture: Let ff_mpeg_unref_picture() free picture tables Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 30/33] avcodec/mpegpicture: Add function to completely free MPEG-Picture Andreas Rheinhardt
2022-01-27 14:21 ` James Almer
2022-01-27 14:35 ` Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 31/33] avcodec/h264data: Add missing rational.h inclusion Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 32/33] avcodec/mpegvideo: Use offset instead of pointer for vbv_delay Andreas Rheinhardt
2022-01-26 21:34 ` [FFmpeg-devel] [PATCH 33/33] avcodec/mpeg4videodec: Move use_intra_dc_vlc to stack, fix data race Andreas Rheinhardt
2022-01-28 11:36 ` [FFmpeg-devel] [PATCH 01/21] avcodec/h263: Remove declaration for inexistent function 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