Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 15/39] lavc/hevcdec: pass SliceHeader explicitly to pred_weight_table()
Date: Fri,  7 Jun 2024 15:01:11 +0200
Message-ID: <20240607130135.9088-15-anton@khirnov.net> (raw)
In-Reply-To: <20240607130135.9088-1-anton@khirnov.net>

And replace the HEVCContext* parameter by void *logctx.

Makes it clear that only SliceHeader is modified by this function.
---
 libavcodec/hevc/hevcdec.c | 75 ++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 37 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 2c26d397df..6a9de79dcd 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -143,7 +143,8 @@ fail:
     return AVERROR(ENOMEM);
 }
 
-static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext *gb)
+static int pred_weight_table(SliceHeader *sh, void *logctx,
+                             const HEVCSPS *sps, GetBitContext *gb)
 {
     int i = 0;
     int j = 0;
@@ -155,40 +156,40 @@ static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext *
 
     luma_log2_weight_denom = get_ue_golomb_long(gb);
     if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
-        av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);
+        av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);
         return AVERROR_INVALIDDATA;
     }
-    s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);
+    sh->luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);
     if (sps->chroma_format_idc != 0) {
         int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb);
         if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
-            av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom);
+            av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom);
             return AVERROR_INVALIDDATA;
         }
-        s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom;
+        sh->chroma_log2_weight_denom = chroma_log2_weight_denom;
     }
 
-    for (i = 0; i < s->sh.nb_refs[L0]; i++) {
+    for (i = 0; i < sh->nb_refs[L0]; i++) {
         luma_weight_l0_flag[i] = get_bits1(gb);
         if (!luma_weight_l0_flag[i]) {
-            s->sh.luma_weight_l0[i] = 1 << s->sh.luma_log2_weight_denom;
-            s->sh.luma_offset_l0[i] = 0;
+            sh->luma_weight_l0[i] = 1 << sh->luma_log2_weight_denom;
+            sh->luma_offset_l0[i] = 0;
         }
     }
     if (sps->chroma_format_idc != 0) {
-        for (i = 0; i < s->sh.nb_refs[L0]; i++)
+        for (i = 0; i < sh->nb_refs[L0]; i++)
             chroma_weight_l0_flag[i] = get_bits1(gb);
     } else {
-        for (i = 0; i < s->sh.nb_refs[L0]; i++)
+        for (i = 0; i < sh->nb_refs[L0]; i++)
             chroma_weight_l0_flag[i] = 0;
     }
-    for (i = 0; i < s->sh.nb_refs[L0]; i++) {
+    for (i = 0; i < sh->nb_refs[L0]; i++) {
         if (luma_weight_l0_flag[i]) {
             int delta_luma_weight_l0 = get_se_golomb(gb);
             if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
                 return AVERROR_INVALIDDATA;
-            s->sh.luma_weight_l0[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l0;
-            s->sh.luma_offset_l0[i] = get_se_golomb(gb);
+            sh->luma_weight_l0[i] = (1 << sh->luma_log2_weight_denom) + delta_luma_weight_l0;
+            sh->luma_offset_l0[i] = get_se_golomb(gb);
         }
         if (chroma_weight_l0_flag[i]) {
             for (j = 0; j < 2; j++) {
@@ -200,39 +201,39 @@ static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext *
                     return AVERROR_INVALIDDATA;
                 }
 
-                s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
-                s->sh.chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])
-                                                                                    >> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
+                sh->chroma_weight_l0[i][j] = (1 << sh->chroma_log2_weight_denom) + delta_chroma_weight_l0;
+                sh->chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * sh->chroma_weight_l0[i][j])
+                                                                                    >> sh->chroma_log2_weight_denom) + 128), -128, 127);
             }
         } else {
-            s->sh.chroma_weight_l0[i][0] = 1 << s->sh.chroma_log2_weight_denom;
-            s->sh.chroma_offset_l0[i][0] = 0;
-            s->sh.chroma_weight_l0[i][1] = 1 << s->sh.chroma_log2_weight_denom;
-            s->sh.chroma_offset_l0[i][1] = 0;
+            sh->chroma_weight_l0[i][0] = 1 << sh->chroma_log2_weight_denom;
+            sh->chroma_offset_l0[i][0] = 0;
+            sh->chroma_weight_l0[i][1] = 1 << sh->chroma_log2_weight_denom;
+            sh->chroma_offset_l0[i][1] = 0;
         }
     }
