54 #define DNXHD_VLC_BITS 9
55 #define DNXHD_DC_VLC_BITS 7
73 if (cid != ctx->
cid) {
104 static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
107 if (buf_size < 0x280)
110 if (memcmp(buf, header_prefix, 5)) {
126 if (buf[0x21] & 0x40) {
188 int i, j, index1, index2,
len;
189 int level, component, sign;
190 const uint8_t *weight_matrix;
194 component = 1 + (n&1);
207 level = (
NEG_USR32(sign ^ level, len) ^ sign) - sign;
210 block[0] = ctx->
last_dc[component];
247 level = (2*level+1) * qscale * weight_matrix[i];
248 if (level_bias < 32 || weight_matrix[i] != level_bias)
250 level >>= level_shift;
253 block[j] = (level^sign) - sign;
276 uint8_t *dest_y, *dest_u, *dest_v;
277 int dct_y_offset, dct_x_offset;
284 for (i = 0; i < 8; i++) {
290 dct_linesize_luma <<= 1;
291 dct_linesize_chroma <<= 1;
294 dest_y = ctx->
picture.
data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 +
shift1));
295 dest_u = ctx->
picture.
data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 +
shift1));
296 dest_v = ctx->
picture.
data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 +
shift1));
304 dct_y_offset = dct_linesize_luma << 3;
305 dct_x_offset = 8 <<
shift1;
309 ctx->
dsp.
idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->
blocks[5]);
312 dct_y_offset = dct_linesize_chroma << 3;
330 for (x = 0; x < ctx->
mb_width; x++) {
342 const uint8_t *buf = avpkt->
data;
343 int buf_size = avpkt->
size;
348 av_dlog(avctx,
"frame size %d\n", buf_size);
380 goto decode_coding_unit;
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
const uint8_t ff_zigzag_direct[64]
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_RB16
AV_WL32 AV_WL24 AV_WL16 AV_RB32
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const uint8_t * luma_weight
AVFrame * coded_frame
the picture in the bitstream
#define AV_LOG_WARNING
Something somehow does not look correct.
const CIDEntry ff_dnxhd_cid_table[]
const uint16_t * run_codes
#define DECLARE_ALIGNED(n, t, v)
static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, DCTELEM *block, int n, int qscale)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
struct DNXHDContext DNXHDContext
static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y)
bitstream reader API header.
uint8_t idct_permutation[64]
idct input permutation.
int interlaced_frame
The content of the picture is interlaced.
unsigned int coding_unit_size
#define DNXHD_DC_VLC_BITS
const uint8_t * ac_index_flag
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
const uint16_t * ac_codes
#define UPDATE_CACHE(name, gb)
int ff_dnxhd_get_cid_table(int cid)
static const int shift1[6]
static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_size, int first_field)
uint32_t mb_scan_index[68]
void(* idct_put)(uint8_t *dest, int line_size, DCTELEM *block)
block -> idct -> clip to unsigned 8 bit -> dest.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
#define CLOSE_READER(name, gb)
void(* clear_block)(DCTELEM *block)
static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, DCTELEM *block, int n, int qscale, int index_bits, int level_bias, int level_shift)
const uint8_t * chroma_weight
#define SKIP_BITS(name, gb, num)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int width
picture width / height.
int type
type of the buffer (to keep track of who has to deallocate data[*])
#define LAST_SKIP_BITS(name, gb, num)
#define GET_VLC(code, name, gb, table, bits, max_depth)
If the vlc code is invalid and max_depth=1, then no bits will be removed.
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
#define SHOW_UBITS(name, gb, num)
static int dnxhd_decode_macroblocks(DNXHDContext *ctx, const uint8_t *buf, int buf_size)
int cur_field
current interlaced field
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
#define PIX_FMT_YUV422P10
const uint8_t * ac_run_flag
main external API structure.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
struct AVPicture AVPicture
four components are given, that's all.
#define OPEN_READER(name, gb)
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static void skip_bits1(GetBitContext *s)
void(* decode_dct_block)(struct DNXHDContext *ctx, DCTELEM *block, int n, int qscale)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define GET_CACHE(name, gb)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define SHOW_SBITS(name, gb, num)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, DCTELEM *block, int n, int qscale)
int top_field_first
If the content is interlaced, is top field displayed first.
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
const CIDEntry * cid_table
static int first_field(int fd)
void ff_free_vlc(VLC *vlc)
static av_cold int dnxhd_decode_init(AVCodecContext *avctx)