FFmpeg  2.1.1
Macros | Functions | Variables
hevc.c File Reference
#include "libavutil/atomic.h"
#include "libavutil/attributes.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/md5.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "bytestream.h"
#include "cabac_functions.h"
#include "dsputil.h"
#include "golomb.h"
#include "hevc.h"

Go to the source code of this file.

Macros

#define CTB(tab, x, y)   ((tab)[(y) * s->sps->ctb_width + (x)])
 
#define SET_SAO(elem, value)
 
#define POS(c_idx, x, y)
 
#define STARTCODE_TEST
 
#define OFFSET(x)   offsetof(HEVCContext, x)
 
#define PAR   (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static void pic_arrays_free (HEVCContext *s)
 NOTE: Each function hls_foo correspond to the function foo in the specification (HLS stands for High Level Syntax). More...
 
static int pic_arrays_init (HEVCContext *s)
 
static void pred_weight_table (HEVCContext *s, GetBitContext *gb)
 
static int decode_lt_rps (HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
 
static int hls_slice_header (HEVCContext *s)
 
static void hls_sao_param (HEVCContext *s, int rx, int ry)
 
static void hls_transform_unit (HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx)
 
static void set_deblocking_bypass (HEVCContext *s, int x0, int y0, int log2_cb_size)
 
static void hls_transform_tree (HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx)
 
static int hls_pcm_sample (HEVCContext *s, int x0, int y0, int log2_cb_size)
 
static void luma_mc (HEVCContext *s, int16_t *dst, ptrdiff_t dststride, AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h)
 8.5.3.2.2.1 Luma sample interpolation process More...
 
static void chroma_mc (HEVCContext *s, int16_t *dst1, int16_t *dst2, ptrdiff_t dststride, AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h)
 8.5.3.2.2.2 Chroma sample interpolation process More...
 
static void hevc_await_progress (HEVCContext *s, HEVCFrame *ref, const Mv *mv, int y0, int height)
 
static void hls_prediction_unit (HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx)
 
static int luma_intra_pred_mode (HEVCContext *s, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag)
 8.4.1 More...
 
static av_always_inline void set_ct_depth (HEVCContext *s, int x0, int y0, int log2_cb_size, int ct_depth)
 
static void intra_prediction_unit (HEVCContext *s, int x0, int y0, int log2_cb_size)
 
static void intra_prediction_unit_default_value (HEVCContext *s, int x0, int y0, int log2_cb_size)
 
static int hls_coding_unit (HEVCContext *s, int x0, int y0, int log2_cb_size)
 
static int hls_coding_quadtree (HEVCContext *s, int x0, int y0, int log2_cb_size, int cb_depth)
 
static void hls_decode_neighbour (HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
 
static int hls_decode_entry (AVCodecContext *avctxt, void *isFilterThread)
 
static int hls_slice_data (HEVCContext *s)
 
static int hls_decode_entry_wpp (AVCodecContext *avctxt, void *input_ctb_row, int job, int self_id)
 
static int hls_slice_data_wpp (HEVCContext *s, const uint8_t *nal, int length)
 
static int hls_nal_unit (HEVCContext *s)
 
static void restore_tqb_pixels (HEVCContext *s)
 
static int hevc_frame_start (HEVCContext *s)
 
static int decode_nal_unit (HEVCContext *s, const uint8_t *nal, int length)
 
int ff_hevc_extract_rbsp (HEVCContext *s, const uint8_t *src, int length, HEVCNAL *nal)
 
static int decode_nal_units (HEVCContext *s, const uint8_t *buf, int length)
 
static void print_md5 (void *log_ctx, int level, uint8_t md5[16])
 
static int verify_md5 (HEVCContext *s, AVFrame *frame)
 
static int hevc_decode_frame (AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt)
 
static int hevc_ref_frame (HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
 
static av_cold int hevc_decode_free (AVCodecContext *avctx)
 
static av_cold int hevc_init_context (AVCodecContext *avctx)
 
static int hevc_update_thread_context (AVCodecContext *dst, const AVCodecContext *src)
 
static int hevc_decode_extradata (HEVCContext *s)
 
static av_cold int hevc_decode_init (AVCodecContext *avctx)
 
static av_cold int hevc_init_thread_copy (AVCodecContext *avctx)
 
static void hevc_decode_flush (AVCodecContext *avctx)
 

Variables

const uint8_t ff_hevc_qpel_extra_before [4] = { 0, 3, 3, 2 }
 
const uint8_t ff_hevc_qpel_extra_after [4] = { 0, 3, 4, 4 }
 
const uint8_t ff_hevc_qpel_extra [4] = { 0, 6, 7, 6 }
 
static const AVOption options []
 
static const AVClass hevc_decoder_class
 
AVCodec ff_hevc_decoder
 

Macro Definition Documentation

#define CTB (   tab,
  x,
  y 
)    ((tab)[(y) * s->sps->ctb_width + (x)])

Definition at line 647 of file hevc.c.

Referenced by hls_sao_param().

#define SET_SAO (   elem,
  value 
)
Value:
do { \
if (!sao_merge_up_flag && !sao_merge_left_flag) \
sao->elem = value; \
else if (sao_merge_left_flag) \
sao->elem = CTB(s->sao, rx-1, ry).elem; \
else if (sao_merge_up_flag) \
sao->elem = CTB(s->sao, rx, ry-1).elem; \
else \
sao->elem = 0; \
} while (0)
const char * s
Definition: avisynth_c.h:668
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
Definition: avfilter.c:965
#define CTB(tab, x, y)
Definition: hevc.c:647
double value
Definition: eval.c:83

Definition at line 649 of file hevc.c.

Referenced by hls_sao_param().

#define POS (   c_idx,
  x,
  y 
)
Value:
&s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
(((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)]
const char * s
Definition: avisynth_c.h:668
float y

Referenced by hls_prediction_unit().

#define STARTCODE_TEST
Value:
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
/* startcode, so we must be past the end */ \
length = i; \
} \
break; \
}
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
Definition: avfilter.c:965
AVS_Value src
Definition: avisynth_c.h:523
const char int length
Definition: avisynth_c.h:668

