aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-13 00:03:45 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-13 00:03:45 +0200
commit5620ed355716896dc1feee2c2a95ab12a982e276 (patch)
tree26b890f32a805a409b8adf18031b38d7dac58554
parent93aa84c1ea9aace875c3e853911e3a4a0ae4c32b (diff)
downloadffmpeg-5620ed355716896dc1feee2c2a95ab12a982e276.tar.gz
avcodec/hevc: Remove skipped_bytes_nal, simplify code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/hevc.c14
-rw-r--r--libavcodec/hevc.h4
-rw-r--r--libavcodec/hevc_parse.c14
3 files changed, 13 insertions, 19 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 4d87d447eb..1efd0787a8 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2422,8 +2422,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
return 0;
}
-static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
+static int hls_slice_data_wpp(HEVCContext *s, const HEVCNAL *nal)
{
+ const uint8_t *data = nal->data;
+ int length = nal->size;
HEVCLocalContext *lc = s->HEVClc;
int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
@@ -2452,7 +2454,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
offset = (lc->gb.index >> 3);
- for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < s->skipped_bytes; j++) {
+ for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
if (s->skipped_bytes_pos[j] >= offset && s->skipped_bytes_pos[j] < startheader) {
startheader--;
cmpt++;
@@ -2462,7 +2464,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
for (i = 1; i < s->sh.num_entry_point_offsets; i++) {
offset += (s->sh.entry_point_offset[i - 1] - cmpt);
for (j = 0, cmpt = 0, startheader = offset
- + s->sh.entry_point_offset[i]; j < s->skipped_bytes; j++) {
+ + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) {
if (s->skipped_bytes_pos[j] >= offset && s->skipped_bytes_pos[j] < startheader) {
startheader--;
cmpt++;
@@ -2478,7 +2480,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
}
- s->data = nal;
+ s->data = data;
for (i = 1; i < s->threads_number; i++) {
s->sList[i]->HEVClc->first_qp_group = 1;
@@ -2720,7 +2722,7 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
goto fail;
} else {
if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0)
- ctb_addr_ts = hls_slice_data_wpp(s, nal->data, nal->size);
+ ctb_addr_ts = hls_slice_data_wpp(s, nal);
else
ctb_addr_ts = hls_slice_data(s);
if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) {
@@ -2779,7 +2781,6 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
/* decode the NAL units */
for (i = 0; i < s->pkt.nb_nals; i++) {
- s->skipped_bytes = s->skipped_bytes_nal[i];
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i];
ret = decode_nal_unit(s, &s->pkt.nals[i]);
@@ -2974,7 +2975,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
av_freep(&s->skipped_bytes_pos_nal[i]);
}
av_freep(&s->skipped_bytes_pos_size_nal);
- av_freep(&s->skipped_bytes_nal);
av_freep(&s->skipped_bytes_pos_nal);
av_freep(&s->cabac_state);
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index a774c6b0bc..b043e95782 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -759,6 +759,8 @@ typedef struct HEVCNAL {
enum NALUnitType type;
int temporal_id;
+
+ int skipped_bytes;
} HEVCNAL;
/* an input packet split into unescaped NAL units */
@@ -897,11 +899,9 @@ typedef struct HEVCContext {
int enable_parallel_tiles;
int wpp_err;
- int skipped_bytes;
int *skipped_bytes_pos;
int skipped_bytes_pos_size;
- int *skipped_bytes_nal;
int **skipped_bytes_pos_nal;
int *skipped_bytes_pos_size_nal;
diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
index ee9a9d9e96..4741e67ce0 100644
--- a/libavcodec/hevc_parse.c
+++ b/libavcodec/hevc_parse.c
@@ -36,7 +36,7 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
uint8_t *dst;
if (s)
- s->skipped_bytes = 0;
+ nal->skipped_bytes = 0;
#define STARTCODE_TEST \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
@@ -111,8 +111,8 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
si += 3;
if (s) {
- s->skipped_bytes++;
- if (s->skipped_bytes_pos_size < s->skipped_bytes) {
+ nal->skipped_bytes++;
+ if (s->skipped_bytes_pos_size < nal->skipped_bytes) {
s->skipped_bytes_pos_size *= 2;
av_reallocp_array(&s->skipped_bytes_pos,
s->skipped_bytes_pos_size,
@@ -121,7 +121,7 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
return AVERROR(ENOMEM);
}
if (s->skipped_bytes_pos)
- s->skipped_bytes_pos[s->skipped_bytes-1] = di - 1;
+ s->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1;
}
continue;
} else // next start code
@@ -218,11 +218,6 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
memset(pkt->nals + pkt->nals_allocated, 0,
(new_size - pkt->nals_allocated) * sizeof(*pkt->nals));
- tmp = av_realloc_array(s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal));
- if (!tmp)
- return AVERROR(ENOMEM);
- s->skipped_bytes_nal = tmp;
-
tmp = av_realloc_array(s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal));
if (!tmp)
return AVERROR(ENOMEM);
@@ -248,7 +243,6 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
if (consumed < 0)
return consumed;
- s->skipped_bytes_nal[pkt->nb_nals] = s->skipped_bytes;
s->skipped_bytes_pos_size_nal[pkt->nb_nals] = s->skipped_bytes_pos_size;
s->skipped_bytes_pos_nal[pkt->nb_nals++] = s->skipped_bytes_pos;