32 #define UNCHECKED_BITSTREAM_READER 1 62 uint32_t mb_scan_index[512];
79 #define DNXHD_VLC_BITS 9 80 #define DNXHD_DC_VLC_BITS 7 115 if (cid != ctx->
cid) {
172 int old_bit_depth = ctx->
bit_depth, bitdepth;
173 uint64_t header_prefix;
174 if (buf_size < 0x280) {
176 "buffer too small (%d < 640).\n", buf_size);
181 if (header_prefix == 0) {
183 "unknown header 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
184 buf[0], buf[1], buf[2], buf[3], buf[4]);
192 "interlaced %d, cur field %d\n", buf[5] & 3, ctx->
cur_field);
196 ctx->
mbaff = (buf[0x6] >> 5) & 1;
197 ctx->
alpha = buf[0x7] & 1;
198 ctx->
lla = (buf[0x7] >> 1) & 1;
205 switch(buf[0x21] >> 5) {
206 case 1: bitdepth = 8;
break;
207 case 2: bitdepth = 10;
break;
208 case 3: bitdepth = 12;
break;
211 "Unknown bitdepth indicator (%d)\n", buf[0x21] >> 5);
223 "Adaptive MB interlace flag in an unsupported profile.\n");
225 switch ((buf[0x2C] >> 1) & 3) {
232 ctx->
act = buf[0x2C] & 1;
235 "Adaptive color transform in an unsupported profile.\n");
237 ctx->
is_444 = (buf[0x2C] >> 6) & 1;
242 }
else if (bitdepth == 10) {
251 }
else if (bitdepth == 12) {
254 }
else if (bitdepth == 10) {
305 "mb height too big: %d\n", ctx->
mb_height);
312 "mb height too big: %d\n", ctx->
mb_height);
318 "buffer too small (%d < %d).\n", buf_size, ctx->
data_offset);
330 ff_dlog(ctx->
avctx,
"mb scan index %d, pos %d: %"PRIu32
"\n",
334 "invalid mb scan index (%"PRIu32
" vs %u).\n",
352 int level, component, sign;
365 component = 1 + (n & 1);
374 component = (n >> 1) % 3;
394 level = (
NEG_USR32(sign ^ level, len) ^ sign) - sign;
395 row->
last_dc[component] += level * (1 << dc_shift);
397 block[0] = row->
last_dc[component];
405 while (index1 != eob_index) {
406 level = ac_info[2*index1+0];
407 flags = ac_info[2*index1+1];
432 level += scale[
i] >> 1;
433 if (level_bias < 32 || weight_matrix[i] != level_bias)
435 level >>= level_shift;
437 block[j] = (level ^ sign) - sign;
482 int dct_linesize_luma = frame->
linesize[0];
483 int dct_linesize_chroma = frame->
linesize[1];
484 uint8_t *dest_y, *dest_u, *dest_v;
485 int dct_y_offset, dct_x_offset;
487 int interlaced_mb = 0;
498 static int act_warned;
502 "ACT flag set, in violation of frame header.\n");
504 }
else if (row->
format == -1) {
506 }
else if (row->
format != act) {
512 for (i = 0; i < 64; i++) {
519 for (i = 0; i < 8 + 4 * ctx->
is_444; i++) {
525 dct_linesize_luma <<= 1;
526 dct_linesize_chroma <<= 1;
529 dest_y = frame->
data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 +
shift1));
530 dest_u = frame->
data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->
is_444));
531 dest_v = frame->
data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->
is_444));
539 dct_linesize_luma <<= 1;
540 dct_linesize_chroma <<= 1;
543 dct_y_offset = interlaced_mb ? frame->
linesize[0] : (dct_linesize_luma << 3);
544 dct_x_offset = 8 <<
shift1;
549 ctx->
idsp.
idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, row->
blocks[5]);
552 dct_y_offset = interlaced_mb ? frame->
linesize[1] : (dct_linesize_chroma << 3);
562 ctx->
idsp.
idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, row->
blocks[7]);
565 dct_y_offset = interlaced_mb ? frame->
linesize[1] : (dct_linesize_chroma << 3);
569 ctx->
idsp.
idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, row->
blocks[9]);
573 ctx->
idsp.
idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, row->
blocks[11]);
581 int rownb,
int threadnb)
596 for (x = 0; x < ctx->
mb_width; x++) {
618 ff_dlog(avctx,
"frame size %d\n", buf_size);
659 goto decode_coding_unit;
669 static int act_warned;
684 "Unsupported: variable ACT flag.\n");
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
static int dnxhd_decode_dct_block_8(const DNXHDContext *ctx, RowContext *row, int n)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
int64_t cid
compression id
static int dnxhd_get_profile(int cid)
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(* decode_dct_block)(const struct DNXHDContext *ctx, RowContext *row, int n)
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.
static av_cold int init(AVCodecContext *avctx)
void(* clear_block)(int16_t *block)
#define avpriv_request_sample(...)
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
#define AV_PIX_FMT_GBRP10
const uint16_t * run_codes
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.
#define FF_ARRAY_ELEMS(a)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static void error(const char *err)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
The exact code depends on how similar the blocks are and how related they are to the block
static int dnxhd_decode_dct_block_12(const DNXHDContext *ctx, RowContext *row, int n)
const AVProfile ff_dnxhd_profiles[]
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Multithreading support functions.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static av_always_inline int dnxhd_decode_dct_block(const DNXHDContext *ctx, RowContext *row, int n, int index_bits, int level_bias, int level_shift, int dc_shift)
int format
-1:not set yet 0:off=RGB 1:on=YUV 2:variable
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
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define DNXHD_DC_VLC_BITS
#define AV_PIX_FMT_YUV422P12
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
enum AVPixelFormat pix_fmt
static int first_field(const struct video_data *s)
const uint16_t * ac_codes
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const int shift1[6]
static int dnxhd_decode_row(AVCodecContext *avctx, void *data, int rownb, int threadnb)
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
#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_*.
enum AVColorSpace colorspace
YUV colorspace type.
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_YUV444P10
#define FF_PROFILE_DNXHR_LB
#define CLOSE_READER(name, gb)
static int dnxhd_decode_dct_block_10_444(const DNXHDContext *ctx, RowContext *row, int n)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static av_always_inline uint64_t ff_dnxhd_parse_header_prefix(const uint8_t *buf)
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)
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 so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames.The frames must then be freed with ff_thread_release_buffer().Otherwise decode directly into the user-supplied frames.Call ff_thread_report_progress() after some part of the current picture has decoded.A good place to put this is where draw_horiz_band() is called-add this if it isn't called anywhere
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static void decode_dct_block(RangeCoder *c, DCTBlockCoder *bc, uint8_t *dst, ptrdiff_t stride, int block_size, int *block, int mb_x, int mb_y)
const CIDEntry * ff_dnxhd_get_cid_table(int cid)
ITU-R BT2020 non-constant luminance system.
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 frame
#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 FF_PROFILE_DNXHR_HQ
void(* idct_put)(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
static int dnxhd_decode_macroblock(const DNXHDContext *ctx, RowContext *row, AVFrame *frame, int x, int y)
#define SHOW_UBITS(name, gb, num)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
Libavcodec external API header.
int cur_field
current interlaced field
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int dnxhd_decode_dct_block_10(const DNXHDContext *ctx, RowContext *row, int n)
main external API structure.
#define OPEN_READER(name, gb)
static unsigned int get_bits1(GetBitContext *s)
static const AVProfile profiles[]
enum AVColorSpace colorspace
YUV colorspace type.
static av_always_inline uint64_t ff_dnxhd_check_header_prefix_hr(uint64_t prefix)
#define GET_CACHE(name, gb)
const uint8_t ff_zigzag_direct[64]
#define FF_PROFILE_DNXHR_SQ
#define AV_PIX_FMT_GBRP12
#define flags(name, subs,...)
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
uint32_t mb_scan_index[512]
ITU-R BT2020 constant luminance system.
#define DNXHD_VARIABLE
Indicate that a CIDEntry value must be read in the bitstream.
#define SHOW_SBITS(name, gb, num)
#define FF_PROFILE_DNXHR_HQX
common internal api header.
#define FF_PROFILE_DNXHR_444
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)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
AVPixelFormat
Pixel format.
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 int dnxhd_decode_dct_block_12_444(const DNXHDContext *ctx, RowContext *row, int n)
static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
void * av_mallocz_array(size_t nmemb, size_t size)