Browse Source

avcodec/hevc: Move skipped_bytes_pos_nal to HEVCNAL, simplify code

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n2.8
Michael Niedermayer 10 years ago
parent
commit
ad92410d90
3 changed files with 10 additions and 18 deletions
  1. +4
    -7
      libavcodec/hevc.c
  2. +1
    -2
      libavcodec/hevc.h
  3. +5
    -9
      libavcodec/hevc_parse.c

+ 4
- 7
libavcodec/hevc.c View File

@@ -2781,7 +2781,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)


/* decode the NAL units */ /* decode the NAL units */
for (i = 0; i < s->pkt.nb_nals; i++) { 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]); ret = decode_nal_unit(s, &s->pkt.nals[i]);
if (ret < 0) { if (ret < 0) {
@@ -2971,11 +2971,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)


av_freep(&s->md5_ctx); 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); av_freep(&s->cabac_state);


for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@@ -3014,8 +3009,10 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
s->HEVClc = NULL; s->HEVClc = NULL;
av_freep(&s->HEVClcList[0]); 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].rbsp_buffer);
av_freep(&s->pkt.nals[i].skipped_bytes_pos_nal);
}
av_freep(&s->pkt.nals); av_freep(&s->pkt.nals);
s->pkt.nals_allocated = 0; s->pkt.nals_allocated = 0;




+ 1
- 2
libavcodec/hevc.h View File

@@ -762,6 +762,7 @@ typedef struct HEVCNAL {


int skipped_bytes; int skipped_bytes;
int skipped_bytes_pos_size_nal; int skipped_bytes_pos_size_nal;
int *skipped_bytes_pos_nal;
} HEVCNAL; } HEVCNAL;


/* an input packet split into unescaped NAL units */ /* an input packet split into unescaped NAL units */
@@ -903,8 +904,6 @@ typedef struct HEVCContext {
int *skipped_bytes_pos; int *skipped_bytes_pos;
int skipped_bytes_pos_size; int skipped_bytes_pos_size;


int **skipped_bytes_pos_nal;

const uint8_t *data; const uint8_t *data;


HEVCPacket pkt; HEVCPacket pkt;


+ 5
- 9
libavcodec/hevc_parse.c View File

@@ -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, memset(pkt->nals + pkt->nals_allocated, 0,
(new_size - pkt->nals_allocated) * sizeof(*pkt->nals)); (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 = &pkt->nals[pkt->nb_nals];
nal->skipped_bytes_pos_size_nal = 1024; // initial buffer size 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); return AVERROR(ENOMEM);


pkt->nals_allocated = new_size; pkt->nals_allocated = new_size;
} }
nal = &pkt->nals[pkt->nb_nals]; nal = &pkt->nals[pkt->nb_nals];
s->skipped_bytes_pos_size = nal->skipped_bytes_pos_size_nal; 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); consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal);
if (consumed < 0) if (consumed < 0)
return consumed; return consumed;


nal->skipped_bytes_pos_size_nal = s->skipped_bytes_pos_size; 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); ret = init_get_bits8(&nal->gb, nal->data, nal->size);
if (ret < 0) if (ret < 0)


Loading…
Cancel
Save