mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-08-21 08:45:06 +02:00
avcodec/hevc: Move skipped_bytes_pos_nal to HEVCNAL, simplify code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
bcc6c7bb65
commit
ad92410d90
@ -2781,7 +2781,7 @@ 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_pos = s->skipped_bytes_pos_nal[i];
|
||||
s->skipped_bytes_pos = s->pkt.nals[i].skipped_bytes_pos_nal;
|
||||
|
||||
ret = decode_nal_unit(s, &s->pkt.nals[i]);
|
||||
if (ret < 0) {
|
||||
@ -2971,11 +2971,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
|
||||
|
||||
av_freep(&s->md5_ctx);
|
||||
|
||||
for(i=0; i < s->pkt.nals_allocated; i++) {
|
||||
av_freep(&s->skipped_bytes_pos_nal[i]);
|
||||
}
|
||||
av_freep(&s->skipped_bytes_pos_nal);
|
||||
|
||||
av_freep(&s->cabac_state);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
@ -3014,8 +3009,10 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
|
||||
s->HEVClc = NULL;
|
||||
av_freep(&s->HEVClcList[0]);
|
||||
|
||||
for (i = 0; i < s->pkt.nals_allocated; i++)
|
||||
for (i = 0; i < s->pkt.nals_allocated; i++) {
|
||||
av_freep(&s->pkt.nals[i].rbsp_buffer);
|
||||
av_freep(&s->pkt.nals[i].skipped_bytes_pos_nal);
|
||||
}
|
||||
av_freep(&s->pkt.nals);
|
||||
s->pkt.nals_allocated = 0;
|
||||
|
||||
|
@ -762,6 +762,7 @@ typedef struct HEVCNAL {
|
||||
|
||||
int skipped_bytes;
|
||||
int skipped_bytes_pos_size_nal;
|
||||
int *skipped_bytes_pos_nal;
|
||||
} HEVCNAL;
|
||||
|
||||
/* an input packet split into unescaped NAL units */
|
||||
@ -903,8 +904,6 @@ typedef struct HEVCContext {
|
||||
int *skipped_bytes_pos;
|
||||
int skipped_bytes_pos_size;
|
||||
|
||||
int **skipped_bytes_pos_nal;
|
||||
|
||||
const uint8_t *data;
|
||||
|
||||
HEVCPacket pkt;
|
||||
|
@ -218,29 +218,25 @@ 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_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal));
|
||||
if (!tmp)
|
||||
return AVERROR(ENOMEM);
|
||||
s->skipped_bytes_pos_nal = tmp;
|
||||
|
||||
nal = &pkt->nals[pkt->nb_nals];
|
||||
nal->skipped_bytes_pos_size_nal = 1024; // initial buffer size
|
||||
s->skipped_bytes_pos_nal[pkt->nals_allocated] = av_malloc_array(nal->skipped_bytes_pos_size_nal, sizeof(*s->skipped_bytes_pos));
|
||||
if (!s->skipped_bytes_pos_nal[pkt->nals_allocated])
|
||||
nal->skipped_bytes_pos_nal = av_malloc_array(nal->skipped_bytes_pos_size_nal, sizeof(*s->skipped_bytes_pos));
|
||||
if (!nal->skipped_bytes_pos_nal)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
pkt->nals_allocated = new_size;
|
||||
}
|
||||
nal = &pkt->nals[pkt->nb_nals];
|
||||
s->skipped_bytes_pos_size = nal->skipped_bytes_pos_size_nal;
|
||||
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[pkt->nb_nals];
|
||||
s->skipped_bytes_pos = nal->skipped_bytes_pos_nal;
|
||||
|
||||
consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal);
|
||||
if (consumed < 0)
|
||||
return consumed;
|
||||
|
||||
nal->skipped_bytes_pos_size_nal = s->skipped_bytes_pos_size;
|
||||
s->skipped_bytes_pos_nal[pkt->nb_nals++] = s->skipped_bytes_pos;
|
||||
nal->skipped_bytes_pos_nal = s->skipped_bytes_pos;
|
||||
pkt->nb_nals++;
|
||||
|
||||
ret = init_get_bits8(&nal->gb, nal->data, nal->size);
|
||||
if (ret < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user