1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

Merge commit '064698d381e1e7790f21b0199a8930ea04e2e942'

* commit '064698d381e1e7790f21b0199a8930ea04e2e942':
  Add HEVC decoder

Conflicts:
	Changelog
	libavcodec/Makefile
	libavcodec/allcodecs.c
	libavcodec/hevc.c
	libavcodec/hevc.h
	libavcodec/hevc_cabac.c
	libavcodec/hevc_filter.c
	libavcodec/hevc_mvs.c
	libavcodec/hevc_parser.c
	libavcodec/hevc_ps.c
	libavcodec/hevc_refs.c
	libavcodec/hevc_sei.c
	libavcodec/hevcdsp.c
	libavcodec/hevcdsp_template.c
	libavcodec/hevcpred.c
	libavcodec/hevcpred_template.c
	libavcodec/version.h

cosmetics from hevc.h & hevc_ps.c mostly merged, other files left as they where in ffmpeg.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-11-01 16:14:39 +01:00
commit 5eb1704d5f
9 changed files with 225 additions and 198 deletions

View File

@ -609,6 +609,7 @@ following image formats are supported:
@item H.263+ / H.263-1998 / H.263 version 2 @tab X @tab X @item H.263+ / H.263-1998 / H.263 version 2 @tab X @tab X
@item H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 @tab E @tab X @item H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 @tab E @tab X
@tab encoding supported through external library libx264 @tab encoding supported through external library libx264
@item HEVC @tab @tab X
@item HNM version 4 @tab @tab X @item HNM version 4 @tab @tab X
@item HuffYUV @tab X @tab X @item HuffYUV @tab X @tab X
@item HuffYUV FFmpeg variant @tab X @tab X @item HuffYUV FFmpeg variant @tab X @tab X

View File

@ -277,6 +277,7 @@ enum AVCodecID {
AV_CODEC_ID_G2M_DEPRECATED, AV_CODEC_ID_G2M_DEPRECATED,
AV_CODEC_ID_WEBP_DEPRECATED, AV_CODEC_ID_WEBP_DEPRECATED,
AV_CODEC_ID_HNM4_VIDEO, AV_CODEC_ID_HNM4_VIDEO,
AV_CODEC_ID_HEVC_DEPRECATED,
AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'), AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'),
AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'), AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),

View File

