* [FFmpeg-devel] [PATCH] avcodec/hevc_ps: use get_ue_golomb() for some PPS Screen Content Coding extension fields
@ 2023-04-27 19:22 James Almer
2023-04-27 19:44 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hevc_ps: use get_{ue, se}_golomb() for some PPS Range " James Almer
0 siblings, 1 reply; 3+ messages in thread
From: James Almer @ 2023-04-27 19:22 UTC (permalink / raw)
To: ffmpeg-devel
Also remove the _minus8 part of the name to be in line with the rest of the
decoder, and fix the storage type for pps_palette_predictor_initializer,
to support hbd values.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc_ps.c | 21 ++++++++++++++-------
libavcodec/hevc_ps.h | 6 +++---
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index f29f783f77..289b8f7d95 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1538,17 +1538,24 @@ static int pps_scc_extension(GetBitContext *gb, AVCodecContext *avctx,
}
if (pps->pps_palette_predictor_initializers_present_flag = get_bits1(gb)) {
- if ((pps->pps_num_palette_predictor_initializers = get_ue_golomb_long(gb)) > 0) {
+ pps->pps_num_palette_predictor_initializers = get_ue_golomb(gb);
+ if (pps->pps_num_palette_predictor_initializers > 0) {
+ if (pps->pps_num_palette_predictor_initializers > HEVC_MAX_PALETTE_PREDICTOR_SIZE) {
+ av_log(avctx, AV_LOG_ERROR,
+ "pps_num_palette_predictor_initializers out of range: %u\n",
+ pps->pps_num_palette_predictor_initializers);
+ return AVERROR_INVALIDDATA;
+ }
pps->monochrome_palette_flag = get_bits1(gb);
- pps->luma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
+ pps->luma_bit_depth_entry = get_ue_golomb_31(gb) + 8;
if (!pps->monochrome_palette_flag)
- pps->chroma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
+ pps->chroma_bit_depth_entry = get_ue_golomb_31(gb) + 8;
num_comps = pps->monochrome_palette_flag ? 1 : 3;
- for (int comp = 0; comp < num_comps; comp++)
+ for (int comp = 0; comp < num_comps; comp++) {
+ int bit_depth = !comp ? pps->luma_bit_depth_entry : pps->chroma_bit_depth_entry;
for (int i = 0; i < pps->pps_num_palette_predictor_initializers; i++)
- pps->pps_palette_predictor_initializer[comp][i] =
- get_bits(gb, 8 + (!comp ? pps->luma_bit_depth_entry_minus8 :
- pps->chroma_bit_depth_entry_minus8));
+ pps->pps_palette_predictor_initializer[comp][i] = get_bits(gb, bit_depth);
+ }
}
}
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 0c9c278662..8cd99bb161 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -358,9 +358,9 @@ typedef struct HEVCPPS {
uint8_t pps_palette_predictor_initializers_present_flag;
uint8_t pps_num_palette_predictor_initializers;
uint8_t monochrome_palette_flag;
- uint8_t luma_bit_depth_entry_minus8;
- uint8_t chroma_bit_depth_entry_minus8;
- uint8_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE];
+ uint8_t luma_bit_depth_entry;
+ uint8_t chroma_bit_depth_entry;
+ uint16_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE];
// Inferred parameters
unsigned int *column_width; ///< ColumnWidth
--
2.40.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] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/hevc_ps: use get_{ue, se}_golomb() for some PPS Range extension fields
2023-04-27 19:22 [FFmpeg-devel] [PATCH] avcodec/hevc_ps: use get_ue_golomb() for some PPS Screen Content Coding extension fields James Almer
@ 2023-04-27 19:44 ` James Almer
2023-04-28 23:06 ` Michael Niedermayer
0 siblings, 1 reply; 3+ messages in thread
From: James Almer @ 2023-04-27 19:44 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc_ps.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 289b8f7d95..585b095073 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1478,33 +1478,33 @@ static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx,
HEVCPPS *pps, HEVCSPS *sps)
{
if (pps->transform_skip_enabled_flag) {
- pps->log2_max_transform_skip_block_size = get_ue_golomb_long(gb) + 2;
+ pps->log2_max_transform_skip_block_size = get_ue_golomb_31(gb) + 2;
}
pps->cross_component_prediction_enabled_flag = get_bits1(gb);
pps->chroma_qp_offset_list_enabled_flag = get_bits1(gb);
if (pps->chroma_qp_offset_list_enabled_flag) {
- pps->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(gb);
- pps->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(gb);
+ pps->diff_cu_chroma_qp_offset_depth = get_ue_golomb_31(gb);
+ pps->chroma_qp_offset_list_len_minus1 = get_ue_golomb_31(gb);
if (pps->chroma_qp_offset_list_len_minus1 > 5) {
av_log(avctx, AV_LOG_ERROR,
"chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
return AVERROR_INVALIDDATA;
}
for (int i = 0; i <= pps->chroma_qp_offset_list_len_minus1; i++) {
- pps->cb_qp_offset_list[i] = get_se_golomb_long(gb);
+ pps->cb_qp_offset_list[i] = get_se_golomb(gb);
if (pps->cb_qp_offset_list[i]) {
av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
- pps->cr_qp_offset_list[i] = get_se_golomb_long(gb);
+ pps->cr_qp_offset_list[i] = get_se_golomb(gb);
if (pps->cr_qp_offset_list[i]) {
av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
}
}
- pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);
- pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);
+ pps->log2_sao_offset_scale_luma = get_ue_golomb_31(gb);
+ pps->log2_sao_offset_scale_chroma = get_ue_golomb_31(gb);
if ( pps->log2_sao_offset_scale_luma > FFMAX(sps->bit_depth - 10, 0)
|| pps->log2_sao_offset_scale_chroma > FFMAX(sps->bit_depth_chroma - 10, 0)
--
2.40.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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/hevc_ps: use get_{ue, se}_golomb() for some PPS Range extension fields
2023-04-27 19:44 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hevc_ps: use get_{ue, se}_golomb() for some PPS Range " James Almer
@ 2023-04-28 23:06 ` Michael Niedermayer
0 siblings, 0 replies; 3+ messages in thread
From: Michael Niedermayer @ 2023-04-28 23:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 553 bytes --]
On Thu, Apr 27, 2023 at 04:44:06PM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> libavcodec/hevc_ps.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
should be ok
thx for going over the spec and "optimizing" each
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 3+ messages in thread
end of thread, other threads:[~2023-04-28 23:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 19:22 [FFmpeg-devel] [PATCH] avcodec/hevc_ps: use get_ue_golomb() for some PPS Screen Content Coding extension fields James Almer
2023-04-27 19:44 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hevc_ps: use get_{ue, se}_golomb() for some PPS Range " James Almer
2023-04-28 23:06 ` Michael Niedermayer
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