25 #include "libavutil/imgutils.h"
55 #define DNXHD_VLC_BITS 9
56 #define DNXHD_DC_VLC_BITS 7
72 if (cid != ctx->
cid) {
108 static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
111 if (buf_size < 0x280)
114 if (memcmp(buf, header_prefix, 5)) {
130 if (buf[0x21] & 0x40) {
192 int i, j, index1, index2,
len,
flags;
193 int level, component, sign;
202 component = 1 + (n&1);
217 level = (
NEG_USR32(sign ^ level, len) ^ sign) - sign;
220 block[0] = ctx->
last_dc[component];
228 while (index1 != eob_index) {
229 level = ac_level[index1];
230 flags = ac_flags[index1];
254 if (level_bias < 32 || weight_matrix[i] != level_bias)
256 level >>= level_shift;
258 block[j] = (level^sign) - sign;
283 int dct_linesize_luma = frame->
linesize[0];
284 int dct_linesize_chroma = frame->
linesize[1];
285 uint8_t *dest_y, *dest_u, *dest_v;
286 int dct_y_offset, dct_x_offset;
293 for (i = 0; i < 64; i++) {
300 for (i = 0; i < 8; i++) {
306 dct_linesize_luma <<= 1;
307 dct_linesize_chroma <<= 1;
310 dest_y = frame->
data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 +
shift1));
311 dest_u = frame->
data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 +
shift1));
312 dest_v = frame->
data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 +
shift1));
320 dct_y_offset = dct_linesize_luma << 3;
321 dct_x_offset = 8 <<
shift1;
325 ctx->
dsp.
idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->
blocks[5]);
328 dct_y_offset = dct_linesize_chroma << 3;
347 for (x = 0; x < ctx->
mb_width; x++) {
360 int buf_size = avpkt->
size;
367 av_dlog(avctx,
"frame size %d\n", buf_size);
397 goto decode_coding_unit;
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
int64_t cid
compression id
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
static av_cold int init(AVCodecContext *avctx)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
const CIDEntry ff_dnxhd_cid_table[]
const uint16_t * run_codes
#define DECLARE_ALIGNED(n, t, v)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void(* decode_dct_block)(struct DNXHDContext *ctx, int16_t *block, int n, int qscale)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", 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)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
void(* idct_put)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
static int first_field(const struct video_data *s, int fd)
Multithreading support functions.
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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 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.
#define CLOSE_READER(name, gb)
Libavcodec external API header.
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...
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 ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
int width
picture width / height.
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.
static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
#define SHOW_UBITS(name, gb, num)
static int dnxhd_decode_macroblocks(DNXHDContext *ctx, AVFrame *frame, const uint8_t *buf, int buf_size)
typedef void(RENAME(mix_any_func_type))
int cur_field
current interlaced field
main external API structure.
static void close(AVCodecParserContext *s)
#define OPEN_READER(name, gb)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
#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)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define GET_CACHE(name, gb)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const uint16_t scale[4]
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.
const uint8_t ff_zigzag_direct[64]
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
void(* clear_block)(int16_t *block)
static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int y)
#define AVERROR_INVALIDDATA
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
#define AV_PIX_FMT_YUV422P10
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, const uint8_t *buf, int buf_size, int first_field)
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int dnxhd_decode_init(AVCodecContext *avctx)