/* bit budget for AC only in 5 MBs */
static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5;
-/* see dv_88_areas and dv_248_areas for details */
static const int mb_area_start[5] = { 1, 6, 21, 43, 64 };
static inline int put_bits_left(PutBitContext* s)
return (s->buf_end - s->buf) * 8 - put_bits_count(s);
}
-/* decode ac coefficients */
+/* decode AC coefficients */
static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block)
{
int last_index = gb->size_in_bits;
OPEN_READER(re, gb);
UPDATE_CACHE(re, gb);
- /* if we must parse a partial vlc, we do it here */
+ /* if we must parse a partial VLC, we do it here */
if (partial_bit_count > 0) {
re_cache = ((unsigned)re_cache >> partial_bit_count) |
(mb->partial_bit_buffer << (sizeof(re_cache) * 8 - partial_bit_count));
GetBitContext gb;
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
- LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]); /* allow some slack */
- LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]); /* allow some slack */
+ LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [ 80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
+ LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5*80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
const int log2_blocksize = 3-s->avctx->lowres;
int is_field_mode[5];
memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));
- /* pass 1 : read DC and AC coefficients in blocks */
+ /* pass 1: read DC and AC coefficients in blocks */
buf_ptr = &s->buf[work_chunk->buf_offset*80];
block1 = &sblock[0][0];
mb1 = mb_data;
last_index = s->sys->block_sizes[j];
init_get_bits(&gb, buf_ptr, last_index);
- /* get the dc */
+ /* get the DC */
dc = get_sbits(&gb, 9);
dct_mode = get_bits1(&gb);
class1 = get_bits(&gb, 2);
av_dlog(avctx, "MB block: %d, %d ", mb_index, j);
dv_decode_ac(&gb, mb, block);
- /* write the remaining bits in a new buffer only if the
+ /* write the remaining bits in a new buffer only if the
block is finished */
if (mb->pos >= 64)
bit_copy(&pb, &gb);
mb++;
}
- /* pass 2 : we can do it just after */
+ /* pass 2: we can do it just after */
av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index);
block = block1;
mb = mb1;
init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));
+ put_bits32(&pb, 0); // padding must be zeroed
flush_put_bits(&pb);
for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) {
if (mb->pos < 64 && get_bits_left(&gb) > 0) {
bit_copy(&vs_pb, &gb);
}
- /* we need a pass other the whole video segment */
+ /* we need a pass over the whole video segment */
av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb));
block = &sblock[0][0];
mb = mb_data;
init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));
+ put_bits32(&vs_pb, 0); // padding must be zeroed
flush_put_bits(&vs_pb);
for (mb_index = 0; mb_index < 5; mb_index++) {
for (j = 0; j < s->sys->bpm; j++) {
}
#if CONFIG_SMALL
-/* Converts run and level (where level != 0) pair into vlc, returning bit size */
+/* Converts run and level (where level != 0) pair into VLC, returning bit size */
static av_always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc)
{
int size;
if (level + 15 > 30U) {
bi->sign[i] = (level >> 31) & 1;
- /* weigh it and and shift down into range, adding for rounding */
+ /* weight it and and shift down into range, adding for rounding */
/* the extra division by a factor of 2^4 reverses the 8x expansion of the DCT
AND the 2x doubling of the weights */
level = (FFABS(level) * weight[i] + (1 << (dv_weight_bits+3))) >> (dv_weight_bits+4);
vsc_pack = buf + 80*5 + 48 + 5;
if ( *vsc_pack == dv_video_control ) {
apt = buf[4] & 0x07;
- is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07)));
+ is16_9 = (vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07);
avctx->sample_aspect_ratio = s->sys->sar[is16_9];
}
#if CONFIG_DVVIDEO_ENCODER
AVCodec ff_dvvideo_encoder = {
- "dvvideo",
- AVMEDIA_TYPE_VIDEO,
- CODEC_ID_DVVIDEO,
- sizeof(DVVideoContext),
- dvvideo_init_encoder,
- dvvideo_encode_frame,
+ .name = "dvvideo",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_DVVIDEO,
+ .priv_data_size = sizeof(DVVideoContext),
+ .init = dvvideo_init_encoder,
+ .encode = dvvideo_encode_frame,
.capabilities = CODEC_CAP_SLICE_THREADS,
.pix_fmts = (const enum PixelFormat[]) {PIX_FMT_YUV411P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
#if CONFIG_DVVIDEO_DECODER
AVCodec ff_dvvideo_decoder = {
- "dvvideo",
- AVMEDIA_TYPE_VIDEO,
- CODEC_ID_DVVIDEO,
- sizeof(DVVideoContext),
- dvvideo_init,
- NULL,
- dvvideo_close,
- dvvideo_decode_frame,
- CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
- NULL,
+ .name = "dvvideo",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_DVVIDEO,
+ .priv_data_size = sizeof(DVVideoContext),
+ .init = dvvideo_init,
+ .close = dvvideo_close,
+ .decode = dvvideo_decode_frame,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
};