57 #define DNXHD_VLC_BITS 9 58 #define DNXHD_DC_VLC_BITS 7 77 if (cid != ctx->
cid) {
109 const uint8_t *buf,
int buf_size,
112 static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
113 static const uint8_t header_prefix444[] = { 0x00, 0x00, 0x02, 0x80, 0x02 };
117 if (buf_size < 0x280) {
123 if (memcmp(buf, header_prefix, 5) && memcmp(buf, header_prefix444, 5)) {
125 "unknown header 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
126 buf[0], buf[1], buf[2], buf[3], buf[4]);
134 "interlaced %d, cur field %d\n", buf[5] & 3, ctx->
cur_field);
136 ctx->
mbaff = buf[0x6] & 32;
143 if (buf[0x21] == 0x58) {
146 if (buf[0x4] == 0x2) {
154 }
else if (buf[0x21] == 0x38) {
176 "Adaptive MB interlace flag in an unsupported profile.\n");
205 "mb height too big: %d\n", ctx->
mb_height);
214 "invalid mb scan index (%d < %d).\n",
224 int16_t *
block,
int n,
230 int i, j, index1, index2,
len;
231 int level, component, sign;
237 component = 1 + (n & 1);
244 component = (n >> 1) % 3;
258 level = (
NEG_USR32(sign ^ level, len) ^ sign) - sign;
261 block[0] = ctx->
last_dc[component];
292 level = (2 * level + 1) * qscale * weight_matrix[i];
293 if (level_bias < 32 || weight_matrix[i] != level_bias)
295 level >>= level_shift;
297 block[j] = (level ^ sign) - sign;
325 int dct_linesize_luma = frame->
linesize[0];
326 int dct_linesize_chroma = frame->
linesize[1];
327 uint8_t *dest_y, *dest_u, *dest_v;
328 int dct_y_offset, dct_x_offset;
330 int interlaced_mb = 0;
340 for (i = 0; i < 8; i++) {
345 for (; i < 12; i++) {
352 dct_linesize_luma <<= 1;
353 dct_linesize_chroma <<= 1;
356 dest_y = frame->
data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 +
shift1));
357 dest_u = frame->
data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->
is_444));
358 dest_v = frame->
data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->
is_444));
366 dct_linesize_luma <<= 1;
367 dct_linesize_chroma <<= 1;
370 dct_y_offset = interlaced_mb ? frame->
linesize[0] : (dct_linesize_luma << 3);
371 dct_x_offset = 8 <<
shift1;
376 ctx->
idsp.
idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->
blocks[5]);
379 dct_y_offset = interlaced_mb ? frame->
linesize[1] : (dct_linesize_chroma << 3);
389 ctx->
idsp.
idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->
blocks[7]);
392 dct_y_offset = interlaced_mb ? frame->
linesize[1] : (dct_linesize_chroma << 3);
396 ctx->
idsp.
idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->
blocks[9]);
400 ctx->
idsp.
idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->
blocks[11]);
408 const uint8_t *buf,
int buf_size)
416 for (x = 0; x < ctx->
mb_width; x++) {
429 int buf_size = avpkt->
size;
437 ff_dlog(avctx,
"frame size %d\n", buf_size);
469 goto decode_coding_unit;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
const uint8_t * luma_weight
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
void(* clear_block)(int16_t *block)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
const CIDEntry ff_dnxhd_cid_table[]
const uint16_t * run_codes
#define DECLARE_ALIGNED(n, t, v)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
Multithreading support functions.
void(* decode_dct_block)(struct DNXHDContext *ctx, int16_t *block, int n, int qscale)
bitstream reader API header.
#define AV_LOG_VERBOSE
Detailed information.
int interlaced_frame
The content of the picture is interlaced.
unsigned int coding_unit_size
#define DNXHD_DC_VLC_BITS
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
high precision timer, useful to profile code
const uint8_t * ac_index_flag
const uint16_t * ac_codes
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_dnxhd_get_cid_table(int cid)
static const int shift1[6]
uint32_t mb_scan_index[68]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int flags
AV_CODEC_FLAG_*.
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_YUV444P10
#define CLOSE_READER(name, gb)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
const uint8_t * chroma_weight
#define SKIP_BITS(name, gb, num)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
void(* idct_put)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, int16_t *block, int n, int qscale, int index_bits, int level_bias, int level_shift)
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, int16_t *block, int n, int qscale)
#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.
uint8_t idct_permutation[64]
IDCT input permutation.
#define SHOW_UBITS(name, gb, num)
static int dnxhd_decode_macroblocks(DNXHDContext *ctx, AVFrame *frame, const uint8_t *buf, int buf_size)
Libavcodec external API header.
int cur_field
current interlaced field
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
const uint8_t * ac_run_flag
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
#define OPEN_READER(name, gb)
static void dnxhd_decode_dct_block_10_444(DNXHDContext *ctx, int16_t *block, int n, int qscale)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define GET_CACHE(name, gb)
const uint8_t ff_zigzag_direct[64]
#define AV_PIX_FMT_YUV422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, int16_t *block, int n, int qscale)
#define SHOW_SBITS(name, gb, num)
common internal api header.
static av_cold int init(AVCodecParserContext *s)
static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int y)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
int top_field_first
If the content is interlaced, is top field displayed first.
static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
const CIDEntry * cid_table
static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, const uint8_t *buf, int buf_size, int first_field)
static int first_field(int fd)
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold int dnxhd_decode_init(AVCodecContext *avctx)