55 "Valid DV profiles are:\n",
72 memset(&fdsp,0,
sizeof(fdsp));
73 memset(&mecc,0,
sizeof(mecc));
74 memset(&pdsp,0,
sizeof(pdsp));
107 *vlc = 0xfe00 | (level << 1) | sign;
111 *vlc |= ((run < 16) ?
dv_vlc_map[run - 1][0].vlc :
112 (0x1f80 | (run - 1))) <<
size;
113 size += (run < 16) ?
dv_vlc_map[run - 1][0].size : 13;
129 size += (run < 16) ?
dv_vlc_map[run - 1][0].size : 13;
176 put_bits(pb, bits_left, vlc >> size);
177 vlc = av_mod_uintp2(vlc, size);
179 if (pb + 1 >= pb_end) {
223 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
224 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
225 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
226 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
227 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
228 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
229 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
230 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
233 131072, 262144, 257107, 257107, 242189, 242189, 242189, 242189,
234 237536, 237536, 229376, 229376, 200636, 200636, 224973, 224973,
235 223754, 223754, 235923, 235923, 229376, 229376, 217965, 217965,
236 211916, 211916, 196781, 196781, 185364, 185364, 206433, 206433,
237 211916, 211916, 222935, 222935, 200636, 200636, 205964, 205964,
238 200704, 200704, 180568, 180568, 175557, 175557, 195068, 195068,
239 185364, 185364, 188995, 188995, 174606, 174606, 175557, 175557,
240 170627, 170627, 153560, 153560, 165371, 165371, 144651, 144651,
262 static const int classes[] = { 12, 24, 36, 0xffff };
264 static const int classes[] = { -1, -1, 255, 0xffff };
266 int max = classes[0];
286 memset(blk, 0, 64 *
sizeof(*blk));
294 for (area = 0; area < 4; area++) {
295 bi->
prev[area] = prev;
298 int level = blk[zigzag_scan[i]];
300 if (level + 15 > 30
U) {
301 bi->
sign[i] = (level >> 31) & 1;
305 level = (
FFABS(level) * weight[i] + (1 << (dv_weight_bits + 3))) >>
306 (dv_weight_bits + 4);
317 for (bi->
cno = 0; max > classes[bi->
cno]; bi->
cno++)
326 for (area = 0; area < 4; area++) {
327 bi->
prev[area] = prev;
349 int i, j, k,
a, prev,
a2;
359 for (i = 0; i < 5; i++) {
365 for (j = 0; j < 6; j++, b++) {
366 for (a = 0; a < 4; a++) {
391 b->
prev[a + 1] = prev;
399 }
while (qnos[0] | qnos[1] | qnos[2] | qnos[3] | qnos[4]);
404 for (j = 0; j < 6 * 5; j++, b++) {
406 for (k = b->
next[prev]; k < 64; k = b->next[k]) {
407 if (b->
mb[k] < a && b->
mb[k] > -a) {
423 int mb_x, mb_y, c_offset;
424 ptrdiff_t linesize, y_stride;
433 int qnos[5] = { 15, 15, 15, 15, 15 };
434 int *qnosp = &qnos[0];
437 enc_blk = &enc_blks[0];
438 for (mb_index = 0; mb_index < 5; mb_index++) {
444 (s->
sys->
height >= 720 && mb_y != 134)) {
471 for (j = 2; j; j--) {
478 for (i = 0; i < 8; i++) {
479 d = c_ptr + (linesize << 3);
506 for (j = 0; j < 5 * s->
sys->
bpm;) {
513 for (i = 0; i < s->
sys->
bpm; i++, j++) {
517 put_sbits(&pbs[j], 9, ((enc_blks[j].
mb[0] >> 3) - 1024 + 2) >> 2);
518 put_bits(&pbs[j], 1, enc_blks[j].dct_mode);
519 put_bits(&pbs[j], 2, enc_blks[j].cno);
527 for (i = 0; i < s->
sys->
bpm; i++)
528 if (enc_blks[start_mb + i].partial_bit_count)
530 &pbs[start_mb + s->
sys->
bpm]);
535 for (j = 0; j < 5 * s->
sys->
bpm; j++) {
536 if (enc_blks[j].partial_bit_count)
538 if (enc_blks[j].partial_bit_count)
542 for (j = 0; j < 5 * s->
sys->
bpm; j++) {
549 "bitstream written beyond buffer size\n");
552 memset(pbs[j].
buf + pos, 0xff, size - pos);
640 buf[1] = (seq_num << 4) |
649 if (syb_num == 0 || syb_num == 6) {
653 }
else if (syb_num == 11) {
673 memset(buf, 0xff, 80 * 6);
682 for (j = 0; j < 2; j++) {
684 for (k = 0; k < 6; k++)
690 for (j = 0; j < 3; j++) {
701 for (j = 0; j < 135; j++) {
703 memset(buf, 0xff, 80);
728 #if FF_API_CODED_FRAME
av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
static av_always_inline int dv_init_enc_block(EncBlockInfo *bi, uint8_t *data, ptrdiff_t linesize, DVVideoContext *s, int bias)
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
const uint8_t * block_sizes
static av_cold int init(AVCodecContext *avctx)
static int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t *buf)
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 ildct_cmp
interlaced DCT comparison function
const uint8_t ff_dv_quant_offset[4]
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
Macro definitions for various function/variable attributes.
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, ptrdiff_t linesize)
void ff_dv_print_profiles(void *logctx, int loglevel)
Print all allowed DV profiles into logctx at specified logging level.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
const uint8_t ff_dv_zigzag248_direct[64]
static av_cold void dv_vlc_map_tableinit(void)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
enum AVPixelFormat pix_fmt
static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
static const int dv_weight_bits
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define LOCAL_ALIGNED_8(t, v,...)
static const int dv_weight_88[64]
DVwork_chunk work_chunks[4 *12 *27]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVCodec ff_dvvideo_encoder
uint8_t partial_bit_count
static int put_bits_left(PutBitContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int dv_work_pool_size(const AVDVProfile *d)
void(* get_pixels)(int16_t *av_restrict block, const uint8_t *pixels, ptrdiff_t stride)
int flags
AV_CODEC_FLAG_*.
uint32_t partial_bit_buffer
const char * name
Name of the codec implementation.
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
common internal API header
static const int vs_total_ac_bits
enum AVPictureType pict_type
Picture type of the frame.
static int dv_write_pack(enum dv_pack_type pack_id, DVVideoContext *c, uint8_t *buf)
#define DV_VLC_MAP_RUN_SIZE
#define DV_MAX_BPM
maximum number of blocks per macroblock in any DV format
int width
picture width / height.
static av_always_inline int dv_rl2vlc(int run, int l, int sign, uint32_t *vlc)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
void(* get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static const int mb_area_start[5]
void(* fdct[2])(int16_t *block)
static void dv_guess_qnos(EncBlockInfo *blks, int *qnos)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
void(* fdct)(int16_t *block)
main external API structure.
#define DV_VLC_MAP_LEV_SIZE
static void dv_format_frame(DVVideoContext *c, uint8_t *buf)
av_cold int ff_dvvideo_init(AVCodecContext *avctx)
const uint8_t ff_zigzag_direct[64]
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static int weight(int i, int blen, int offset)
static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
static enum AVPixelFormat pix_fmts[]
static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt, const AVFrame *frame, int *got_packet)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_always_inline PutBitContext * dv_encode_ac(EncBlockInfo *bi, PutBitContext *pb_pool, PutBitContext *pb_end)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
const uint8_t ff_dv_quant_shifts[22][4]
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, uint8_t seq_num, uint8_t dif_num, uint8_t *buf)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
void(* fdct248)(int16_t *block)
int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d)
const AVDVProfile * av_dv_codec_profile2(int width, int height, enum AVPixelFormat pix_fmt, AVRational frame_rate)
Get a DV profile for the provided stream parameters.
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
#define FF_ENABLE_DEPRECATION_WARNINGS
int top_field_first
If the content is interlaced, is top field displayed first.
static void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y)
static const int dv_weight_248[64]
int key_frame
1 -> keyframe, 0-> not
#define LOCAL_ALIGNED_16(t, v,...)
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.
static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]
static av_always_inline int dv_rl2vlc_size(int run, int l)
AVPixelFormat
Pixel format.
This structure stores compressed data.