mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-27 21:40:34 +00:00
hevc: avoid some unnecessary differences with libav
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
6026a5ad4f
commit
679a6377e4
@ -2294,7 +2294,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
|
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
|
||||||
between these functions would be nice. */
|
* between these functions would be nice. */
|
||||||
int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
|
int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
|
||||||
HEVCNAL *nal)
|
HEVCNAL *nal)
|
||||||
{
|
{
|
||||||
@ -2857,7 +2857,7 @@ static int hevc_decode_extradata(HEVCContext *s)
|
|||||||
avctx->extradata[2] > 1)) {
|
avctx->extradata[2] > 1)) {
|
||||||
/* It seems the extradata is encoded as hvcC format.
|
/* It seems the extradata is encoded as hvcC format.
|
||||||
* Temporarily, we support configurationVersion==0 until 14496-15 3rd
|
* Temporarily, we support configurationVersion==0 until 14496-15 3rd
|
||||||
* finalized. When finalized, configurationVersion will be 1 and we
|
* is finalized. When finalized, configurationVersion will be 1 and we
|
||||||
* can recognize hvcC by checking if avctx->extradata[0]==1 or not. */
|
* can recognize hvcC by checking if avctx->extradata[0]==1 or not. */
|
||||||
int i, j, num_arrays, nal_len_size;
|
int i, j, num_arrays, nal_len_size;
|
||||||
|
|
||||||
|
@ -374,8 +374,6 @@ typedef struct HEVCVPS {
|
|||||||
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;
|
||||||
|
|
||||||
int vps_extension_flag;
|
|
||||||
} HEVCVPS;
|
} HEVCVPS;
|
||||||
|
|
||||||
typedef struct ScalingList {
|
typedef struct ScalingList {
|
||||||
@ -508,7 +506,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 scaling_list_data_present_flag;
|
uint8_t scaling_list_data_present_flag;
|
||||||
ScalingList scaling_list;
|
ScalingList scaling_list;
|
||||||
|
|
||||||
uint8_t lists_modification_present_flag;
|
uint8_t lists_modification_present_flag;
|
||||||
@ -516,9 +514,6 @@ typedef struct HEVCPPS {
|
|||||||
int num_extra_slice_header_bits;
|
int num_extra_slice_header_bits;
|
||||||
uint8_t slice_header_extension_present_flag;
|
uint8_t slice_header_extension_present_flag;
|
||||||
|
|
||||||
uint8_t pps_extension_flag;
|
|
||||||
uint8_t pps_extension_data_flag;
|
|
||||||
|
|
||||||
// Inferred parameters
|
// Inferred parameters
|
||||||
int *column_width; ///< ColumnWidth
|
int *column_width; ///< ColumnWidth
|
||||||
int *row_height; ///< RowHeight
|
int *row_height; ///< RowHeight
|
||||||
@ -580,8 +575,7 @@ typedef struct SliceHeader {
|
|||||||
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 max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
|
unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
|
||||||
|
|
||||||
|
|
||||||
int *entry_point_offset;
|
int *entry_point_offset;
|
||||||
int * offset;
|
int * offset;
|
||||||
@ -768,7 +762,7 @@ typedef struct HEVCLocalContext {
|
|||||||
|
|
||||||
typedef struct HEVCContext {
|
typedef struct HEVCContext {
|
||||||
const AVClass *c; // needed by private avoptions
|
const AVClass *c; // needed by private avoptions
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
|
|
||||||
struct HEVCContext *sList[MAX_NB_THREADS];
|
struct HEVCContext *sList[MAX_NB_THREADS];
|
||||||
|
|
||||||
@ -791,9 +785,9 @@ typedef struct HEVCContext {
|
|||||||
AVFrame *tmp_frame;
|
AVFrame *tmp_frame;
|
||||||
AVFrame *output_frame;
|
AVFrame *output_frame;
|
||||||
|
|
||||||
HEVCVPS *vps;
|
const HEVCVPS *vps;
|
||||||
const HEVCSPS *sps;
|
const HEVCSPS *sps;
|
||||||
HEVCPPS *pps;
|
const HEVCPPS *pps;
|
||||||
AVBufferRef *vps_list[MAX_VPS_COUNT];
|
AVBufferRef *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];
|
||||||
@ -876,8 +870,8 @@ typedef struct HEVCContext {
|
|||||||
uint8_t md5[3][16];
|
uint8_t md5[3][16];
|
||||||
uint8_t is_md5;
|
uint8_t is_md5;
|
||||||
|
|
||||||
int context_initialized;
|
uint8_t context_initialized;
|
||||||
int is_nalff; ///< this flag is != 0 if bitstream is encapsulated
|
uint8_t 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 apply_defdispwin;
|
int apply_defdispwin;
|
||||||
|
|
||||||
|
@ -412,8 +412,7 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
|
|||||||
decode_hrd(s, common_inf_present, vps->vps_max_sub_layers);
|
decode_hrd(s, common_inf_present, vps->vps_max_sub_layers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
get_bits1(gb); /* vps_extension_flag */
|
||||||
vps->vps_extension_flag = get_bits1(gb);
|
|
||||||
|
|
||||||
av_buffer_unref(&s->vps_list[vps_id]);
|
av_buffer_unref(&s->vps_list[vps_id]);
|
||||||
s->vps_list[vps_id] = vps_buf;
|
s->vps_list[vps_id] = vps_buf;
|
||||||
@ -1183,7 +1182,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pps->slice_header_extension_present_flag = get_bits1(gb);
|
pps->slice_header_extension_present_flag = get_bits1(gb);
|
||||||
pps->pps_extension_flag = get_bits1(gb);
|
skip_bits1(gb); // pps_extension_flag
|
||||||
|
|
||||||
// Inferred parameters
|
// Inferred parameters
|
||||||
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
|
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* HEVC video Decoder
|
* HEVC video decoder
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 - 2013 Guillaume Martres
|
* Copyright (C) 2012 - 2013 Guillaume Martres
|
||||||
* Copyright (C) 2012 - 2013 Gildas Cocherel
|
* Copyright (C) 2012 - 2013 Gildas Cocherel
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
* 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 "hevc.h"
|
|
||||||
#include "golomb.h"
|
#include "golomb.h"
|
||||||
|
#include "hevc.h"
|
||||||
|
|
||||||
static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
|
static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
|
||||||
{
|
{
|
||||||
|
@ -194,8 +194,6 @@ static void FUNC(transform_4x4_luma_add)(uint8_t *_dst, int16_t *coeffs,
|
|||||||
assign(dst[2 * dstep], e1 - o1); \
|
assign(dst[2 * dstep], e1 - o1); \
|
||||||
assign(dst[3 * dstep], e0 - o0); \
|
assign(dst[3 * dstep], e0 - o0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define TR_4_1(dst, src) TR_4(dst, src, 4, 4, SCALE)
|
|
||||||
#define TR_4_2(dst, src) TR_4(dst, src, 1, 1, ADD_AND_SCALE)
|
|
||||||
|
|
||||||
static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
|
static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
|
||||||
ptrdiff_t stride)
|
ptrdiff_t stride)
|
||||||
@ -209,14 +207,14 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
|
|||||||
stride /= sizeof(pixel);
|
stride /= sizeof(pixel);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
TR_4_1(src, src);
|
TR_4(src, src, 4, 4, SCALE);
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
shift = 20 - BIT_DEPTH;
|
shift = 20 - BIT_DEPTH;
|
||||||
add = 1 << (shift - 1);
|
add = 1 << (shift - 1);
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
TR_4_2(dst, coeffs);
|
TR_4(dst, coeffs, 1, 1, ADD_AND_SCALE);
|
||||||
coeffs += 4;
|
coeffs += 4;
|
||||||
dst += stride;
|
dst += stride;
|
||||||
}
|
}
|
||||||
@ -270,13 +268,7 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TR_8_1(dst, src) TR_8(dst, src, 8, 8, SCALE)
|
|
||||||
#define TR_16_1(dst, src) TR_16(dst, src, 16, 16, SCALE)
|
|
||||||
#define TR_32_1(dst, src) TR_32(dst, src, 32, 32, SCALE)
|
|
||||||
|
|
||||||
#define TR_8_2(dst, src) TR_8(dst, src, 1, 1, ADD_AND_SCALE)
|
|
||||||
#define TR_16_2(dst, src) TR_16(dst, src, 1, 1, ADD_AND_SCALE)
|
|
||||||
#define TR_32_2(dst, src) TR_32(dst, src, 1, 1, ADD_AND_SCALE)
|
|
||||||
|
|
||||||
static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
|
static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
|
||||||
ptrdiff_t stride)
|
ptrdiff_t stride)
|
||||||
@ -290,14 +282,14 @@ static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
|
|||||||
stride /= sizeof(pixel);
|
stride /= sizeof(pixel);
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
TR_8_1(src, src);
|
TR_8(src, src, 8, 8, SCALE);
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
shift = 20 - BIT_DEPTH;
|
shift = 20 - BIT_DEPTH;
|
||||||
add = 1 << (shift - 1);
|
add = 1 << (shift - 1);
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
TR_8_2(dst, coeffs);
|
TR_8(dst, coeffs, 1, 1, ADD_AND_SCALE);
|
||||||
coeffs += 8;
|
coeffs += 8;
|
||||||
dst += stride;
|
dst += stride;
|
||||||
}
|
}
|
||||||
@ -315,14 +307,14 @@ static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs,
|
|||||||
stride /= sizeof(pixel);
|
stride /= sizeof(pixel);
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
TR_16_1(src, src);
|
TR_16(src, src, 16, 16, SCALE);
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
shift = 20 - BIT_DEPTH;
|
shift = 20 - BIT_DEPTH;
|
||||||
add = 1 << (shift - 1);
|
add = 1 << (shift - 1);
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
TR_16_2(dst, coeffs);
|
TR_16(dst, coeffs, 1, 1, ADD_AND_SCALE);
|
||||||
coeffs += 16;
|
coeffs += 16;
|
||||||
dst += stride;
|
dst += stride;
|
||||||
}
|
}
|
||||||
@ -331,15 +323,6 @@ static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs,
|
|||||||
static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs,
|
static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs,
|
||||||
ptrdiff_t stride)
|
ptrdiff_t stride)
|
||||||
{
|
{
|
||||||
#define IT32x32_even(i,w) ( src[ 0*w] * transform[ 0][i] ) + ( src[16*w] * transform[16][i] )
|
|
||||||
#define IT32x32_odd(i,w) ( src[ 8*w] * transform[ 8][i] ) + ( src[24*w] * transform[24][i] )
|
|
||||||
#define IT16x16(i,w) ( src[ 4*w] * transform[ 4][i] ) + ( src[12*w] * transform[12][i] ) + ( src[20*w] * transform[20][i] ) + ( src[28*w] * transform[28][i] )
|
|
||||||
#define IT8x8(i,w) ( src[ 2*w] * transform[ 2][i] ) + ( src[ 6*w] * transform[ 6][i] ) + ( src[10*w] * transform[10][i] ) + ( src[14*w] * transform[14][i] ) + \
|
|
||||||
( src[18*w] * transform[18][i] ) + ( src[22*w] * transform[22][i] ) + ( src[26*w] * transform[26][i] ) + ( src[30*w] * transform[30][i] )
|
|
||||||
#define IT4x4(i,w) ( src[ 1*w] * transform[ 1][i] ) + ( src[ 3*w] * transform[ 3][i] ) + ( src[ 5*w] * transform[ 5][i] ) + ( src[ 7*w] * transform[ 7][i] ) + \
|
|
||||||
( src[ 9*w] * transform[ 9][i] ) + ( src[11*w] * transform[11][i] ) + ( src[13*w] * transform[13][i] ) + ( src[15*w] * transform[15][i] ) + \
|
|
||||||
( src[17*w] * transform[17][i] ) + ( src[19*w] * transform[19][i] ) + ( src[21*w] * transform[21][i] ) + ( src[23*w] * transform[23][i] ) + \
|
|
||||||
( src[25*w] * transform[25][i] ) + ( src[27*w] * transform[27][i] ) + ( src[29*w] * transform[29][i] ) + ( src[31*w] * transform[31][i] )
|
|
||||||
int i;
|
int i;
|
||||||
pixel *dst = (pixel *)_dst;
|
pixel *dst = (pixel *)_dst;
|
||||||
int shift = 7;
|
int shift = 7;
|
||||||
@ -349,22 +332,17 @@ static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs,
|
|||||||
stride /= sizeof(pixel);
|
stride /= sizeof(pixel);
|
||||||
|
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
TR_32_1(src, src);
|
TR_32(src, src, 32, 32, SCALE);
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
src = coeffs;
|
src = coeffs;
|
||||||
shift = 20 - BIT_DEPTH;
|
shift = 20 - BIT_DEPTH;
|
||||||
add = 1 << (shift - 1);
|
add = 1 << (shift - 1);
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
TR_32_2(dst, coeffs);
|
TR_32(dst, coeffs, 1, 1, ADD_AND_SCALE);
|
||||||
coeffs += 32;
|
coeffs += 32;
|
||||||
dst += stride;
|
dst += stride;
|
||||||
}
|
}
|
||||||
#undef IT32x32_even
|
|
||||||
#undef IT32x32_odd
|
|
||||||
#undef IT16x16
|
|
||||||
#undef IT8x8
|
|
||||||
#undef IT4x4
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
|
static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
|
||||||
@ -670,6 +648,7 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
|
|||||||
int chroma = !!c_idx;
|
int chroma = !!c_idx;
|
||||||
int *sao_offset_val = sao->offset_val[c_idx];
|
int *sao_offset_val = sao->offset_val[c_idx];
|
||||||
int sao_eo_class = sao->eo_class[c_idx];
|
int sao_eo_class = sao->eo_class[c_idx];
|
||||||
|
int init_x = 0, init_y = 0, width = _width, height = _height;
|
||||||
|
|
||||||
static const int8_t pos[4][2][2] = {
|
static const int8_t pos[4][2][2] = {
|
||||||
{ { -1, 0 }, { 1, 0 } }, // horizontal
|
{ { -1, 0 }, { 1, 0 } }, // horizontal
|
||||||
@ -679,9 +658,8 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
|
|||||||
};
|
};
|
||||||
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
|
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
|
||||||
|
|
||||||
int init_x = 0, init_y = 0, width = _width, height = _height;
|
|
||||||
|
|
||||||
#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
|
#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
|
||||||
|
|
||||||
stride /= sizeof(pixel);
|
stride /= sizeof(pixel);
|
||||||
|
|
||||||
init_x = -(8 >> chroma) - 2;
|
init_x = -(8 >> chroma) - 2;
|
||||||
@ -822,17 +800,9 @@ static void FUNC(sao_edge_filter_3)(uint8_t *_dst, uint8_t *_src,
|
|||||||
#undef SCALE
|
#undef SCALE
|
||||||
#undef ADD_AND_SCALE
|
#undef ADD_AND_SCALE
|
||||||
#undef TR_4
|
#undef TR_4
|
||||||
#undef TR_4_1
|
|
||||||
#undef TR_4_2
|
|
||||||
#undef TR_8
|
#undef TR_8
|
||||||
#undef TR_8_1
|
|
||||||
#undef TR_8_2
|
|
||||||
#undef TR_16
|
#undef TR_16
|
||||||
#undef TR_16_1
|
|
||||||
#undef TR_16_2
|
|
||||||
#undef TR_32
|
#undef TR_32
|
||||||
#undef TR_32_1
|
|
||||||
#undef TR_32_2
|
|
||||||
|
|
||||||
static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
|
static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
|
||||||
uint8_t *_src, ptrdiff_t _srcstride,
|
uint8_t *_src, ptrdiff_t _srcstride,
|
||||||
@ -1216,7 +1186,7 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix,
|
|||||||
const int no_p = _no_p[j];
|
const int no_p = _no_p[j];
|
||||||
const int no_q = _no_q[j];
|
const int no_q = _no_q[j];
|
||||||
|
|
||||||
if (d0 + d3 >= beta /*|| tc <= 0*/) {
|
if (d0 + d3 >= beta) {
|
||||||
pix += 4 * ystride;
|
pix += 4 * ystride;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user