Re: [FFmpeg-devel] [PATCH] Update sample upload instructions

2022-10-16 Thread Anton Khirnov
pushed

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCHv2] avcodec: ViewQuest VQC decoder

2022-10-16 Thread Peter Ross
On Sun, Oct 09, 2022 at 11:36:09AM +1100, Peter Ross wrote:
> Reviewed-by: Andreas Rheinhardt 
> Reviewed-by: Tomas Härdin 
> ---
> 
> Thanks for reviews. All suggestions implemented.
> 
>  Changelog |   1 +
>  doc/general_contents.texi |   1 +
>  libavcodec/Makefile   |   1 +
>  libavcodec/allcodecs.c|   1 +
>  libavcodec/codec_desc.c   |   7 +
>  libavcodec/codec_id.h |   1 +
>  libavcodec/vqcdec.c   | 430 ++
>  libavformat/riff.c|   2 +
>  8 files changed, 444 insertions(+)
>  create mode 100644 libavcodec/vqcdec.c

i will push in couple of days if no one objects.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] lavc/audiodsp: fix RISC-V V scalar product (again)

2022-10-16 Thread Rémi Denis-Courmont
The loop uses a 32-bit accumulator. The current code would only zero
the lower 16 bits thereof.
---
 libavcodec/riscv/audiodsp_rvv.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S
index 8e8bbd2058..af1e07bef9 100644
--- a/libavcodec/riscv/audiodsp_rvv.S
+++ b/libavcodec/riscv/audiodsp_rvv.S
@@ -21,7 +21,7 @@
 #include "libavutil/riscv/asm.S"
 
 func ff_scalarproduct_int16_rvv, zve32x
-vsetivlizero, 1, e16, m1, ta, ma
+vsetivlizero, 1, e32, m1, ta, ma
 vmv.s.x v8, zero
 1:
 vsetvli t0, a2, e16, m1, ta, ma
-- 
2.37.2

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

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


Re: [FFmpeg-devel] [PATCH v13 2/9] avcodec/evc_parser: Added parser implementaion for EVC format

2022-10-16 Thread Anton Khirnov
Quoting Dawid Kozinski (2022-10-07 11:11:13)
> +
> +static int get_nalu_type(const uint8_t *bits, int bits_size, AVCodecContext 
> *avctx)

You seem to be doing custom bitreading here and in
read_nal_unit_length(). You should use either the get_bits.h API for
bitreading or bytestream2 API for byte reading.

Also, avctx is unused (same in read_nal_unit_length()).

> +{
> +int unit_type_plus1 = 0;
> +
> +if (bits_size >= EVC_NAL_HEADER_SIZE) {
> +unsigned char *p = (unsigned char *)bits;
> +// forbidden_zero_bit
> +if ((p[0] & 0x80) != 0)
> +return -1;
> +
> +// nal_unit_type
> +unit_type_plus1 = (p[0] >> 1) & 0x3F;
> +}
> +
> +return unit_type_plus1 - 1;
> +}
> +
> +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size, 
> AVCodecContext *avctx)
> +{
> +uint32_t nalu_len = 0;
> +
> +if (bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) {
> +
> +int t = 0;
> +unsigned char *p = (unsigned char *)bits;
> +
> +for (int i = 0; i < EVC_NAL_UNIT_LENGTH_BYTE; i++)
> +t = (t << 8) | p[i];
> +
> +nalu_len = t;
> +if (nalu_len == 0)
> +return 0;
> +}
> +
> +return nalu_len;
> +}

this whole function looks very much like AV_RB32 or
bytestream2_get_be32.

> +static int parse_nal_units(AVCodecParserContext *s, const uint8_t *bs,
> +   int bs_size, AVCodecContext *avctx)
> +{
> +EVCParserContext *ev = s->priv_data;
> +int nalu_type, nalu_size;
> +unsigned char *bits = (unsigned char *)bs;
> +int bits_size = bs_size;

First, casting away const is something you should almost never do.
Especially in a parser, which should never modify the input bitstream.

> +avctx->codec_id = AV_CODEC_ID_EVC;

This seems unnecessary.

> +s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
> +s->key_frame = -1;
> +
> +nalu_size = read_nal_unit_length(bits, bits_size, avctx);
> +if (nalu_size == 0) {

IIUC read_nal_unit_length() can return -1, which should be handled here.

> +av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", 
> nalu_size);
> +return -1;
> +}
> +
> +bits += EVC_NAL_UNIT_LENGTH_BYTE;
> +bits_size -= EVC_NAL_UNIT_LENGTH_BYTE;
> +
> +nalu_type = get_nalu_type(bits, bits_size, avctx);

Invalid type should be handled here.
> +
> +bits += EVC_NAL_HEADER_SIZE;
> +bits_size -= EVC_NAL_HEADER_SIZE;
> +
> +if (nalu_type == EVC_SPS_NUT) { // NAL Unit type: SPS (Sequence 
> Parameter Set)

useless comment, the check is obvious

> +EVCParserSPS *sps;
> +
> +sps = parse_sps(bits, bits_size, ev);
> +if (!sps) {
> +av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n");
> +return -1;
> +}
> +
> +s->coded_width = sps->pic_width_in_luma_samples;
> +s->coded_height= sps->pic_height_in_luma_samples;
> +s->width   = sps->pic_width_in_luma_samples;
> +s->height  = sps->pic_height_in_luma_samples;
> +
> +if (sps->profile_idc == 1) avctx->profile = FF_PROFILE_EVC_MAIN;
> +else avctx->profile = FF_PROFILE_EVC_BASELINE;
> +
> +// Currently XEVD decoder supports ony YCBCR420_10LE chroma format 
> for EVC stream

The parser is standalone, limitations of some specific decoder
implementation should not affect parsing.