@ -225,13 +225,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
}, },
{
.id = AV_CODEC_ID_HEVC,
.type = AVMEDIA_TYPE_VIDEO,
.name = "hevc",
.long_name = NULL_IF_CONFIG_SMALL("H.265 / HEVC"),
.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
},
{ {
.id = AV_CODEC_ID_INDEO3, .id = AV_CODEC_ID_INDEO3,
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
@ -1401,6 +1394,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("HNM 4 video"), .long_name = NULL_IF_CONFIG_SMALL("HNM 4 video"),
.props = AV_CODEC_PROP_LOSSY, .props = AV_CODEC_PROP_LOSSY,
}, },
{
.id = AV_CODEC_ID_HEVC,
.type = AVMEDIA_TYPE_VIDEO,
.name = "hevc",
.long_name = NULL_IF_CONFIG_SMALL("H.265 / HEVC (High Efficiency Video Coding)"),
.props = AV_CODEC_PROP_LOSSY,
},
/* various PCM "codecs" */ /* various PCM "codecs" */
{ {

View File

@ -2882,7 +2882,7 @@ static void hevc_decode_flush(AVCodecContext *avctx)
#define OFFSET(x) offsetof(HEVCContext, x) #define OFFSET(x) offsetof(HEVCContext, x)
#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM) #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
static const AVOption options[] = { static const AVOption options[] = {
{ "strict-displaywin", "stricly apply default display window size", OFFSET(strict_def_disp_win), { "strict-displaywin", "stricly apply default display window size", OFFSET(apply_defdispwin),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, PAR }, AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, PAR },
{ NULL }, { NULL },
}; };

View File

@ -1,5 +1,5 @@
/* /*
* HEVC video Decoder * HEVC video decoder
* *
* Copyright (C) 2012 - 2013 Guillaume Martres * Copyright (C) 2012 - 2013 Guillaume Martres
* *
@ -347,7 +347,7 @@ typedef struct PTL {
int sub_layer_level_idc[MAX_SUB_LAYERS]; int sub_layer_level_idc[MAX_SUB_LAYERS];
} PTL; } PTL;
typedef struct VPS { typedef struct HEVCVPS {
uint8_t vps_temporal_id_nesting_flag; uint8_t vps_temporal_id_nesting_flag;
int vps_max_layers; int vps_max_layers;
int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1 int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1
@ -365,10 +365,11 @@ typedef struct VPS {
uint8_t vps_poc_proportional_to_timing_flag; uint8_t vps_poc_proportional_to_timing_flag;
int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1 int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1
int vps_num_hrd_parameters; int vps_num_hrd_parameters;
} VPS; } HEVCVPS;
typedef struct ScalingList { typedef struct ScalingList {
// This is a little wasteful, since sizeID 0 only needs 8 coeffs, and size ID 3 only has 2 arrays, not 6. /* This is a little wasteful, since sizeID 0 only needs 8 coeffs,
* and size ID 3 only has 2 arrays, not 6. */
uint8_t sl[4][6][64]; uint8_t sl[4][6][64];
uint8_t sl_dc[2][6]; uint8_t sl_dc[2][6];
} ScalingList; } ScalingList;
@ -496,7 +497,7 @@ typedef struct HEVCPPS {
int beta_offset; ///< beta_offset_div2 * 2 int beta_offset; ///< beta_offset_div2 * 2
int tc_offset; ///< tc_offset_div2 * 2 int tc_offset; ///< tc_offset_div2 * 2
int pps_scaling_list_data_present_flag; int scaling_list_data_present_flag;
ScalingList scaling_list; ScalingList scaling_list;
uint8_t lists_modification_present_flag; uint8_t lists_modification_present_flag;
@ -778,10 +779,10 @@ typedef struct HEVCContext {
AVFrame *sao_frame; AVFrame *sao_frame;
AVFrame *tmp_frame; AVFrame *tmp_frame;
AVFrame *output_frame; AVFrame *output_frame;
VPS *vps; HEVCVPS *vps;
const HEVCSPS *sps; const HEVCSPS *sps;
HEVCPPS *pps; HEVCPPS *pps;
VPS *vps_list[MAX_VPS_COUNT]; HEVCVPS *vps_list[MAX_VPS_COUNT];
AVBufferRef *sps_list[MAX_SPS_COUNT]; AVBufferRef *sps_list[MAX_SPS_COUNT];
AVBufferRef *pps_list[MAX_PPS_COUNT]; AVBufferRef *pps_list[MAX_PPS_COUNT];
@ -825,7 +826,6 @@ typedef struct HEVCContext {
// PU // PU
uint8_t *tab_ipm; uint8_t *tab_ipm;
uint8_t *cbf_luma; // cbf_luma of colocated TU uint8_t *cbf_luma; // cbf_luma of colocated TU
uint8_t *is_pcm; uint8_t *is_pcm;
@ -867,7 +867,7 @@ typedef struct HEVCContext {
int context_initialized; int context_initialized;
int is_nalff; ///< this flag is != 0 if bitstream is encapsulated int is_nalff; ///< this flag is != 0 if bitstream is encapsulated
///< as a format defined in 14496-15 ///< as a format defined in 14496-15
int strict_def_disp_win; int apply_defdispwin;
int active_seq_parameter_set_id; int active_seq_parameter_set_id;
@ -902,7 +902,8 @@ void ff_hevc_flush_dpb(HEVCContext *s);
*/ */
int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb); int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb);
RefPicList* ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame, int x0, int y0); RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame,
int x0, int y0);
/** /**
* Construct the reference picture sets for the current frame. * Construct the reference picture sets for the current frame.
@ -924,9 +925,11 @@ int ff_hevc_sao_offset_sign_decode(HEVCContext *s);
int ff_hevc_sao_eo_class_decode(HEVCContext *s); int ff_hevc_sao_eo_class_decode(HEVCContext *s);
int ff_hevc_end_of_slice_flag_decode(HEVCContext *s); int ff_hevc_end_of_slice_flag_decode(HEVCContext *s);
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s); int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s);
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb); int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0,
int x_cb, int y_cb);
int ff_hevc_pred_mode_decode(HEVCContext *s); int ff_hevc_pred_mode_decode(HEVCContext *s);
int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0, int y0); int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth,
int x0, int y0);
int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size); int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size);
int ff_hevc_pcm_flag_decode(HEVCContext *s); int ff_hevc_pcm_flag_decode(HEVCContext *s);
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s); int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s);
@ -959,12 +962,21 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *frame, int flush);
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags); void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags);
void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0, int nPbW, int nPbH); void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0,
void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv); int nPbW, int nPbH);
void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv , int mvp_lx_flag, int LX); void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0,
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size); int nPbW, int nPbH, int log2_cb_size,
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size, int part_idx, int merge_idx, MvField *mv);
int slice_or_tiles_up_boundary, int slice_or_tiles_left_boundary); void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0,
int nPbW, int nPbH, int log2_cb_size,
int part_idx, int merge_idx,
MvField *mv, int mvp_lx_flag, int LX);
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase,
int log2_cb_size);
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
int log2_trafo_size,
int slice_or_tiles_up_boundary,
int slice_or_tiles_left_boundary);
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s); int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s);
int ff_hevc_cu_qp_delta_abs(HEVCContext *s); int ff_hevc_cu_qp_delta_abs(HEVCContext *s);
void ff_hevc_hls_filter(HEVCContext *s, int x, int y); void ff_hevc_hls_filter(HEVCContext *s, int x, int y);
@ -986,4 +998,4 @@ extern const uint8_t ff_hevc_diag_scan4x4_y[16];
extern const uint8_t ff_hevc_diag_scan8x8_x[64]; extern const uint8_t ff_hevc_diag_scan8x8_x[64];
extern const uint8_t ff_hevc_diag_scan8x8_y[64]; extern const uint8_t ff_hevc_diag_scan8x8_y[64];
#endif // AVCODEC_HEVC_H #endif /* AVCODEC_HEVC_H */

