aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2022-12-14 00:25:48 +0100
committerLynne <dev@lynne.ee>2023-05-29 00:41:33 +0200
commitf58db8e534b38e4a3b776ceb465d6915af641068 (patch)
tree461f0eb6ca280e2a1e883adc3453e84b7d6fe77e /libavcodec
parentabdd87d44ebafb1ee39bee183bc4fdaaa88238d3 (diff)
downloadffmpeg-f58db8e534b38e4a3b776ceb465d6915af641068.tar.gz
hevc_ps: expose rps fields
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/hevc_ps.c37
-rw-r--r--libavcodec/hevc_ps.h7
2 files changed, 25 insertions, 19 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 5b5cd9d980..7181398e90 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -100,51 +100,50 @@ static void remove_vps(HEVCParamSets *s, int id)
int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
{
- uint8_t rps_predict = 0;
int delta_poc;
int k0 = 0;
int k = 0;
int i;
+ rps->rps_predict = 0;
+
if (rps != sps->st_rps && sps->nb_st_rps)
- rps_predict = get_bits1(gb);
+ rps->rps_predict = get_bits1(gb);
- if (rps_predict) {
+ if (rps->rps_predict) {
const ShortTermRPS *rps_ridx;
int delta_rps;
- unsigned abs_delta_rps;
- uint8_t use_delta_flag = 0;
- uint8_t delta_rps_sign;
if (is_slice_header) {
- unsigned int delta_idx = get_ue_golomb_long(gb) + 1;
- if (delta_idx > sps->nb_st_rps) {
+ rps->delta_idx = get_ue_golomb_long(gb) + 1;
+ if (rps->delta_idx > sps->nb_st_rps) {
av_log(avctx, AV_LOG_ERROR,
"Invalid value of delta_idx in slice header RPS: %d > %d.\n",
- delta_idx, sps->nb_st_rps);
+ rps->delta_idx, sps->nb_st_rps);
return AVERROR_INVALIDDATA;
}
- rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx];
+ rps_ridx = &sps->st_rps[sps->nb_st_rps - rps->delta_idx];
rps->rps_idx_num_delta_pocs = rps_ridx->num_delta_pocs;
} else
rps_ridx = &sps->st_rps[rps - sps->st_rps - 1];
- delta_rps_sign = get_bits1(gb);
- abs_delta_rps = get_ue_golomb_long(gb) + 1;
- if (abs_delta_rps < 1 || abs_delta_rps > 32768) {
+ rps->delta_rps_sign = get_bits1(gb);
+ rps->abs_delta_rps = get_ue_golomb_long(gb) + 1;
+ if (rps->abs_delta_rps > 32768) {
av_log(avctx, AV_LOG_ERROR,
"Invalid value of abs_delta_rps: %d\n",
- abs_delta_rps);
+ rps->abs_delta_rps);
return AVERROR_INVALIDDATA;
}
- delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
+ delta_rps = (1 - (rps->delta_rps_sign << 1)) * rps->abs_delta_rps;
for (i = 0; i <= rps_ridx->num_delta_pocs; i++) {
int used = rps->used[k] = get_bits1(gb);
+ rps->use_delta_flag = 0;
if (!used)
- use_delta_flag = get_bits1(gb);
+ rps->use_delta_flag = get_bits1(gb);
- if (used || use_delta_flag) {
+ if (used || rps->use_delta_flag) {
if (i < rps_ridx->num_delta_pocs)
delta_poc = delta_rps + rps_ridx->delta_poc[i];
else
@@ -210,7 +209,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
if (rps->num_delta_pocs) {
prev = 0;
for (i = 0; i < rps->num_negative_pics; i++) {
- delta_poc = get_ue_golomb_long(gb) + 1;
+ delta_poc = rps->delta_poc_s0[i] = get_ue_golomb_long(gb) + 1;
if (delta_poc < 1 || delta_poc > 32768) {
av_log(avctx, AV_LOG_ERROR,
"Invalid value of delta_poc: %d\n",
@@ -223,7 +222,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
}
prev = 0;
for (i = 0; i < nb_positive_pics; i++) {
- delta_poc = get_ue_golomb_long(gb) + 1;
+ delta_poc = rps->delta_poc_s1[i] = get_ue_golomb_long(gb) + 1;
if (delta_poc < 1 || delta_poc > 32768) {
av_log(avctx, AV_LOG_ERROR,
"Invalid value of delta_poc: %d\n",
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 344c5bbc7f..2b89cdc9fd 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -70,9 +70,16 @@ typedef struct HEVCHdrParams {
} HEVCHdrParams;
typedef struct ShortTermRPS {
+ uint8_t rps_predict;
+ unsigned int delta_idx;
+ uint8_t use_delta_flag;
+ uint8_t delta_rps_sign;
+ unsigned int abs_delta_rps;
unsigned int num_negative_pics;
int num_delta_pocs;
int rps_idx_num_delta_pocs;
+ int32_t delta_poc_s0[32];
+ int32_t delta_poc_s1[32];
int32_t delta_poc[32];
uint8_t used[32];
} ShortTermRPS;