return 0;
}
+static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
+{
+ if (!ff_dv_codec_profile(avctx)) {
+ av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video\n",
+ avctx->width, avctx->height, avcodec_get_pix_fmt_name(avctx->pix_fmt));
+ return -1;
+ }
+
+ return dvvideo_init(avctx);
+}
+
// #define VLC_DEBUG
// #define printf(...) av_log(NULL, AV_LOG_ERROR, __VA_ARGS__)
/* 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 get_bits_left(GetBitContext *s)
-{
- return s->size_in_bits - get_bits_count(s);
-}
-
static inline int put_bits_left(PutBitContext* s)
{
return (s->buf_end - s->buf) * 8 - put_bits_count(s);
PutBitContext pb, vs_pb;
GetBitContext gb;
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
- DECLARE_ALIGNED_16(DCTELEM, sblock[5*DV_MAX_BPM][64]);
- uint8_t mb_bit_buffer[80 + 4]; /* allow some slack */
- uint8_t vs_bit_buffer[5 * 80 + 4]; /* allow some slack */
+ 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 */
const int log2_blocksize = 3-s->avctx->lowres;
int is_field_mode[5];
assert((((int)mb_bit_buffer) & 7) == 0);
assert((((int)vs_bit_buffer) & 7) == 0);
- memset(sblock, 0, sizeof(sblock));
+ memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));
/* pass 1 : read DC and AC coefficients in blocks */
buf_ptr = &s->buf[work_chunk->buf_offset*80];
dv_decode_ac(&gb, mb, block);
}
if (mb->pos >= 64 && mb->pos < 127)
- av_log(NULL, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos);
+ av_log(avctx, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos);
block += 64;
mb++;
}
{
const int *weight;
const uint8_t* zigzag_scan;
- DECLARE_ALIGNED_16(DCTELEM, blk[64]);
+ LOCAL_ALIGNED_16(DCTELEM, blk, [64]);
int i, area;
/* We offer two different methods for class number assignment: the
method suggested in SMPTE 314M Table 22, and an improved
} else {
/* We rely on the fact that encoding all zeros leads to an immediate EOB,
which is precisely what the spec calls for in the "dummy" blocks. */
- memset(blk, 0, sizeof(blk));
+ memset(blk, 0, 64*sizeof(*blk));
bi->dct_mode = 0;
}
bi->mb[0] = blk[0];
if (enc_blks[j].partial_bit_count)
pb = dv_encode_ac(&enc_blks[j], pb, &pbs[s->sys->bpm*5]);
if (enc_blks[j].partial_bit_count)
- av_log(NULL, AV_LOG_ERROR, "ac bitstream overflow\n");
+ av_log(avctx, AV_LOG_ERROR, "ac bitstream overflow\n");
}
for (j=0; j<5*s->sys->bpm; j++) {
int buf_size = avpkt->size;
DVVideoContext *s = avctx->priv_data;
- s->sys = dv_frame_profile(s->sys, buf, buf_size);
+ s->sys = ff_dv_frame_profile(s->sys, buf, buf_size);
if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) {
av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");
return -1; /* NOTE: we only accept several full frames */
{
DVVideoContext *s = c->priv_data;
- s->sys = dv_codec_profile(c);
+ s->sys = ff_dv_codec_profile(c);
if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys))
return -1;
CODEC_TYPE_VIDEO,
CODEC_ID_DVVIDEO,
sizeof(DVVideoContext),
- dvvideo_init,
+ dvvideo_init_encoder,
dvvideo_encode_frame,
.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)"),