FFmpeg
Macros | Functions | Variables
proresdec2.c File Reference
#include "config_components.h"
#include "libavutil/internal.h"
#include "libavutil/mem_internal.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "hwconfig.h"
#include "idctdsp.h"
#include "profiles.h"
#include "proresdec.h"
#include "proresdata.h"
#include "thread.h"

Go to the source code of this file.

Macros

#define LONG_BITSTREAM_READER
 
#define ALPHA_SHIFT_16_TO_10(alpha_val)   (alpha_val >> 6)
 
#define ALPHA_SHIFT_8_TO_10(alpha_val)   ((alpha_val << 2) | (alpha_val >> 6))
 
#define ALPHA_SHIFT_16_TO_12(alpha_val)   (alpha_val >> 4)
 
#define ALPHA_SHIFT_8_TO_12(alpha_val)   ((alpha_val << 4) | (alpha_val >> 4))
 
#define HWACCEL_MAX   (CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL)
 
#define DECODE_CODEWORD(val, codebook, SKIP)
 
#define TOSIGNED(x)   (((x) >> 1) ^ (-((x) & 1)))
 
#define FIRST_DC_CB   0xB8
 

Functions

static void permute (uint8_t *dst, const uint8_t *src, const uint8_t permutation[64])
 
static void unpack_alpha (GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits, const int decode_precision)
 
static void unpack_alpha_10 (GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits)
 
static void unpack_alpha_12 (GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits)
 
static av_cold int decode_init (AVCodecContext *avctx)
 
static int decode_frame_header (ProresContext *ctx, const uint8_t *buf, const int data_size, AVCodecContext *avctx)
 
static int decode_picture_header (AVCodecContext *avctx, const uint8_t *buf, const int buf_size)
 
static av_always_inline int decode_dc_coeffs (GetBitContext *gb, int16_t *out, int blocks_per_slice)
 
static av_always_inline int decode_ac_coeffs (AVCodecContext *avctx, GetBitContext *gb, int16_t *out, int blocks_per_slice)
 
static int decode_slice_luma (AVCodecContext *avctx, SliceContext *slice, uint16_t *dst, int dst_stride, const uint8_t *buf, unsigned buf_size, const int16_t *qmat)
 
static int decode_slice_chroma (AVCodecContext *avctx, SliceContext *slice, uint16_t *dst, int dst_stride, const uint8_t *buf, unsigned buf_size, const int16_t *qmat, int log2_blocks_per_mb)
 
static void decode_slice_alpha (const ProresContext *ctx, uint16_t *dst, int dst_stride, const uint8_t *buf, int buf_size, int blocks_per_slice)
 Decode alpha slice plane. More...
 
