summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_parser.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-08-21 17:35:28 +0200
committerAnton Khirnov <anton@khirnov.net>2016-10-16 20:26:28 +0200
commitc359d624d3efc3fd1d83210d78c4152bd329b765 (patch)
tree6e0cffd42aff5636052d4540c1d56b7be579e8cf /libavcodec/hevc_parser.c
parent4abe3b049d987420eb891f74a35af2cebbf52144 (diff)
hevcdec: move decoder-independent declarations into a separate header
This way they can be reused by other code without including the whole decoder-specific hevcdec.h Also, add the HEVC_ prefix to them, since similarly named values exist for H.264 as well and are sometimes used in the same code.
Diffstat (limited to 'libavcodec/hevc_parser.c')
-rw-r--r--libavcodec/hevc_parser.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index b68ceb985e..49e712269b 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"
@@ -55,7 +56,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;
}
@@ -92,25 +93,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: hevc_parse_slice_header(s, nal, avctx); break;
+ 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: hevc_parse_slice_header(s, nal, avctx); break;
}
}
@@ -138,19 +139,19 @@ 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) {
pc->frame_start_found = 1;
- s->key_frame = nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT;
+ s->key_frame = nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT;
} else { // First slice of next frame found
pc->frame_start_found = 0;
return i - 5;
@@ -205,7 +206,7 @@ static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
state = (state << 8) | buf[i];
if (((state >> 8) & 0xFFFFFF) == START_CODE) {
int nut = (state >> 1) & 0x3F;
- if (nut >= NAL_VPS && nut <= NAL_PPS)
+ if (nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_PPS)
has_ps = 1;
else if (has_ps)
return i - 3;