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.
This commit is contained in:
parent
4abe3b049d
commit
c359d624d3
65
libavcodec/hevc.h
Normal file
65
libavcodec/hevc.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* HEVC shared code
|
||||||
|
*
|
||||||
|
* This file is part of Libav.
|
||||||
|
*
|
||||||
|
* Libav is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Libav is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with Libav; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AVCODEC_HEVC_H
|
||||||
|
#define AVCODEC_HEVC_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table 7-3: NAL unit type codes
|
||||||
|
*/
|
||||||
|
enum HEVCNALUnitType {
|
||||||
|
HEVC_NAL_TRAIL_N = 0,
|
||||||
|
HEVC_NAL_TRAIL_R = 1,
|
||||||
|
HEVC_NAL_TSA_N = 2,
|
||||||
|
HEVC_NAL_TSA_R = 3,
|
||||||
|
HEVC_NAL_STSA_N = 4,
|
||||||
|
HEVC_NAL_STSA_R = 5,
|
||||||
|
HEVC_NAL_RADL_N = 6,
|
||||||
|
HEVC_NAL_RADL_R = 7,
|
||||||
|
HEVC_NAL_RASL_N = 8,
|
||||||
|
HEVC_NAL_RASL_R = 9,
|
||||||
|
HEVC_NAL_BLA_W_LP = 16,
|
||||||
|
HEVC_NAL_BLA_W_RADL = 17,
|
||||||
|
HEVC_NAL_BLA_N_LP = 18,
|
||||||
|
HEVC_NAL_IDR_W_RADL = 19,
|
||||||
|
HEVC_NAL_IDR_N_LP = 20,
|
||||||
|
HEVC_NAL_CRA_NUT = 21,
|
||||||
|
HEVC_NAL_VPS = 32,
|
||||||
|
HEVC_NAL_SPS = 33,
|
||||||
|
HEVC_NAL_PPS = 34,
|
||||||
|
HEVC_NAL_AUD = 35,
|
||||||
|
HEVC_NAL_EOS_NUT = 36,
|
||||||
|
HEVC_NAL_EOB_NUT = 37,
|
||||||
|
HEVC_NAL_FD_NUT = 38,
|
||||||
|
HEVC_NAL_SEI_PREFIX = 39,
|
||||||
|
HEVC_NAL_SEI_SUFFIX = 40,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 7.4.2.1
|
||||||
|
*/
|
||||||
|
#define HEVC_MAX_SUB_LAYERS 7
|
||||||
|
#define HEVC_MAX_VPS_COUNT 16
|
||||||
|
#define HEVC_MAX_SPS_COUNT 32
|
||||||
|
#define HEVC_MAX_PPS_COUNT 256
|
||||||
|
#define HEVC_MAX_SHORT_TERM_RPS_COUNT 64
|
||||||
|
#define HEVC_MAX_CU_SIZE 128
|
||||||
|
|
||||||
|
#endif /* AVCODEC_HEVC_H */
|
@ -27,7 +27,7 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "bsf.h"
|
#include "bsf.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "hevcdec.h"
|
#include "hevc.h"
|
||||||
|
|
||||||
#define MIN_HEVCC_LENGTH 23
|
#define MIN_HEVCC_LENGTH 23
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx)
|
|||||||
int type = bytestream2_get_byte(&gb) & 0x3f;
|
int type = bytestream2_get_byte(&gb) & 0x3f;
|
||||||
int cnt = bytestream2_get_be16(&gb);
|
int cnt = bytestream2_get_be16(&gb);
|
||||||
|
|
||||||
if (!(type == NAL_VPS || type == NAL_SPS || type == NAL_PPS ||
|
if (!(type == HEVC_NAL_VPS || type == HEVC_NAL_SPS || type == HEVC_NAL_PPS ||
|
||||||
type == NAL_SEI_PREFIX || type == NAL_SEI_SUFFIX)) {
|
type == HEVC_NAL_SEI_PREFIX || type == HEVC_NAL_SEI_SUFFIX)) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n",
|
av_log(ctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n",
|
||||||
type);
|
type);
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
|
|
||||||
#include "golomb.h"
|
#include "golomb.h"
|
||||||
|
#include "hevc.h"
|
||||||
#include "hevcdec.h"
|
#include "hevcdec.h"
|
||||||
#include "h2645_parse.h"
|
#include "h2645_parse.h"
|
||||||
#include "parser.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
|
get_bits1(gb); // no output of prior pics
|
||||||
|
|
||||||
pps_id = get_ue_golomb_long(gb);
|
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);
|
av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
|
||||||
return AVERROR_INVALIDDATA;
|
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 */
|
/* ignore everything except parameter sets and VCL NALUs */
|
||||||
switch (nal->type) {
|
switch (nal->type) {
|
||||||
case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break;
|
case HEVC_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 HEVC_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 HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break;
|
||||||
case NAL_TRAIL_R:
|
case HEVC_NAL_TRAIL_R:
|
||||||
case NAL_TRAIL_N:
|
case HEVC_NAL_TRAIL_N:
|
||||||
case NAL_TSA_N:
|
case HEVC_NAL_TSA_N:
|
||||||
case NAL_TSA_R:
|
case HEVC_NAL_TSA_R:
|
||||||
case NAL_STSA_N:
|
case HEVC_NAL_STSA_N:
|
||||||
case NAL_STSA_R:
|
case HEVC_NAL_STSA_R:
|
||||||
case NAL_BLA_W_LP:
|
case HEVC_NAL_BLA_W_LP:
|
||||||
case NAL_BLA_W_RADL:
|
case HEVC_NAL_BLA_W_RADL:
|
||||||
case NAL_BLA_N_LP:
|
case HEVC_NAL_BLA_N_LP:
|
||||||
case NAL_IDR_W_RADL:
|
case HEVC_NAL_IDR_W_RADL:
|
||||||
case NAL_IDR_N_LP:
|
case HEVC_NAL_IDR_N_LP:
|
||||||
case NAL_CRA_NUT:
|
case HEVC_NAL_CRA_NUT:
|
||||||
case NAL_RADL_N:
|
case HEVC_NAL_RADL_N:
|
||||||
case NAL_RADL_R:
|
case HEVC_NAL_RADL_R:
|
||||||
case NAL_RASL_N:
|
case HEVC_NAL_RASL_N:
|
||||||
case NAL_RASL_R: hevc_parse_slice_header(s, nal, avctx); break;
|
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;
|
nut = (pc->state64 >> 2 * 8 + 1) & 0x3F;
|
||||||
// Beginning of access unit
|
// 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)) {
|
(nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
|
||||||
if (pc->frame_start_found) {
|
if (pc->frame_start_found) {
|
||||||
pc->frame_start_found = 0;
|
pc->frame_start_found = 0;
|
||||||
return i - 5;
|
return i - 5;
|
||||||
}
|
}
|
||||||
} else if (nut <= NAL_RASL_R ||
|
} else if (nut <= HEVC_NAL_RASL_R ||
|
||||||
(nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT)) {
|
(nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT)) {
|
||||||
int first_slice_segment_in_pic_flag = buf[i] >> 7;
|
int first_slice_segment_in_pic_flag = buf[i] >> 7;
|
||||||
if (first_slice_segment_in_pic_flag) {
|
if (first_slice_segment_in_pic_flag) {
|
||||||
if (!pc->frame_start_found) {
|
if (!pc->frame_start_found) {
|
||||||
pc->frame_start_found = 1;
|
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
|
} else { // First slice of next frame found
|
||||||
pc->frame_start_found = 0;
|
pc->frame_start_found = 0;
|
||||||
return i - 5;
|
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];
|
state = (state << 8) | buf[i];
|
||||||
if (((state >> 8) & 0xFFFFFF) == START_CODE) {
|
if (((state >> 8) & 0xFFFFFF) == START_CODE) {
|
||||||
int nut = (state >> 1) & 0x3F;
|
int nut = (state >> 1) & 0x3F;
|
||||||
if (nut >= NAL_VPS && nut <= NAL_PPS)
|
if (nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_PPS)
|
||||||
has_ps = 1;
|
has_ps = 1;
|
||||||
else if (has_ps)
|
else if (has_ps)
|
||||||
return i - 3;
|
return i - 3;
|
||||||
|
@ -370,7 +370,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
|
|||||||
av_log(avctx, AV_LOG_DEBUG, "Decoding VPS\n");
|
av_log(avctx, AV_LOG_DEBUG, "Decoding VPS\n");
|
||||||
|
|
||||||
vps_id = get_bits(gb, 4);
|
vps_id = get_bits(gb, 4);
|
||||||
if (vps_id >= MAX_VPS_COUNT) {
|
if (vps_id >= HEVC_MAX_VPS_COUNT) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
|
av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vps->vps_max_sub_layers > MAX_SUB_LAYERS) {
|
if (vps->vps_max_sub_layers > HEVC_MAX_SUB_LAYERS) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "vps_max_sub_layers out of range: %d\n",
|
av_log(avctx, AV_LOG_ERROR, "vps_max_sub_layers out of range: %d\n",
|
||||||
vps->vps_max_sub_layers);
|
vps->vps_max_sub_layers);
|
||||||
goto err;
|
goto err;
|
||||||
@ -690,7 +690,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
|
|||||||
// Coded parameters
|
// Coded parameters
|
||||||
|
|
||||||
sps->vps_id = get_bits(gb, 4);
|
sps->vps_id = get_bits(gb, 4);
|
||||||
if (sps->vps_id >= MAX_VPS_COUNT) {
|
if (sps->vps_id >= HEVC_MAX_VPS_COUNT) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", sps->vps_id);
|
av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", sps->vps_id);
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto err;
|
goto err;
|
||||||
@ -704,7 +704,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
sps->max_sub_layers = get_bits(gb, 3) + 1;
|
sps->max_sub_layers = get_bits(gb, 3) + 1;
|
||||||
if (sps->max_sub_layers > MAX_SUB_LAYERS) {
|
if (sps->max_sub_layers > HEVC_MAX_SUB_LAYERS) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
|
av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
|
||||||
sps->max_sub_layers);
|
sps->max_sub_layers);
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
@ -716,7 +716,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
|
|||||||
parse_ptl(gb, avctx, &sps->ptl, sps->max_sub_layers);
|
parse_ptl(gb, avctx, &sps->ptl, sps->max_sub_layers);
|
||||||
|
|
||||||
*sps_id = get_ue_golomb_long(gb);
|
*sps_id = get_ue_golomb_long(gb);
|
||||||
if (*sps_id >= MAX_SPS_COUNT) {
|
if (*sps_id >= HEVC_MAX_SPS_COUNT) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", *sps_id);
|
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", *sps_id);
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto err;
|
goto err;
|
||||||
@ -867,7 +867,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
sps->nb_st_rps = get_ue_golomb_long(gb);
|
sps->nb_st_rps = get_ue_golomb_long(gb);
|
||||||
if (sps->nb_st_rps > MAX_SHORT_TERM_RPS_COUNT) {
|
if (sps->nb_st_rps > HEVC_MAX_SHORT_TERM_RPS_COUNT) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Too many short term RPS: %d.\n",
|
av_log(avctx, AV_LOG_ERROR, "Too many short term RPS: %d.\n",
|
||||||
sps->nb_st_rps);
|
sps->nb_st_rps);
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
@ -1205,13 +1205,13 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
|
|||||||
|
|
||||||
// Coded parameters
|
// Coded parameters
|
||||||
pps_id = get_ue_golomb_long(gb);
|
pps_id = get_ue_golomb_long(gb);
|
||||||
if (pps_id >= MAX_PPS_COUNT) {
|
if (pps_id >= HEVC_MAX_PPS_COUNT) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
|
av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
pps->sps_id = get_ue_golomb_long(gb);
|
pps->sps_id = get_ue_golomb_long(gb);
|
||||||
if (pps->sps_id >= MAX_SPS_COUNT) {
|
if (pps->sps_id >= HEVC_MAX_SPS_COUNT) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
|
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include "hevc.h"
|
||||||
#include "hevcdec.h"
|
#include "hevcdec.h"
|
||||||
|
|
||||||
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
|
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
|
||||||
@ -477,9 +478,9 @@ int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
|
|||||||
poc_msb = prev_poc_msb;
|
poc_msb = prev_poc_msb;
|
||||||
|
|
||||||
// For BLA picture types, POCmsb is set to 0.
|
// For BLA picture types, POCmsb is set to 0.
|
||||||
if (s->nal_unit_type == NAL_BLA_W_LP ||
|
if (s->nal_unit_type == HEVC_NAL_BLA_W_LP ||
|
||||||
s->nal_unit_type == NAL_BLA_W_RADL ||
|
s->nal_unit_type == HEVC_NAL_BLA_W_RADL ||
|
||||||
s->nal_unit_type == NAL_BLA_N_LP)
|
s->nal_unit_type == HEVC_NAL_BLA_N_LP)
|
||||||
poc_msb = 0;
|
poc_msb = 0;
|
||||||
|
|
||||||
return poc_msb + poc_lsb;
|
return poc_msb + poc_lsb;
|
||||||
|
@ -168,7 +168,7 @@ static int decode_nal_sei_message(HEVCContext *s)
|
|||||||
byte = get_bits(gb, 8);
|
byte = get_bits(gb, 8);
|
||||||
payload_size += byte;
|
payload_size += byte;
|
||||||
}
|
}
|
||||||
if (s->nal_unit_type == NAL_SEI_PREFIX) {
|
if (s->nal_unit_type == HEVC_NAL_SEI_PREFIX) {
|
||||||
return decode_nal_sei_prefix(s, payload_type, payload_size);
|
return decode_nal_sei_prefix(s, payload_type, payload_size);
|
||||||
} else { /* nal_unit_type == NAL_SEI_SUFFIX */
|
} else { /* nal_unit_type == NAL_SEI_SUFFIX */
|
||||||
return decode_nal_sei_suffix(s, payload_type, payload_size);
|
return decode_nal_sei_suffix(s, payload_type, payload_size);
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "cabac_functions.h"
|
#include "cabac_functions.h"
|
||||||
#include "golomb.h"
|
#include "golomb.h"
|
||||||
|
#include "hevc.h"
|
||||||
#include "hevcdec.h"
|
#include "hevcdec.h"
|
||||||
#include "profiles.h"
|
#include "profiles.h"
|
||||||
|
|
||||||
@ -461,7 +462,7 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
sh->no_output_of_prior_pics_flag = get_bits1(gb);
|
sh->no_output_of_prior_pics_flag = get_bits1(gb);
|
||||||
|
|
||||||
sh->pps_id = get_ue_golomb_long(gb);
|
sh->pps_id = get_ue_golomb_long(gb);
|
||||||
if (sh->pps_id >= MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
|
if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
|
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@ -594,13 +595,13 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
|
|
||||||
/* 8.3.1 */
|
/* 8.3.1 */
|
||||||
if (s->temporal_id == 0 &&
|
if (s->temporal_id == 0 &&
|
||||||
s->nal_unit_type != NAL_TRAIL_N &&
|
s->nal_unit_type != HEVC_NAL_TRAIL_N &&
|
||||||
s->nal_unit_type != NAL_TSA_N &&
|
s->nal_unit_type != HEVC_NAL_TSA_N &&
|
||||||
s->nal_unit_type != NAL_STSA_N &&
|
s->nal_unit_type != HEVC_NAL_STSA_N &&
|
||||||
s->nal_unit_type != NAL_RADL_N &&
|
s->nal_unit_type != HEVC_NAL_RADL_N &&
|
||||||
s->nal_unit_type != NAL_RADL_R &&
|
s->nal_unit_type != HEVC_NAL_RADL_R &&
|
||||||
s->nal_unit_type != NAL_RASL_N &&
|
s->nal_unit_type != HEVC_NAL_RASL_N &&
|
||||||
s->nal_unit_type != NAL_RASL_R)
|
s->nal_unit_type != HEVC_NAL_RASL_R)
|
||||||
s->pocTid0 = s->poc;
|
s->pocTid0 = s->poc;
|
||||||
|
|
||||||
if (s->ps.sps->sao_enabled) {
|
if (s->ps.sps->sao_enabled) {
|
||||||
@ -2455,50 +2456,50 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
|
|||||||
s->temporal_id = nal->temporal_id;
|
s->temporal_id = nal->temporal_id;
|
||||||
|
|
||||||
switch (s->nal_unit_type) {
|
switch (s->nal_unit_type) {
|
||||||
case NAL_VPS:
|
case HEVC_NAL_VPS:
|
||||||
ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps);
|
ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_SPS:
|
case HEVC_NAL_SPS:
|
||||||
ret = ff_hevc_decode_nal_sps(gb, s->avctx, &s->ps,
|
ret = ff_hevc_decode_nal_sps(gb, s->avctx, &s->ps,
|
||||||
s->apply_defdispwin);
|
s->apply_defdispwin);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_PPS:
|
case HEVC_NAL_PPS:
|
||||||
ret = ff_hevc_decode_nal_pps(gb, s->avctx, &s->ps);
|
ret = ff_hevc_decode_nal_pps(gb, s->avctx, &s->ps);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_SEI_PREFIX:
|
case HEVC_NAL_SEI_PREFIX:
|
||||||
case NAL_SEI_SUFFIX:
|
case HEVC_NAL_SEI_SUFFIX:
|
||||||
ret = ff_hevc_decode_nal_sei(s);
|
ret = ff_hevc_decode_nal_sei(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_TRAIL_R:
|
case HEVC_NAL_TRAIL_R:
|
||||||
case NAL_TRAIL_N:
|
case HEVC_NAL_TRAIL_N:
|
||||||
case NAL_TSA_N:
|
case HEVC_NAL_TSA_N:
|
||||||
case NAL_TSA_R:
|
case HEVC_NAL_TSA_R:
|
||||||
case NAL_STSA_N:
|
case HEVC_NAL_STSA_N:
|
||||||
case NAL_STSA_R:
|
case HEVC_NAL_STSA_R:
|
||||||
case NAL_BLA_W_LP:
|
case HEVC_NAL_BLA_W_LP:
|
||||||
case NAL_BLA_W_RADL:
|
case HEVC_NAL_BLA_W_RADL:
|
||||||
case NAL_BLA_N_LP:
|
case HEVC_NAL_BLA_N_LP:
|
||||||
case NAL_IDR_W_RADL:
|
case HEVC_NAL_IDR_W_RADL:
|
||||||
case NAL_IDR_N_LP:
|
case HEVC_NAL_IDR_N_LP:
|
||||||
case NAL_CRA_NUT:
|
case HEVC_NAL_CRA_NUT:
|
||||||
case NAL_RADL_N:
|
case HEVC_NAL_RADL_N:
|
||||||
case NAL_RADL_R:
|
case HEVC_NAL_RADL_R:
|
||||||
case NAL_RASL_N:
|
case HEVC_NAL_RASL_N:
|
||||||
case NAL_RASL_R:
|
case HEVC_NAL_RASL_R:
|
||||||
ret = hls_slice_header(s);
|
ret = hls_slice_header(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (s->max_ra == INT_MAX) {
|
if (s->max_ra == INT_MAX) {
|
||||||
if (s->nal_unit_type == NAL_CRA_NUT || IS_BLA(s)) {
|
if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) {
|
||||||
s->max_ra = s->poc;
|
s->max_ra = s->poc;
|
||||||
} else {
|
} else {
|
||||||
if (IS_IDR(s))
|
if (IS_IDR(s))
|
||||||
@ -2506,12 +2507,12 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s->nal_unit_type == NAL_RASL_R || s->nal_unit_type == NAL_RASL_N) &&
|
if ((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == HEVC_NAL_RASL_N) &&
|
||||||
s->poc <= s->max_ra) {
|
s->poc <= s->max_ra) {
|
||||||
s->is_decoded = 0;
|
s->is_decoded = 0;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (s->nal_unit_type == NAL_RASL_R && s->poc > s->max_ra)
|
if (s->nal_unit_type == HEVC_NAL_RASL_R && s->poc > s->max_ra)
|
||||||
s->max_ra = INT_MIN;
|
s->max_ra = INT_MIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2567,13 +2568,13 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NAL_EOS_NUT:
|
case HEVC_NAL_EOS_NUT:
|
||||||
case NAL_EOB_NUT:
|
case HEVC_NAL_EOB_NUT:
|
||||||
s->seq_decode = (s->seq_decode + 1) & 0xff;
|
s->seq_decode = (s->seq_decode + 1) & 0xff;
|
||||||
s->max_ra = INT_MAX;
|
s->max_ra = INT_MAX;
|
||||||
break;
|
break;
|
||||||
case NAL_AUD:
|
case HEVC_NAL_AUD:
|
||||||
case NAL_FD_NUT:
|
case HEVC_NAL_FD_NUT:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(s->avctx, AV_LOG_INFO,
|
av_log(s->avctx, AV_LOG_INFO,
|
||||||
@ -2605,8 +2606,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < s->pkt.nb_nals; i++) {
|
for (i = 0; i < s->pkt.nb_nals; i++) {
|
||||||
if (s->pkt.nals[i].type == NAL_EOB_NUT ||
|
if (s->pkt.nals[i].type == HEVC_NAL_EOB_NUT ||
|
||||||
s->pkt.nals[i].type == NAL_EOS_NUT)
|
s->pkt.nals[i].type == HEVC_NAL_EOS_NUT)
|
||||||
s->eos = 1;
|
s->eos = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "cabac.h"
|
#include "cabac.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "h2645_parse.h"
|
#include "h2645_parse.h"
|
||||||
|
#include "hevc.h"
|
||||||
#include "hevcdsp.h"
|
#include "hevcdsp.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
@ -42,16 +43,6 @@
|
|||||||
#define MAX_DPB_SIZE 16 // A.4.1
|
#define MAX_DPB_SIZE 16 // A.4.1
|
||||||
#define MAX_REFS 16
|
#define MAX_REFS 16
|
||||||
|
|
||||||
/**
|
|
||||||
* 7.4.2.1
|
|
||||||
*/
|
|
||||||
#define MAX_SUB_LAYERS 7
|
|
||||||
#define MAX_VPS_COUNT 16
|
|
||||||
#define MAX_SPS_COUNT 32
|
|
||||||
#define MAX_PPS_COUNT 256
|
|
||||||
#define MAX_SHORT_TERM_RPS_COUNT 64
|
|
||||||
#define MAX_CU_SIZE 128
|
|
||||||
|
|
||||||
//TODO: check if this is really the maximum
|
//TODO: check if this is really the maximum
|
||||||
#define MAX_TRANSFORM_DEPTH 5
|
#define MAX_TRANSFORM_DEPTH 5
|
||||||
|
|
||||||
@ -80,45 +71,14 @@
|
|||||||
#define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
|
#define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
|
||||||
#define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
|
#define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
|
||||||
|
|
||||||
#define IS_IDR(s) (s->nal_unit_type == NAL_IDR_W_RADL || s->nal_unit_type == NAL_IDR_N_LP)
|
#define IS_IDR(s) (s->nal_unit_type == HEVC_NAL_IDR_W_RADL || s->nal_unit_type == HEVC_NAL_IDR_N_LP)
|
||||||
#define IS_BLA(s) (s->nal_unit_type == NAL_BLA_W_RADL || s->nal_unit_type == NAL_BLA_W_LP || \
|
#define IS_BLA(s) (s->nal_unit_type == HEVC_NAL_BLA_W_RADL || s->nal_unit_type == HEVC_NAL_BLA_W_LP || \
|
||||||
s->nal_unit_type == NAL_BLA_N_LP)
|
s->nal_unit_type == HEVC_NAL_BLA_N_LP)
|
||||||
#define IS_IRAP(s) (s->nal_unit_type >= 16 && s->nal_unit_type <= 23)
|
#define IS_IRAP(s) (s->nal_unit_type >= 16 && s->nal_unit_type <= 23)
|
||||||
|
|
||||||
#define FFUDIV(a,b) (((a) > 0 ? (a) : (a) - (b) + 1) / (b))
|
#define FFUDIV(a,b) (((a) > 0 ? (a) : (a) - (b) + 1) / (b))
|
||||||
#define FFUMOD(a,b) ((a) - (b) * FFUDIV(a,b))
|
#define FFUMOD(a,b) ((a) - (b) * FFUDIV(a,b))
|
||||||
|
|
||||||
/**
|
|
||||||
* Table 7-3: NAL unit type codes
|
|
||||||
*/
|
|
||||||
enum NALUnitType {
|
|
||||||
NAL_TRAIL_N = 0,
|
|
||||||
NAL_TRAIL_R = 1,
|
|
||||||
NAL_TSA_N = 2,
|
|
||||||
NAL_TSA_R = 3,
|
|
||||||
NAL_STSA_N = 4,
|
|
||||||
NAL_STSA_R = 5,
|
|
||||||
NAL_RADL_N = 6,
|
|
||||||
NAL_RADL_R = 7,
|
|
||||||
NAL_RASL_N = 8,
|
|
||||||
NAL_RASL_R = 9,
|
|
||||||
NAL_BLA_W_LP = 16,
|
|
||||||
NAL_BLA_W_RADL = 17,
|
|
||||||
NAL_BLA_N_LP = 18,
|
|
||||||
NAL_IDR_W_RADL = 19,
|
|
||||||
NAL_IDR_N_LP = 20,
|
|
||||||
NAL_CRA_NUT = 21,
|
|
||||||
NAL_VPS = 32,
|
|
||||||
NAL_SPS = 33,
|
|
||||||
NAL_PPS = 34,
|
|
||||||
NAL_AUD = 35,
|
|
||||||
NAL_EOS_NUT = 36,
|
|
||||||
NAL_EOB_NUT = 37,
|
|
||||||
NAL_FD_NUT = 38,
|
|
||||||
NAL_SEI_PREFIX = 39,
|
|
||||||
NAL_SEI_SUFFIX = 40,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum RPSType {
|
enum RPSType {
|
||||||
ST_CURR_BEF = 0,
|
ST_CURR_BEF = 0,
|
||||||
ST_CURR_AFT,
|
ST_CURR_AFT,
|
||||||
@ -349,10 +309,10 @@ typedef struct PTLCommon {
|
|||||||
|
|
||||||
typedef struct PTL {
|
typedef struct PTL {
|
||||||
PTLCommon general_ptl;
|
PTLCommon general_ptl;
|
||||||
PTLCommon sub_layer_ptl[MAX_SUB_LAYERS];
|
PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS];
|
||||||
|
|
||||||
uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS];
|
uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
|
||||||
uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS];
|
uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
|
||||||
} PTL;
|
} PTL;
|
||||||
|
|
||||||
typedef struct HEVCVPS {
|
typedef struct HEVCVPS {
|
||||||
@ -362,9 +322,9 @@ typedef struct HEVCVPS {
|
|||||||
|
|
||||||
PTL ptl;
|
PTL ptl;
|
||||||
int vps_sub_layer_ordering_info_present_flag;
|
int vps_sub_layer_ordering_info_present_flag;
|
||||||
unsigned int vps_max_dec_pic_buffering[MAX_SUB_LAYERS];
|
unsigned int vps_max_dec_pic_buffering[HEVC_MAX_SUB_LAYERS];
|
||||||
unsigned int vps_num_reorder_pics[MAX_SUB_LAYERS];
|
unsigned int vps_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
|
||||||
unsigned int vps_max_latency_increase[MAX_SUB_LAYERS];
|
unsigned int vps_max_latency_increase[HEVC_MAX_SUB_LAYERS];
|
||||||
int vps_max_layer_id;
|
int vps_max_layer_id;
|
||||||
int vps_num_layer_sets; ///< vps_num_layer_sets_minus1 + 1
|
int vps_num_layer_sets; ///< vps_num_layer_sets_minus1 + 1
|
||||||
uint8_t vps_timing_info_present_flag;
|
uint8_t vps_timing_info_present_flag;
|
||||||
@ -405,7 +365,7 @@ typedef struct HEVCSPS {
|
|||||||
int max_dec_pic_buffering;
|
int max_dec_pic_buffering;
|
||||||
int num_reorder_pics;
|
int num_reorder_pics;
|
||||||
int max_latency_increase;
|
int max_latency_increase;
|
||||||
} temporal_layer[MAX_SUB_LAYERS];
|
} temporal_layer[HEVC_MAX_SUB_LAYERS];
|
||||||
|
|
||||||
VUI vui;
|
VUI vui;
|
||||||
PTL ptl;
|
PTL ptl;
|
||||||
@ -414,7 +374,7 @@ typedef struct HEVCSPS {
|
|||||||
ScalingList scaling_list;
|
ScalingList scaling_list;
|
||||||
|
|
||||||
unsigned int nb_st_rps;
|
unsigned int nb_st_rps;
|
||||||
ShortTermRPS st_rps[MAX_SHORT_TERM_RPS_COUNT];
|
ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_RPS_COUNT];
|
||||||
|
|
||||||
uint8_t amp_enabled_flag;
|
uint8_t amp_enabled_flag;
|
||||||
uint8_t sao_enabled;
|
uint8_t sao_enabled;
|
||||||
@ -528,9 +488,9 @@ typedef struct HEVCPPS {
|
|||||||
} HEVCPPS;
|
} HEVCPPS;
|
||||||
|
|
||||||
typedef struct HEVCParamSets {
|
typedef struct HEVCParamSets {
|
||||||
AVBufferRef *vps_list[MAX_VPS_COUNT];
|
AVBufferRef *vps_list[HEVC_MAX_VPS_COUNT];
|
||||||
AVBufferRef *sps_list[MAX_SPS_COUNT];
|
AVBufferRef *sps_list[HEVC_MAX_SPS_COUNT];
|
||||||
AVBufferRef *pps_list[MAX_PPS_COUNT];
|
AVBufferRef *pps_list[HEVC_MAX_PPS_COUNT];
|
||||||
|
|
||||||
/* currently active parameter sets */
|
/* currently active parameter sets */
|
||||||
const HEVCVPS *vps;
|
const HEVCVPS *vps;
|
||||||
@ -783,7 +743,7 @@ typedef struct HEVCContext {
|
|||||||
SliceHeader sh;
|
SliceHeader sh;
|
||||||
SAOParams *sao;
|
SAOParams *sao;
|
||||||
DBParams *deblock;
|
DBParams *deblock;
|
||||||
enum NALUnitType nal_unit_type;
|
enum HEVCNALUnitType nal_unit_type;
|
||||||
int temporal_id; ///< temporal_id_plus1 - 1
|
int temporal_id; ///< temporal_id_plus1 - 1
|
||||||
HEVCFrame *ref;
|
HEVCFrame *ref;
|
||||||
HEVCFrame DPB[32];
|
HEVCFrame DPB[32];
|
||||||
@ -832,7 +792,7 @@ typedef struct HEVCContext {
|
|||||||
|
|
||||||
H2645Packet pkt;
|
H2645Packet pkt;
|
||||||
// type of the first VCL NAL of the current frame
|
// type of the first VCL NAL of the current frame
|
||||||
enum NALUnitType first_nal_type;
|
enum HEVCNALUnitType first_nal_type;
|
||||||
|
|
||||||
// for checking the frame checksums
|
// for checking the frame checksums
|
||||||
struct AVMD5 *md5_ctx;
|
struct AVMD5 *md5_ctx;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
|
#include "hevc.h"
|
||||||
#include "hevcdec.h"
|
#include "hevcdec.h"
|
||||||
#include "h2645_parse.h"
|
#include "h2645_parse.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
@ -83,7 +84,7 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx)
|
|||||||
|
|
||||||
get_bits(&gb, 1);
|
get_bits(&gb, 1);
|
||||||
type = get_bits(&gb, 6);
|
type = get_bits(&gb, 6);
|
||||||
if (type != NAL_SPS) {
|
if (type != HEVC_NAL_SPS) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unexpected NAL type in the extradata: %d\n",
|
av_log(avctx, AV_LOG_ERROR, "Unexpected NAL type in the extradata: %d\n",
|
||||||
type);
|
type);
|
||||||
av_freep(&sps_nal.rbsp_buffer);
|
av_freep(&sps_nal.rbsp_buffer);
|
||||||
@ -103,7 +104,7 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx)
|
|||||||
vps.vps_max_sub_layers = sps.max_sub_layers;
|
vps.vps_max_sub_layers = sps.max_sub_layers;
|
||||||
memcpy(&vps.ptl, &sps.ptl, sizeof(vps.ptl));
|
memcpy(&vps.ptl, &sps.ptl, sizeof(vps.ptl));
|
||||||
vps.vps_sub_layer_ordering_info_present_flag = 1;
|
vps.vps_sub_layer_ordering_info_present_flag = 1;
|
||||||
for (i = 0; i < MAX_SUB_LAYERS; i++) {
|
for (i = 0; i < HEVC_MAX_SUB_LAYERS; i++) {
|
||||||
vps.vps_max_dec_pic_buffering[i] = sps.temporal_layer[i].max_dec_pic_buffering;
|
vps.vps_max_dec_pic_buffering[i] = sps.temporal_layer[i].max_dec_pic_buffering;
|
||||||
vps.vps_num_reorder_pics[i] = sps.temporal_layer[i].num_reorder_pics;
|
vps.vps_num_reorder_pics[i] = sps.temporal_layer[i].num_reorder_pics;
|
||||||
vps.vps_max_latency_increase[i] = sps.temporal_layer[i].max_latency_increase;
|
vps.vps_max_latency_increase[i] = sps.temporal_layer[i].max_latency_increase;
|
||||||
@ -127,9 +128,9 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx)
|
|||||||
bytestream2_init(&gbc, vps_rbsp_buf, ret);
|
bytestream2_init(&gbc, vps_rbsp_buf, ret);
|
||||||
bytestream2_init_writer(&pbc, vps_buf, sizeof(vps_buf));
|
bytestream2_init_writer(&pbc, vps_buf, sizeof(vps_buf));
|
||||||
|
|
||||||
bytestream2_put_be32(&pbc, 1); // startcode
|
bytestream2_put_be32(&pbc, 1); // startcode
|
||||||
bytestream2_put_byte(&pbc, NAL_VPS << 1); // NAL
|
bytestream2_put_byte(&pbc, HEVC_NAL_VPS << 1); // NAL
|
||||||
bytestream2_put_byte(&pbc, 1); // header
|
bytestream2_put_byte(&pbc, 1); // header
|
||||||
|
|
||||||
while (bytestream2_get_bytes_left(&gbc)) {
|
while (bytestream2_get_bytes_left(&gbc)) {
|
||||||
uint32_t b = bytestream2_peek_be24(&gbc);
|
uint32_t b = bytestream2_peek_be24(&gbc);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "libavutil/pixfmt.h"
|
#include "libavutil/pixfmt.h"
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "hevcdec.h"
|
#include "hevc.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "put_bits.h"
|
#include "put_bits.h"
|
||||||
#include "vaapi_encode.h"
|
#include "vaapi_encode.h"
|
||||||
@ -275,7 +275,7 @@ static void vaapi_encode_h265_write_vps(PutBitContext *pbc,
|
|||||||
VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params;
|
VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
vaapi_encode_h265_write_nal_unit_header(pbc, NAL_VPS);
|
vaapi_encode_h265_write_nal_unit_header(pbc, HEVC_NAL_VPS);
|
||||||
|
|
||||||
u(4, mseq->video_parameter_set_id, vps_video_parameter_set_id);
|
u(4, mseq->video_parameter_set_id, vps_video_parameter_set_id);
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ static void vaapi_encode_h265_write_sps(PutBitContext *pbc,
|
|||||||
VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params;
|
VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
vaapi_encode_h265_write_nal_unit_header(pbc, NAL_SPS);
|
vaapi_encode_h265_write_nal_unit_header(pbc, HEVC_NAL_SPS);
|
||||||
|
|
||||||
u(4, mseq->video_parameter_set_id, sps_video_parameter_set_id);
|
u(4, mseq->video_parameter_set_id, sps_video_parameter_set_id);
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ static void vaapi_encode_h265_write_pps(PutBitContext *pbc,
|
|||||||
VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params;
|
VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
vaapi_encode_h265_write_nal_unit_header(pbc, NAL_PPS);
|
vaapi_encode_h265_write_nal_unit_header(pbc, HEVC_NAL_PPS);
|
||||||
|
|
||||||
ue(vpic->slice_pic_parameter_set_id, pps_pic_parameter_set_id);
|
ue(vpic->slice_pic_parameter_set_id, pps_pic_parameter_set_id);
|
||||||
ue(mseq->seq_parameter_set_id, pps_seq_parameter_set_id);
|
ue(mseq->seq_parameter_set_id, pps_seq_parameter_set_id);
|
||||||
@ -576,7 +576,7 @@ static void vaapi_encode_h265_write_slice_header2(PutBitContext *pbc,
|
|||||||
vaapi_encode_h265_write_nal_unit_header(pbc, vpic->nal_unit_type);
|
vaapi_encode_h265_write_nal_unit_header(pbc, vpic->nal_unit_type);
|
||||||
|
|
||||||
u(1, mslice_var(first_slice_segment_in_pic_flag));
|
u(1, mslice_var(first_slice_segment_in_pic_flag));
|
||||||
if (vpic->nal_unit_type >= NAL_BLA_W_LP &&
|
if (vpic->nal_unit_type >= HEVC_NAL_BLA_W_LP &&
|
||||||
vpic->nal_unit_type <= 23)
|
vpic->nal_unit_type <= 23)
|
||||||
u(1, mslice_var(no_output_of_prior_pics_flag));
|
u(1, mslice_var(no_output_of_prior_pics_flag));
|
||||||
|
|
||||||
@ -597,8 +597,8 @@ static void vaapi_encode_h265_write_slice_header2(PutBitContext *pbc,
|
|||||||
u(1, 1, pic_output_flag);
|
u(1, 1, pic_output_flag);
|
||||||
if (vseq->seq_fields.bits.separate_colour_plane_flag)
|
if (vseq->seq_fields.bits.separate_colour_plane_flag)
|
||||||
u(2, vslice_field(colour_plane_id));
|
u(2, vslice_field(colour_plane_id));
|
||||||
if (vpic->nal_unit_type != NAL_IDR_W_RADL &&
|
if (vpic->nal_unit_type != HEVC_NAL_IDR_W_RADL &&
|
||||||
vpic->nal_unit_type != NAL_IDR_N_LP) {
|
vpic->nal_unit_type != HEVC_NAL_IDR_N_LP) {
|
||||||
u(4 + mseq->log2_max_pic_order_cnt_lsb_minus4,
|
u(4 + mseq->log2_max_pic_order_cnt_lsb_minus4,
|
||||||
(pslice->pic_order_cnt &
|
(pslice->pic_order_cnt &
|
||||||
((1 << (mseq->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1)),
|
((1 << (mseq->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1)),
|
||||||
@ -998,25 +998,25 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
|
|||||||
|
|
||||||
switch (pic->type) {
|
switch (pic->type) {
|
||||||
case PICTURE_TYPE_IDR:
|
case PICTURE_TYPE_IDR:
|
||||||
vpic->nal_unit_type = NAL_IDR_W_RADL;
|
vpic->nal_unit_type = HEVC_NAL_IDR_W_RADL;
|
||||||
vpic->pic_fields.bits.idr_pic_flag = 1;
|
vpic->pic_fields.bits.idr_pic_flag = 1;
|
||||||
vpic->pic_fields.bits.coding_type = 1;
|
vpic->pic_fields.bits.coding_type = 1;
|
||||||
vpic->pic_fields.bits.reference_pic_flag = 1;
|
vpic->pic_fields.bits.reference_pic_flag = 1;
|
||||||
break;
|
break;
|
||||||
case PICTURE_TYPE_I:
|
case PICTURE_TYPE_I:
|
||||||
vpic->nal_unit_type = NAL_TRAIL_R;
|
vpic->nal_unit_type = HEVC_NAL_TRAIL_R;
|
||||||
vpic->pic_fields.bits.idr_pic_flag = 0;
|
vpic->pic_fields.bits.idr_pic_flag = 0;
|
||||||
vpic->pic_fields.bits.coding_type = 1;
|
vpic->pic_fields.bits.coding_type = 1;
|
||||||
vpic->pic_fields.bits.reference_pic_flag = 1;
|
vpic->pic_fields.bits.reference_pic_flag = 1;
|
||||||
break;
|
break;
|
||||||
case PICTURE_TYPE_P:
|
case PICTURE_TYPE_P:
|
||||||
vpic->nal_unit_type = NAL_TRAIL_R;
|
vpic->nal_unit_type = HEVC_NAL_TRAIL_R;
|
||||||
vpic->pic_fields.bits.idr_pic_flag = 0;
|
vpic->pic_fields.bits.idr_pic_flag = 0;
|
||||||
vpic->pic_fields.bits.coding_type = 2;
|
vpic->pic_fields.bits.coding_type = 2;
|
||||||
vpic->pic_fields.bits.reference_pic_flag = 1;
|
vpic->pic_fields.bits.reference_pic_flag = 1;
|
||||||
break;
|
break;
|
||||||
case PICTURE_TYPE_B:
|
case PICTURE_TYPE_B:
|
||||||
vpic->nal_unit_type = NAL_TRAIL_R;
|
vpic->nal_unit_type = HEVC_NAL_TRAIL_R;
|
||||||
vpic->pic_fields.bits.idr_pic_flag = 0;
|
vpic->pic_fields.bits.idr_pic_flag = 0;
|
||||||
vpic->pic_fields.bits.coding_type = 3;
|
vpic->pic_fields.bits.coding_type = 3;
|
||||||
vpic->pic_fields.bits.reference_pic_flag = 0;
|
vpic->pic_fields.bits.reference_pic_flag = 0;
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "libavcodec/avcodec.h"
|
||||||
#include "libavcodec/get_bits.h"
|
#include "libavcodec/get_bits.h"
|
||||||
#include "libavcodec/golomb.h"
|
#include "libavcodec/golomb.h"
|
||||||
#include "libavcodec/hevcdec.h"
|
#include "libavcodec/hevc.h"
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "avc.h"
|
#include "avc.h"
|
||||||
#include "avio.h"
|
#include "avio.h"
|
||||||
@ -127,8 +128,8 @@ static void hvcc_parse_ptl(GetBitContext *gb,
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HVCCProfileTierLevel general_ptl;
|
HVCCProfileTierLevel general_ptl;
|
||||||
uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS];
|
uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
|
||||||
uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS];
|
uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
|
||||||
|
|
||||||
general_ptl.profile_space = get_bits(gb, 2);
|
general_ptl.profile_space = get_bits(gb, 2);
|
||||||
general_ptl.tier_flag = get_bits1(gb);
|
general_ptl.tier_flag = get_bits1(gb);
|
||||||
@ -411,7 +412,7 @@ static void skip_scaling_list_data(GetBitContext *gb)
|
|||||||
|
|
||||||
static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
|
static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
|
||||||
unsigned int num_rps,
|
unsigned int num_rps,
|
||||||
unsigned int num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT])
|
unsigned int num_delta_pocs[HEVC_MAX_SHORT_TERM_RPS_COUNT])
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@ -477,7 +478,7 @@ static int hvcc_parse_sps(GetBitContext *gb,
|
|||||||
HEVCDecoderConfigurationRecord *hvcc)
|
HEVCDecoderConfigurationRecord *hvcc)
|
||||||
{
|
{
|
||||||
unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
|
unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
|
||||||
unsigned int num_short_term_ref_pic_sets, num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT];
|
unsigned int num_short_term_ref_pic_sets, num_delta_pocs[HEVC_MAX_SHORT_TERM_RPS_COUNT];
|
||||||
|
|
||||||
skip_bits(gb, 4); // sps_video_parameter_set_id
|
skip_bits(gb, 4); // sps_video_parameter_set_id
|
||||||
|
|
||||||
@ -547,7 +548,7 @@ static int hvcc_parse_sps(GetBitContext *gb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
num_short_term_ref_pic_sets = get_ue_golomb_long(gb);
|
num_short_term_ref_pic_sets = get_ue_golomb_long(gb);
|
||||||
if (num_short_term_ref_pic_sets > MAX_SHORT_TERM_RPS_COUNT)
|
if (num_short_term_ref_pic_sets > HEVC_MAX_SHORT_TERM_RPS_COUNT)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
for (i = 0; i < num_short_term_ref_pic_sets; i++) {
|
for (i = 0; i < num_short_term_ref_pic_sets; i++) {
|
||||||
@ -722,7 +723,7 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
|
|||||||
* for all other arrays. When the sample entry name is ‘hev1’, the default
|
* for all other arrays. When the sample entry name is ‘hev1’, the default
|
||||||
* value of array_completeness is 0 for all arrays.
|
* value of array_completeness is 0 for all arrays.
|
||||||
*/
|
*/
|
||||||
if (nal_type == NAL_VPS || nal_type == NAL_SPS || nal_type == NAL_PPS)
|
if (nal_type == HEVC_NAL_VPS || nal_type == HEVC_NAL_SPS || nal_type == HEVC_NAL_PPS)
|
||||||
array->array_completeness = ps_array_completeness;
|
array->array_completeness = ps_array_completeness;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -756,20 +757,20 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
|
|||||||
* and non-declarative SEI messages discarded?
|
* and non-declarative SEI messages discarded?
|
||||||
*/
|
*/
|
||||||
switch (nal_type) {
|
switch (nal_type) {
|
||||||
case NAL_VPS:
|
case HEVC_NAL_VPS:
|
||||||
case NAL_SPS:
|
case HEVC_NAL_SPS:
|
||||||
case NAL_PPS:
|
case HEVC_NAL_PPS:
|
||||||
case NAL_SEI_PREFIX:
|
case HEVC_NAL_SEI_PREFIX:
|
||||||
case NAL_SEI_SUFFIX:
|
case HEVC_NAL_SEI_SUFFIX:
|
||||||
ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
|
ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
|
||||||
ps_array_completeness, hvcc);
|
ps_array_completeness, hvcc);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
else if (nal_type == NAL_VPS)
|
else if (nal_type == HEVC_NAL_VPS)
|
||||||
ret = hvcc_parse_vps(&gbc, hvcc);
|
ret = hvcc_parse_vps(&gbc, hvcc);
|
||||||
else if (nal_type == NAL_SPS)
|
else if (nal_type == HEVC_NAL_SPS)
|
||||||
ret = hvcc_parse_sps(&gbc, hvcc);
|
ret = hvcc_parse_sps(&gbc, hvcc);
|
||||||
else if (nal_type == NAL_PPS)
|
else if (nal_type == HEVC_NAL_PPS)
|
||||||
ret = hvcc_parse_pps(&gbc, hvcc);
|
ret = hvcc_parse_pps(&gbc, hvcc);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
@ -903,21 +904,21 @@ static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < hvcc->numOfArrays; i++)
|
for (i = 0; i < hvcc->numOfArrays; i++)
|
||||||
switch (hvcc->array[i].NAL_unit_type) {
|
switch (hvcc->array[i].NAL_unit_type) {
|
||||||
case NAL_VPS:
|
case HEVC_NAL_VPS:
|
||||||
vps_count += hvcc->array[i].numNalus;
|
vps_count += hvcc->array[i].numNalus;
|
||||||
break;
|
break;
|
||||||
case NAL_SPS:
|
case HEVC_NAL_SPS:
|
||||||
sps_count += hvcc->array[i].numNalus;
|
sps_count += hvcc->array[i].numNalus;
|
||||||
break;
|
break;
|
||||||
case NAL_PPS:
|
case HEVC_NAL_PPS:
|
||||||
pps_count += hvcc->array[i].numNalus;
|
pps_count += hvcc->array[i].numNalus;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!vps_count || vps_count > MAX_VPS_COUNT ||
|
if (!vps_count || vps_count > HEVC_MAX_VPS_COUNT ||
|
||||||
!sps_count || sps_count > MAX_SPS_COUNT ||
|
!sps_count || sps_count > HEVC_MAX_SPS_COUNT ||
|
||||||
!pps_count || pps_count > MAX_PPS_COUNT)
|
!pps_count || pps_count > HEVC_MAX_PPS_COUNT)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* unsigned int(8) configurationVersion = 1; */
|
/* unsigned int(8) configurationVersion = 1; */
|
||||||
@ -1040,9 +1041,9 @@ int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
|
|||||||
buf += 4;
|
buf += 4;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NAL_VPS:
|
case HEVC_NAL_VPS:
|
||||||
case NAL_SPS:
|
case HEVC_NAL_SPS:
|
||||||
case NAL_PPS:
|
case HEVC_NAL_PPS:
|
||||||
num_ps++;
|
num_ps++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1115,11 +1116,11 @@ int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
|
|||||||
buf += 4;
|
buf += 4;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NAL_VPS:
|
case HEVC_NAL_VPS:
|
||||||
case NAL_SPS:
|
case HEVC_NAL_SPS:
|
||||||
case NAL_PPS:
|
case HEVC_NAL_PPS:
|
||||||
case NAL_SEI_PREFIX:
|
case HEVC_NAL_SEI_PREFIX:
|
||||||
case NAL_SEI_SUFFIX:
|
case HEVC_NAL_SEI_SUFFIX:
|
||||||
ret = hvcc_add_nal_unit(buf, len, ps_array_completeness, &hvcc);
|
ret = hvcc_add_nal_unit(buf, len, ps_array_completeness, &hvcc);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libavcodec/hevcdec.h"
|
#include "libavcodec/hevc.h"
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
#include "rawdec.h"
|
#include "rawdec.h"
|
||||||
@ -43,15 +43,15 @@ static int hevc_probe(AVProbeData *p)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NAL_VPS: vps++; break;
|
case HEVC_NAL_VPS: vps++; break;
|
||||||
case NAL_SPS: sps++; break;
|
case HEVC_NAL_SPS: sps++; break;
|
||||||
case NAL_PPS: pps++; break;
|
case HEVC_NAL_PPS: pps++; break;
|
||||||
case NAL_BLA_N_LP:
|
case HEVC_NAL_BLA_N_LP:
|
||||||
case NAL_BLA_W_LP:
|
case HEVC_NAL_BLA_W_LP:
|
||||||
case NAL_BLA_W_RADL:
|
case HEVC_NAL_BLA_W_RADL:
|
||||||
case NAL_CRA_NUT:
|
case HEVC_NAL_CRA_NUT:
|
||||||
case NAL_IDR_N_LP:
|
case HEVC_NAL_IDR_N_LP:
|
||||||
case NAL_IDR_W_RADL: irap++; break;
|
case HEVC_NAL_IDR_W_RADL: irap++; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user