static int decode_slice_thread (AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 
static int decode_picture (AVCodecContext *avctx)
 
static int decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
 
static av_cold int decode_close (AVCodecContext *avctx)
 

Variables

static const uint8_t dc_codebook [7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70}
 
static const uint8_t run_to_cb [16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C }
 
static const uint8_t lev_to_cb [10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28, 0x28, 0x28, 0x4C }
 
const FFCodec ff_prores_decoder
 

Detailed Description

Known FOURCCs: 'apch' (HQ), 'apcn' (SD), 'apcs' (LT), 'apco' (Proxy), 'ap4h' (4444), 'ap4x' (4444 XQ)

Definition in file proresdec2.c.

Macro Definition Documentation

◆ LONG_BITSTREAM_READER

#define LONG_BITSTREAM_READER

Definition at line 29 of file proresdec2.c.

◆ ALPHA_SHIFT_16_TO_10

#define ALPHA_SHIFT_16_TO_10 (   alpha_val)    (alpha_val >> 6)

Definition at line 54 of file proresdec2.c.

◆ ALPHA_SHIFT_8_TO_10

#define ALPHA_SHIFT_8_TO_10 (   alpha_val)    ((alpha_val << 2) | (alpha_val >> 6))

Definition at line 55 of file proresdec2.c.

◆ ALPHA_SHIFT_16_TO_12

#define ALPHA_SHIFT_16_TO_12 (   alpha_val)    (alpha_val >> 4)

Definition at line 56 of file proresdec2.c.

◆ ALPHA_SHIFT_8_TO_12

#define ALPHA_SHIFT_8_TO_12 (   alpha_val)    ((alpha_val << 4) | (alpha_val >> 4))

Definition at line 57 of file proresdec2.c.

◆ HWACCEL_MAX

#define HWACCEL_MAX   (CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL)

◆ DECODE_CODEWORD

#define DECODE_CODEWORD (   val,
  codebook,
  SKIP 
)
Value:
do { \
unsigned int rice_order, exp_order, switch_bits; \
unsigned int q, buf, bits; \
buf = GET_CACHE(re, gb); \
\
/* number of bits to switch between rice and exp golomb */ \
switch_bits = codebook & 3; \
rice_order = codebook >> 5; \
exp_order = (codebook >> 2) & 7; \
\
q = 31 - av_log2(buf); \
if (q > switch_bits) { /* exp golomb */ \
bits = exp_order - switch_bits + (q<<1); \
if (bits > FFMIN(MIN_CACHE_BITS, 31)) \
val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \
((switch_bits + 1) << rice_order); \
SKIP(re, gb, bits); \
} else if (rice_order) { \
SKIP_BITS(re, gb, q+1); \
val = (q << rice_order) + SHOW_UBITS(re, gb, rice_order); \
SKIP(re, gb, rice_order); \
} else { \
val = q; \
SKIP(re, gb, q+1); \
} \
} while (0)

Definition at line 430 of file proresdec2.c.

◆ TOSIGNED

#define TOSIGNED (   x)    (((x) >> 1) ^ (-((x) & 1)))

Definition at line 462 of file proresdec2.c.

◆ FIRST_DC_CB

#define FIRST_DC_CB   0xB8

Definition at line 464 of file proresdec2.c.

Function Documentation

◆ permute()

static void permute ( uint8_t *  dst,
const uint8_t *  src,
const uint8_t  permutation[64] 
)
static

◆ unpack_alpha()

static void unpack_alpha ( GetBitContext gb,
uint16_t *  dst,
int  num_coeffs,
const int  num_bits,
const int  decode_precision 
)
inlinestatic

Definition at line 59 of file proresdec2.c.

Referenced by unpack_alpha_10(), and unpack_alpha_12().

◆ unpack_alpha_10()

static void unpack_alpha_10 ( GetBitContext gb,
uint16_t *  dst,
int  num_coeffs,
const int  num_bits 
)
static

Definition at line 120 of file proresdec2.c.

Referenced by decode_init().

◆ unpack_alpha_12()

static void unpack_alpha_12 ( GetBitContext gb,
uint16_t *  dst,
int  num_coeffs,
const int  num_bits 
)
static

Definition at line 130 of file proresdec2.c.

Referenced by decode_init().

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 140 of file proresdec2.c.

◆ decode_frame_header()

static int decode_frame_header ( ProresContext ctx,
const uint8_t *  buf,
const int  data_size,
AVCodecContext avctx 
)
static

Definition at line 206 of file proresdec2.c.

Referenced by decode_frame().

◆ decode_picture_header()

static int decode_picture_header ( AVCodecContext avctx,
const uint8_t *  buf,
const int  buf_size 
)
static

Definition at line 325 of file proresdec2.c.

Referenced by decode_frame().

◆ decode_dc_coeffs()

static av_always_inline int decode_dc_coeffs ( GetBitContext gb,
int16_t *  out,
int  blocks_per_slice 
)
static

Definition at line 468 of file proresdec2.c.

Referenced by decode_slice_chroma(), and decode_slice_luma().

◆ decode_ac_coeffs()

static av_always_inline int decode_ac_coeffs ( AVCodecContext avctx,
GetBitContext gb,
int16_t *  out,
int  blocks_per_slice 
)
static