-    if (s->sh.slice_type == HEVC_SLICE_B) {
-        for (i = 0; i < s->sh.nb_refs[L1]; i++) {
+    if (sh->slice_type == HEVC_SLICE_B) {
+        for (i = 0; i < sh->nb_refs[L1]; i++) {
             luma_weight_l1_flag[i] = get_bits1(gb);
             if (!luma_weight_l1_flag[i]) {
-                s->sh.luma_weight_l1[i] = 1 << s->sh.luma_log2_weight_denom;
-                s->sh.luma_offset_l1[i] = 0;
+                sh->luma_weight_l1[i] = 1 << sh->luma_log2_weight_denom;
+                sh->luma_offset_l1[i] = 0;
             }
         }
         if (sps->chroma_format_idc != 0) {
-            for (i = 0; i < s->sh.nb_refs[L1]; i++)
+            for (i = 0; i < sh->nb_refs[L1]; i++)
                 chroma_weight_l1_flag[i] = get_bits1(gb);
         } else {
-            for (i = 0; i < s->sh.nb_refs[L1]; i++)
+            for (i = 0; i < sh->nb_refs[L1]; i++)
                 chroma_weight_l1_flag[i] = 0;
         }
-        for (i = 0; i < s->sh.nb_refs[L1]; i++) {
+        for (i = 0; i < sh->nb_refs[L1]; i++) {
             if (luma_weight_l1_flag[i]) {
                 int delta_luma_weight_l1 = get_se_golomb(gb);
                 if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1)
                     return AVERROR_INVALIDDATA;
-                s->sh.luma_weight_l1[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l1;
-                s->sh.luma_offset_l1[i] = get_se_golomb(gb);
+                sh->luma_weight_l1[i] = (1 << sh->luma_log2_weight_denom) + delta_luma_weight_l1;
+                sh->luma_offset_l1[i] = get_se_golomb(gb);
             }
             if (chroma_weight_l1_flag[i]) {
                 for (j = 0; j < 2; j++) {
@@ -244,15 +245,15 @@ static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext *
                         return AVERROR_INVALIDDATA;
                     }
 
-                    s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
-                    s->sh.chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])
-                                                                                        >> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
+                    sh->chroma_weight_l1[i][j] = (1 << sh->chroma_log2_weight_denom) + delta_chroma_weight_l1;
+                    sh->chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * sh->chroma_weight_l1[i][j])
+                                                                                        >> sh->chroma_log2_weight_denom) + 128), -128, 127);
                 }
             } else {
-                s->sh.chroma_weight_l1[i][0] = 1 << s->sh.chroma_log2_weight_denom;
-                s->sh.chroma_offset_l1[i][0] = 0;
-                s->sh.chroma_weight_l1[i][1] = 1 << s->sh.chroma_log2_weight_denom;
-                s->sh.chroma_offset_l1[i][1] = 0;
+                sh->chroma_weight_l1[i][0] = 1 << sh->chroma_log2_weight_denom;
+                sh->chroma_offset_l1[i][0] = 0;
+                sh->chroma_weight_l1[i][1] = 1 << sh->chroma_log2_weight_denom;
+                sh->chroma_offset_l1[i][1] = 0;
             }
         }
     }
