FFmpeg
Macros | Functions | Variables
proresdec2.c File Reference

Known FOURCCs: 'apch' (HQ), 'apcn' (SD), 'apcs' (LT), 'acpo' (Proxy), 'ap4h' (4444) More...

#include "libavutil/internal.h"
#include "avcodec.h"
#include "get_bits.h"
#include "idctdsp.h"
#include "internal.h"
#include "profiles.h"
#include "simple_idct.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 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 (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, void *data, 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 }
 
AVCodec ff_prores_decoder
 

Detailed Description

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

Definition in file proresdec2.c.

Macro Definition Documentation

#define LONG_BITSTREAM_READER

Definition at line 29 of file proresdec2.c.

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

Definition at line 49 of file proresdec2.c.

Referenced by unpack_alpha().

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

Definition at line 50 of file proresdec2.c.

Referenced by unpack_alpha().

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

Definition at line 51 of file proresdec2.c.

Referenced by unpack_alpha().

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

Definition at line 52 of file proresdec2.c.

Referenced by unpack_alpha().

#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)
const char const char void * val
Definition: avisynth_c.h:863
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
float re
Definition: fft.c:82
int av_log2(unsigned v)
Definition: intmath.c:26
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:178
uint8_t bits
Definition: vp3data.h:202
#define SKIP_BITS(name, gb, num)
Definition: get_bits.h:193
#define FFMIN(a, b)
Definition: common.h:96
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:211
if(ret)
void * buf
Definition: avisynth_c.h:766
#define GET_CACHE(name, gb)
Definition: get_bits.h:215
#define MIN_CACHE_BITS
Definition: get_bits.h:128
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return

Definition at line 403 of file proresdec2.c.

Referenced by decode_ac_coeffs(), and decode_dc_coeffs().

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

Definition at line 435 of file proresdec2.c.

Referenced by decode_dc_coeffs().

#define FIRST_DC_CB   0xB8

Definition at line 437 of file proresdec2.c.

Referenced by decode_dc_coeffs().

Function Documentation

static void permute ( uint8_t dst,
const uint8_t src,
const uint8_t  permutation[64] 
)
static
static void unpack_alpha ( GetBitContext gb,
uint16_t *  dst,
int  num_coeffs,
const int  num_bits,
const int  decode_precision 
)
inlinestatic

Definition at line 54 of file proresdec2.c.

Referenced by unpack_alpha_10(), and unpack_alpha_12().

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

Definition at line 115 of file proresdec2.c.

Referenced by decode_init().

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

Definition at line 125 of file proresdec2.c.

Referenced by decode_init().

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 135 of file proresdec2.c.

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

Definition at line 199 of file proresdec2.c.

Referenced by decode_frame().

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

Definition at line 298 of file proresdec2.c.

Referenced by decode_frame().

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

Definition at line 441 of file proresdec2.c.

Referenced by decode_slice_chroma(), and decode_slice_luma().

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

Definition at line 472 of file proresdec2.c.

Referenced by decode_slice_chroma(), and 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 515 of file proresdec2.c.

Referenced by decode_slice_thread().

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 549 of file proresdec2.c.

Referenced by decode_slice_thread().

static void decode_slice_alpha ( 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 586 of file proresdec2.c.

Referenced by decode_slice_thread().

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

Definition at line 616 of file proresdec2.c.

Referenced by decode_picture().

static int decode_picture ( AVCodecContext avctx)
static

Definition at line 732 of file proresdec2.c.

Referenced by decode_frame().

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

Definition at line 751 of file proresdec2.c.

static av_cold int decode_close ( AVCodecContext avctx)
static

Definition at line 821 of file proresdec2.c.

Variable Documentation

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

Definition at line 439 of file proresdec2.c.

Referenced by decode_dc_coeffs().

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 469 of file proresdec2.c.

Referenced by decode_ac_coeffs().

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

Definition at line 470 of file proresdec2.c.

Referenced by decode_ac_coeffs().

AVCodec ff_prores_decoder
Initial value:
= {
.name = "prores",
.long_name = NULL_IF_CONFIG_SMALL("ProRes (iCodec Pro)"),
.priv_data_size = sizeof(ProresContext),
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
.close = decode_close,
.decode = decode_frame,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
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 add an init_thread_copy() which re-allocates them for other threads.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
static av_cold int decode_init(AVCodecContext *avctx)
Definition: proresdec2.c:135
const AVProfile ff_prores_profiles[]
Definition: profiles.c:154
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1043
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:225
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:1047
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: proresdec2.c:751
static av_cold int decode_close(AVCodecContext *avctx)
Definition: proresdec2.c:821
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:987

Definition at line 830 of file proresdec2.c.