Referenced by ff_hevc_extract_rbsp().

#define OFFSET (   x)    offsetof(HEVCContext, x)

Definition at line 2864 of file hevc.c.

Definition at line 2865 of file hevc.c.

Function Documentation

static void pic_arrays_free ( HEVCContext s)
static

NOTE: Each function hls_foo correspond to the function foo in the specification (HLS stands for High Level Syntax).

Section 5.7

Definition at line 54 of file hevc.c.

Referenced by hevc_decode_free(), hls_slice_header(), and pic_arrays_init().

static int pic_arrays_init ( HEVCContext s)
static

Definition at line 83 of file hevc.c.

Referenced by hls_slice_header().

static void pred_weight_table ( HEVCContext s,
GetBitContext gb 
)
static

Definition at line 142 of file hevc.c.

Referenced by hls_slice_header().

static int decode_lt_rps ( HEVCContext s,
LongTermRPS rps,
GetBitContext gb 
)
static

Definition at line 231 of file hevc.c.

Referenced by hls_slice_header().

static int hls_slice_header ( HEVCContext s)
static

Definition at line 283 of file hevc.c.

Referenced by decode_nal_unit().

static void hls_sao_param ( HEVCContext s,
int  rx,
int  ry 
)
static

Definition at line 661 of file hevc.c.

Referenced by hls_decode_entry(), and hls_decode_entry_wpp().

static void hls_transform_unit ( HEVCContext s,
int  x0,
int  y0,
int  xBase,
int  yBase,
int  cb_xBase,
int  cb_yBase,
int  log2_cb_size,
int  log2_trafo_size,
int  trafo_depth,
int  blk_idx 
)
static

Definition at line 732 of file hevc.c.

Referenced by hls_transform_tree().

static void set_deblocking_bypass ( HEVCContext s,
int  x0,
int  y0,
int  log2_cb_size 
)
static

Definition at line 806 of file hevc.c.

Referenced by hls_coding_unit(), and hls_transform_tree().

static void hls_transform_tree ( HEVCContext s,
int  x0,
int  y0,
int  xBase,
int  yBase,
int  cb_xBase,
int  cb_yBase,
int  log2_cb_size,
int  log2_trafo_size,
int  trafo_depth,
int  blk_idx 
)
static

Definition at line 821 of file hevc.c.

Referenced by hls_coding_unit().

static int hls_pcm_sample ( HEVCContext s,
int  x0,
int  y0,
int  log2_cb_size 
)
static

Definition at line 922 of file hevc.c.

Referenced by hls_coding_unit().

static void luma_mc ( HEVCContext s,
int16_t *  dst,
ptrdiff_t  dststride,
AVFrame ref,
const Mv mv,
int  x_off,
int  y_off,
int  block_w,
int  block_h 
)
static

8.5.3.2.2.1 Luma sample interpolation process

Parameters
sHEVC decoding context
dsttarget buffer for block data at block position
dststridestride of the dst buffer
refreference picture buffer at origin (0, 0)
mvmotion vector (relative to block position) to get pixel data from
x_offhorizontal position of block from origin (0, 0)
y_offvertical position of block from origin (0, 0)
block_wwidth of block
block_hheight of block

Definition at line 966 of file hevc.c.

Referenced by hls_prediction_unit().

static void chroma_mc ( HEVCContext s,
int16_t *  dst1,
int16_t *  dst2,
ptrdiff_t  dststride,
AVFrame ref,
const Mv mv,
int  x_off,
int  y_off,
int  block_w,
int  block_h 
)
static

8.5.3.2.2.2 Chroma sample interpolation process

Parameters
sHEVC decoding context
dst1target buffer for block data at block position (U plane)
dst2target buffer for block data at block position (V plane)
dststridestride of the dst1 and dst2 buffers
refreference picture buffer at origin (0, 0)
mvmotion vector (relative to block position) to get pixel data from
x_offhorizontal position of block from origin (0, 0)
y_offvertical position of block from origin (0, 0)
block_wwidth of block
block_hheight of block

Definition at line 1014 of file hevc.c.

Referenced by hls_prediction_unit(), and rv34_mc().

static void hevc_await_progress ( HEVCContext s,
HEVCFrame ref,
const Mv mv,
int  y0,
int  height 
)
static

Definition at line 1068 of file hevc.c.

Referenced by hls_prediction_unit().

static void hls_prediction_unit ( HEVCContext s,
int  x0,
int  y0,
int  nPbW,
int  nPbH,
int  log2_cb_size,
int  partIdx 
)
static

Definition at line 1077 of file hevc.c.

Referenced by hls_coding_unit().

static int luma_intra_pred_mode ( HEVCContext s,
int  x0,
int  y0,
int  pu_size,
int  prev_intra_luma_pred_flag 
)
static

8.4.1

Definition at line 1336 of file hevc.c.

Referenced by intra_prediction_unit().

static av_always_inline void set_ct_depth ( HEVCContext s,
int  x0,
int  y0,
int  log2_cb_size,
int  ct_depth 
)
static

Definition at line 1424 of file hevc.c.

Referenced by hls_coding_unit().

static void intra_prediction_unit ( HEVCContext s,
int  x0,
int  y0,
int  log2_cb_size 
)
static

Definition at line 1437 of file hevc.c.

Referenced by hls_coding_unit().

static void intra_prediction_unit_default_value ( HEVCContext s,
int  x0,
int  y0,
int  log2_cb_size 
)
static

Definition at line 1477 of file hevc.c.

Referenced by hls_coding_unit().

static int hls_coding_unit ( HEVCContext s,
int  x0,
int  y0,
int  log2_cb_size 
)
static

Definition at line 1499 of file hevc.c.

Referenced by hls_coding_quadtree().

static int hls_coding_quadtree ( HEVCContext s,
int  x0,
int  y0,
int  log2_cb_size,
int  cb_depth 
)
static

Definition at line 1649 of file hevc.c.

Referenced by hls_decode_entry(), and hls_decode_entry_wpp().

static void hls_decode_neighbour ( HEVCContext s,
int  x_ctb,
int  y_ctb,
int  ctb_addr_ts 
)
static

Definition at line 1715 of file hevc.c.

Referenced by hls_decode_entry(), and hls_decode_entry_wpp().

static int hls_decode_entry ( AVCodecContext avctxt,
void isFilterThread 
)
static

Definition at line 1769 of file hevc.c.

Referenced by hls_slice_data().

static int hls_slice_data ( HEVCContext s)
static

Definition at line 1809 of file hevc.c.

Referenced by decode_nal_unit().

static int hls_decode_entry_wpp ( AVCodecContext avctxt,
void input_ctb_row,
int  job,
int  self_id 
)
static

Definition at line 1820 of file hevc.c.

Referenced by hls_slice_data_wpp().

static int hls_slice_data_wpp ( HEVCContext s,
const uint8_t nal,
int  length 
)
static

Definition at line 1893 of file hevc.c.

Referenced by decode_nal_unit().

static int hls_nal_unit ( HEVCContext s)
static
Returns
AVERROR_INVALIDDATA if the packet is not a valid NAL unit, 0 if the unit should be skipped, 1 otherwise

Definition at line 1975 of file hevc.c.

Referenced by decode_nal_unit(), and decode_nal_units().

static void restore_tqb_pixels ( HEVCContext s)
static

Definition at line 1997 of file hevc.c.

Referenced by decode_nal_unit().

static int hevc_frame_start ( HEVCContext s)
static

Definition at line 2024 of file hevc.c.

Referenced by decode_nal_unit().

static int decode_nal_unit ( HEVCContext s,
const uint8_t nal,
int  length 
)
static

Definition at line 2073 of file hevc.c.

Referenced by decode_nal_units().

