summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_parser.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-03-23 14:27:48 -0300
committerJames Almer <jamrial@gmail.com>2017-03-23 14:27:48 -0300
commit6397815be0bee10948387fcb90ead36ec2834ef7 (patch)
treee616efad05f1147821dd80f88dae04707d795193 /libavcodec/hevc_parser.c
parenta1a80a6c9ce5309632a8b5c0241fa5ffcd09b5fc (diff)
parentc359d624d3efc3fd1d83210d78c4152bd329b765 (diff)
downloadffmpeg-6397815be0bee10948387fcb90ead36ec2834ef7.tar.gz
Merge commit 'c359d624d3efc3fd1d83210d78c4152bd329b765'
* commit 'c359d624d3efc3fd1d83210d78c4152bd329b765': hevcdec: move decoder-independent declarations into a separate header Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/hevc_parser.c')
-rw-r--r--libavcodec/hevc_parser.c119
1 files changed, 60 insertions, 59 deletions
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 22a9623601..2a5190dcb8 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -23,6 +23,7 @@
#include "libavutil/common.h"
#include "golomb.h"
+#include "hevc.h"
#include "hevcdec.h"
#include "h2645_parse.h"
#include "parser.h"
@@ -62,7 +63,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
get_bits1(gb); // no output of prior pics
pps_id = get_ue_golomb_long(gb);
- if (pps_id >= MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) {
+ if (pps_id >= HEVC_MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) {
av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
return AVERROR_INVALIDDATA;
}
@@ -99,25 +100,25 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
/* ignore everything except parameter sets and VCL NALUs */
switch (nal->type) {
- case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break;
- case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break;
- case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break;
- case NAL_TRAIL_R:
- case NAL_TRAIL_N:
- case NAL_TSA_N:
- case NAL_TSA_R:
- case NAL_STSA_N:
- case NAL_STSA_R:
- case NAL_BLA_W_LP:
- case NAL_BLA_W_RADL:
- case NAL_BLA_N_LP:
- case NAL_IDR_W_RADL:
- case NAL_IDR_N_LP:
- case NAL_CRA_NUT:
- case NAL_RADL_N:
- case NAL_RADL_R:
- case NAL_RASL_N:
- case NAL_RASL_R:
+ case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break;
+ case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break;
+ case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break;
+ case HEVC_NAL_TRAIL_R:
+ case HEVC_NAL_TRAIL_N:
+ case HEVC_NAL_TSA_N:
+ case HEVC_NAL_TSA_R:
+ case HEVC_NAL_STSA_N:
+ case HEVC_NAL_STSA_R:
+ case HEVC_NAL_BLA_W_LP:
+ case HEVC_NAL_BLA_W_RADL:
+ case HEVC_NAL_BLA_N_LP:
+ case HEVC_NAL_IDR_W_RADL:
+ case HEVC_NAL_IDR_N_LP:
+ case HEVC_NAL_CRA_NUT:
+ case HEVC_NAL_RADL_N:
+ case HEVC_NAL_RADL_R:
+ case HEVC_NAL_RASL_N:
+ case HEVC_NAL_RASL_R:
if (buf == avctx->extradata) {
av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type);
return AVERROR_INVALIDDATA;
@@ -151,14 +152,14 @@ static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf,
nut = (pc->state64 >> 2 * 8 + 1) & 0x3F;
// Beginning of access unit
- if ((nut >= NAL_VPS && nut <= NAL_AUD) || nut == NAL_SEI_PREFIX ||
+ if ((nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_AUD) || nut == HEVC_NAL_SEI_PREFIX ||
(nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
if (pc->frame_start_found) {
pc->frame_start_found = 0;
return i - 5;
}
- } else if (nut <= NAL_RASL_R ||
- (nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT)) {
+ } else if (nut <= HEVC_NAL_RASL_R ||
+ (nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT)) {
int first_slice_segment_in_pic_flag = buf[i] >> 7;
if (first_slice_segment_in_pic_flag) {
if (!pc->frame_start_found) {
@@ -238,7 +239,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
h->nal_unit_type = (*buf >> 1) & 0x3f;
h->temporal_id = (*(buf + 1) & 0x07) - 1;
- if (h->nal_unit_type <= NAL_CRA_NUT) {
+ if (h->nal_unit_type <= HEVC_NAL_CRA_NUT) {
// Do not walk the whole buffer just to decode slice segment header
if (src_length > 20)
src_length = 20;
@@ -253,35 +254,35 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
return ret;
switch (h->nal_unit_type) {
- case NAL_VPS:
+ case HEVC_NAL_VPS:
ff_hevc_decode_nal_vps(gb, avctx, ps);
break;
- case NAL_SPS:
+ case HEVC_NAL_SPS:
ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
break;
- case NAL_PPS:
+ case HEVC_NAL_PPS:
ff_hevc_decode_nal_pps(gb, avctx, ps);
break;
- case NAL_SEI_PREFIX:
- case NAL_SEI_SUFFIX:
+ case HEVC_NAL_SEI_PREFIX:
+ case HEVC_NAL_SEI_SUFFIX:
ff_hevc_decode_nal_sei(h);
break;
- case NAL_TRAIL_N:
- case NAL_TRAIL_R:
- case NAL_TSA_N:
- case NAL_TSA_R:
- case NAL_STSA_N:
- case NAL_STSA_R:
- case NAL_RADL_N:
- case NAL_RADL_R:
- case NAL_RASL_N:
- case NAL_RASL_R:
- case NAL_BLA_W_LP:
- case NAL_BLA_W_RADL:
- case NAL_BLA_N_LP:
- case NAL_IDR_W_RADL:
- case NAL_IDR_N_LP:
- case NAL_CRA_NUT:
+ case HEVC_NAL_TRAIL_N:
+ case HEVC_NAL_TRAIL_R:
+ case HEVC_NAL_TSA_N:
+ case HEVC_NAL_TSA_R:
+ case HEVC_NAL_STSA_N:
+ case HEVC_NAL_STSA_R:
+ case HEVC_NAL_RADL_N:
+ case HEVC_NAL_RADL_R:
+ case HEVC_NAL_RASL_N:
+ case HEVC_NAL_RASL_R:
+ case HEVC_NAL_BLA_W_LP:
+ case HEVC_NAL_BLA_W_RADL:
+ case HEVC_NAL_BLA_N_LP:
+ case HEVC_NAL_IDR_W_RADL:
+ case HEVC_NAL_IDR_N_LP:
+ case HEVC_NAL_CRA_NUT:
if (is_global) {
av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type);
@@ -298,13 +299,13 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
}
sh->pps_id = get_ue_golomb(gb);
- if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
+ if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
- if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
+ if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
return AVERROR_INVALIDDATA;
}
@@ -382,13 +383,13 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
s->output_picture_number = h->poc = 0;
if (h->temporal_id == 0 &&
- h->nal_unit_type != NAL_TRAIL_N &&
- h->nal_unit_type != NAL_TSA_N &&
- h->nal_unit_type != NAL_STSA_N &&
- h->nal_unit_type != NAL_RADL_N &&
- h->nal_unit_type != NAL_RASL_N &&
- h->nal_unit_type != NAL_RADL_R &&
- h->nal_unit_type != NAL_RASL_R)
+ h->nal_unit_type != HEVC_NAL_TRAIL_N &&
+ h->nal_unit_type != HEVC_NAL_TSA_N &&
+ h->nal_unit_type != HEVC_NAL_STSA_N &&
+ h->nal_unit_type != HEVC_NAL_RADL_N &&
+ h->nal_unit_type != HEVC_NAL_RASL_N &&
+ h->nal_unit_type != HEVC_NAL_RADL_R &&
+ h->nal_unit_type != HEVC_NAL_RASL_R)
h->pocTid0 = h->poc;
return 0; /* no need to evaluate the rest */
@@ -449,14 +450,14 @@ static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
if ((state >> 8) != START_CODE)
break;
nut = (state >> 1) & 0x3F;
- if (nut == NAL_VPS)
+ if (nut == HEVC_NAL_VPS)
has_vps = 1;
- else if (nut == NAL_SPS)
+ else if (nut == HEVC_NAL_SPS)
has_sps = 1;
- else if (nut == NAL_PPS)
+ else if (nut == HEVC_NAL_PPS)
has_pps = 1;
- else if ((nut != NAL_SEI_PREFIX || has_pps) &&
- nut != NAL_AUD) {
+ else if ((nut != HEVC_NAL_SEI_PREFIX || has_pps) &&
+ nut != HEVC_NAL_AUD) {
if (has_vps && has_sps) {
while (ptr - 4 > buf && ptr[-5] == 0)
ptr--;