40 "Valid DV profiles are:\n",
73 *vlc = 0xfe00 | (level << 1) | sign;
77 *vlc |= ((run < 16) ?
dv_vlc_map[run-1][0].vlc :
78 (0x1f80 | (run - 1))) <<
size;
79 size += (run < 16) ?
dv_vlc_map[run-1][0].size : 13;
96 size += (run < 16) ?
dv_vlc_map[run-1][0].size : 13;
143 put_bits(pb, bits_left, vlc >> size);
144 vlc = vlc & ((1 <<
size) - 1);
146 if (pb + 1 >= pb_end) {
186 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
187 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
188 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
189 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
190 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
191 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
192 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
193 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
196 131072, 242189, 257107, 237536, 229376, 200636, 242189, 223754,
197 224969, 196781, 262144, 242189, 229376, 200636, 257107, 237536,
198 211916, 185364, 235923, 217965, 229376, 211916, 206433, 180568,
199 242189, 223754, 224969, 196781, 211916, 185364, 235923, 217965,
200 200704, 175557, 222935, 205965, 200636, 185364, 195068, 170627,
201 229376, 211916, 206433, 180568, 200704, 175557, 222935, 205965,
202 175557, 153560, 188995, 174609, 165371, 144651, 200636, 185364,
203 195068, 170627, 175557, 153560, 188995, 174609, 165371, 144651,
223 static const int classes[] = {12, 24, 36, 0xffff};
225 static const int classes[] = {-1, -1, 255, 0xffff};
227 int max = classes[0];
230 assert((((
int)
blk) & 15) == 0);
243 memset(blk, 0, 64*
sizeof(*blk));
251 for (area = 0; area < 4; area++) {
252 bi->
prev[area] = prev;
255 int level = blk[zigzag_scan[i]];
257 if (level + 15 > 30
U) {
258 bi->
sign[i] = (level >> 31) & 1;
262 level = (
FFABS(level) * weight[i] + (1 << (dv_weight_bits+3))) >> (dv_weight_bits+4);
273 for (bi->
cno = 0; max > classes[bi->
cno]; bi->
cno++);
281 for (area = 0; area < 4; area++) {
282 bi->
prev[area] = prev;
303 int i, j, k,
a, prev, a2;
306 size[0] = size[1] = size[2] = size[3] = size[4] = 1 << 24;
309 for (i = 0; i < 5; i++) {
315 for (j = 0; j < 6; j++, b++) {
316 for (a = 0; a < 4; a++) {
332 assert(b->
mb[b->
next[k]]);
335 assert(b->
prev[a2] == k && (a2 + 1 >= 4 || b->
prev[a2+1] != k));
349 }
while (qnos[0]|qnos[1]|qnos[2]|qnos[3]|qnos[4]);
355 for (j = 0; j < 6 *5; j++, b++) {
357 for (k = b->
next[prev]; k < 64; k = b->next[k]) {
358 if (b->
mb[k] < a && b->
mb[k] > -a){
374 int mb_x, mb_y, c_offset, linesize, y_stride;
383 int qnos[5] = {15, 15, 15, 15, 15};
384 int* qnosp = &qnos[0];
387 enc_blk = &enc_blks[0];
388 for (mb_index = 0; mb_index < 5; mb_index++) {
394 (s->
sys->
height >= 720 && mb_y != 134)) {
420 for (j = 2; j; j--) {
427 for (i = 0; i < 8; i++) {
428 d = c_ptr + (linesize << 3);
429 b[0] = c_ptr[0]; b[1] = c_ptr[1]; b[2] = c_ptr[2]; b[3] = c_ptr[3];
430 b[4] = d[0]; b[5] = d[1]; b[6] = d[2]; b[7] = d[3];
449 for (j=0; j<5*s->
sys->
bpm;) {
456 for (i=0; i<s->
sys->
bpm; i++, j++) {
460 put_sbits(&pbs[j], 9, ((enc_blks[j].mb[0] >> 3) - 1024 + 2) >> 2);
461 put_bits(&pbs[j], 1, enc_blks[j].dct_mode);
462 put_bits(&pbs[j], 2, enc_blks[j].cno);
470 for (i=0; i<s->
sys->
bpm; i++) {
471 if (enc_blks[start_mb+i].partial_bit_count)
478 for (j=0; j<5*s->
sys->
bpm; j++) {
479 if (enc_blks[j].partial_bit_count)
481 if (enc_blks[j].partial_bit_count)
485 for (j=0; j<5*s->
sys->
bpm; j++) {
494 memset(pbs[j].buf + pos, 0xff, size - pos);
567 buf[1] = buf[2] = buf[3] = buf[4] = 0xff;
577 buf[1] = (seq_num << 4) |
587 if (syb_num == 0 || syb_num == 6) {
592 else if (syb_num == 11) {
613 memset(buf, 0xff, 80 * 6);
621 for (j = 0; j < 2; j++) {
623 for (k = 0; k < 6; k++)
629 for (j = 0; j < 3; j++) {
640 for (j = 0; j < 135; j++) {
642 memset(buf, 0xff, 80);
658 const AVFrame *frame,
int *got_packet)
static av_always_inline int dv_init_enc_block(EncBlockInfo *bi, uint8_t *data, int linesize, DVVideoContext *s, int bias)
void ff_dv_print_profiles(void *logctx, int loglevel)
Print all allowed DV profiles into logctx at specified logging level.
This structure describes decoded (raw) audio or video data.
static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, int linesize)
static void put_sbits(PutBitContext *pb, int n, int32_t value)
int ff_dv_init_dynamic_tables(const DVprofile *d)
AVFrame * coded_frame
the picture in the bitstream
static int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t *buf)
const uint8_t ff_zigzag248_direct[64]
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.
const uint8_t ff_dv_quant_offset[4]
static const uint8_t zigzag_scan[16]
Macro definitions for various function/variable attributes.
static int dvvideo_encode_close(AVCodecContext *avctx)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
enum AVPixelFormat pix_fmt
static double av_q2d(AVRational a)
Convert rational to double.
static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
const uint8_t * block_sizes
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]
#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)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
uint32_t partial_bit_buffer
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
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)
const DVprofile * avpriv_dv_codec_profile(AVCodecContext *codec)
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)
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
#define CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
static void dv_vlc_map_tableinit(void)
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.
main external API structure.
static void close(AVCodecParserContext *s)
#define DV_VLC_MAP_LEV_SIZE
void(* get_pixels)(int16_t *block, const uint8_t *pixels, int line_size)
static void dv_format_frame(DVVideoContext *c, uint8_t *buf)
av_cold int ff_dvvideo_init(AVCodecContext *avctx)
static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
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 CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
common internal api header.
const uint8_t ff_zigzag_direct[64]
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
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.
static av_cold int init(AVCodecParserContext *s)
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.
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 int dv_work_pool_size(const DVprofile *d)
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)
DVwork_chunk * work_chunks
AVPixelFormat
Pixel format.
This structure stores compressed data.