@@ -857,7 +858,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
 
             if ((pps->weighted_pred_flag   && sh->slice_type == HEVC_SLICE_P) ||
                 (pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
-                int ret = pred_weight_table(s, sps, gb);
+                int ret = pred_weight_table(sh, s->avctx, sps, gb);
                 if (ret < 0)
                     return ret;
             }
-- 
2.43.0

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

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

  parent reply	other threads:[~2024-06-07 13:05 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 13:00 [FFmpeg-devel] [PATCH 01/39] lavc/hevcdec: do not free SliceHeader arrays in pic_arrays_free() Anton Khirnov
2024-06-07 13:00 ` [FFmpeg-devel] [PATCH 02/39] lavc/hevcdec: simplify condition Anton Khirnov
2024-06-07 13:00 ` [FFmpeg-devel] [PATCH 03/39] lavc/hevcdec: drop a redundant assignment in hevc_decode_frame() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 04/39] lavc/hevc_ps: make PPS hold a reference to its SPS Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 05/39] lavc/hevc_ps: make SPS hold a reference to its VPS Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 06/39] lavc/hevc/parser: stop using HEVCParamSets.[psv]ps Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 07/39] lavc/hevc/mvs: stop accessing parameter sets through HEVCParamSets Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 08/39] lavc/hevc/filter: " Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 09/39] lavc/hevc/cabac: " Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 10/39] lavc/hevc/pred: " Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 11/39] lavc/hevcdec: " Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 12/39] lavc/hevcdec: move active PPS from HEVCParamSets to HEVCContext Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 13/39] lavc/hevcdec: drop an always-zero variable Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 14/39] lavc/hevcdec: only ignore INVALIDDATA in decode_nal_unit() Anton Khirnov
2024-06-07 13:01 ` Anton Khirnov [this message]
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 16/39] lavc/hevcdec: do not pass HEVCContext to decode_lt_rps() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 17/39] lavc/hevcdec: move pocTid0 computation to hevc_frame_start() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 18/39] lavc/hevcdec: only call export_stream_params_from_sei() once per frame Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 19/39] lavc/hevcdec: do not pass HEVCContext to ff_hevc_frame_nb_refs() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 20/39] lavc/hevcdec: only set no_rasl_output_flag for IRAP frames Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 21/39] lavc/hevcdec: output RASL frames based on the value of no_rasl_output_flag Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 22/39] lavc/hevc/cabac: do not infer WPP use based on HEVCContext.threads_number Anton Khirnov
2024-06-08  7:02   ` Christophe Gisquet
2024-06-08 13:06     ` Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 23/39] lavc/hevcdec: drop redundant HEVCContext.threads_{type, number} Anton Khirnov
2024-06-08  7:08   ` Christophe Gisquet
2024-06-08 13:07     ` Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 24/39] lavc/hevcdec: store slice header POC in SliceHeader Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 25/39] lavc/hevcdec: move a slice segment sanity check to hls_slice_header() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 26/39] lavc/hevcdec: move slice decoding dispatch to its own function Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 27/39] lavc/hevcdec: move per-slice local_ctx setup out of hls_slice_header() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 28/39] lavc/hevcdec: move calling hwaccel start_frame to hevc_frame_start() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 29/39] lavc/hevcdec: move calling hwaccel decode_slice to decode_slice_data() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 30/39] lavc/hevcdec: move constructing slice RPL " Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 31/39] lavc/hevcdec: set active PPS/SPS in hevc_frame_start() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 32/39] lavc/hevcdec: move sequence increment/IDR handling to hevc_frame_start() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 33/39] lavc/hevcdec: move setting slice_initialized out of hls_slice_header() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 34/39] lavc/hevcdec: move the check for multiple frames in a packet Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 35/39] lavc/hevcdec: drop a redundant multiple-frame-per-packet check Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 36/39] lavc/hevcdec: factor decoding a slice NALU out of decode_nal_unit() Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 37/39] lavc/hevcdec: move some frame-end code to hevc_frame_end() Anton Khirnov
2024-06-13  5:55   ` Wang, Fei W
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 38/39] lavc/hevcdec: do not unref current frame on frame_end() failure Anton Khirnov
2024-06-07 13:01 ` [FFmpeg-devel] [PATCH 39/39] lavc/hevcdec: constify source frame in hevc_ref_frame() Anton Khirnov
2024-06-08 12:48   ` Vittorio Giovara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240607130135.9088-15-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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