mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
avcodec/hevc: Remove skipped_bytes_nal, simplify code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
93aa84c1ea
commit
5620ed3557
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user