[FFmpeg-cvslog] avutil/tests/adler32: Remove unnecessary volatile

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Jan 23 11:20:50 2022 +0100| [98cef1ebbea61a605d151f5b46b453321e1b63a6] | 
committer: Andreas Rheinhardt

avutil/tests/adler32: Remove unnecessary volatile

And use an ordinary stack variable.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98cef1ebbea61a605d151f5b46b453321e1b63a6
---

 libavutil/tests/adler32.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavutil/tests/adler32.c b/libavutil/tests/adler32.c
index 13f760b477..356e1a97e7 100644
--- a/libavutil/tests/adler32.c
+++ b/libavutil/tests/adler32.c
@@ -27,12 +27,11 @@
 
 #define LEN 7001
 
-static volatile int checksum;
-
 int main(int argc, char **argv)
 {
 int i;
 uint8_t data[LEN];
+AVAdler checksum;
 
 av_log_set_level(AV_LOG_DEBUG);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/h264_ps: Remove ALLOW_INTERLACED cruft

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jan 27 16:39:26 2022 +0100| [f0a7db12a28b4f1675b1b8e125d92024fd98d239] | 
committer: Andreas Rheinhardt

avcodec/h264_ps: Remove ALLOW_INTERLACED cruft

Since e1027aba680c4382c103fd1100cc5567a1530abc,
ALLOW_INTERLACED is no longer defined in h264_ps.c,
leading to a warning when encountering an SPS compatible
with MBAFF. This warning was always nonsense, because
ff_h264_decode_seq_parameter_set() is also used by the parser
and it makes no sense for the parser to warn about missing
decoder features; after all, it is not a parser's job
to warn when a feature is unsupported by a decoder
(and in this case it is even weirder, because even if the H.264
decoder is disabled, the warning will only be shown for MBAFF
sequence parameter sets). So remove the warning in h264_ps.c.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f0a7db12a28b4f1675b1b8e125d92024fd98d239
---

 libavcodec/h264_ps.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index f68d5bf81c..6927fa7198 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -517,11 +517,6 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, 
AVCodecContext *avctx,
 
 sps->direct_8x8_inference_flag = get_bits1(gb);
 
-#ifndef ALLOW_INTERLACE
-if (sps->mb_aff)
-av_log(avctx, AV_LOG_ERROR,
-   "MBAFF support not included; enable it at compile-time.\n");
-#endif
 sps->crop = get_bits1(gb);
 if (sps->crop) {
 unsigned int crop_left   = get_ue_golomb(gb);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/matroskadec: Export rectangular projection as displaymatrix

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Jan 21 19:42:50 2022 +0100| [937bb6bbc1e8654633737e69e403e95a37113058] | 
committer: Andreas Rheinhardt

avformat/matroskadec: Export rectangular projection as displaymatrix

This is the officially supported way to express rotations
and flips in Matroska.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=937bb6bbc1e8654633737e69e403e95a37113058
---

 libavformat/matroskadec.c | 44 +---
 1 file changed, 41 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 594543748d..d165f6ab90 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -37,6 +37,7 @@
 #include "libavutil/base64.h"
 #include "libavutil/bprint.h"
 #include "libavutil/dict.h"
+#include "libavutil/display.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/lzo.h"
@@ -2231,6 +2232,44 @@ static int mkv_parse_video_color(AVStream *st, const 
MatroskaTrack *track) {
 return 0;
 }
 
+static int mkv_create_display_matrix(AVStream *st,
+ const MatroskaTrackVideoProjection *proj,
+ void *logctx)
+{
+double pitch = proj->pitch, yaw = proj->yaw, roll = proj->roll;
+int32_t *matrix;
+int hflip;
+
+if (pitch == 0.0 && yaw == 0.0 && roll == 0.0)
+return 0;
+
+/* Note: The following constants are exactly representable
+ * as floating-point numbers. */
+if (pitch != 0.0 || (yaw != 0.0 && yaw != 180.0 && yaw != -180.0) ||
+isnan(roll)) {
+av_log(logctx, AV_LOG_WARNING, "Ignoring non-2D rectangular "
+   "projection in stream %u (yaw %f, pitch %f, roll %f)\n",
+   st->index, yaw, pitch, roll);
+return 0;
+}
+matrix = (int32_t*)av_stream_new_side_data(st, AV_PKT_DATA_DISPLAYMATRIX,
+   9 * sizeof(*matrix));
+if (!matrix)
+return AVERROR(ENOMEM);
+
+hflip = yaw != 0.0;
+/* ProjectionPoseRoll is in the counter-clockwise direction
+ * whereas av_display_rotation_set() expects its argument
+ * to be oriented clockwise, so we need to negate roll.
+ * Furthermore, if hflip is set, we need to negate it again
+ * to account for the fact that the Matroska specifications
+ * require the yaw rotation to be applied first. */
+av_display_rotation_set(matrix, roll * (2 * hflip - 1));
+av_display_matrix_flip(matrix, hflip, 0);
+
+return 0;
+}
+
 static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track,
   void *logctx)
 {
@@ -2249,6 +2288,8 @@ static int mkv_parse_video_projection(AVStream *st, const 
MatroskaTrack *track,
 }
 
 switch (track->video.projection.type) {
+case MATROSKA_VIDEO_PROJECTION_TYPE_RECTANGULAR:
+return mkv_create_display_matrix(st, mkv_projection, logctx);
 case MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR:
 if (track->video.projection.private.size == 20) {
 t = AV_RB32(priv_data +  4);
@@ -2291,9 +2332,6 @@ static int mkv_parse_video_projection(AVStream *st, const 
MatroskaTrack *track,
 return AVERROR_INVALIDDATA;
 }
 break;
-case MATROSKA_VIDEO_PROJECTION_TYPE_RECTANGULAR:
-/* No Spherical metadata */
-return 0;
 default:
 av_log(logctx, AV_LOG_WARNING,
"Unknown spherical metadata type %"PRIu64"\n",

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/libxvid: Don't set AVCodecContext.codec_id

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jan 27 00:11:08 2022 +0100| [b065a70afa4f89dae9f4aa84050f20c4d856af2b] | 
committer: Andreas Rheinhardt

avcodec/libxvid: Don't set AVCodecContext.codec_id

Unnecessary since 2325bdad7b67b1c8539ef6beebb99d3247f08669
(and crazy even before then).

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b065a70afa4f89dae9f4aa84050f20c4d856af2b
---

 libavcodec/libxvid.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 7cf9d7661c..94746d0bda 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -657,7 +657,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
 if (xvid_flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
 /* In this case, we are claiming to be MPEG-4 */
 x->quicktime_format = 1;
-avctx->codec_id = AV_CODEC_ID_MPEG4;
 } else {
 /* We are claiming to be Xvid */
 x->quicktime_format = 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo: Use offset instead of pointer for vbv_delay

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 21:04:53 2022 +0100| [24a654c6c96310b1b408a6d053ad52de41640e5e] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Use offset instead of pointer for vbv_delay

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 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=24a654c6c96310b1b408a6d053ad52de41640e5e
---

 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(>pb, 3, s->pict_type);
 
-s->vbv_delay_ptr = s->pb.buf + put_bytes_count(>pb, 0);
+s->vbv_delay_pos = put_bytes_count(>pb, 0);
 put_bits(>pb, 16, 0x);   /* vbv_delay */
 
 // RAL: Forward f_code also needed for B-frames
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 86954348f0..84d79d2e59 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -432,7 +432,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 ead78e13ad..33f2937217 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);
 intminbits = 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 < 0x);
 
-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(_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(>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(>pb, 0) < threshold)
 return AVERROR(EINVAL);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg4videodec: Move use_intra_dc_vlc to stack, fix data race

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 21:29:42 2022 +0100| [577ba4a1af08f47d1a2f0d175092f770a1d897c8] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Move use_intra_dc_vlc to stack, fix data race

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 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=577ba4a1af08f47d1a2f0d175092f770a1d897c8
---

 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 = >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], _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(>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);
 
-   

[FFmpeg-cvslog] avcodec/mpegpicture: Add function to completely free MPEG-Picture

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 19:02:37 2022 +0100| [5a04c6a2697568c2b7233a0a9f4f20aa8a2a1706] | 
committer: Andreas Rheinhardt

avcodec/mpegpicture: Add function to completely free MPEG-Picture

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.

Reviewed-by: James Almer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5a04c6a2697568c2b7233a0a9f4f20aa8a2a1706
---

 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..27e497c404 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(>mb_var_buf);
+av_buffer_unref(>mc_mb_var_buf);
+av_buffer_unref(>mb_mean_buf);
+av_buffer_unref(>mbskip_table_buf);
+av_buffer_unref(>qscale_table_buf);
+av_buffer_unref(>mb_type_buf);
+
+for (int i = 0; i < 2; i++) {
+av_buffer_unref(>motion_val_buf[i]);
+av_buffer_unref(>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(>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_mpv_picture_free(AVCodecContext *avctx, Picture *pic)
 {
-int i;
-
-pic->alloc_mb_width  =
-pic->alloc_mb_height = 0;
-
-av_buffer_unref(>mb_var_buf);
-av_buffer_unref(>mc_mb_var_buf);
-av_buffer_unref(>mb_mean_buf);
-av_buffer_unref(>mbskip_table_buf);
-av_buffer_unref(>qscale_table_buf);
-av_buffer_unref(>mb_type_buf);
-
-for (i = 0; i < 2; i++) {
-av_buffer_unref(>motion_val_buf[i]);
-av_buffer_unref(>ref_index_buf[i]);
-}
+free_picture_tables(pic);
+ff_mpeg_unref_picture(avctx, pic);
+av_frame_free(>f);
 }
diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index a354c2a83c..e1e9f8d7e0 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_mpv_picture_free(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..bbcf00b014 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(>picture[i]);
-ff_mpeg_unref_picture(s->avctx, >picture[i]);
-av_frame_free(>picture[i].f);
-}
+for (int i = 0; i < MAX_PICTURE_COUNT; i++)
+

[FFmpeg-cvslog] avcodec/mpegpicture: Let ff_mpeg_unref_picture() free picture tables

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 17:26:56 2022 +0100| [d0ceb90f44ff342e8de8259548a04fb9fce2ed68] | 
committer: Andreas Rheinhardt

avcodec/mpegpicture: Let ff_mpeg_unref_picture() free picture tables

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0ceb90f44ff342e8de8259548a04fb9fce2ed68
---

 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([ret]);
 ff_mpeg_unref_picture(avctx, [ret]);
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo: Move MPEG-4 Simple Studio Profile fields to mpeg4video

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 01:50:56 2022 +0100| [dcdb34be9121adf0cf499d75b84a3ba242a872d4] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move MPEG-4 Simple Studio Profile fields to mpeg4video

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 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dcdb34be9121adf0cf499d75b84a3ba242a872d4
---

 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 

[FFmpeg-cvslog] avcodec/mpegvideo: Fix crash when using lowres with 10bit MPEG-4

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 23:07:25 2022 +0100| [d4d87f2ac56e13aaad68f2dd2efc69a977e6a3bc] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Fix crash when using lowres with 10bit MPEG-4

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 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d4d87f2ac56e13aaad68f2dd2efc69a977e6a3bc
---

 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;
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo: Move handling Simple Studio Profile to mpeg4videodec

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 01:26:15 2022 +0100| [85ac29ad1cbb1ab2e1294a7e8a30db20df7c0b86] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move handling Simple Studio Profile to mpeg4videodec

This is its only user.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85ac29ad1cbb1ab2e1294a7e8a30db20df7c0b86
---

 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] / 

[FFmpeg-cvslog] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 00:22:50 2022 +0100| [9953fc9a2372cb09ec8e3d9395611f4285916d46] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4

Fixes visual corruptions on two macroblocks from two frames from
https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4447/A003C003_SR_422_23.98p.mxf

Reviewed-by: Kieran Kunhya 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9953fc9a2372cb09ec8e3d9395611f4285916d46
---

 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;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] fate/mpeg4: Add test for MPEG-4 Simple Studio Profile

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Jan 26 01:04:08 2022 +0100| [b8b1c49bfa929fd01b5ea2923ca747eecb31b875] | 
committer: Andreas Rheinhardt

fate/mpeg4: Add test for MPEG-4 Simple Studio Profile

The sample mpeg4/mpeg4_sstp_dpcm.m4v existed in the FATE-suite,
but it was surprisingly unused.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b8b1c49bfa929fd01b5ea2923ca747eecb31b875
---

 tests/fate/mpeg4.mak   | 5 +
 tests/ref/fate/mpeg4-simple-studio-profile | 6 ++
 2 files changed, 11 insertions(+)

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 00..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

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't hardcode list of codecs supporting bframes

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 20:38:22 2022 +0100| [83c1ac65701f10f21186447aa5e20d83044914c5] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Don't hardcode list of codecs supporting bframes

Check for the encoder's AV_CODEC_CAP_DELAY instead.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83c1ac65701f10f21186447aa5e20d83044914c5
---

 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);
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Localize check for invalid number of b-frames

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 20:34:31 2022 +0100| [0063a06aaa900ff69e26f21d7ad7c1725c01a29c] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Localize check for invalid number of b-frames

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0063a06aaa900ff69e26f21d7ad7c1725c01a29c
---

 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) &&

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)Context

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 17:39:19 2022 +0100| [aeb83322aa26621b940c32e76d8601b4d5378a09] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)Context

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aeb83322aa26621b940c32e76d8601b4d5378a09
---

 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(>avctx->framerate.num,
   >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(>gb, 4);
-if (s->frame_rate_index == 0 || s->frame_rate_index > 13) {
+s1->frame_rate_index = get_bits(>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(>gb, 18) * 400LL;
 if (check_marker(s->avctx, >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/3 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(>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 

[FFmpeg-cvslog] avcodec/mpegvideo_enc: Move H.263p? encoders to ituh263enc.c

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 14:54:31 2022 +0100| [e17ceeba3cfec8015846a4866cb84d2b51b82667] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Move H.263p? encoders to ituh263enc.c

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e17ceeba3cfec8015846a4866cb84d2b51b82667
---

 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(>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 = _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 = _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
-

[FFmpeg-cvslog] avcodec/mpegvideo_enc: Move msmpeg4/wmv1 encoders to msmpeg4enc.c

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 14:58:22 2022 +0100| [2098d1f4c5c2ce0104b9128d7106f521c2f636f5] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Move msmpeg4/wmv1 encoders to msmpeg4enc.c

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2098d1f4c5c2ce0104b9128d7106f521c2f636f5
---

 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 = _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 = _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 = _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 = _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 = _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 = _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 = _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= 

[FFmpeg-cvslog] avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContext

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 14:44:20 2022 +0100| [4bbfe02ca08984d873cbdf06f9643abca63f1333] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContext

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4bbfe02ca08984d873cbdf06f9643abca63f1333
---

 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(>pb, 1, 1);
 put_bits(>pb, 6, (uint32_t)((time_code / fps) % 60));
 put_bits(>pb, 6, (uint32_t)((time_code % fps)));
-put_bits(>pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || 
s->intra_only || !s->gop_picture_number);
+put_bits(>pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) ||
+s->intra_only || !mpeg12->gop_picture_number);
 put_bits(>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(>pb, 10,
- (s->picture_number - s->gop_picture_number) & 0x3ff);
+ (s->picture_number - mpeg12->gop_picture_number) & 0x3ff);
 put_bits(>pb, 3, s->pict_type);
 
 s->vbv_delay_ptr = s->pb.buf + put_bytes_count(>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
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't sync gop_picture_number among slice threads

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 14:38:04 2022 +0100| [b90ea35182a04ba79e5d77f732bbcd50f1281dfb] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Don't sync gop_picture_number among slice threads

It is only used by the main thread.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b90ea35182a04ba79e5d77f732bbcd50f1281dfb
---

 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

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo: Move timecode_frame_start to Mpeg1Context

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 14:18:01 2022 +0100| [757be51dedbad231490e73e9b69a87f9bc51f81c] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move timecode_frame_start to Mpeg1Context

It is only used there and only by the main thread.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=757be51dedbad231490e73e9b69a87f9bc51f81c
---

 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   0x2000
@@ -2443,7 +2444,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
 
 init_get_bits(>gb, buf, buf_size * 8);
 
-tc = s-> timecode_frame_start = get_bits(>gb, 25);
+tc = s1->timecode_frame_start = get_bits(>gb, 25);
 
 s1->closed_gop = get_bits1(>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, >timecode_frame_start, sizeof(int64_t));
+memcpy(tcside->data, >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(>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;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpegvideo: Move aspect_ratio_info to Mpeg1Context

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:29:49 2022 +0100| [01f60973a44962df2b3a69780f1e80094d30f79e] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Move aspect_ratio_info to Mpeg1Context

Only used there and only by the main thread.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01f60973a44962df2b3a69780f1e80094d30f79e
---

 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(>gb, 4);
-if (s->aspect_ratio_info == 0) {
+s1->aspect_ratio_info = get_bits(>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;   ///< 

[FFmpeg-cvslog] avcodec/mpeg4videodec: Use stack variable for aspect_ratio_info

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:25:42 2022 +0100| [30dfd87da19b1ac3ce1db5558d84cc3f6d624c60] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Use stack variable for aspect_ratio_info

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=30dfd87da19b1ac3ce1db5558d84cc3f6d624c60
---

 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 = >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 = >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 */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/ituh263dec: Use stack variable for aspect_ratio_info

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:24:13 2022 +0100| [9288b6366b5f917ea80415bf48c6a0f621189ec0] | 
committer: Andreas Rheinhardt

avcodec/ituh263dec: Use stack variable for aspect_ratio_info

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9288b6366b5f917ea80415bf48c6a0f621189ec0
---

 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(>gb, 4);
-ff_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info);
+int aspect_ratio_info = get_bits(>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, >gb, "in dimensions");
 height = get_bits(>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(>gb, 8);
 s->avctx->sample_aspect_ratio.den= get_bits(>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];

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg12enc: Use stack variable for aspect_ratio_info

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:01:58 2022 +0100| [f05ba7b169f95a980dac8193a1065737fb9d3435] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Use stack variable for aspect_ratio_info

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f05ba7b169f95a980dac8193a1065737fb9d3435
---

 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(>pb, 4, s->aspect_ratio_info);
+put_bits(>pb, 4, aspect_ratio_info);
 put_bits(>pb, 4, s->frame_rate_index);
 
 if (s->avctx->rc_max_rate) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/ituh263enc: Use stack variable for aspect_ratio_info

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:22:10 2022 +0100| [f2da6502580504f271c102160d4b1421f602cf5b] | 
committer: Andreas Rheinhardt

avcodec/ituh263enc: Use stack variable for aspect_ratio_info

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2da6502580504f271c102160d4b1421f602cf5b
---

 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(>pb,4,s->aspect_ratio_info);
+put_bits(>pb,4, aspect_ratio_info);
 put_bits(>pb,9,(s->width >> 2) - 1);
 put_bits(>pb,1,1); /* "1" to prevent start code emulation */
 put_bits(>pb,9,(s->height >> 2));
-if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
+if (aspect_ratio_info == FF_ASPECT_EXTENDED){
 put_bits(>pb, 8, s->avctx->sample_aspect_ratio.num);
 put_bits(>pb, 8, s->avctx->sample_aspect_ratio.den);
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg4videoenc: Use stack variable for aspect_ratio_info

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:18:59 2022 +0100| [b326c2dcdcb7bf3011f2c1fa0c259ca94b50fd45] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videoenc: Use stack variable for aspect_ratio_info

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b326c2dcdcb7bf3011f2c1fa0c259ca94b50fd45
---

 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(>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(>pb, 4, s->aspect_ratio_info); /* aspect ratio info */
-if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
+put_bits(>pb, 4, aspect_ratio_info); /* aspect ratio info */
+if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
 av_reduce(>avctx->sample_aspect_ratio.num, 
>avctx->sample_aspect_ratio.den,
s->avctx->sample_aspect_ratio.num,  
s->avctx->sample_aspect_ratio.den, 255);
 put_bits(>pb, 8, s->avctx->sample_aspect_ratio.num);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg12enc: Reindent after the previous commit

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:17:32 2022 +0100| [5256658af5bbbee12c2ddd1d2aafe0a9d6ce4e37] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Reindent after the previous commit

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5256658af5bbbee12c2ddd1d2aafe0a9d6ce4e37
---

 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(>pb, 12, s->width  & 0xFFF);
+put_sbits(>pb, 12, s->height & 0xFFF);
 
-put_sbits(>pb, 12, s->width  & 0xFFF);
-put_sbits(>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(>pb, 4, aspect_ratio_info);
-put_bits(>pb, 4, s->frame_rate_index);
+put_bits(>pb, 4, aspect_ratio_info);
+put_bits(>pb, 4, s->frame_rate_index);
 
-if (s->avctx->rc_max_rate) {
-v = (s->avctx->rc_max_rate + 399) / 400;
-if (v > 0x3 && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)
-v = 0x3;
-} else {
-v = 0x3;
-}
+if (s->avctx->rc_max_rate) {
+v = (s->avctx->rc_max_rate + 399) / 400;
+if (v > 0x3 && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)
+v = 0x3;
+} else {
+v = 0x3;
+}
 
-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(>pb, 18, v);
-put_bits(>pb, 1, 1); // marker
-put_sbits(>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(>pb, 1, constraint_parameter_flag);
-
-ff_write_quant_matrix(>pb, s->avctx->intra_matrix);
-ff_write_quant_matrix(>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)
+   

[FFmpeg-cvslog] avcodec/ituh263enc: Use stack variable for custom_pcf

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 03:49:14 2022 +0100| [769703613acc6af335c0d0a3eee4b0eaf59caed4] | 
committer: Andreas Rheinhardt

avcodec/ituh263enc: Use stack variable for custom_pcf

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=769703613acc6af335c0d0a3eee4b0eaf59caed4
---

 libavcodec/ituh263enc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 5a779e..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= 180;
 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(>pb, 3, format);
 
-put_bits(>pb,1, s->custom_pcf);
+put_bits(>pb,1, custom_pcf);
 put_bits(>pb,1, s->umvplus); /* Unrestricted Motion Vector */
 put_bits(>pb,1,0); /* SAC: off */
 put_bits(>pb,1,s->obmc); /* Advanced Prediction Mode */
@@ -203,7 +204,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int 
picture_number)
 put_bits(>pb, 8, s->avctx->sample_aspect_ratio.den);
 }
 }
-if(s->custom_pcf){
+if (custom_pcf) {
 if(ufep){
 put_bits(>pb, 1, best_clock_code);
 put_bits(>pb, 7, best_divisor);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg12enc: Return early if no Sequence Header is written

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 13:08:50 2022 +0100| [d3a2d066333061fe3d9248b52d23de1e363d5b84] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Return early if no Sequence Header is written

Allows to avoid one level of indentation.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d3a2d066333061fe3d9248b52d23de1e363d5b84
---

 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(>pb, 6, (uint32_t)((time_code % fps)));
 put_bits(>pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || 
s->intra_only || !s->gop_picture_number);
 put_bits(>pb, 1, 0); // broken link
-}
 }
 
 static inline void encode_mb_skip_run(MpegEncContext *s, int run)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg4?video: Move vo_type to Mpeg4DecContext

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 03:45:01 2022 +0100| [426d65e3e3d72e9d00a54875ff121a8c8425ad50] | 
committer: Andreas Rheinhardt

avcodec/mpeg4?video: Move vo_type to Mpeg4DecContext

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=426d65e3e3d72e9d00a54875ff121a8c8425ad50
---

 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;   ///< 

[FFmpeg-cvslog] avcodec/mpeg4videodec: Keep vo_type in sync between threads

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 03:38:56 2022 +0100| [eb6765988426f7232f3479330e1ae722acc6189f] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videodec: Keep vo_type in sync between threads

Otherwise one can get outdated values when setting FF_DEBUG_PICT_INFO.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb6765988426f7232f3479330e1ae722acc6189f
---

 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;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/mpeg4videoenc: Use stack variable for vo_type

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Jan 25 02:46:07 2022 +0100| [49627b2f2ac7d930724c4125bb656a5879721cea] | 
committer: Andreas Rheinhardt

avcodec/mpeg4videoenc: Use stack variable for vo_type

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=49627b2f2ac7d930724c4125bb656a5879721cea
---

 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(>pb, 16, 0);
@@ -977,7 +977,7 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
 put_bits(>pb, 16, 0x120 + vol_number);   /* video obj layer */
 
 put_bits(>pb, 1, 0); /* random access vol */
-put_bits(>pb, 8, s->vo_type);/* video obj type indication */
+put_bits(>pb, 8, vo_type);   /* video obj type indication */
 if (s->workaround_bugs & FF_BUG_MS) {
 put_bits(>pb, 1, 0); /* is obj layer id= no */
 } else {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/h263: Move decoding-only stuff to a new header h263dec.h

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jan 24 21:54:45 2022 +0100| [7f6596c8bb63d5ab8dec240568461b51d3b79c76] | 
committer: Andreas Rheinhardt

avcodec/h263: Move decoding-only stuff to a new header h263dec.h

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f6596c8bb63d5ab8dec240568461b51d3b79c76
---

 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(-)

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 
 #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 00..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
+ * 

[FFmpeg-cvslog] avcodec/h263: Remove declaration for inexistent function

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jan 24 22:17:16 2022 +0100| [85bbae8473029a96d60cd0f9d8956a7c8aca49bb] | 
committer: Andreas Rheinhardt

avcodec/h263: Remove declaration for inexistent function

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85bbae8473029a96d60cd0f9d8956a7c8aca49bb
---

 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);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/jpeg2000dec: Move preparations to main thread, fix race

2022-01-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Jan 27 15:53:48 2022 +0100| [218d1f76d46fc5b59a27d5ec9e88e821dc888d11] | 
committer: Andreas Rheinhardt

avcodec/jpeg2000dec: Move preparations to main thread, fix race

jpeg2000_decode_tile() (which is run concurrently by several threads
when using slice threading) currently modifies some joint values
before doing its actual work. This is a data race that happens to work
because all threads set the same values; but it is nevertheless
undefined behaviour.

Fix this by performing said preparatory work in the main thread instead.
This fixes the vsynth(1|2|_lena)-jpeg2000(-97)? FATE-tests when using
TSAN and slice threading.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=218d1f76d46fc5b59a27d5ec9e88e821dc888d11
---

 libavcodec/jpeg2000dec.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 80b2e2d627..a7eb809f30 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2080,7 +2080,6 @@ static int jpeg2000_decode_tile(AVCodecContext *avctx, 
void *td,
 Jpeg2000DecoderContext *s = avctx->priv_data;
 AVFrame *picture = td;
 Jpeg2000Tile *tile = s->tile + jobnr;
-int x;
 
 tile_codeblocks(s, tile);
 
@@ -2088,17 +2087,6 @@ static int jpeg2000_decode_tile(AVCodecContext *avctx, 
void *td,
 if (tile->codsty[0].mct)
 mct_decode(s, tile);
 
-for (x = 0; x < s->ncomponents; x++) {
-if (s->cdef[x] < 0) {
-for (x = 0; x < s->ncomponents; x++) {
-s->cdef[x] = x + 1;
-}
-if ((s->ncomponents & 1) == 0)
-s->cdef[s->ncomponents-1] = 0;
-break;
-}
-}
-
 if (s->precision <= 8) {
 write_frame_8(s, tile, picture, 8);
 } else {
@@ -2537,6 +2525,17 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, 
void *data,
 if (ret = jpeg2000_read_bitstream_packets(s))
 goto end;
 
+for (int x = 0; x < s->ncomponents; x++) {
+if (s->cdef[x] < 0) {
+for (x = 0; x < s->ncomponents; x++) {
+s->cdef[x] = x + 1;
+}
+if ((s->ncomponents & 1) == 0)
+s->cdef[s->ncomponents-1] = 0;
+break;
+}
+}
+
 avctx->execute2(avctx, jpeg2000_decode_tile, picture, NULL, s->numXtiles * 
s->numYtiles);
 
 jpeg2000_dec_cleanup(s);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vf_v360: improve xyz_to_dfisheye() even more

2022-01-29 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Jan 29 17:07:47 
2022 +0100| [3981dbd192aaa51377019de9868bca082cfd8c7d] | committer: Paul B Mahol

avfilter/vf_v360: improve xyz_to_dfisheye() even more

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3981dbd192aaa51377019de9868bca082cfd8c7d
---

 libavfilter/vf_v360.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 7f1baa4850..e2c90e7eb7 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -3479,7 +3479,7 @@ static int xyz_to_dfisheye(const V360Context *s,
 
 for (int i = 0; i < 4; i++) {
 for (int j = 0; j < 4; j++) {
-us[i][j] = av_clip(u_shift + ui + j - 1, 0, width  - 1);
+us[i][j] = u_shift + av_clip(ui + j - 1, 0, ew - 1);
 vs[i][j] = av_clip(  vi + i - 1, 0, height - 1);
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vf_v360: improve xyz_to_fisheye()

2022-01-29 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Jan 29 17:18:16 
2022 +0100| [e13f0b9456a5028594090e4f6f10f0a9d76f1bd2] | committer: Paul B Mahol

avfilter/vf_v360: improve xyz_to_fisheye()

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e13f0b9456a5028594090e4f6f10f0a9d76f1bd2
---

 libavfilter/vf_v360.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index e2c90e7eb7..a216aeebdd 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -2941,8 +2941,8 @@ static int xyz_to_fisheye(const V360Context *s,
 const int visible = -0.5f < uf && uf < 0.5f && -0.5f < vf && vf < 0.5f;
 int ui, vi;
 
-uf = (uf + 0.5f) * width;
-vf = (vf + 0.5f) * height;
+uf = scale(uf * 2.f, width);
+vf = scale(vf * 2.f, height);
 
 ui = floorf(uf);
 vi = floorf(vf);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avutil/hwcontext_qsv: fix typo

2022-01-29 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Sat Jan 
29 15:37:38 2022 +0100| [2f323b19789dac87ec57b9fec663e049e0dc4164] | committer: 
Timo Rothenpieler

avutil/hwcontext_qsv: fix typo

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f323b19789dac87ec57b9fec663e049e0dc4164
---

 libavutil/hwcontext_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 6d9b8324c2..d3d8f42c99 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -134,7 +134,7 @@ int ff_qsv_get_surface_base_handle(mfxFrameSurface1 *surf,
 #if CONFIG_D3D11VA
 case AV_HWDEVICE_TYPE_D3D11VA:
 base_handle[0] = handle_pair->first;
-base_handle[1] = handle_pair->secode;
+base_handle[1] = handle_pair->second;
 return 0;
 #endif
 #if CONFIG_DXVA2

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/af_afir: switch to lavu/tx

2022-01-29 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Jan 29 11:35:40 
2022 +0100| [d388dc20b9dacb5775d701000f23bc78b7d21402] | committer: Paul B Mahol

avfilter/af_afir: switch to lavu/tx

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d388dc20b9dacb5775d701000f23bc78b7d21402
---

 libavfilter/af_afir.c | 98 +--
 libavfilter/af_afir.h | 11 +++---
 2 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index ace5087e90..7690218ff4 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -25,6 +25,7 @@
 
 #include 
 
+#include "libavutil/tx.h"
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
@@ -32,7 +33,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "libavutil/xga_font_data.h"
-#include "libavcodec/avfft.h"
 
 #include "audio.h"
 #include "avfilter.h"
@@ -58,7 +58,7 @@ static void fcmul_add_c(float *sum, const float *t, const 
float *c, ptrdiff_t le
 sum[2 * n] += t[2 * n] * c[2 * n];
 }
 
-static void direct(const float *in, const FFTComplex *ir, int len, float *out)
+static void direct(const float *in, const AVComplexFloat *ir, int len, float 
*out)
 {
 for (int n = 0; n < len; n++)
 for (int m = 0; m <= n; m++)
@@ -79,7 +79,7 @@ static int fir_quantum(AVFilterContext *ctx, AVFrame *out, 
int ch, int offset)
 {
 AudioFIRContext *s = ctx->priv;
 const float *in = (const float *)s->in->extended_data[ch] + offset;
-float *block, *buf, *ptr = (float *)out->extended_data[ch] + offset;
+float *blockin, *blockout, *buf, *ptr = (float *)out->extended_data[ch] + 
offset;
 const int nb_samples = FFMIN(s->min_part_size, out->nb_samples - offset);
 int n, i, j;
 
@@ -87,7 +87,8 @@ static int fir_quantum(AVFilterContext *ctx, AVFrame *out, 
int ch, int offset)
 AudioFIRSegment *seg = >seg[segment];
 float *src = (float *)seg->input->extended_data[ch];
 float *dst = (float *)seg->output->extended_data[ch];
-float *sum = (float *)seg->sum->extended_data[ch];
+float *sumin = (float *)seg->sumin->extended_data[ch];
+float *sumout = (float *)seg->sumout->extended_data[ch];
 
 if (s->min_part_size >= 8) {
 s->fdsp->vector_fmul_scalar(src + seg->input_offset, in, 
s->dry_gain, FFALIGN(nb_samples, 4));
@@ -115,7 +116,7 @@ static int fir_quantum(AVFilterContext *ctx, AVFrame *out, 
int ch, int offset)
 
 for (i = 0; i < seg->nb_partitions; i++) {
 const int coffset = j * seg->coeff_size;
-const FFTComplex *coeff = (const FFTComplex 
*)seg->coeff->extended_data[ch * !s->one2many] + coffset;
+const AVComplexFloat *coeff = (const AVComplexFloat 
*)seg->coeff->extended_data[ch * !s->one2many] + coffset;
 
 direct(src, coeff, nb_samples, dst);
 
@@ -134,40 +135,38 @@ static int fir_quantum(AVFilterContext *ctx, AVFrame 
*out, int ch, int offset)
 continue;
 }
 
-memset(sum, 0, sizeof(*sum) * seg->fft_length);
-block = (float *)seg->block->extended_data[ch] + seg->part_index[ch] * 
seg->block_size;
-memset(block + seg->part_size, 0, sizeof(*block) * (seg->fft_length - 
seg->part_size));
+memset(sumin, 0, sizeof(*sumin) * seg->fft_length);
+blockin = (float *)seg->blockin->extended_data[ch] + 
seg->part_index[ch] * seg->block_size;
+blockout = (float *)seg->blockout->extended_data[ch] + 
seg->part_index[ch] * seg->block_size;
+memset(blockin + seg->part_size, 0, sizeof(*blockin) * 
(seg->fft_length - seg->part_size));
 
-memcpy(block, src, sizeof(*src) * seg->part_size);
+memcpy(blockin, src, sizeof(*src) * seg->part_size);
 
-av_rdft_calc(seg->rdft[ch], block);
-block[2 * seg->part_size] = block[1];
-block[1] = 0;
+seg->tx_fn(seg->tx[ch], blockout, blockin, sizeof(float));
 
 j = seg->part_index[ch];
 
 for (i = 0; i < seg->nb_partitions; i++) {
 const int coffset = j * seg->coeff_size;
-const float *block = (const float *)seg->block->extended_data[ch] 
+ i * seg->block_size;
-const FFTComplex *coeff = (const FFTComplex 
*)seg->coeff->extended_data[ch * !s->one2many] + coffset;
+const float *blockout = (const float 
*)seg->blockout->extended_data[ch] + i * seg->block_size;
+const AVComplexFloat *coeff = (const AVComplexFloat 
*)seg->coeff->extended_data[ch * !s->one2many] + coffset;
 
-s->afirdsp.fcmul_add(sum, block, (const float *)coeff, 
seg->part_size);
+s->afirdsp.fcmul_add(sumin, blockout, (const float *)coeff, 
seg->part_size);
 
 if (j == 0)
 j = seg->nb_partitions;
 j--;
 }
 
-sum[1] = sum[2 * seg->part_size];
-av_rdft_calc(seg->irdft[ch], sum);
+