Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avcodec/mpegvideo_enc: Initialize dct_unquantize_int(ra|er) only once
@ 2022-10-27 17:50 Andreas Rheinhardt
  2022-10-29 16:47 ` Andreas Rheinhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Rheinhardt @ 2022-10-27 17:50 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

For encoders, mpeg_quant is an option of the MPEG-4 encoder
and therefore constant. This implies that one can set
the dct_unquantize_(intra|inter) function pointers during init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ce363a585d..0b709974a1 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -880,6 +880,17 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 
     ff_dct_encode_init(s);
 
+    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
+        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
+    } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
+        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
+        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
+    } else {
+        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
+        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
+    }
+
     if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)
         s->chroma_qscale_table = ff_h263_chroma_qscale_table;
 
@@ -1723,17 +1734,6 @@ static int frame_start(MpegEncContext *s)
         }
     }
 
-    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
-        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
-        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
-    } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
-        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
-        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
-    } else {
-        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
-        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
-    }
-
     if (s->dct_error_sum) {
         av_assert2(s->noise_reduction && s->encoding);
         update_noise_reduction(s);
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/mpegvideo_enc: Initialize dct_unquantize_int(ra|er) only once
  2022-10-27 17:50 [FFmpeg-devel] [PATCH] avcodec/mpegvideo_enc: Initialize dct_unquantize_int(ra|er) only once Andreas Rheinhardt
@ 2022-10-29 16:47 ` Andreas Rheinhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Rheinhardt @ 2022-10-29 16:47 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> For encoders, mpeg_quant is an option of the MPEG-4 encoder
> and therefore constant. This implies that one can set
> the dct_unquantize_(intra|inter) function pointers during init.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/mpegvideo_enc.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index ce363a585d..0b709974a1 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -880,6 +880,17 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
>  
>      ff_dct_encode_init(s);
>  
> +    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
> +        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
> +        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
> +    } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
> +        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
> +        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
> +    } else {
> +        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
> +        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
> +    }
> +
>      if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)
>          s->chroma_qscale_table = ff_h263_chroma_qscale_table;
>  
> @@ -1723,17 +1734,6 @@ static int frame_start(MpegEncContext *s)
>          }
>      }
>  
> -    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
> -        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
> -        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
> -    } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
> -        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
> -        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
> -    } else {
> -        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
> -        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
> -    }
> -
>      if (s->dct_error_sum) {
>          av_assert2(s->noise_reduction && s->encoding);
>          update_noise_reduction(s);

Will apply this patch tomorrow unless there are objections.

- Andreas

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

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-29 16:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 17:50 [FFmpeg-devel] [PATCH] avcodec/mpegvideo_enc: Initialize dct_unquantize_int(ra|er) only once Andreas Rheinhardt
2022-10-29 16:47 ` Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git