*/
#include "libavutil/intmath.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "dwt.h"
}Plane;
typedef struct SnowContext{
-
+ AVClass *class;
AVCodecContext *avctx;
RangeCoder c;
DSPContext dsp;
int me_cache[ME_CACHE_SIZE];
int me_cache_generation;
slice_buffer sb;
+ int memc_only;
MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX)
}
AVCodec ff_snow_decoder = {
- "snow",
- AVMEDIA_TYPE_VIDEO,
- CODEC_ID_SNOW,
- sizeof(SnowContext),
- decode_init,
- NULL,
- decode_end,
- decode_frame,
- CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
- NULL,
+ .name = "snow",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_SNOW,
+ .priv_data_size = sizeof(SnowContext),
+ .init = decode_init,
+ .close = decode_end,
+ .decode = decode_frame,
+ .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
.long_name = NULL_IF_CONFIG_SMALL("Snow"),
};
static int qscale2qlog(int qscale){
return rint(QROOT*log(qscale / (float)FF_QP2LAMBDA)/log(2))
- + 61*QROOT/8; //<64 >60
+ + 61*QROOT/8; ///< 64 > 60
}
static int ratecontrol_1pass(SnowContext *s, AVFrame *pict)
frame_start(s);
s->m.current_picture_ptr= &s->m.current_picture;
- s->m.last_picture.pts= s->m.current_picture.pts;
- s->m.current_picture.pts= pict->pts;
+ s->m.last_picture.f.pts = s->m.current_picture.f.pts;
+ s->m.current_picture.f.pts = pict->pts;
if(pict->pict_type == AV_PICTURE_TYPE_P){
int block_width = (width +15)>>4;
int block_height= (height+15)>>4;
assert(s->last_picture[0].data[0]);
s->m.avctx= s->avctx;
- s->m.current_picture.data[0]= s->current_picture.data[0];
- s->m. last_picture.data[0]= s->last_picture[0].data[0];
- s->m. new_picture.data[0]= s-> input_picture.data[0];
+ s->m.current_picture.f.data[0] = s->current_picture.data[0];
+ s->m. last_picture.f.data[0] = s->last_picture[0].data[0];
+ s->m. new_picture.f.data[0] = s-> input_picture.data[0];
s->m. last_picture_ptr= &s->m. last_picture;
s->m.linesize=
- s->m. last_picture.linesize[0]=
- s->m. new_picture.linesize[0]=
- s->m.current_picture.linesize[0]= stride;
+ s->m. last_picture.f.linesize[0] =
+ s->m. new_picture.f.linesize[0] =
+ s->m.current_picture.f.linesize[0] = stride;
s->m.uvlinesize= s->current_picture.linesize[1];
s->m.width = width;
s->m.height= height;
int x, y;
// int bits= put_bits_count(&s->c.pb);
- if(!(avctx->flags2 & CODEC_FLAG2_MEMC_ONLY)){
+ if (!s->memc_only) {
//FIXME optimize
if(pict->data[plane_index]) //FIXME gray hack
for(y=0; y<h; y++){
s->current_picture.quality = pict->quality;
s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start);
s->m.p_tex_bits = s->m.frame_bits - s->m.misc_bits - s->m.mv_bits;
- s->m.current_picture.display_picture_number =
- s->m.current_picture.coded_picture_number = avctx->frame_number;
- s->m.current_picture.quality = pict->quality;
+ s->m.current_picture.f.display_picture_number =
+ s->m.current_picture.f.coded_picture_number = avctx->frame_number;
+ s->m.current_picture.f.quality = pict->quality;
s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start);
if(s->pass1_rc)
if (ff_rate_estimate_qscale(&s->m, 0) < 0)
return 0;
}
+#define OFFSET(x) offsetof(SnowContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "memc_only", "Only do ME/MC (I frames -> ref, P frame -> ME+MC).", OFFSET(memc_only), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
+ { NULL },
+};
+
+static const AVClass snowenc_class = {
+ .class_name = "snow encoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_snow_encoder = {
- "snow",
- AVMEDIA_TYPE_VIDEO,
- CODEC_ID_SNOW,
- sizeof(SnowContext),
- encode_init,
- encode_frame,
- encode_end,
+ .name = "snow",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_SNOW,
+ .priv_data_size = sizeof(SnowContext),
+ .init = encode_init,
+ .encode = encode_frame,
+ .close = encode_end,
.long_name = NULL_IF_CONFIG_SMALL("Snow"),
+ .priv_class = &snowenc_class,
};
#endif