Definition at line 499 of file proresdec2.c.

Referenced by decode_slice_chroma(), and decode_slice_luma().

◆ decode_slice_luma()

static int decode_slice_luma ( AVCodecContext avctx,
SliceContext slice,
uint16_t *  dst,
int  dst_stride,
const uint8_t *  buf,
unsigned  buf_size,
const int16_t *  qmat 
)
static

Definition at line 542 of file proresdec2.c.

Referenced by decode_slice_thread().

◆ decode_slice_chroma()

static int decode_slice_chroma ( AVCodecContext avctx,
SliceContext slice,
uint16_t *  dst,
int  dst_stride,
const uint8_t *  buf,
unsigned  buf_size,
const int16_t *  qmat,
int  log2_blocks_per_mb 
)
static

Definition at line 576 of file proresdec2.c.

Referenced by decode_slice_thread().

◆ decode_slice_alpha()

static void decode_slice_alpha ( const ProresContext ctx,
uint16_t *  dst,
int  dst_stride,
const uint8_t *  buf,
int  buf_size,
int  blocks_per_slice 
)
static

Decode alpha slice plane.

Definition at line 613 of file proresdec2.c.

Referenced by decode_slice_thread().

◆ decode_slice_thread()

static int decode_slice_thread ( AVCodecContext avctx,
void *  arg,
int  jobnr,
int  threadnr 
)
static

Definition at line 643 of file proresdec2.c.

Referenced by decode_picture().

◆ decode_picture()

static int decode_picture ( AVCodecContext avctx)
static

Definition at line 761 of file proresdec2.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( AVCodecContext avctx,
AVFrame frame,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 780 of file proresdec2.c.

◆ decode_close()

static av_cold int decode_close ( AVCodecContext avctx)
static

Definition at line 851 of file proresdec2.c.

Variable Documentation

◆ dc_codebook

const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70}
static

Definition at line 466 of file proresdec2.c.

Referenced by decode_dc_coeffs().

◆ run_to_cb

const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C }
static

Definition at line 496 of file proresdec2.c.

Referenced by decode_ac_coeffs().

◆ lev_to_cb

const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28, 0x28, 0x28, 0x4C }
static

Definition at line 497 of file proresdec2.c.

Referenced by decode_ac_coeffs().

◆ ff_prores_decoder

const FFCodec ff_prores_decoder
Initial value:
= {
.p.name = "prores",
CODEC_LONG_NAME("Apple ProRes (iCodec Pro)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(ProresContext),
.close = decode_close,
.hw_configs = (const AVCodecHWConfigInternal *const []) {
},
}

Definition at line 872 of file proresdec2.c.

ff_prores_profiles
const AVProfile ff_prores_profiles[]
Definition: profiles.c:159
ProresContext
Definition: proresdec.h:38
UPDATE_CACHE
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:216
GET_CACHE
#define GET_CACHE(name, gb)
Definition: get_bits.h:253
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
bits
uint8_t bits
Definition: vp3data.h:128
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
if
if(ret)
Definition: filter_design.txt:179
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:107
NULL
#define NULL
Definition: coverity.c:32
UPDATE_THREAD_CONTEXT
#define UPDATE_THREAD_CONTEXT(func)
Definition: codec_internal.h:281
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:115
decode_close
static av_cold int decode_close(AVCodecContext *avctx)
Definition: proresdec2.c:851
AVCodecHWConfigInternal
Definition: hwconfig.h:29
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:111
MIN_CACHE_BITS
#define MIN_CACHE_BITS
Definition: get_bits.h:168
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: proresdec2.c:780
update_thread_context
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. If there are inter-frame dependencies
SHOW_UBITS
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:249
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: proresdec2.c:140
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
codebook
static const unsigned codebook[256][2]
Definition: cfhdenc.c:42
AV_CODEC_ID_PRORES
@ AV_CODEC_ID_PRORES
Definition: codec_id.h:200
re
float re
Definition: fft.c:79