> +switch (sps->chroma_format_idc) {
> +case 0: /* YCBCR400_10LE */
> +av_log(avctx, AV_LOG_ERROR, "YCBCR400_10LE: Not supported chroma 
> format\n");
> +s->format = AV_PIX_FMT_GRAY10LE;
> +return -1;
> +case 1: /* YCBCR420_10LE */
> +s->format = AV_PIX_FMT_YUV420P10LE;
> +break;
> +case 2: /* YCBCR422_10LE */
> +av_log(avctx, AV_LOG_ERROR, "YCBCR422_10LE: Not supported chroma 
> format\n");
> +s->format = AV_PIX_FMT_YUV422P10LE;
> +return -1;
> +case 3: /* YCBCR444_10LE */
> +av_log(avctx, AV_LOG_ERROR, "YCBCR444_10LE: Not supported chroma 
> format\n");
> +s->format = AV_PIX_FMT_YUV444P10LE;
> +return -1;
> +default:
> +s->format = AV_PIX_FMT_NONE;
> +av_log(avctx, AV_LOG_ERROR, "Unknown supported chroma format\n");
> +return -1;
> +}
> +
> +// @note
> +// The current implementation of parse_sps function doesn't handle 
> VUI parameters parsing.
> +// If it will be needed, parse_sps function could be extended to 
> handle VUI parameters parsing
> +// to initialize fields of the AVCodecContex i.e. color_primaries, 
> color_trc,color_range
> +
> +} else if (nalu_type == EVC_PPS_NUT) { // NAL Unit type: PPS (Video 
> Parameter Set)
> +EVCParserPPS *pps;
> +
> +pps = parse_pps(bits, bits_size, ev);
> +if (!pps) {
> +av_log(avctx, AV_LOG_ERROR,

Re: [FFmpeg-devel] [PATCH v3 10/54] avutil/channel_layout: Group deprecated functions

2022-10-16 Thread Anton Khirnov
Quoting Marvin Scholz (2022-09-25 02:10:37)
> Makes it a bit easier to spot the deprecated ones when
> looking at the overview.
> ---
>  libavutil/channel_layout.h | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
> index 070c98072b..52af52390c 100644
> --- a/libavutil/channel_layout.h
> +++ b/libavutil/channel_layout.h
> @@ -394,6 +394,11 @@ typedef struct AVChannelLayout {
>  struct AVBPrint;
>  
>  #if FF_API_OLD_CHANNEL_LAYOUT
> +/**
> + * @name Depreacted Functins

tpyoes

will fix myself on pushing

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/9] avcodec/(ffv1|h264|png|snow)dec: Remove comment out DRAW_HORIZ_BAND cap

2022-10-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ffv1dec.c | 2 +-
 libavcodec/h264dec.c | 2 +-
 libavcodec/pngdec.c  | 4 ++--
 libavcodec/snowdec.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index d4bc60a7da..9a610c2ff9 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -1099,7 +1099,7 @@ const FFCodec ff_ffv1_decoder = {
 .close  = ffv1_decode_close,
 FF_CODEC_DECODE_CB(decode_frame),
 UPDATE_THREAD_CONTEXT(update_thread_context),
-.p.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ |
+.p.capabilities = AV_CODEC_CAP_DR1 |
   AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
   FF_CODEC_CAP_ALLOCATE_PROGRESS,
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 8f56f3ff92..6ede4e8c9f 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -1075,7 +1075,7 @@ const FFCodec ff_h264_decoder = {
 .init  = h264_decode_init,
 .close = h264_decode_end,
 FF_CODEC_DECODE_CB(h264_decode_frame),
-.p.capabilities= /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ 
AV_CODEC_CAP_DR1 |
+.p.capabilities= AV_CODEC_CAP_DR1 |
  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
  AV_CODEC_CAP_FRAME_THREADS,
 .hw_configs= (const AVCodecHWConfigInternal *const []) {
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 3c3eca601e..8080094d65 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1723,7 +1723,7 @@ const FFCodec ff_apng_decoder = {
 .close  = png_dec_end,
 FF_CODEC_DECODE_CB(decode_frame_apng),
 UPDATE_THREAD_CONTEXT(update_thread_context),
-.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| 
AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
+.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
   FF_CODEC_CAP_ALLOCATE_PROGRESS |
   FF_CODEC_CAP_ICC_PROFILES,
@@ -1741,7 +1741,7 @@ const FFCodec ff_png_decoder = {
 .close  = png_dec_end,
 FF_CODEC_DECODE_CB(decode_frame_png),
 UPDATE_THREAD_CONTEXT(update_thread_context),
-.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| 
AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
+.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
 .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
   FF_CODEC_CAP_ALLOCATE_PROGRESS | 
FF_CODEC_CAP_INIT_CLEANUP |
   FF_CODEC_CAP_ICC_PROFILES,
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index 5c95ffde11..bed29d3390 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -662,6 +662,6 @@ const FFCodec ff_snow_decoder = {
 .init   = ff_snow_common_init,
 .close  = decode_end,
 FF_CODEC_DECODE_CB(decode_frame),
-.p.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
+.p.capabilities = AV_CODEC_CAP_DR1,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/9] avcodec/vc1_block: Remove dead calls to ff_mpeg_draw_horiz_band()

2022-10-16 Thread Andreas Rheinhardt
The VC-1 decoders don't support draw_horiz_band at all.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dxva2_vc1.c |  2 --
 libavcodec/vaapi_vc1.c |  2 --
 libavcodec/vc1_block.c | 23 ---
 3 files changed, 27 deletions(-)

diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index cf660a50d2..12e3de59ec 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -372,8 +372,6 @@ static int dxva2_vc1_end_frame(AVCodecContext *avctx)
 &ctx_pic->pp, sizeof(ctx_pic->pp),
 NULL, 0,
 commit_bitstream_and_slice_buffer);
-if (!ret)
-ff_mpeg_draw_horiz_band(&v->s, 0, avctx->height);
 return ret;
 }
 
diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c
index d82336a3b3..fb2132e814 100644
--- a/libavcodec/vaapi_vc1.c
+++ b/libavcodec/vaapi_vc1.c
@@ -457,8 +457,6 @@ static int vaapi_vc1_end_frame(AVCodecContext *avctx)
 if (ret < 0)
 goto fail;
 
-ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
-
 fail:
 return ret;
 }
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 3267fc269b..ef8ce40e68 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -2640,15 +2640,9 @@ static void vc1_decode_i_blocks(VC1Context *v)
 v->left_blk_idx = (v->left_blk_idx + 1) % (v->end_mb_x + 2);
 v->cur_blk_idx = (v->cur_blk_idx + 1) % (v->end_mb_x + 2);
 }
-if (!v->s.loop_filter)
-ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
-else if (s->mb_y)
-ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
 
 s->first_slice_line = 0;
 }
-if (v->s.loop_filter)
-ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
 
 /* This is intentionally mb_height and not end_mb_y - unlike in advanced
  * profile, these only differ are when decoding MSS2 rectangles. */
@@ -2786,15 +2780,9 @@ static int vc1_decode_i_blocks_adv(VC1Context *v)
 inc_blk_idx(v->left_blk_idx);
 inc_blk_idx(v->cur_blk_idx);
 }
-if (!v->s.loop_filter)
-ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
-else if (s->mb_y)
-ff_mpeg_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
 s->first_slice_line = 0;
 }
 
-if (v->s.loop_filter)
-ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
 return 0;
@@ -2882,12 +2870,8 @@ static void vc1_decode_p_blocks(VC1Context *v)
 memmove(v->luma_mv_base,
 v->luma_mv - s->mb_stride,
 sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride);
-if (s->mb_y != s->start_mb_y)
-ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
 s->first_slice_line = 0;
 }
-if (s->end_mb_y >= s->start_mb_y)
-ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
 }
@@ -2964,14 +2948,8 @@ static void vc1_decode_b_blocks(VC1Context *v)
 memmove(v->is_intra_base,
 v->is_intra - s->mb_stride,
 sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
-if (!v->s.loop_filter)
-ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
-else if (s->mb_y)
-ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
 s->first_slice_line = 0;
 }
-if (v->s.loop_filter)
-ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
 }
@@ -2992,7 +2970,6 @@ static void vc1_decode_skip_blocks(VC1Context *v)
 memcpy(s->dest[0], s->last_picture.f->data[0] + s->mb_y * 16 * 
s->linesize,   s->linesize   * 16);
 memcpy(s->dest[1], s->last_picture.f->data[1] + s->mb_y *  8 * 
s->uvlinesize, s->uvlinesize *  8);
 memcpy(s->dest[2], s->last_picture.f->data[2] + s->mb_y *  8 * 
s->uvlinesize, s->uvlinesize *  8);
-ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
 s->first_slice_line = 0;
 }
 s->pict_type = AV_PICTURE_TYPE_P;
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 3/9] avcodec/mpegvideo: Don't check for draw_horiz_band

2022-10-16 Thread Andreas Rheinhardt
Some parts of mpegvideo.c behave differently depending
upon whether AVCodecContext.draw_horiz_band is set or not.
This differing behaviour makes lots of FATE tests fail
and leads to garbage output, although setting this callback
is not supposed to change the output at all.