int ff_hevc_extract_rbsp ( HEVCContext s,
const uint8_t src,
int  length,
HEVCNAL nal 
)

Definition at line 2208 of file hevc.c.

Referenced by decode_nal_units(), and parse_nal_units().

static int decode_nal_units ( HEVCContext s,
const uint8_t buf,
int  length 
)
static

Definition at line 2315 of file hevc.c.

Referenced by hevc_decode_extradata(), and hevc_decode_frame().

static void print_md5 ( void log_ctx,
int  level,
uint8_t  md5[16] 
)
static

Definition at line 2427 of file hevc.c.

Referenced by verify_md5().

static int verify_md5 ( HEVCContext s,
AVFrame frame 
)
static

Definition at line 2434 of file hevc.c.

Referenced by hevc_decode_frame().

static int hevc_decode_frame ( AVCodecContext avctx,
void data,
int *  got_output,
AVPacket avpkt 
)
static

Definition at line 2500 of file hevc.c.

static int hevc_ref_frame ( HEVCContext s,
HEVCFrame dst,
HEVCFrame src 
)
static

Definition at line 2545 of file hevc.c.

Referenced by hevc_update_thread_context().

static av_cold int hevc_decode_free ( AVCodecContext avctx)
static

Definition at line 2579 of file hevc.c.

Referenced by hevc_decode_init(), and hevc_init_context().

static av_cold int hevc_init_context ( AVCodecContext avctx)
static

Definition at line 2637 of file hevc.c.

Referenced by hevc_decode_init(), hevc_init_thread_copy(), and hevc_update_thread_context().

static int hevc_update_thread_context ( AVCodecContext dst,
const AVCodecContext src 
)
static

Definition at line 2685 of file hevc.c.

static int hevc_decode_extradata ( HEVCContext s)
static

Definition at line 2744 of file hevc.c.

Referenced by hevc_decode_init().

static av_cold int hevc_decode_init ( AVCodecContext avctx)
static

Definition at line 2807 of file hevc.c.

static av_cold int hevc_init_thread_copy ( AVCodecContext avctx)
static

Definition at line 2843 of file hevc.c.

static void hevc_decode_flush ( AVCodecContext avctx)
static

Definition at line 2857 of file hevc.c.

Variable Documentation

const uint8_t ff_hevc_qpel_extra_before[4] = { 0, 3, 3, 2 }

Definition at line 40 of file hevc.c.

Referenced by luma_mc().

const uint8_t ff_hevc_qpel_extra_after[4] = { 0, 3, 4, 4 }

Definition at line 41 of file hevc.c.

Referenced by luma_mc().

const uint8_t ff_hevc_qpel_extra[4] = { 0, 6, 7, 6 }

Definition at line 42 of file hevc.c.

Referenced by luma_mc().

const AVOption options[]
static
Initial value:
= {
{ "strict-displaywin", "stricly apply default display window size", OFFSET(strict_def_disp_win),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, PAR },
{ NULL },
}
#define OFFSET(x)
Definition: hevc.c:2864
#define PAR
Definition: ac3dec.c:1434

Definition at line 2866 of file hevc.c.

const AVClass hevc_decoder_class
static
Initial value:
= {
.class_name = "HEVC decoder",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: avcodec.h:820
const char * av_default_item_name(void *ctx)
Return the context name.
Definition: log.c:145
const OptionDef options[]
Definition: ffserver.c:4682

Definition at line 2872 of file hevc.c.

AVCodec ff_hevc_decoder
Initial value:
= {
.name = "hevc",
.long_name = NULL_IF_CONFIG_SMALL("HEVC (High Efficiency Video Coding)"),
.priv_data_size = sizeof(HEVCContext),
.priv_class = &hevc_decoder_class,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt)
Definition: hevc.c:2500
static av_cold int hevc_decode_init(AVCodecContext *avctx)
Definition: hevc.c:2807
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:742
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:769
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:151
static void hevc_decode_flush(AVCodecContext *avctx)
Definition: hevc.c:2857
static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Definition: ffv1dec.c:1023
static av_cold int hevc_init_thread_copy(AVCodecContext *avctx)
Definition: hevc.c:2843
static void flush(AVCodecContext *avctx)
Definition: aacdec.c:498
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:538
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:815
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:811
static int hevc_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Definition: hevc.c:2685
static const AVClass hevc_decoder_class
Definition: hevc.c:2872
static int init_thread_copy(AVCodecContext *avctx)
Definition: alac.c:620
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: crystalhd.c:868
static av_cold int hevc_decode_free(AVCodecContext *avctx)
Definition: hevc.c:2579

Definition at line 2879 of file hevc.c.