View File

@ -1137,7 +1137,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
dc_scale = 16; dc_scale = 16;
if (s->sps->scaling_list_enable_flag) { if (s->sps->scaling_list_enable_flag) {
const ScalingList *sl = s->pps->pps_scaling_list_data_present_flag ? const ScalingList *sl = s->pps->scaling_list_data_present_flag ?
&s->pps->scaling_list : &s->sps->scaling_list; &s->pps->scaling_list : &s->sps->scaling_list;
int matrix_id = lc->cu.pred_mode != MODE_INTRA; int matrix_id = lc->cu.pred_mode != MODE_INTRA;

View File

@ -1,5 +1,5 @@
/* /*
* HEVC Parameter Set Decoding * HEVC Parameter Set decoding
* *
* Copyright (C) 2012 - 2103 Guillaume Martres * Copyright (C) 2012 - 2103 Guillaume Martres
* Copyright (C) 2012 - 2103 Mickael Raulet * Copyright (C) 2012 - 2103 Mickael Raulet
@ -23,8 +23,9 @@
* 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 "golomb.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "golomb.h"
#include "hevc.h" #include "hevc.h"
static const uint8_t default_scaling_list_intra[] = { static const uint8_t default_scaling_list_intra[] = {
@ -94,9 +95,9 @@ int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps,
if (is_slice_header) { if (is_slice_header) {
int delta_idx = get_ue_golomb_long(gb) + 1; int delta_idx = get_ue_golomb_long(gb) + 1;
if (delta_idx > sps->nb_st_rps) { if (delta_idx > sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid value of delta_idx " av_log(s->avctx, AV_LOG_ERROR,
"in slice header RPS: %d > %d.\n", delta_idx, "Invalid value of delta_idx in slice header RPS: %d > %d.\n",
sps->nb_st_rps); delta_idx, sps->nb_st_rps);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx]; rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx];
@ -191,11 +192,12 @@ int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps,
return 0; return 0;
} }
static int decode_profile_tier_level(HEVCContext *s, PTL *ptl, int max_num_sub_layers) static int decode_profile_tier_level(HEVCContext *s, PTL *ptl,
int max_num_sub_layers)
{ {
int i, j;
HEVCLocalContext *lc = s->HEVClc; HEVCLocalContext *lc = s->HEVClc;
GetBitContext *gb = &lc->gb; GetBitContext *gb = &lc->gb;
int i, j;
ptl->general_profile_space = get_bits(gb, 2); ptl->general_profile_space = get_bits(gb, 2);
ptl->general_tier_flag = get_bits1(gb); ptl->general_tier_flag = get_bits1(gb);
@ -253,7 +255,8 @@ static int decode_profile_tier_level(HEVCContext *s, PTL *ptl, int max_num_sub_l
return 0; return 0;
} }
static void decode_sublayer_hrd(HEVCContext *s, int nb_cpb, int subpic_params_present) static void decode_sublayer_hrd(HEVCContext *s, int nb_cpb,
int subpic_params_present)
{ {
GetBitContext *gb = &s->HEVClc->gb; GetBitContext *gb = &s->HEVClc->gb;
int i; int i;
@ -331,7 +334,7 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
int i,j; int i,j;
GetBitContext *gb = &s->HEVClc->gb; GetBitContext *gb = &s->HEVClc->gb;
int vps_id = 0; int vps_id = 0;
VPS *vps; HEVCVPS *vps;
av_log(s->avctx, AV_LOG_DEBUG, "Decoding VPS\n"); av_log(s->avctx, AV_LOG_DEBUG, "Decoding VPS\n");
@ -440,8 +443,8 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps)
vui->sar.num = get_bits(gb, 16); vui->sar.num = get_bits(gb, 16);
vui->sar.den = get_bits(gb, 16); vui->sar.den = get_bits(gb, 16);
} else } else
av_log(s->avctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n", av_log(s->avctx, AV_LOG_WARNING,
sar_idx); "Unknown SAR index: %u.\n", sar_idx);
} }
vui->overscan_info_present_flag = get_bits1(gb); vui->overscan_info_present_flag = get_bits1(gb);
@ -478,7 +481,7 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps)
vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * 2;
vui->def_disp_win.bottom_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.bottom_offset = get_ue_golomb_long(gb) * 2;
if (s->strict_def_disp_win && if (s->apply_defdispwin &&
s->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { s->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) {
av_log(s->avctx, AV_LOG_DEBUG, av_log(s->avctx, AV_LOG_DEBUG,
"discarding vui default display window, " "discarding vui default display window, "
@ -551,14 +554,15 @@ static int scaling_list_data(HEVCContext *s, ScalingList *sl)
GetBitContext *gb = &s->HEVClc->gb; GetBitContext *gb = &s->HEVClc->gb;
uint8_t scaling_list_pred_mode_flag[4][6]; uint8_t scaling_list_pred_mode_flag[4][6];
int32_t scaling_list_dc_coef[2][6]; int32_t scaling_list_dc_coef[2][6];
int size_id, matrix_id, i, pos, delta; int size_id, matrix_id, i, pos, delta;
for (size_id = 0; size_id < 4; size_id++) for (size_id = 0; size_id < 4; size_id++)
for (matrix_id = 0; matrix_id < ((size_id == 3) ? 2 : 6); matrix_id++) { for (matrix_id = 0; matrix_id < (size_id == 3 ? 2 : 6); matrix_id++) {
scaling_list_pred_mode_flag[size_id][matrix_id] = get_bits1(gb); scaling_list_pred_mode_flag[size_id][matrix_id] = get_bits1(gb);
if (!scaling_list_pred_mode_flag[size_id][matrix_id]) { if (!scaling_list_pred_mode_flag[size_id][matrix_id]) {
delta = get_ue_golomb_long(gb); delta = get_ue_golomb_long(gb);
// Only need to handle non-zero delta. Zero means default, which should already be in the arrays. /* Only need to handle non-zero delta. Zero means default,
* which should already be in the arrays. */
if (delta) { if (delta) {
// Copy from previous array. // Copy from previous array.
if (matrix_id - delta < 0) { if (matrix_id - delta < 0) {
@ -574,12 +578,11 @@ static int scaling_list_data(HEVCContext *s, ScalingList *sl)
sl->sl_dc[size_id - 2][matrix_id] = sl->sl_dc[size_id - 2][matrix_id - delta]; sl->sl_dc[size_id - 2][matrix_id] = sl->sl_dc[size_id - 2][matrix_id - delta];
} }
} else { } else {
int next_coef; int next_coef, coef_num;
int coef_num;
int32_t scaling_list_delta_coef; int32_t scaling_list_delta_coef;
next_coef = 8; next_coef = 8;
coef_num = FFMIN(64, (1 << (4 + (size_id << 1)))); coef_num = FFMIN(64, 1 << (4 + (size_id << 1)));
if (size_id > 1) { if (size_id > 1) {
scaling_list_dc_coef[size_id - 2][matrix_id] = get_se_golomb(gb) + 8; scaling_list_dc_coef[size_id - 2][matrix_id] = get_se_golomb(gb) + 8;
next_coef = scaling_list_dc_coef[size_id - 2][matrix_id]; next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
@ -587,9 +590,11 @@ static int scaling_list_data(HEVCContext *s, ScalingList *sl)
} }
for (i = 0; i < coef_num; i++) { for (i = 0; i < coef_num; i++) {
if (size_id == 0) if (size_id == 0)
pos = 4 * ff_hevc_diag_scan4x4_y[i] + ff_hevc_diag_scan4x4_x[i]; pos = 4 * ff_hevc_diag_scan4x4_y[i] +
ff_hevc_diag_scan4x4_x[i];
else else
pos = 8 * ff_hevc_diag_scan8x8_y[i] + ff_hevc_diag_scan8x8_x[i]; pos = 8 * ff_hevc_diag_scan8x8_y[i] +
ff_hevc_diag_scan8x8_x[i];
scaling_list_delta_coef = get_se_golomb(gb); scaling_list_delta_coef = get_se_golomb(gb);
next_coef = (next_coef + scaling_list_delta_coef + 256) % 256; next_coef = (next_coef + scaling_list_delta_coef + 256) % 256;
@ -653,7 +658,7 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
sps->chroma_format_idc = get_ue_golomb_long(gb); sps->chroma_format_idc = get_ue_golomb_long(gb);
if (sps->chroma_format_idc != 1) { if (sps->chroma_format_idc != 1) {
avpriv_report_missing_feature(s->avctx, "chroma_format_idc != 1\n"); avpriv_report_missing_feature(s->avctx, "chroma_format_idc != 1\n");
ret = AVERROR_INVALIDDATA; ret = AVERROR_PATCHWELCOME;
goto err; goto err;
} }
@ -694,7 +699,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
bit_depth_chroma = get_ue_golomb_long(gb) + 8; bit_depth_chroma = get_ue_golomb_long(gb) + 8;
if (bit_depth_chroma != sps->bit_depth) { if (bit_depth_chroma != sps->bit_depth) {
av_log(s->avctx, AV_LOG_ERROR, av_log(s->avctx, AV_LOG_ERROR,
"Luma bit depth (%d) is different from chroma bit depth (%d), this is unsupported.\n", "Luma bit depth (%d) is different from chroma bit depth (%d), "
"this is unsupported.\n",
sps->bit_depth, bit_depth_chroma); sps->bit_depth, bit_depth_chroma);
ret = AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto err; goto err;
@ -712,7 +718,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
goto err; goto err;
} }
} else { } else {
av_log(s->avctx, AV_LOG_ERROR, "non-4:2:0 support is currently unspecified.\n"); av_log(s->avctx, AV_LOG_ERROR,
"non-4:2:0 support is currently unspecified.\n");
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
@ -768,7 +775,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
sps->log2_diff_max_min_coding_block_size = get_ue_golomb_long(gb); sps->log2_diff_max_min_coding_block_size = get_ue_golomb_long(gb);
sps->log2_min_tb_size = get_ue_golomb_long(gb) + 2; sps->log2_min_tb_size = get_ue_golomb_long(gb) + 2;
log2_diff_max_min_transform_block_size = get_ue_golomb_long(gb); log2_diff_max_min_transform_block_size = get_ue_golomb_long(gb);
sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size + sps->log2_min_tb_size; sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size +
sps->log2_min_tb_size;
if (sps->log2_min_tb_size >= sps->log2_min_cb_size) { if (sps->log2_min_tb_size >= sps->log2_min_cb_size) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size"); av_log(s->avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size");
@ -840,7 +848,7 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
decode_vui(s, sps); decode_vui(s, sps);
skip_bits1(gb); // sps_extension_flag skip_bits1(gb); // sps_extension_flag
if (s->strict_def_disp_win) { if (s->apply_defdispwin) {
sps->output_window.left_offset += sps->vui.def_disp_win.left_offset; sps->output_window.left_offset += sps->vui.def_disp_win.left_offset;
sps->output_window.right_offset += sps->vui.def_disp_win.right_offset; sps->output_window.right_offset += sps->vui.def_disp_win.right_offset;
sps->output_window.top_offset += sps->vui.def_disp_win.top_offset; sps->output_window.top_offset += sps->vui.def_disp_win.top_offset;
@ -864,7 +872,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
ret = AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto err; goto err;
} }
av_log(s->avctx, AV_LOG_WARNING, "Displaying the whole video surface.\n"); av_log(s->avctx, AV_LOG_WARNING,
"Displaying the whole video surface.\n");
sps->pic_conf_win.left_offset = sps->pic_conf_win.left_offset =
sps->pic_conf_win.right_offset = sps->pic_conf_win.right_offset =
sps->pic_conf_win.top_offset = sps->pic_conf_win.top_offset =
@ -874,8 +883,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
} }
// Inferred parameters // Inferred parameters
sps->log2_ctb_size = sps->log2_min_cb_size sps->log2_ctb_size = sps->log2_min_cb_size +
+ sps->log2_diff_max_min_coding_block_size; sps->log2_diff_max_min_coding_block_size;
sps->log2_min_pu_size = sps->log2_min_cb_size - 1; sps->log2_min_pu_size = sps->log2_min_cb_size - 1;
sps->ctb_width = (sps->width + (1 << sps->log2_ctb_size) - 1) >> sps->log2_ctb_size; sps->ctb_width = (sps->width + (1 << sps->log2_ctb_size) - 1) >> sps->log2_ctb_size;
@ -912,13 +921,15 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
goto err; goto err;
} }
if (sps->log2_max_trafo_size > FFMIN(sps->log2_ctb_size, 5)) { if (sps->log2_max_trafo_size > FFMIN(sps->log2_ctb_size, 5)) {
av_log(s->avctx, AV_LOG_ERROR, "max transform block size out of range: %d\n", av_log(s->avctx, AV_LOG_ERROR,
"max transform block size out of range: %d\n",
sps->log2_max_trafo_size); sps->log2_max_trafo_size);
goto err; goto err;
} }
if (s->avctx->debug & FF_DEBUG_BITSTREAM) { if (s->avctx->debug & FF_DEBUG_BITSTREAM) {
av_log(s->avctx, AV_LOG_DEBUG, "Parsed SPS: id %d; coded wxh: %dx%d; " av_log(s->avctx, AV_LOG_DEBUG,
"Parsed SPS: id %d; coded wxh: %dx%d; "
"cropped wxh: %dx%d; pix_fmt: %s.\n", "cropped wxh: %dx%d; pix_fmt: %s.\n",
sps_id, sps->width, sps->height, sps_id, sps->width, sps->height,
sps->output_width, sps->output_height, sps->output_width, sps->output_height,
@ -941,8 +952,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
} }
return 0; return 0;
err:
err:
av_buffer_unref(&sps_buf); av_buffer_unref(&sps_buf);
return ret; return ret;
} }
@ -982,7 +993,8 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
if (!pps) if (!pps)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
pps_buf = av_buffer_create((uint8_t*)pps, sizeof(*pps), hevc_pps_free, NULL, 0); pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
hevc_pps_free, NULL, 0);
if (!pps_buf) { if (!pps_buf) {
av_freep(&pps); av_freep(&pps);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -1141,8 +1153,8 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
} }
} }
pps->pps_scaling_list_data_present_flag = get_bits1(gb); pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->pps_scaling_list_data_present_flag) { if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list); set_default_scaling_list_data(&pps->scaling_list);
ret = scaling_list_data(s, &pps->scaling_list); ret = scaling_list_data(s, &pps->scaling_list);
if (ret < 0) if (ret < 0)

View File

@ -2606,6 +2606,7 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
case AV_CODEC_ID_ESCAPE130_DEPRECATED : return AV_CODEC_ID_ESCAPE130; case AV_CODEC_ID_ESCAPE130_DEPRECATED : return AV_CODEC_ID_ESCAPE130;
case AV_CODEC_ID_G2M_DEPRECATED : return AV_CODEC_ID_G2M; case AV_CODEC_ID_G2M_DEPRECATED : return AV_CODEC_ID_G2M;
case AV_CODEC_ID_WEBP_DEPRECATED: return AV_CODEC_ID_WEBP; case AV_CODEC_ID_WEBP_DEPRECATED: return AV_CODEC_ID_WEBP;
case AV_CODEC_ID_HEVC_DEPRECATED: return AV_CODEC_ID_HEVC;
default : return id; default : return id;
} }
} }

View File

@ -30,7 +30,7 @@
#define LIBAVCODEC_VERSION_MAJOR 55 #define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MINOR 40 #define LIBAVCODEC_VERSION_MINOR 40
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \