FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
h264.c File Reference

H.264 / AVC / MPEG4 part10 codec. More...

#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/stereo3d.h"
#include "libavutil/timer.h"
#include "internal.h"
#include "cabac.h"
#include "cabac_functions.h"
#include "dsputil.h"
#include "error_resilience.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "h264.h"
#include "h264data.h"
#include "h264chroma.h"
#include "h264_mvpred.h"
#include "golomb.h"
#include "mathops.h"
#include "rectangle.h"
#include "svq3.h"
#include "thread.h"
#include "vdpau_internal.h"
#include <assert.h>
#include "h264_mb_template.c"

Go to the source code of this file.

Macros

#define UNCHECKED_BITSTREAM_READER   1
 
#define STARTCODE_TEST
 
#define IN_RANGE(a, b, size)   (((a) >= (b)) && ((a) < ((b) + (size))))
 
#define REBASE_PICTURE(pic, new_ctx, old_ctx)
 
#define copy_fields(to, from, start_field, end_field)
 
#define XCHG(a, b, xchg)
 
#define BITS   8
 
#define SIMPLE   1
 
#define BITS   16
 
#define SIMPLE   0
 
#define TRANSPOSE(x)   (x >> 2) | ((x << 2) & 0xF)
 
#define TRANSPOSE(x)   (x >> 3) | ((x & 7) << 3)
 

Functions

static void flush_change (H264Context *h)
 
int avpriv_h264_has_num_reorder_frames (AVCodecContext *avctx)
 
static void h264_er_decode_mb (void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
 
void ff_h264_draw_horiz_band (H264Context *h, int y, int height)
 
static void unref_picture (H264Context *h, Picture *pic)
 
static void release_unused_pictures (H264Context *h, int remove_current)
 
static int ref_picture (H264Context *h, Picture *dst, Picture *src)
 
static int alloc_scratch_buffers (H264Context *h, int linesize)
 
static int init_table_pools (H264Context *h)
 
static int alloc_picture (H264Context *h, Picture *pic)
 
static int pic_is_unused (H264Context *h, Picture *pic)
 
static int find_unused_picture (H264Context *h)
 
int ff_h264_check_intra4x4_pred_mode (H264Context *h)
 Check if the top & left blocks are available if needed and change the dc mode so it only uses the available blocks.
 
int ff_h264_check_intra_pred_mode (H264Context *h, int mode, int is_chroma)
 Check if the top & left blocks are available if needed and change the dc mode so it only uses the available blocks.
 
const uint8_tff_h264_decode_nal (H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length)
 Decode a network abstraction layer unit.
 
static int decode_rbsp_trailing (H264Context *h, const uint8_t *src)
 Identify the exact end of the bitstream.
 
static int get_lowest_part_list_y (H264Context *h, Picture *pic, int n, int height, int y_offset, int list)
 
static void get_lowest_part_y (H264Context *h, int refs[2][48], int n, int height, int y_offset, int list0, int list1, int *nrefs)
 
static void await_references (H264Context *h)
 Wait until all reference frames are available for MC operations.
 
static av_always_inline void mc_dir_part (H264Context *h, Picture *pic, int n, int square, int height, int delta, int list, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int src_x_offset, int src_y_offset, qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op, int pixel_shift, int chroma_idc)
 
static av_always_inline void mc_part_std (H264Context *h, int n, int square, int height, int delta, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int x_offset, int y_offset, qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, int list0, int list1, int pixel_shift, int chroma_idc)
 
static av_always_inline void mc_part_weighted (H264Context *h, int n, int square, int height, int delta, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int x_offset, int y_offset, qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, h264_weight_func luma_weight_op, h264_weight_func chroma_weight_op, h264_biweight_func luma_weight_avg, h264_biweight_func chroma_weight_avg, int list0, int list1, int pixel_shift, int chroma_idc)
 
static av_always_inline void prefetch_motion (H264Context *h, int list, int pixel_shift, int chroma_idc)
 
static void free_tables (H264Context *h, int free_rbsp)
 
static void init_dequant8_coeff_table (H264Context *h)
 
static void init_dequant4_coeff_table (H264Context *h)
 
static void init_dequant_tables (H264Context *h)
 
int ff_h264_alloc_tables (H264Context *h)
 Allocate tables.
 
static void clone_tables (H264Context *dst, H264Context *src, int i)
 Mimic alloc_tables(), but for every context thread.
 
static int context_init (H264Context *h)
 Init context Allocate buffers which are not shared amongst multiple threads.
 
static int decode_nal_units (H264Context *h, const uint8_t *buf, int buf_size, int parse_extradata)
 
int ff_h264_decode_extradata (H264Context *h, const uint8_t *buf, int size)
 
av_cold int ff_h264_decode_init (AVCodecContext *avctx)
 
static void copy_picture_range (Picture **to, Picture **from, int count, H264Context *new_base, H264Context *old_base)
 
static int copy_parameter_set (void **to, void **from, int count, int size)
 
static int decode_init_thread_copy (AVCodecContext *avctx)
 
static int h264_slice_header_init (H264Context *, int)
 
static int h264_set_parameter_from_sps (H264Context *h)
 
static int decode_update_thread_context (AVCodecContext *dst, const AVCodecContext *src)
 
static int h264_frame_start (H264Context *h)
 
static void decode_postinit (H264Context *h, int setup_finished)
 Run setup operations that must be run after slice header decoding.
 
static av_always_inline void backup_mb_border (H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int simple)
 
static av_always_inline void xchg_mb_border (H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg, int chroma444, int simple, int pixel_shift)
 
static av_always_inline int dctcoef_get (int16_t *mb, int high_bit_depth, int index)
 
static av_always_inline void dctcoef_set (int16_t *mb, int high_bit_depth, int index, int value)
 
static av_always_inline void hl_decode_mb_predict_luma (H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
 
static av_always_inline void hl_decode_mb_idct_luma (H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
 
void ff_h264_hl_decode_mb (H264Context *h)
 
int ff_pred_weight_table (H264Context *h)
 
static void implicit_weight_table (H264Context *h, int field)
 Initialize implicit_weight table.
 
static void idr (H264Context *h)
 instantaneous decoder refresh.
 
static void flush_dpb (AVCodecContext *avctx)
 
int ff_init_poc (H264Context *h, int pic_field_poc[2], int *pic_poc)
 
static void init_scan_tables (H264Context *h)
 initialize scan tables
 
static int field_end (H264Context *h, int in_setup)
 
static int clone_slice (H264Context *dst, H264Context *src)
 Replicate H264 "master" context to thread contexts.
 
int ff_h264_get_profile (SPS *sps)
 Compute profile from profile_idc and constraint_set?_flags.
 
static enum AVPixelFormat get_pixel_format (H264Context *h, int force_callback)
 
static int init_dimensions (H264Context *h)
 
int ff_set_ref_count (H264Context *h)
 
static enum AVPixelFormat non_j_pixfmt (enum AVPixelFormat a)
 
static int decode_slice_header (H264Context *h, H264Context *h0)
 Decode a slice header.
 
int ff_h264_get_slice_type (const H264Context *h)
 Reconstruct bitstream slice_type.
 
static av_always_inline void fill_filter_caches_inter (H264Context *h, int mb_type, int top_xy, int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)
 
static int fill_filter_caches (H264Context *h, int mb_type)
 
static void loop_filter (H264Context *h, int start_x, int end_x)
 
static void predict_field_decoding_flag (H264Context *h)
 
static void decode_finish_row (H264Context *h)
 Draw edges and report progress for the last MB row.
 
static void er_add_slice (H264Context *h, int startx, int starty, int endx, int endy, int status)
 
static int decode_slice (struct AVCodecContext *avctx, void *arg)
 
static int execute_decode_slices (H264Context *h, unsigned context_count)
 Call decode_slice() for each context.
 
static int get_consumed_bytes (int pos, int buf_size)
 Return the number of bytes consumed for building the current frame.
 
static int output_frame (H264Context *h, AVFrame *dst, Picture *srcp)
 
static int h264_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
av_cold void ff_h264_free_context (H264Context *h)
 Free any data that may have been allocated in the H264 context like SPS, PPS etc.
 
static av_cold int h264_decode_end (AVCodecContext *avctx)
 

Variables

const uint16_t ff_h264_mb_sizes [4] = { 256, 384, 512, 768 }
 
static const uint8_t rem6 [QP_MAX_NUM+1]
 
static const uint8_t div6 [QP_MAX_NUM+1]
 
static const uint8_t field_scan [16+1]
 
static const uint8_t field_scan8x8 [64+1]
 
static const uint8_t field_scan8x8_cavlc [64+1]
 
static const uint8_t zigzag_scan8x8_cavlc [64+1]
 
static const uint8_t dequant4_coeff_init [6][3]
 
static const uint8_t dequant8_coeff_init_scan [16]
 
static const uint8_t dequant8_coeff_init [6][6]
 
static enum AVPixelFormat h264_hwaccel_pixfmt_list_420 []
 
static enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420 []
 
static const uint8_t start_code [] = { 0x00, 0x00, 0x01 }
 
static const AVProfile profiles []
 
static const AVOption h264_options []
 
static const AVClass h264_class
 
static const AVClass h264_vdpau_class
 
AVCodec ff_h264_decoder
 

Detailed Description

H.264 / AVC / MPEG4 part10 codec.

Author
Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at

Definition in file h264.c.

Macro Definition Documentation

#define UNCHECKED_BITSTREAM_READER   1

Definition at line 28 of file h264.c.

#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; \
}

Referenced by ff_h264_decode_nal(), and ff_hevc_extract_rbsp().

#define IN_RANGE (   a,
  b,
  size 
)    (((a) >= (b)) && ((a) < ((b) + (size))))

Definition at line 1660 of file h264.c.

Referenced by copy_picture_range().

#define REBASE_PICTURE (   pic,
  new_ctx,
  old_ctx 
)
Value:
((pic && pic >= old_ctx->DPB && \
pic < old_ctx->DPB + MAX_PICTURE_COUNT) ? \
&new_ctx->DPB[pic - old_ctx->DPB] : NULL)

Definition at line 1662 of file h264.c.

Referenced by copy_picture_range(), decode_update_thread_context(), and ff_mpeg_update_thread_context().

#define copy_fields (   to,
  from,
  start_field,
  end_field 
)
Value:
memcpy(&to->start_field, &from->start_field, \
(char *)&to->end_field - (char *)&to->start_field)

Definition at line 1720 of file h264.c.

Referenced by decode_update_thread_context(), update_context_from_user(), and vp3_update_thread_context().

#define XCHG (   a,
  b,
  xchg 
)
Value:
if (pixel_shift) { \
if (xchg) { \
AV_SWAP64(b + 0, a + 0); \
AV_SWAP64(b + 8, a + 8); \
} else { \
AV_COPY128(b, a); \
} \
} else if (xchg) \
AV_SWAP64(b, a); \

Referenced by xchg_mb_border().

#define BITS   8

Definition at line 2660 of file h264.c.

#define SIMPLE   1

Definition at line 2664 of file h264.c.

Referenced by hl_decode_mb(), and hl_decode_mb_444().

#define BITS   16

Definition at line 2660 of file h264.c.

#define SIMPLE   0

Definition at line 2664 of file h264.c.

#define TRANSPOSE (   x)    (x >> 2) | ((x << 2) & 0xF)
#define TRANSPOSE (   x)    (x >> 3) | ((x & 7) << 3)

Function Documentation

static void flush_change ( H264Context h)
static

Definition at line 2831 of file h264.c.

Referenced by decode_slice_header(), ff_h264_decode_init(), and flush_dpb().

int avpriv_h264_has_num_reorder_frames ( AVCodecContext avctx)

Definition at line 196 of file h264.c.

Referenced by has_decode_delay_been_guessed().

static void h264_er_decode_mb ( void opaque,
int  ref,
int  mv_dir,
int  mv_type,
int(*)  mv[2][4][2],
int  mb_x,
int  mb_y,
int  mb_intra,
int  mb_skipped 
)
static

Definition at line 202 of file h264.c.

Referenced by context_init().

void ff_h264_draw_horiz_band ( H264Context h,
int  y,
int  height 
)
static void unref_picture ( H264Context h,
Picture pic 
)
static
static void release_unused_pictures ( H264Context h,
int  remove_current 
)
static

Definition at line 302 of file h264.c.

Referenced by decode_slice_header(), and h264_frame_start().

static int ref_picture ( H264Context h,
Picture dst,
Picture src 
)
static
static int alloc_scratch_buffers ( H264Context h,
int  linesize 
)
static

Definition at line 378 of file h264.c.

Referenced by decode_slice_header().

static int init_table_pools ( H264Context h)
static

Definition at line 403 of file h264.c.

Referenced by alloc_picture().

static int alloc_picture ( H264Context h,
Picture pic 
)
static

Definition at line 430 of file h264.c.

Referenced by h264_frame_start().

static int pic_is_unused ( H264Context h,
Picture pic 
)
inlinestatic

Definition at line 501 of file h264.c.

Referenced by find_unused_picture().

static int find_unused_picture ( H264Context h)
static

Definition at line 510 of file h264.c.

Referenced by h264_frame_start().

int ff_h264_check_intra4x4_pred_mode ( H264Context h)

Check if the top & left blocks are available if needed and change the dc mode so it only uses the available blocks.

Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.

Definition at line 533 of file h264.c.

Referenced by ff_h264_decode_mb_cabac(), ff_h264_decode_mb_cavlc(), and svq3_decode_mb().

int ff_h264_check_intra_pred_mode ( H264Context h,
int  mode,
int  is_chroma 
)

Check if the top & left blocks are available if needed and change the dc mode so it only uses the available blocks.

Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.

Definition at line 580 of file h264.c.

Referenced by ff_h264_decode_mb_cabac(), ff_h264_decode_mb_cavlc(), and svq3_decode_mb().

const uint8_t* ff_h264_decode_nal ( H264Context h,
const uint8_t src,
int *  dst_length,
int *  consumed,
int  length 
)

Decode a network abstraction layer unit.

Parameters
consumedis the number of bytes used as input
lengthis the length of the array
dst_lengthis the number of decoded bytes FIXME here or a decode rbsp tailing?
Returns
decoded bytes, might be src+1 if no escapes

Definition at line 621 of file h264.c.

Referenced by decode_nal_units(), and parse_nal_units().

static int decode_rbsp_trailing ( H264Context h,
const uint8_t src 
)
static

Identify the exact end of the bitstream.

Returns
the length of the trailing, or 0 if damaged

Definition at line 739 of file h264.c.

Referenced by decode_nal_units().

static int get_lowest_part_list_y ( H264Context h,
Picture pic,
int  n,
int  height,
int  y_offset,
int  list 
)
inlinestatic

Definition at line 754 of file h264.c.

Referenced by get_lowest_part_y().

static void get_lowest_part_y ( H264Context h,
int  refs[2][48],
int  n,
int  height,
int  y_offset,
int  list0,
int  list1,
int *  nrefs 
)
inlinestatic

Definition at line 767 of file h264.c.

Referenced by await_references().

static void await_references ( H264Context h)
static

Wait until all reference frames are available for MC operations.

Parameters
hthe H264 context

Definition at line 810 of file h264.c.

Referenced by hl_motion().

static av_always_inline void mc_dir_part ( H264Context h,
Picture pic,
int  n,
int  square,
int  height,
int  delta,
int  list,
uint8_t dest_y,
uint8_t dest_cb,
uint8_t dest_cr,
int  src_x_offset,
int  src_y_offset,
qpel_mc_func qpix_op,
h264_chroma_mc_func  chroma_op,
int  pixel_shift,
int  chroma_idc 
)
static

Definition at line 918 of file h264.c.

Referenced by mc_part_std(), and mc_part_weighted().

static av_always_inline void mc_part_std ( H264Context h,
int  n,
int  square,
int  height,
int  delta,
uint8_t dest_y,
uint8_t dest_cb,
uint8_t dest_cr,
int  x_offset,
int  y_offset,
qpel_mc_func qpix_put,
h264_chroma_mc_func  chroma_put,
qpel_mc_func qpix_avg,
h264_chroma_mc_func  chroma_avg,
int  list0,
int  list1,
int  pixel_shift,
int  chroma_idc 
)
static

Definition at line 1033 of file h264.c.

static av_always_inline void mc_part_weighted ( H264Context h,
int  n,
int  square,
int  height,
int  delta,
uint8_t dest_y,
uint8_t dest_cb,
uint8_t dest_cr,
int  x_offset,
int  y_offset,
qpel_mc_func qpix_put,
h264_chroma_mc_func  chroma_put,
h264_weight_func  luma_weight_op,
h264_weight_func  chroma_weight_op,
h264_biweight_func  luma_weight_avg,
h264_biweight_func  chroma_weight_avg,
int  list0,
int  list1,
int  pixel_shift,
int  chroma_idc 
)
static

Definition at line 1080 of file h264.c.

Referenced by mc_part().

static av_always_inline void prefetch_motion ( H264Context h,
int  list,
int  pixel_shift,
int  chroma_idc 
)
static

Definition at line 1187 of file h264.c.

Referenced by hl_motion().

static void free_tables ( H264Context h,
int  free_rbsp 
)
static
static void init_dequant8_coeff_table ( H264Context h)
static

Definition at line 1273 of file h264.c.

Referenced by init_dequant_tables().

static void init_dequant4_coeff_table ( H264Context h)
static

Definition at line 1300 of file h264.c.

Referenced by init_dequant_tables().

static void init_dequant_tables ( H264Context h)
static

Definition at line 1326 of file h264.c.

Referenced by decode_slice_header(), and ff_h264_alloc_tables().

int ff_h264_alloc_tables ( H264Context h)

Allocate tables.

needs width/height

Definition at line 1345 of file h264.c.

Referenced by decode_update_thread_context(), h264_slice_header_init(), and svq3_decode_init().

static void clone_tables ( H264Context dst,
H264Context src,
int  i 
)
static

Mimic alloc_tables(), but for every context thread.

Definition at line 1409 of file h264.c.

Referenced by h264_slice_header_init().

static int context_init ( H264Context h)
static

Init context Allocate buffers which are not shared amongst multiple threads.

Definition at line 1436 of file h264.c.

Referenced by decode_update_thread_context(), and h264_slice_header_init().

static int decode_nal_units ( H264Context h,
const uint8_t buf,
int  buf_size,
int  parse_extradata 
)
static

< thread context

< number of NALs that need decoding before the next frame thread starts

Definition at line 4767 of file h264.c.

Referenced by ff_h264_decode_extradata(), and h264_decode_frame().

int ff_h264_decode_extradata ( H264Context h,
const uint8_t buf,
int  size 
)

Definition at line 1508 of file h264.c.

Referenced by ff_h264_decode_init(), h264_decode_frame(), and h264_parse().

av_cold int ff_h264_decode_init ( AVCodecContext avctx)

Definition at line 1570 of file h264.c.

Referenced by svq3_decode_init().

static void copy_picture_range ( Picture **  to,
Picture **  from,
int  count,
H264Context new_base,
H264Context old_base 
)
static

Definition at line 1667 of file h264.c.

Referenced by decode_update_thread_context().

static int copy_parameter_set ( void **  to,
void **  from,
int  count,
int  size 
)
static

Definition at line 1682 of file h264.c.

Referenced by decode_update_thread_context().

static int decode_init_thread_copy ( AVCodecContext avctx)
static

Definition at line 1702 of file h264.c.

static int h264_slice_header_init ( H264Context h,
int  reinit 
)
static

Definition at line 3288 of file h264.c.

Referenced by decode_slice_header(), and decode_update_thread_context().

static int h264_set_parameter_from_sps ( H264Context h)
static

Definition at line 3120 of file h264.c.

Referenced by decode_slice_header(), and decode_update_thread_context().

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

Definition at line 1728 of file h264.c.

static int h264_frame_start ( H264Context h)
static

Definition at line 1943 of file h264.c.

Referenced by decode_slice_header().

static void decode_postinit ( H264Context h,
int  setup_finished 
)
static

Run setup operations that must be run after slice header decoding.

This includes finding the next displayed frame.

Parameters
hh264 master context
setup_finishedenough NALs have been read that we can call ff_thread_finish_setup()

Definition at line 2044 of file h264.c.

Referenced by decode_nal_units(), and h264_decode_frame().

static av_always_inline void backup_mb_border ( H264Context h,
uint8_t src_y,
uint8_t src_cb,
uint8_t src_cr,
int  linesize,
int  uvlinesize,
int  simple 
)
static

Definition at line 2269 of file h264.c.

Referenced by loop_filter().

static av_always_inline void xchg_mb_border ( H264Context h,
uint8_t src_y,
uint8_t src_cb,
uint8_t src_cr,
int  linesize,
int  uvlinesize,
int  xchg,
int  chroma444,
int  simple,
int  pixel_shift 
)
static

Definition at line 2365 of file h264.c.

Referenced by hl_decode_mb(), and hl_decode_mb_444().

static av_always_inline int dctcoef_get ( int16_t *  mb,
int  high_bit_depth,
int  index 
)
static

Definition at line 2451 of file h264.c.

Referenced by hl_decode_mb(), hl_decode_mb_idct_luma(), and hl_decode_mb_predict_luma().

static av_always_inline void dctcoef_set ( int16_t *  mb,
int  high_bit_depth,
int  index,
int  value 
)
static

Definition at line 2460 of file h264.c.

Referenced by hl_decode_mb_predict_luma().

static av_always_inline void hl_decode_mb_predict_luma ( H264Context h,
int  mb_type,
int  is_h264,
int  simple,
int  transform_bypass,
int  pixel_shift,
int *  block_offset,
int  linesize,
uint8_t dest_y,
int  p 
)
static

Definition at line 2469 of file h264.c.

Referenced by hl_decode_mb(), and hl_decode_mb_444().

static av_always_inline void hl_decode_mb_idct_luma ( H264Context h,
int  mb_type,
int  is_h264,
int  simple,
int  transform_bypass,
int  pixel_shift,
int *  block_offset,
int  linesize,
uint8_t dest_y,
int  p 
)
static

Definition at line 2585 of file h264.c.

Referenced by hl_decode_mb(), and hl_decode_mb_444().

void ff_h264_hl_decode_mb ( H264Context h)

Definition at line 2667 of file h264.c.

Referenced by decode_slice(), h264_er_decode_mb(), and svq3_decode_frame().

int ff_pred_weight_table ( H264Context h)

Definition at line 2687 of file h264.c.

Referenced by decode_slice_header(), and scan_mmco_reset().

static void implicit_weight_table ( H264Context h,
int  field 
)
static

Initialize implicit_weight table.

Parameters
field0/1 initialize the weight for interlaced MBAFF -1 initializes the rest

Definition at line 2754 of file h264.c.

Referenced by decode_slice_header().

static void idr ( H264Context h)
static

instantaneous decoder refresh.

Definition at line 2818 of file h264.c.

Referenced by decode_nal_units(), flush_change(), and h264_probe().

static void flush_dpb ( AVCodecContext avctx)
static

Definition at line 2861 of file h264.c.

int ff_init_poc ( H264Context h,
int  pic_field_poc[2],
int *  pic_poc 
)

Definition at line 2893 of file h264.c.

Referenced by decode_slice_header(), and parse_nal_units().

static void init_scan_tables ( H264Context h)
static

initialize scan tables

Definition at line 2974 of file h264.c.

Referenced by h264_slice_header_init().

static int field_end ( H264Context h,
int  in_setup 
)
static

Definition at line 3008 of file h264.c.

Referenced by decode_slice_header(), and h264_decode_frame().

static int clone_slice ( H264Context dst,
H264Context src 
)
static

Replicate H264 "master" context to thread contexts.

Definition at line 3068 of file h264.c.

Referenced by decode_slice_header().

int ff_h264_get_profile ( SPS sps)

Compute profile from profile_idc and constraint_set?_flags.

compute profile from sps

Parameters
spsSPS
Returns
profile as defined by FF_PROFILE_H264_*

Definition at line 3100 of file h264.c.

Referenced by decode_slice_header(), and parse_nal_units().

static enum AVPixelFormat get_pixel_format ( H264Context h,
int  force_callback 
)
static

Definition at line 3169 of file h264.c.

Referenced by decode_slice_header().

static int init_dimensions ( H264Context h)
static

Definition at line 3251 of file h264.c.

Referenced by decode_slice_header().

int ff_set_ref_count ( H264Context h)

Definition at line 3393 of file h264.c.

Referenced by decode_slice_header(), and scan_mmco_reset().

static enum AVPixelFormat non_j_pixfmt ( enum AVPixelFormat  a)
static

Definition at line 3447 of file h264.c.

Referenced by decode_slice_header().

static int decode_slice_header ( H264Context h,
H264Context h0 
)
static

Decode a slice header.

This will (re)intialize the decoder and call h264_frame_start() as needed.

Parameters
hh264context
h0h264 master context (differs from 'h' when doing sliced based parallel decoding)
Returns
0 if okay, <0 if an error occurred, 1 if decoding must not be multithreaded

Definition at line 3468 of file h264.c.

Referenced by decode_nal_units().

int ff_h264_get_slice_type ( const H264Context h)

Reconstruct bitstream slice_type.

Definition at line 4172 of file h264.c.

Referenced by fill_slice_long(), and vaapi_h264_decode_slice().

static av_always_inline void fill_filter_caches_inter ( H264Context h,
int  mb_type,
int  top_xy,
int  left_xy[LEFT_MBS],
int  top_type,
int  left_type[LEFT_MBS],
int  mb_xy,
int  list 
)
static

Definition at line 4190 of file h264.c.

Referenced by fill_filter_caches().

static int fill_filter_caches ( H264Context h,
int  mb_type 
)
static
Returns
non zero if the loop filter can be skipped

Definition at line 4274 of file h264.c.

Referenced by loop_filter().

static void loop_filter ( H264Context h,
int  start_x,
int  end_x 
)
static

Definition at line 4419 of file h264.c.

Referenced by decode_slice(), and xmv_read_extradata().

static void predict_field_decoding_flag ( H264Context h)
static

Definition at line 4488 of file h264.c.

Referenced by decode_slice().

static void decode_finish_row ( H264Context h)
static

Draw edges and report progress for the last MB row.

Definition at line 4501 of file h264.c.

Referenced by decode_slice().

static void er_add_slice ( H264Context h,
int  startx,
int  starty,
int  endx,
int  endy,
int  status 
)
static

Definition at line 4532 of file h264.c.

Referenced by decode_slice().

static int decode_slice ( struct AVCodecContext avctx,
void arg 
)
static

Definition at line 4542 of file h264.c.

Referenced by execute_decode_slices().

static int execute_decode_slices ( H264Context h,
unsigned  context_count 
)
static

Call decode_slice() for each context.

Parameters
hh264 master context
context_countnumber of contexts to execute

Definition at line 4724 of file h264.c.

Referenced by decode_nal_units().

static int get_consumed_bytes ( int  pos,
int  buf_size 
)
static

Return the number of bytes consumed for building the current frame.

Definition at line 5151 of file h264.c.

Referenced by h264_decode_frame().

static int output_frame ( H264Context h,
AVFrame dst,
Picture srcp 
)
static
Examples:
transcode_aac.c.

Definition at line 5161 of file h264.c.

Referenced by h264_decode_frame(), and load_encode_and_write().

static int h264_decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame,
AVPacket avpkt 
)
static

Definition at line 5185 of file h264.c.

av_cold void ff_h264_free_context ( H264Context h)

Free any data that may have been allocated in the H264 context like SPS, PPS etc.

Definition at line 5306 of file h264.c.

Referenced by close(), ff_h264_decode_init(), h264_decode_end(), and svq3_decode_end().

static av_cold int h264_decode_end ( AVCodecContext avctx)
static

Definition at line 5319 of file h264.c.

Variable Documentation

const uint16_t ff_h264_mb_sizes[4] = { 256, 384, 512, 768 }

Definition at line 57 of file h264.c.

Referenced by ff_h264_decode_mb_cabac(), ff_h264_decode_mb_cavlc(), and hl_decode_mb().

const uint8_t rem6[QP_MAX_NUM+1]
static
Initial value:
= {
0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
0, 1, 2, 3,
}

Definition at line 59 of file h264.c.

Referenced by ff_hevc_hls_residual_coding(), init_dequant4_coeff_table(), and init_dequant8_coeff_table().

const uint8_t div6[QP_MAX_NUM+1]
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10,
10,10,10,11,11,11,11,11,11,12,12,12,12,12,12,13,13,13, 13, 13, 13,
14,14,14,14,
}

Definition at line 67 of file h264.c.

Referenced by ff_hevc_hls_residual_coding(), init_dequant4_coeff_table(), and init_dequant8_coeff_table().

const uint8_t field_scan[16+1]
static
Initial value:
= {
0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4,
}

Definition at line 75 of file h264.c.

Referenced by init_scan_tables().

const uint8_t field_scan8x8[64+1]
static
Initial value:
= {
0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8,
2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8,
2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8,
2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8,
3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8,
3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8,
4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8,
4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8,
5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8,
5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8,
7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8,
6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8,
7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
}

Definition at line 82 of file h264.c.

Referenced by init_scan_tables().

const uint8_t field_scan8x8_cavlc[64+1]
static
Initial value:
= {
0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8,
0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8,
1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8,
3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8,
5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8,
0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8,
1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8,
3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8,
5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8,
1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8,
1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8,
3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8,
6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8,
}

Definition at line 101 of file h264.c.

Referenced by init_scan_tables().

const uint8_t zigzag_scan8x8_cavlc[64+1]
static
Initial value:
= {
0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8,
1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8,
3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8,
2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8,
3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8,
0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8,
2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8,
1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8,
4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8,
0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8,
1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8,
0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8,
5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
}

Definition at line 121 of file h264.c.

Referenced by init_scan_tables().

const uint8_t dequant4_coeff_init[6][3]
static
Initial value:
= {
{ 10, 13, 16 },
{ 11, 14, 18 },
{ 13, 16, 20 },
{ 14, 18, 23 },
{ 16, 20, 25 },
{ 18, 23, 29 },
}

Definition at line 140 of file h264.c.

Referenced by init_dequant4_coeff_table().

const uint8_t dequant8_coeff_init_scan[16]
static
Initial value:
= {
0, 3, 4, 3, 3, 1, 5, 1, 4, 5, 2, 5, 3, 1, 5, 1
}

Definition at line 149 of file h264.c.

Referenced by init_dequant8_coeff_table().

const uint8_t dequant8_coeff_init[6][6]
static
Initial value:
= {
{ 20, 18, 32, 19, 25, 24 },
{ 22, 19, 35, 21, 28, 26 },
{ 26, 23, 42, 24, 33, 31 },
{ 28, 25, 45, 26, 35, 33 },
{ 32, 28, 51, 30, 40, 38 },
{ 36, 32, 58, 34, 46, 43 },
}

Definition at line 153 of file h264.c.

Referenced by init_dequant8_coeff_table().

enum AVPixelFormat h264_hwaccel_pixfmt_list_420[]
static
Initial value:

Definition at line 162 of file h264.c.

Referenced by get_pixel_format().

enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420[]
static
Initial value:

Definition at line 179 of file h264.c.

Referenced by get_pixel_format().

const uint8_t start_code[] = { 0x00, 0x00, 0x01 }
static
const AVProfile profiles[]
static
Initial value:
= {
{ FF_PROFILE_H264_BASELINE, "Baseline" },
{ FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
{ FF_PROFILE_H264_MAIN, "Main" },
{ FF_PROFILE_H264_EXTENDED, "Extended" },
{ FF_PROFILE_H264_HIGH, "High" },
{ FF_PROFILE_H264_HIGH_10, "High 10" },
{ FF_PROFILE_H264_HIGH_10_INTRA, "High 10 Intra" },
{ FF_PROFILE_H264_HIGH_422, "High 4:2:2" },
{ FF_PROFILE_H264_HIGH_422_INTRA, "High 4:2:2 Intra" },
{ FF_PROFILE_H264_HIGH_444, "High 4:4:4" },
{ FF_PROFILE_H264_HIGH_444_PREDICTIVE, "High 4:4:4 Predictive" },
{ FF_PROFILE_H264_HIGH_444_INTRA, "High 4:4:4 Intra" },
{ FF_PROFILE_H264_CAVLC_444, "CAVLC 4:4:4" },
}

Definition at line 5331 of file h264.c.

const AVOption h264_options[]
static
Initial value:
= {
{"is_avc", "is avc", 0x42, FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0},
{"nal_length_size", "nal_length_size", 0x42, FF_OPT_TYPE_INT, {.i64 = 0}, 0, 4, 0},
{NULL}
}

Definition at line 5348 of file h264.c.

const AVClass h264_class
static
Initial value:
= {
.class_name = "H264 Decoder",
.item_name = av_default_item_name,
.option = h264_options,
}

Definition at line 5354 of file h264.c.

const AVClass h264_vdpau_class
static
Initial value:
= {
.class_name = "H264 VDPAU Decoder",
.item_name = av_default_item_name,
.option = h264_options,
}

Definition at line 5361 of file h264.c.

AVCodec ff_h264_decoder
Initial value:
= {
.name = "h264",
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.priv_data_size = sizeof(H264Context),
.capabilities = CODEC_CAP_DR1 |
.priv_class = &h264_class,
}

Definition at line 5368 of file h264.c.