These checks have been added in commits
3994623df2efd2749631c3492184dd8d4ffa9d1b and
b68ab2609c67d07b6f12ed65125d76bf9a054479. The commit messages
do not contain a real reason for adding the checks and it is
indeed a mystery to me. But removing these checks fixes
the FATE tests when one adds an (empty) draw_horiz_band
when using a codec that claims to support it.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 5095149eaa..ad13832fff 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1337,7 +1337,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 qpel_mc_func (*op_qpix)[16];
 const int linesize   = s->current_picture.f->linesize[0]; //not 
s->linesize as this would be wrong for field pics
 const int uvlinesize = s->current_picture.f->linesize[1];
-const int readable = s->pict_type != AV_PICTURE_TYPE_B || 
IS_ENCODER(s) || s->avctx->draw_horiz_band || lowres_flag;
+const int readable = s->pict_type != AV_PICTURE_TYPE_B || 
IS_ENCODER(s) || lowres_flag;
 const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
 
 /* avoid copy if macroblock skipped in last frame too */
@@ -1584,8 +1584,6 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME 
maybe rename
 s->dest[1] = s->current_picture.f->data[1] + (int)((s->mb_x - 1U) << 
(width_of_mb - s->chroma_x_shift));
 s->dest[2] = s->current_picture.f->data[2] + (int)((s->mb_x - 1U) << 
(width_of_mb - s->chroma_x_shift));
 
-if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && 
s->picture_structure==PICT_FRAME))
-{
 if(s->picture_structure==PICT_FRAME){
 s->dest[0] += s->mb_y *   linesize << height_of_mb;
 s->dest[1] += s->mb_y * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
@@ -1596,7 +1594,6 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME 
maybe rename
 s->dest[2] += (s->mb_y>>1) * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
 av_assert1((s->mb_y&1) == (s->picture_structure == 
PICT_BOTTOM_FIELD));
 }
-}
 }
 
 /**
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 4/9] avcodec/mpegvideo: Reindent after the last commit

2022-10-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ad13832fff..87dae1b098 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1584,16 +1584,16 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME 
maybe rename
 s->dest[1] = s->current_picture.f->data[1] + (int)((s->mb_x - 1U) << 
(width_of_mb - s->chroma_x_shift));
 s->dest[2] = s->current_picture.f->data[2] + (int)((s->mb_x - 1U) << 
(width_of_mb - s->chroma_x_shift));
 
-if(s->picture_structure==PICT_FRAME){
+if (s->picture_structure == PICT_FRAME) {
 s->dest[0] += s->mb_y *   linesize << height_of_mb;
 s->dest[1] += s->mb_y * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
 s->dest[2] += s->mb_y * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
-}else{
-s->dest[0] += (s->mb_y>>1) *   linesize << height_of_mb;
-s->dest[1] += (s->mb_y>>1) * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
-s->dest[2] += (s->mb_y>>1) * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
-av_assert1((s->mb_y&1) == (s->picture_structure == 
PICT_BOTTOM_FIELD));
-}
+} else {
+s->dest[0] += (s->mb_y>>1) *   linesize << height_of_mb;
+s->dest[1] += (s->mb_y>>1) * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
+s->dest[2] += (s->mb_y>>1) * uvlinesize << (height_of_mb - 
s->chroma_y_shift);
+av_assert1((s->mb_y&1) == (s->picture_structure == PICT_BOTTOM_FIELD));
+}
 }
 
 /**
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 5/9] avcodec/h261: Use ptrdiff_t for stride

2022-10-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h261.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/h261.c b/libavcodec/h261.c
index 7dfaee7dc4..8e0e13459a 100644
--- a/libavcodec/h261.c
+++ b/libavcodec/h261.c
@@ -30,9 +30,9 @@
 
 #define IS_FIL(a)((a) & MB_TYPE_H261_FIL)
 
-static void h261_loop_filter(uint8_t *src, int stride)
+static void h261_loop_filter(uint8_t *src, ptrdiff_t stride)
 {
-int x, y, xy, yz;
+int x, y;
 int temp[64];
 
 for (x = 0; x < 8; x++) {
@@ -41,8 +41,8 @@ static void h261_loop_filter(uint8_t *src, int stride)
 }
 for (y = 1; y < 7; y++) {
 for (x = 0; x < 8; x++) {
-xy   = y * stride + x;
-yz   = y * 8  + x;
+ptrdiff_t xy = y * stride + x;
+ptrdiff_t yz = y * 8  + x;
 temp[yz] = src[xy - stride] + 2 * src[xy] + src[xy + stride];
 }
 }
@@ -51,8 +51,8 @@ static void h261_loop_filter(uint8_t *src, int stride)
 src[y * stride] = (temp[y * 8] + 2) >> 2;
 src[y * stride + 7] = (temp[y * 8 + 7] + 2) >> 2;
 for (x = 1; x < 7; x++) {
-xy  = y * stride + x;
-yz  = y * 8  + x;
+ptrdiff_t xy = y * stride + x;
+ptrdiff_t yz = y * 8  + x;
 src[xy] = (temp[yz - 1] + 2 * temp[yz] + temp[yz + 1] + 8) >> 4;
 }
 }
@@ -61,8 +61,8 @@ static void h261_loop_filter(uint8_t *src, int stride)
 void ff_h261_loop_filter(MpegEncContext *s)
 {
 H261Context *const h = s->private_ctx;
-const int linesize   = s->linesize;
-const int uvlinesize = s->uvlinesize;
+const ptrdiff_t linesize   = s->linesize;
+const ptrdiff_t uvlinesize = s->uvlinesize;
 uint8_t *dest_y  = s->dest[0];
 uint8_t *dest_cb = s->dest[1];
 uint8_t *dest_cr = s->dest[2];
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 6/9] avcodec/mpegvideo: Move VIDEO_FORMAT_* defines to mpeg12enc.c

2022-10-16 Thread Andreas Rheinhardt
Forgotten in f899e3b51bc85c45f54f7ac64abfbde6b2cd7d3d.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12enc.c | 6 ++
 libavcodec/mpegvideo.h | 6 --
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 01cfd1c1fa..c3df924b64 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -83,6 +83,12 @@ typedef struct MPEG12EncContext {
 int a53_cc;
 int seq_disp_ext;
 int video_format;
+#define VIDEO_FORMAT_COMPONENT   0
+#define VIDEO_FORMAT_PAL 1
+#define VIDEO_FORMAT_NTSC2
+#define VIDEO_FORMAT_SECAM   3
+#define VIDEO_FORMAT_MAC 4
+#define VIDEO_FORMAT_UNSPECIFIED 5
 } MPEG12EncContext;
 
 #define A53_MAX_CC_COUNT 0x1f
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 1ddf8034aa..daaa7c95b4 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -445,12 +445,6 @@ typedef struct MpegEncContext {
 int brd_scale;
 int intra_vlc_format;
 int alternate_scan;
-#define VIDEO_FORMAT_COMPONENT   0
-#define VIDEO_FORMAT_PAL 1
-#define VIDEO_FORMAT_NTSC2
-#define VIDEO_FORMAT_SECAM   3
-#define VIDEO_FORMAT_MAC 4
-#define VIDEO_FORMAT_UNSPECIFIED 5
 int repeat_first_field;
 int chroma_420_type;
 int chroma_format;
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 8/9] avcodec/mpegutils: Reindent after the previous commit

2022-10-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegutils.c | 51 +-
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index afbb16e201..36d75b9633 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -56,7 +56,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 const int field_pic = picture_structure != PICT_FRAME;
 const AVFrame *src;
 int offset[AV_NUM_DATA_POINTERS];
-int i;
 
 if (!avctx->draw_horiz_band)
 return;
@@ -72,34 +71,34 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
 return;
 
-if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay ||
-   (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
-src = cur;
-else if (last)
-src = last;
-else
-return;
+if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay ||
+(avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
+src = cur;
+else if (last)
+src = last;
+else
+return;
 
-if (cur->pict_type == AV_PICTURE_TYPE_B &&
-picture_structure == PICT_FRAME &&
-avctx->codec_id != AV_CODEC_ID_SVQ3) {
-for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
-offset[i] = 0;
-} else {
-const AVPixFmtDescriptor *desc = 
av_pix_fmt_desc_get(avctx->pix_fmt);
-int vshift = desc->log2_chroma_h;
-
-offset[0]= y * src->linesize[0];
-offset[1]=
-offset[2]= (y >> vshift) * src->linesize[1];
-for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
-offset[i] = 0;
-}
+if (cur->pict_type == AV_PICTURE_TYPE_B &&
+picture_structure == PICT_FRAME &&
+avctx->codec_id != AV_CODEC_ID_SVQ3) {
+for (int i = 0; i < AV_NUM_DATA_POINTERS; i++)
+offset[i] = 0;
+} else {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+int vshift = desc->log2_chroma_h;
+
+offset[0] = y * src->linesize[0];
+offset[1] =
+offset[2] = (y >> vshift) * src->linesize[1];
+for (int i = 3; i < AV_NUM_DATA_POINTERS; i++)
+offset[i] = 0;
+}
 
-emms_c();
+emms_c();
 
-avctx->draw_horiz_band(avctx, src, offset,
-   y, picture_structure, h);
+avctx->draw_horiz_band(avctx, src, offset,
+y, picture_structure, h);
 }
 
 static char get_type_mv_char(int mb_type)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 9/9] avcodec/ffv1: Move ffv1_template.c inclusion to dec/enc templates

2022-10-16 Thread Andreas Rheinhardt
Both the FFV1 decoder and encoder use a template of their own
to generate code multiple times. They also use a common template,
used by both decoder and encoder templates which is currently
instantiated in ffv1.h (and therefore also in ffv1.c, which
doesn't need it at all).

All these templates have the prerequisite that two macros
are defined, namely RENAME() and TYPE. The codec-specific
templates call the functions generated via the common template
via the RENAME() macro and therefore the macros used for
the common template must coincide with the macros used for
the codec-specific templates. But then it is better to not
instantiate the common template in ffv1.h, but in the codec
specific templates.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ffv1.h | 12 
 libavcodec/ffv1dec_template.c |  2 ++
 libavcodec/ffv1enc_template.c |  2 ++
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 3532815501..005f308784 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -182,16 +182,4 @@ static inline void update_vlc_state(VlcState *const state, 
const int v)
 state->count = count;
 }
 
-#define TYPE int16_t
-#define RENAME(name) name
-#include "ffv1_template.c"
-#undef TYPE
-#undef RENAME
-
-#define TYPE int32_t
-#define RENAME(name) name ## 32
-#include "ffv1_template.c"
-#undef TYPE
-#undef RENAME
-
 #endif /* AVCODEC_FFV1_H */
diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
index 9b1d65e825..590ccac022 100644
--- a/libavcodec/ffv1dec_template.c
+++ b/libavcodec/ffv1dec_template.c
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "ffv1_template.c"
+
 static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
  TYPE *sample[2],
  int plane_index, int bits)
diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c
index 8a4a387923..8953dbe07c 100644
--- a/libavcodec/ffv1enc_template.c
+++ b/libavcodec/ffv1enc_template.c
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "ffv1_template.c"
+
 static av_always_inline int RENAME(encode_line)(FFV1Context *s, int w,
 TYPE *sample[3],
 int plane_index, int bits)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 7/9] avcodec/mpegutils: Return early in ff_draw_horiz_band()

2022-10-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegutils.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index ff9418232b..afbb16e201 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -53,9 +53,14 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 int y, int h, int picture_structure,
 int first_field, int low_delay)
 {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
-int vshift = desc->log2_chroma_h;
 const int field_pic = picture_structure != PICT_FRAME;
+const AVFrame *src;
+int offset[AV_NUM_DATA_POINTERS];
+int i;
+
+if (!avctx->draw_horiz_band)
+return;
+
 if (field_pic) {
 h <<= 1;
 y <<= 1;
@@ -67,11 +72,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
 return;
 
-if (avctx->draw_horiz_band) {
-const AVFrame *src;
-int offset[AV_NUM_DATA_POINTERS];
-int i;
-
 if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay ||
(avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
 src = cur;
@@ -86,6 +86,9 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
 offset[i] = 0;
 } else {
+const AVPixFmtDescriptor *desc = 
av_pix_fmt_desc_get(avctx->pix_fmt);
+int vshift = desc->log2_chroma_h;
+
 offset[0]= y * src->linesize[0];
 offset[1]=
 offset[2]= (y >> vshift) * src->linesize[1];
@@ -97,7 +100,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 
 avctx->draw_horiz_band(avctx, src, offset,
y, picture_structure, h);
-}
 }
 
 static char get_type_mv_char(int mb_type)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/6] avcodec/mpegvideo: Ignore skip_idct for encoders

2022-10-16 Thread Andreas Rheinhardt
It is documented to be unused for encoders.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 5095149eaa..448b65bb96 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1413,7 +1413,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, 
s->next_picture.f->data, op_pix, op_qpix);
 }
 }
-}
 
 /* skip dequant / idct if we are really late ;) */
 if(s->avctx->skip_idct){
@@ -1422,6 +1421,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
|| s->avctx->skip_idct >= AVDISCARD_ALL)
 goto skip_idct;
 }
