aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-04-10 11:27:51 +0200
committerAnton Khirnov <anton@khirnov.net>2024-05-31 19:26:06 +0200
commitbd1a06dc439403d7e16a220629165e34791016d7 (patch)
treec2c7e82e0847041a6c85ee9660ef0b49dbb8b211 /libavcodec
parent72bdbce00d4d84008c40f5aa7a655f7dddafa5b1 (diff)
downloadffmpeg-bd1a06dc439403d7e16a220629165e34791016d7.tar.gz
lavc/hevc_ps: reduce the size of used_by_curr_pic_lt_sps_flag
It is currently an array of 32 uint8_t, each storing a single flag. A single uint32_t is sufficient.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/hevc_ps.c4
-rw-r--r--libavcodec/hevc_ps.h2
-rw-r--r--libavcodec/hevcdec.c2
-rw-r--r--libavcodec/vulkan_hevc.c3
4 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 25f087ed75..8d5fc0d0ca 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1094,9 +1094,11 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->num_long_term_ref_pics_sps);
return AVERROR_INVALIDDATA;
}
+
+ sps->used_by_curr_pic_lt = 0;
for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
sps->lt_ref_pic_poc_lsb_sps[i] = get_bits(gb, sps->log2_max_poc_lsb);
- sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb);
+ sps->used_by_curr_pic_lt |= get_bits1(gb) * (1 << i);
}
}
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 61a0fe2219..b2f3a8dbd1 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -230,7 +230,7 @@ typedef struct HEVCSPS {
uint8_t long_term_ref_pics_present_flag;
uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS];
- uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS];
+ uint32_t used_by_curr_pic_lt;
uint8_t num_long_term_ref_pics_sps;
struct {
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index b8ab34d710..ef3ed75c8a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -295,7 +295,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
lt_idx_sps = get_bits(gb, av_ceil_log2(sps->num_long_term_ref_pics_sps));
rps->poc[i] = sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];
- rps->used[i] = sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps];
+ rps->used[i] = !!(sps->used_by_curr_pic_lt & (1 << lt_idx_sps));
} else {
rps->poc[i] = get_bits(gb, sps->log2_max_poc_lsb);
rps->used[i] = get_bits1(gb);
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index 2705a965b9..9b40f5ad58 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -386,11 +386,10 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
}
*ltr = (StdVideoH265LongTermRefPicsSps) {
- .used_by_curr_pic_lt_sps_flag = 0x0,
+ .used_by_curr_pic_lt_sps_flag = sps->used_by_curr_pic_lt,
};
for (int i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
- ltr->used_by_curr_pic_lt_sps_flag |= sps->used_by_curr_pic_lt_sps_flag[i] << i;
ltr->lt_ref_pic_poc_lsb_sps[i] = sps->lt_ref_pic_poc_lsb_sps[i];
}