mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 12:09:55 +00:00
AMV video encoder.
Authors are Vladimir Voroshilov and Dobrica Pavlinušić based on svn blame/log For full details of authorship see http://code.google.com/p/amv-codec-tools/ Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
ccecab4a0d
commit
f2f28861da
@ -71,7 +71,7 @@ void avcodec_register_all(void)
|
||||
REGISTER_ENCODER (A64MULTI, a64multi);
|
||||
REGISTER_ENCODER (A64MULTI5, a64multi5);
|
||||
REGISTER_DECODER (AASC, aasc);
|
||||
REGISTER_DECODER (AMV, amv);
|
||||
REGISTER_ENCDEC (AMV, amv);
|
||||
REGISTER_DECODER (ANM, anm);
|
||||
REGISTER_DECODER (ANSI, ansi);
|
||||
REGISTER_ENCDEC (ASV1, asv1);
|
||||
|
@ -200,6 +200,9 @@ void ff_mjpeg_encode_picture_header(MpegEncContext *s)
|
||||
|
||||
put_marker(&s->pb, SOI);
|
||||
|
||||
// hack for AMV mjpeg format
|
||||
if(s->avctx->codec_id == CODEC_ID_AMV) return;
|
||||
|
||||
jpeg_put_comments(s);
|
||||
|
||||
jpeg_table_header(s);
|
||||
@ -445,6 +448,28 @@ void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
||||
s->i_tex_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
// maximum over s->mjpeg_vsample[i]
|
||||
#define V_MAX 2
|
||||
static int amv_encode_picture(AVCodecContext *avctx,
|
||||
unsigned char *buf, int buf_size, void *data)
|
||||
{
|
||||
|
||||
AVFrame* pic=data;
|
||||
MpegEncContext *s = avctx->priv_data;
|
||||
int i;
|
||||
|
||||
//CODEC_FLAG_EMU_EDGE have to be cleared
|
||||
if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
|
||||
return -1;
|
||||
|
||||
//picture should be flipped upside-down
|
||||
for(i=0; i < 3; i++) {
|
||||
pic->data[i] += (pic->linesize[i] * (s->mjpeg_vsample[i] * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
|
||||
pic->linesize[i] *= -1;
|
||||
}
|
||||
return MPV_encode_picture(avctx,buf, buf_size, pic);
|
||||
}
|
||||
|
||||
AVCodec ff_mjpeg_encoder = {
|
||||
.name = "mjpeg",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
@ -456,3 +481,14 @@ AVCodec ff_mjpeg_encoder = {
|
||||
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_NONE},
|
||||
.long_name= NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
|
||||
};
|
||||
|
||||
AVCodec ff_amv_encoder = {
|
||||
"amv",
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_AMV,
|
||||
sizeof(MpegEncContext),
|
||||
MPV_encode_init,
|
||||
amv_encode_picture,
|
||||
MPV_encode_end,
|
||||
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, -1},
|
||||
};
|
||||
|
@ -265,6 +265,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|
||||
}
|
||||
break;
|
||||
case CODEC_ID_MJPEG:
|
||||
case CODEC_ID_AMV:
|
||||
if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUVJ422P &&
|
||||
((avctx->pix_fmt != PIX_FMT_YUV420P && avctx->pix_fmt != PIX_FMT_YUV422P) || avctx->strict_std_compliance>FF_COMPLIANCE_UNOFFICIAL)){
|
||||
av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
|
||||
@ -530,6 +531,11 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|
||||
if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO || s->codec_id==CODEC_ID_MJPEG){
|
||||
s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
|
||||
s->inter_quant_bias= 0;
|
||||
}else if(s->codec_id==CODEC_ID_AMV){
|
||||
s->intra_quant_bias= 0;
|
||||
s->inter_quant_bias= 0;
|
||||
s->fixed_qscale = 1;
|
||||
s->adaptive_quant = 0;
|
||||
}else{
|
||||
s->intra_quant_bias=0;
|
||||
s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x
|
||||
@ -540,6 +546,8 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|
||||
if(avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
|
||||
s->inter_quant_bias= avctx->inter_quant_bias;
|
||||
|
||||
av_log(avctx, AV_LOG_DEBUG, "intra_quant_bias = %d inter_quant_bias = %d\n",s->intra_quant_bias,s->inter_quant_bias);
|
||||
|
||||
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
|
||||
|
||||
if(avctx->codec_id == CODEC_ID_MPEG4 && s->avctx->time_base.den > (1<<16)-1){
|
||||
@ -564,6 +572,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|
||||
break;
|
||||
case CODEC_ID_LJPEG:
|
||||
case CODEC_ID_MJPEG:
|
||||
case CODEC_ID_AMV:
|
||||
s->out_format = FMT_MJPEG;
|
||||
s->intra_only = 1; /* force intra only for jpeg */
|
||||
if(avctx->codec->id == CODEC_ID_LJPEG && avctx->pix_fmt == PIX_FMT_BGRA){
|
||||
@ -1788,6 +1797,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x,
|
||||
h263_encode_mb(s, s->block, motion_x, motion_y);
|
||||
break;
|
||||
case CODEC_ID_MJPEG:
|
||||
case CODEC_ID_AMV:
|
||||
if (CONFIG_MJPEG_ENCODER)
|
||||
ff_mjpeg_encode_mb(s, s->block);
|
||||
break;
|
||||
|
@ -276,6 +276,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
|
||||
{ CODEC_ID_G2M, MKTAG('G', '2', 'M', '2') },
|
||||
{ CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') },
|
||||
{ CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') },
|
||||
{ CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') },
|
||||
{ CODEC_ID_NONE, 0 }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user