+}
 
 /* add dct residue */
 if (IS_ENCODER(s) || !(IS_MPEG12(s) || s->msmpeg4_version
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideo: Make inlining is_mpeg12 more flexible

2022-10-16 Thread Andreas Rheinhardt
There are two types of checks for whether the current codec
is MPEG-1/2 in mpv_reconstruct_mb_internal(): Those that are
required for correctness and those that are not; an example
of the latter is "is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)".
The reason for the existence of such checks is that
mpv_reconstruct_mb_internal() has the av_always_inline attribute
and is_mpeg12 is usually inlined, so that in case we are dealing
with MPEG-1/2 the above check can be completely optimized away.

But is_mpeg12 is not always inlined: it is not in case
CONFIG_SMALL is true in which case is_mpeg12 is always zero,
so that the checks required for correctness need to check
out_format explicitly. This is currently done via a macro
in mpv_reconstruct_mb_internal(), so that the fact that
it is CONFIG_SMALL that determines this is encoded at two places.

This commit changes this by making is_mpeg12 a three-state:
DEFINITELY_MPEG12, MAY_BE_MPEG12 and NOT_MPEG12. In the second
case, one has to resort to check out_format, in the other cases
is_mpeg12 can be taken at face-value. This will allow to make
inlining is_mpeg12 more flexible in a future commit.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 448b65bb96..c2fedbfdaa 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1294,6 +1294,10 @@ void ff_clean_intra_table_entries(MpegEncContext *s)
 s->mbintra_table[xy]= 0;
 }
 
+#define NOT_MPEG120
+#define MAY_BE_MPEG12 1
+#define DEFINITELY_MPEG12 2
+
 /* generic function called after a macroblock has been parsed by the
decoder or after it has been encoded by the encoder.
 
@@ -1309,14 +1313,14 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 int lowres_flag, int is_mpeg12)
 {
 #define IS_ENCODER(s) (CONFIG_MPEGVIDEOENC && !lowres_flag && (s)->encoding)
-#define IS_MPEG12(s) (CONFIG_SMALL ? ((s)->out_format == FMT_MPEG1) : 
is_mpeg12)
+#define IS_MPEG12(s) (is_mpeg12 == MAY_BE_MPEG12 ? ((s)->out_format == 
FMT_MPEG1) : is_mpeg12)
 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
 
 s->current_picture.qscale_table[mb_xy] = s->qscale;
 
 /* update DC predictors for P macroblocks */
 if (!s->mb_intra) {
-if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) {
+if (is_mpeg12 != DEFINITELY_MPEG12 && (s->h263_pred || s->h263_aic)) {
 if(s->mbintra_table[mb_xy])
 ff_clean_intra_table_entries(s);
 } else {
@@ -1324,8 +1328,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 s->last_dc[1] =
 s->last_dc[2] = 128 << s->intra_dc_precision;
 }
-}
-else if (!is_mpeg12 && (s->h263_pred || s->h263_aic))
+} else if (is_mpeg12 != DEFINITELY_MPEG12 && (s->h263_pred || s->h263_aic))
 s->mbintra_table[mb_xy]=1;
 
 if (!IS_ENCODER(s) || (s->avctx->flags & AV_CODEC_FLAG_PSNR) || 
s->frame_skip_threshold || s->frame_skip_factor ||
@@ -1399,7 +1402,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 }
 }else{
 op_qpix = s->me.qpel_put;
-if ((is_mpeg12 || !s->no_rounding) || s->pict_type == 
AV_PICTURE_TYPE_B) {
+if ((is_mpeg12 == DEFINITELY_MPEG12 || !s->no_rounding) || 
s->pict_type == AV_PICTURE_TYPE_B) {
 op_pix = s->hdsp.put_pixels_tab;
 }else{
 op_pix = s->hdsp.put_no_rnd_pixels_tab;
@@ -1444,7 +1447,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, 
dct_linesize, s->chroma_qscale);
 }
 }
-} else if(is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)){
+} else if (is_mpeg12 == DEFINITELY_MPEG12 || (s->codec_id != 
AV_CODEC_ID_WMV2)){
 add_dct(s, block[0], 0, dest_y  , 
dct_linesize);
 add_dct(s, block[1], 1, dest_y  + block_size, 
dct_linesize);
 add_dct(s, block[2], 2, dest_y + dct_offset , 
dct_linesize);
@@ -1477,7 +1480,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 } else {
 /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
TODO: Integrate 10-bit properly into mpegvideo.c so that ER 
works properly */
-if (!is_mpeg12 && CONFIG_MPEG4_DECODER && /* s->codec_id == 
AV_CODEC_ID_MPEG4 && */
+if (is_mpeg12 != DEFINITELY_MPEG12 && CONFIG_MPEG4_DECODER &&
+/* s->codec_id == AV_CODEC_ID_MPEG4 && */
 s->avctx->bits_per_raw_sample > 8) {
  

[FFmpeg-devel] [PATCH 3/6] avcodec/mpegvideo: Inline is_encoder in mpv_reconstruct_mb_internal()

2022-10-16 Thread Andreas Rheinhardt
Up until now, we inlined lowres_flag as well as is_mpeg12
independently (unless CONFIG_SMALL was true); this commit
changes this to instead inline mpv_reconstruct_mb_internal()
(at most) four times, namely once for encoders, once for decoders
using lowres and once for non-lowres mpeg-1/2 decoders and once
for non-lowres non-mpeg-1/2 decoders (mpeg-1/2 is not inlined
in case of CONFIG_SMALL). This is neutral performance-wise,
but proved beneficial size-wise: It saved 1776B of .text
for GCC 11 or 1344B for Clang 14 (both -O3 x64).

Notice that inlining is_mpeg12 for is_encoder would not really
be beneficial, as the encoder codepath does mostly not depend
on is_mpeg12 at all.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index c2fedbfdaa..43f3ec5a47 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1310,9 +1310,8 @@ void ff_clean_intra_table_entries(MpegEncContext *s)
  */
 static av_always_inline
 void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
-int lowres_flag, int is_mpeg12)
+ int lowres_flag, int is_mpeg12, int 
is_encoder)
 {
-#define IS_ENCODER(s) (CONFIG_MPEGVIDEOENC && !lowres_flag && (s)->encoding)
 #define IS_MPEG12(s) (is_mpeg12 == MAY_BE_MPEG12 ? ((s)->out_format == 
FMT_MPEG1) : is_mpeg12)
 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
 
@@ -1331,7 +1330,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 } else if (is_mpeg12 != DEFINITELY_MPEG12 && (s->h263_pred || s->h263_aic))
 s->mbintra_table[mb_xy]=1;
 
-if (!IS_ENCODER(s) || (s->avctx->flags & AV_CODEC_FLAG_PSNR) || 
s->frame_skip_threshold || s->frame_skip_factor ||
+if (!is_encoder || (s->avctx->flags & AV_CODEC_FLAG_PSNR) || 
s->frame_skip_threshold || s->frame_skip_factor ||
 !((s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
   s->avctx->mb_decision != FF_MB_DECISION_RD)) { // FIXME precalc
 uint8_t *dest_y, *dest_cb, *dest_cr;
@@ -1340,12 +1339,12 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 qpel_mc_func (*op_qpix)[16];
 const int linesize   = s->current_picture.f->linesize[0]; //not 
s->linesize as this would be wrong for field pics
 const int uvlinesize = s->current_picture.f->linesize[1];
-const int readable = s->pict_type != AV_PICTURE_TYPE_B || 
IS_ENCODER(s) || s->avctx->draw_horiz_band || lowres_flag;
+const int readable = s->pict_type != AV_PICTURE_TYPE_B || is_encoder 
|| s->avctx->draw_horiz_band || lowres_flag;
 const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
 
 /* avoid copy if macroblock skipped in last frame too */
 /* skip only during decoding as we might trash the buffers during 
encoding a bit */
-if (!IS_ENCODER(s)) {
+if (!is_encoder) {
 uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
 
 if (s->mb_skipped) {
@@ -1375,7 +1374,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 if (!s->mb_intra) {
 /* motion handling */
 /* decoding or more than one mb_type (MC was already done 
otherwise) */
-if (!IS_ENCODER(s)) {
+if (!is_encoder) {
 
 if(HAVE_THREADS && 
s->avctx->active_thread_type&FF_THREAD_FRAME) {
 if (s->mv_dir & MV_DIR_FORWARD) {
@@ -1427,7 +1426,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 }
 
 /* add dct residue */
-if (IS_ENCODER(s) || !(IS_MPEG12(s) || s->msmpeg4_version
+if (is_encoder || !(IS_MPEG12(s) || s->msmpeg4_version
 || (s->codec_id==AV_CODEC_ID_MPEG4 && 
!s->mpeg_quant))){
 add_dequant_dct(s, block[0], 0, dest_y 
 , dct_linesize, s->qscale);
 add_dequant_dct(s, block[1], 1, dest_y  + 
block_size, dct_linesize, s->qscale);
@@ -1480,14 +1479,14 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 } else {
 /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
TODO: Integrate 10-bit properly into mpegvideo.c so that ER 
works properly */
-if (is_mpeg12 != DEFINITELY_MPEG12 && CONFIG_MPEG4_DECODER &&
+if (!is_encoder && is_mpeg12 != DEFINITELY_MPEG12 && 
CONFIG_MPEG4_DECODER &&
 /* s->codec_id == AV_CODEC_ID_MPEG4 && */
 s->avctx->bits_per_raw_sample > 8) {
 ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
uvlinesize, dct_linesize, dct_offset);
 }
 /* dct only in

[FFmpeg-devel] [PATCH 4/6] avcodec/mpegvideo: Split ff_mpv_reconstruct_mb() into de/encoder part

2022-10-16 Thread Andreas Rheinhardt
This has the advantage of not having to check for whether
a given MpegEncContext is actually a decoder or an encoder
context at runtime.

To do so, mpv_reconstruct_mb_internal() is moved into a new
template file that is included by both mpegvideo_enc.c
and mpegvideo_dec.c; the decoder-only code (mainly lowres)
are also moved to mpegvideo_dec.c. The is_encoder checks are
changed to #if IS_ENCODER in order to avoid having to include
headers for decoder-only functions in mpegvideo_enc.c.

This approach also has the advantage that it is easy to adapt
mpv_reconstruct_mb_internal() to using different structures
for decoders and encoders (e.g. the check for whether
a macroblock should be processed for the encoder or not
uses MpegEncContext elements that make no sense for decoders
and should not be part of their context).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg_er.c |   1 +
 libavcodec/mpegvideo.c   | 737 ---
 libavcodec/mpegvideo.h   |   2 -
 libavcodec/mpegvideo_dec.c   | 467 ++
 libavcodec/mpegvideo_enc.c   |  26 +-
 libavcodec/mpegvideodec.h|   1 +
 libavcodec/mpv_reconstruct_mb_template.c | 300 +
 7 files changed, 792 insertions(+), 742 deletions(-)
 create mode 100644 libavcodec/mpv_reconstruct_mb_template.c

diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index 02f407d8ea..8034963253 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -18,6 +18,7 @@
 
 #include "error_resilience.h"
 #include "mpegvideo.h"
+#include "mpegvideodec.h"
 #include "mpeg_er.h"
 
 static void set_erpic(ERPicture *dst, Picture *src)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 43f3ec5a47..850d8f2e94 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -27,8 +27,6 @@
  * The simplest mpeg encoder (well, it was the simplest!).
  */
 
-#include "config_components.h"
-
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
@@ -42,12 +40,7 @@
 #include "mpeg_er.h"
 #include "mpegutils.h"
 #include "mpegvideo.h"
-#include "mpeg4videodec.h"
 #include "mpegvideodata.h"
-#include "qpeldsp.h"
-#include "threadframe.h"
-#include "wmv2dec.h"
-#include 
 
 static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
int16_t *block, int n, int qscale)
@@ -811,456 +804,6 @@ void ff_mpv_common_end(MpegEncContext *s)
 }
 
 
-static inline int hpel_motion_lowres(MpegEncContext *s,
- uint8_t *dest, const uint8_t *src,
- int field_based, int field_select,
- int src_x, int src_y,
- int width, int height, ptrdiff_t stride,
- int h_edge_pos, int v_edge_pos,
- int w, int h, const h264_chroma_mc_func 
*pix_op,
- int motion_x, int motion_y)
-{
-const int lowres   = s->avctx->lowres;
-const int op_index = FFMIN(lowres, 3);
-const int s_mask   = (2 << lowres) - 1;
-int emu = 0;
-int sx, sy;
-
-if (s->quarter_sample) {
-motion_x /= 2;
-motion_y /= 2;
-}
-
-sx = motion_x & s_mask;
-sy = motion_y & s_mask;
-src_x += motion_x >> lowres + 1;
-src_y += motion_y >> lowres + 1;
-
-src   += src_y * stride + src_x;
-
-if ((unsigned)src_x > FFMAX( h_edge_pos - (!!sx) - w, 0) ||
-(unsigned)src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
-s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src,
- s->linesize, s->linesize,
- w + 1, (h + 1) << field_based,
- src_x, src_y * (1 << field_based),
- h_edge_pos, v_edge_pos);
-src = s->sc.edge_emu_buffer;
-emu = 1;
-}
-
-sx = (sx << 2) >> lowres;
-sy = (sy << 2) >> lowres;
-if (field_select)
-src += s->linesize;
-pix_op[op_index](dest, src, stride, h, sx, sy);
-return emu;
-}
-
-/* apply one mpeg motion vector to the three components */
-static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
-uint8_t *dest_y,
-uint8_t *dest_cb,
-uint8_t *dest_cr,
-int field_based,
-int bottom_field,
-int field_select,
-uint8_t *const *ref_picture,
-const h264_chroma_mc_func 
*pix_op,
-int motion_x, int 

[FFmpeg-devel] [PATCH 5/6] avcodec/mpeg12dec: Remove always-true check

2022-10-16 Thread Andreas Rheinhardt
mpeg12dec.c is a decoder-only file.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index df76a90c6c..56bf73df11 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1788,7 +1788,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
 return ret;
 
 // Note motion_val is normally NULL unless we want to extract the MVs.
-if (s->current_picture.motion_val[0] && !s->encoding) {
+if (s->current_picture.motion_val[0]) {
 const int wrap = s->b8_stride;
 int xy = s->mb_x * 2 + s->mb_y * 2 * wrap;
 int b8_xy  = 4 * (s->mb_x + s->mb_y * s->mb_stride);
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 6/6] avcodec/mpv_reconstruct_mb_template: Optimize dead code away

2022-10-16 Thread Andreas Rheinhardt
None of the MPEG-1/2 codecs support frame threading,
so one can optimize the check for it away.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpv_reconstruct_mb_template.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpv_reconstruct_mb_template.c 
b/libavcodec/mpv_reconstruct_mb_template.c
index 7d74ec1f5c..5f2a19e587 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -121,7 +121,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t 
block[12][64],
 /* decoding or more than one mb_type (MC was already done 
otherwise) */
 
 #if !IS_ENCODER
-if (HAVE_THREADS && s->avctx->active_thread_type & 
FF_THREAD_FRAME) {
+if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12 &&
+s->avctx->active_thread_type & FF_THREAD_FRAME) {
 if (s->mv_dir & MV_DIR_FORWARD) {
 ff_thread_await_progress(&s->last_picture_ptr->tf,
  lowest_referenced_row(s, 0), 0);
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH] lavc/qsvenc: fill the padding area

2022-10-16 Thread Xiang, Haihao
On Mon, 2022-10-10 at 16:05 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang 
> 
> qsvenc makes a copy when the input in system memory is not padded as the
> SDK requires, however the padding area is not filled with right data
> 
> Signed-off-by: Haihao Xiang 
> ---
>  libavcodec/qsvenc.c | 69 +++--
>  1 file changed, 67 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index dc5479d0f3..15e6936a65 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -1514,6 +1514,64 @@ static int get_free_frame(QSVEncContext *q, QSVFrame
> **f)
>  return 0;
>  }
>  
> +static int qsvenc_fill_padding_area(AVFrame *frame, int new_w, int new_h)
> +{
> +const AVPixFmtDescriptor *desc;
> +int max_step[4], filled[4] = { 0 };
> +
> +desc = av_pix_fmt_desc_get(frame->format);
> +av_assert0(desc);
> +av_image_fill_max_pixsteps(max_step, NULL, desc);
> +
> +for (int i = 0; i < desc->nb_components; i++) {
> +const AVComponentDescriptor *comp = &desc->comp[i];
> +int sheight, dheight, plane = comp->plane;
> +ptrdiff_t swidth = av_image_get_linesize(frame->format,
> + frame->width,
> + plane);
> +ptrdiff_t dwidth = av_image_get_linesize(frame->format,
> + new_w,
> + plane);
> +
> +if (swidth < 0 || dwidth < 0) {
> +av_log(NULL, AV_LOG_ERROR, "av_image_get_linesize failed\n");
> +return AVERROR(EINVAL);
> +}
> +
> +if (filled[plane])
> +continue;
> +
> +sheight = frame->height;
> +dheight = new_h;
> +
> +if (plane) {
> +sheight = AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h);
> +dheight = AV_CEIL_RSHIFT(new_h, desc->log2_chroma_h);
> +}
> +
> +// Fill right padding
> +if (new_w > frame->width) {
> +for (int j = 0; j < sheight; j++) {
> +void *line_ptr = frame->data[plane] + j * frame-
> >linesize[plane] + swidth;
> +
> +av_memcpy_backptr(line_ptr,
> +  max_step[plane],
> +  new_w - frame->width);
> +}
> +}
> +
> +// Fill bottom padding
> +for (int j = sheight; j < dheight; j++)
> +memcpy(frame->data[plane] + j * frame->linesize[plane],
> +   frame->data[plane] + (sheight - 1) * frame-
> >linesize[plane],
> +   dwidth);
> +
> +filled[plane] = 1;
> +}
> +
> +return 0;
> +}
> +
>  static int submit_frame(QSVEncContext *q, const AVFrame *frame,
>  QSVFrame **new_frame)
>  {
> @@ -1543,8 +1601,9 @@ static int submit_frame(QSVEncContext *q, const AVFrame
> *frame,
>  /* and to make allocation continious for data[0]/data[1] */
>   if ((frame->height & 31 || frame->linesize[0] & (q->width_align -
> 1)) ||
>  (frame->data[1] - frame->data[0] != frame->linesize[0] *
> FFALIGN(qf->frame->height, q->height_align))) {
> -qf->frame->height = FFALIGN(frame->height, q->height_align);
> -qf->frame->width  = FFALIGN(frame->width, q->width_align);
> +int tmp_w, tmp_h;
> +qf->frame->height = tmp_h = FFALIGN(frame->height, q-
> >height_align);
> +qf->frame->width  = tmp_w = FFALIGN(frame->width, q-
> >width_align);
>  
>  qf->frame->format = frame->format;
>  
> @@ -1562,6 +1621,12 @@ static int submit_frame(QSVEncContext *q, const AVFrame
> *frame,
>  av_frame_unref(qf->frame);
>  return ret;
>  }
> +
> +ret = qsvenc_fill_padding_area(qf->frame, tmp_w, tmp_h);
> +if (ret < 0) {
> +av_frame_unref(qf->frame);
> +return ret;
> +}
>  } else {
>  av_frame_unref(qf->frame);
>  ret = av_frame_ref(qf->frame, frame);

Will apply,

-Haihao

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

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


[FFmpeg-devel] [PATCH] avcodec/svq1: fix interframe mean VLC symbols

2022-10-16 Thread Peter Ross
Fixes ticket #128.

The SVQ1 interframe mean VLC symbols -128 and 128 are incorrectly swapped
in our SVQ1 implementation, resulting in visible artifacts for some videos.
This patch unswaps the order of these two symbols.

The most noticable example of the artiacts caused by this error can be observed 
in
https://trac.ffmpeg.org/attachment/ticket/128/svq1_set.7z '352_288_k_50.mov'.
The artifacts are not observed when using the reference decoder
(QuickTime 7.7.9 x86 binary).

As a result of this patch, the reference data for the fate-svq1 test
($SAMPLES/svq1/marymary-shackles.mov) must be modified. For this file, our
decoder output is now bitwise identical to the reference decoder. I have
tested patch with various other samples and they are all now bitwise identical.
---
 libavcodec/svq1_vlc.h |  4 ++--
 tests/ref/fate/svq1   | 22 +++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/svq1_vlc.h b/libavcodec/svq1_vlc.h
index 06e3509e4d..5c27928c2a 100644
--- a/libavcodec/svq1_vlc.h
+++ b/libavcodec/svq1_vlc.h
@@ -167,7 +167,7 @@ const uint16_t ff_svq1_inter_mean_vlc[512][2] = {
 { 0xA0, 22 },  { 0xA1, 22 },  { 0xA2, 22 },  { 0xA3, 22 },
 { 0xA4, 22 },  { 0xA5, 22 },  { 0xA6, 22 },  { 0xA7, 22 },
 { 0xA8, 22 },  { 0xA9, 22 },  { 0xAA, 22 },  { 0xAB, 22 },
-{ 0x7F, 22 },  { 0x8F, 21 },  { 0xAC, 22 },  { 0xAD, 22 },
+{ 0x8E, 21 },  { 0x8F, 21 },  { 0xAC, 22 },  { 0xAD, 22 },
 { 0xAE, 22 },  { 0xAF, 22 },  { 0xB0, 22 },  { 0xB1, 22 },
 { 0x53, 20 },  { 0x90, 21 },  { 0xB2, 22 },  { 0x91, 21 },
 { 0xB3, 22 },  { 0xB4, 22 },  { 0x54, 20 },  { 0xB5, 22 },
@@ -231,7 +231,7 @@ const uint16_t ff_svq1_inter_mean_vlc[512][2] = {
 { 0x87, 21 },  { 0x4F, 20 },  { 0x35, 19 },  { 0x4E, 20 },
 { 0x33, 19 },  { 0x32, 19 },  { 0x4D, 20 },  { 0x4C, 20 },
 { 0x83, 22 },  { 0x4B, 20 },  { 0x81, 22 },  { 0x80, 22 },
-{ 0x8E, 21 },  { 0x7E, 22 },  { 0x7D, 22 },  { 0x84, 21 },
+{ 0x7F, 22 },  { 0x7E, 22 },  { 0x7D, 22 },  { 0x84, 21 },
 { 0x8D, 21 },  { 0x7A, 22 },  { 0x79, 22 },  { 0x4A, 20 },
 { 0x77, 22 },  { 0x76, 22 },  { 0x89, 21 },  { 0x74, 22 },
 { 0x73, 22 },  { 0x72, 22 },  { 0x49, 20 },  { 0x70, 22 },
diff --git a/tests/ref/fate/svq1 b/tests/ref/fate/svq1
index d53e2952e4..0b0948cce6 100644
--- a/tests/ref/fate/svq1
+++ b/tests/ref/fate/svq1
@@ -24,19 +24,19 @@
 0, 18, 18,1,21600, 0x8d5b2ad0
 0, 19, 19,1,21600, 0xe67128e6
 0, 20, 20,1,21600, 0xb7bf613e
-0, 21, 21,1,21600, 0xefd0f51b
-0, 22, 22,1,21600, 0x31b7da59
+0, 21, 21,1,21600, 0xf697fa3e
+0, 22, 22,1,21600, 0x5b6ede88
 0, 23, 23,1,21600, 0x7a84a8f7
 0, 24, 24,1,21600, 0x0351ad27
-0, 25, 25,1,21600, 0xed6f434d
-0, 26, 26,1,21600, 0x0e771127
-0, 27, 27,1,21600, 0x37bf0b95
-0, 28, 28,1,21600, 0x30e10a77
-0, 29, 29,1,21600, 0x1a48288a
-0, 30, 30,1,21600, 0xf43c6770
-0, 31, 31,1,21600, 0x3c43ae68
-0, 32, 32,1,21600, 0x04dc0949
-0, 33, 33,1,21600, 0x7920758d
+0, 25, 25,1,21600, 0x57b547c2
+0, 26, 26,1,21600, 0xbb9e1558
+0, 27, 27,1,21600, 0xcb470f6b
+0, 28, 28,1,21600, 0xeb100de0
+0, 29, 29,1,21600, 0x089c2bf0
+0, 30, 30,1,21600, 0xe27b6a42
+0, 31, 31,1,21600, 0xbfe2b11b
+0, 32, 32,1,21600, 0xd9ca0bb5
+0, 33, 33,1,21600, 0x12fe783c
 0, 34, 34,1,21600, 0x6c12bab5
 0, 35, 35,1,21600, 0x1ac23706
 0, 36, 36,1,21600, 0x7a95cb5f
-- 
2.35.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avcodec/svq1: fix interframe mean VLC symbols

2022-10-16 Thread Andreas Rheinhardt
Peter Ross:
> Fixes ticket #128.
> 
> The SVQ1 interframe mean VLC symbols -128 and 128 are incorrectly swapped
> in our SVQ1 implementation, resulting in visible artifacts for some videos.
> This patch unswaps the order of these two symbols.
> 
> The most noticable example of the artiacts caused by this error can be 
> observed in
> https://trac.ffmpeg.org/attachment/ticket/128/svq1_set.7z '352_288_k_50.mov'.
> The artifacts are not observed when using the reference decoder
> (QuickTime 7.7.9 x86 binary).
> 
> As a result of this patch, the reference data for the fate-svq1 test
> ($SAMPLES/svq1/marymary-shackles.mov) must be modified. For this file, our
> decoder output is now bitwise identical to the reference decoder. I have
> tested patch with various other samples and they are all now bitwise 
> identical.

Seems like this is not the only test whose reference needs to be
updated. There are also the fate-vsynth%-svq1 tests.

> ---
>  libavcodec/svq1_vlc.h |  4 ++--
>  tests/ref/fate/svq1   | 22 +++---
>  2 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/libavcodec/svq1_vlc.h b/libavcodec/svq1_vlc.h
> index 06e3509e4d..5c27928c2a 100644
> --- a/libavcodec/svq1_vlc.h
> +++ b/libavcodec/svq1_vlc.h
> @@ -167,7 +167,7 @@ const uint16_t ff_svq1_inter_mean_vlc[512][2] = {
>  { 0xA0, 22 },  { 0xA1, 22 },  { 0xA2, 22 },  { 0xA3, 22 },
>  { 0xA4, 22 },  { 0xA5, 22 },  { 0xA6, 22 },  { 0xA7, 22 },
>  { 0xA8, 22 },  { 0xA9, 22 },  { 0xAA, 22 },  { 0xAB, 22 },
> -{ 0x7F, 22 },  { 0x8F, 21 },  { 0xAC, 22 },  { 0xAD, 22 },
> +{ 0x8E, 21 },  { 0x8F, 21 },  { 0xAC, 22 },  { 0xAD, 22 },
>  { 0xAE, 22 },  { 0xAF, 22 },  { 0xB0, 22 },  { 0xB1, 22 },
>  { 0x53, 20 },  { 0x90, 21 },  { 0xB2, 22 },  { 0x91, 21 },
>  { 0xB3, 22 },  { 0xB4, 22 },  { 0x54, 20 },  { 0xB5, 22 },
> @@ -231,7 +231,7 @@ const uint16_t ff_svq1_inter_mean_vlc[512][2] = {
>  { 0x87, 21 },  { 0x4F, 20 },  { 0x35, 19 },  { 0x4E, 20 },
>  { 0x33, 19 },  { 0x32, 19 },  { 0x4D, 20 },  { 0x4C, 20 },
>  { 0x83, 22 },  { 0x4B, 20 },  { 0x81, 22 },  { 0x80, 22 },
> -{ 0x8E, 21 },  { 0x7E, 22 },  { 0x7D, 22 },  { 0x84, 21 },
> +{ 0x7F, 22 },  { 0x7E, 22 },  { 0x7D, 22 },  { 0x84, 21 },
>  { 0x8D, 21 },  { 0x7A, 22 },  { 0x79, 22 },  { 0x4A, 20 },
>  { 0x77, 22 },  { 0x76, 22 },  { 0x89, 21 },  { 0x74, 22 },
>  { 0x73, 22 },  { 0x72, 22 },  { 0x49, 20 },  { 0x70, 22 },
> diff --git a/tests/ref/fate/svq1 b/tests/ref/fate/svq1
> index d53e2952e4..0b0948cce6 100644
> --- a/tests/ref/fate/svq1
> +++ b/tests/ref/fate/svq1
> @@ -24,19 +24,19 @@
>  0, 18, 18,1,21600, 0x8d5b2ad0
>  0, 19, 19,1,21600, 0xe67128e6
>  0, 20, 20,1,21600, 0xb7bf613e
> -0, 21, 21,1,21600, 0xefd0f51b
> -0, 22, 22,1,21600, 0x31b7da59
> +0, 21, 21,1,21600, 0xf697fa3e
> +0, 22, 22,1,21600, 0x5b6ede88
>  0, 23, 23,1,21600, 0x7a84a8f7
>  0, 24, 24,1,21600, 0x0351ad27
> -0, 25, 25,1,21600, 0xed6f434d
> -0, 26, 26,1,21600, 0x0e771127
> -0, 27, 27,1,21600, 0x37bf0b95
> -0, 28, 28,1,21600, 0x30e10a77
> -0, 29, 29,1,21600, 0x1a48288a
> -0, 30, 30,1,21600, 0xf43c6770
> -0, 31, 31,1,21600, 0x3c43ae68
> -0, 32, 32,1,21600, 0x04dc0949
> -0, 33, 33,1,21600, 0x7920758d
> +0, 25, 25,1,21600, 0x57b547c2
> +0, 26, 26,1,21600, 0xbb9e1558
> +0, 27, 27,1,21600, 0xcb470f6b
> +0, 28, 28,1,21600, 0xeb100de0
> +0, 29, 29,1,21600, 0x089c2bf0
> +0, 30, 30,1,21600, 0xe27b6a42
> +0, 31, 31,1,21600, 0xbfe2b11b
> +0, 32, 32,1,21600, 0xd9ca0bb5
> +0, 33, 33,1,21600, 0x12fe783c
>  0, 34, 34,1,21600, 0x6c12bab5
>  0, 35, 35,1,21600, 0x1ac23706
>  0, 36, 36,1,21600, 0x7a95cb5f
> 
> 

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

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