put_bits(pb, 1, 0);
}
+/**
+ * init s->current_picture.qscale_table from s->lambda_table
+ */
+void ff_init_qscale_tab(MpegEncContext *s){
+ int8_t * const qscale_table= s->current_picture.qscale_table;
+ int i;
+
+ for(i=0; i<s->mb_num; i++){
+ unsigned int lam= s->lambda_table[ s->mb_index2xy[i] ];
+ int qp= (lam*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
+ qscale_table[ s->mb_index2xy[i] ]= av_clip(qp, s->avctx->qmin, s->avctx->qmax);
+ }
+}
+
static void copy_picture_attributes(MpegEncContext *s, AVFrame *dst, AVFrame *src){
int i;
return -1;
}
+ if ((s->codec_id == CODEC_ID_MPEG4 || s->codec_id == CODEC_ID_H263 ||
+ s->codec_id == CODEC_ID_H263P) &&
+ (avctx->sample_aspect_ratio.num > 255 || avctx->sample_aspect_ratio.den > 255)) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid pixel aspect ratio %i/%i, limit is 255/255\n",
+ avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
+ return -1;
+ }
+
if((s->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME|CODEC_FLAG_ALT_SCAN))
&& s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG2VIDEO){
av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
return -1;
}
+ if(s->avctx->thread_count < 1){
+ av_log(avctx, AV_LOG_ERROR, "automatic thread number detection not supported by codec, patch welcome\n");
+ return -1;
+ }
+
if(s->avctx->thread_count > 1)
s->rtp_mode= 1;
case CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
s->intra_only = 1; /* force intra only for jpeg */
- s->mjpeg_vsample[0] = 2;
- s->mjpeg_vsample[1] = 2>>chroma_v_shift;
- s->mjpeg_vsample[2] = 2>>chroma_v_shift;
- s->mjpeg_hsample[0] = 2;
- s->mjpeg_hsample[1] = 2>>chroma_h_shift;
- s->mjpeg_hsample[2] = 2>>chroma_h_shift;
+ if(avctx->codec->id == CODEC_ID_LJPEG && avctx->pix_fmt == PIX_FMT_BGRA){
+ s->mjpeg_vsample[0] = s->mjpeg_hsample[0] =
+ s->mjpeg_vsample[1] = s->mjpeg_hsample[1] =
+ s->mjpeg_vsample[2] = s->mjpeg_hsample[2] = 1;
+ }else{
+ s->mjpeg_vsample[0] = 2;
+ s->mjpeg_vsample[1] = 2>>chroma_v_shift;
+ s->mjpeg_vsample[2] = 2>>chroma_v_shift;
+ s->mjpeg_hsample[0] = 2;
+ s->mjpeg_hsample[1] = 2>>chroma_h_shift;
+ s->mjpeg_hsample[2] = 2>>chroma_h_shift;
+ }
if (!(CONFIG_MJPEG_ENCODER || CONFIG_LJPEG_ENCODER)
|| ff_mjpeg_encode_init(s) < 0)
return -1;
pic->data[i]= pic_arg->data[i];
pic->linesize[i]= pic_arg->linesize[i];
}
- alloc_picture(s, (Picture*)pic, 1);
+ ff_alloc_picture(s, (Picture*)pic, 1);
}else{
i= ff_find_unused_picture(s, 0);
pic= (AVFrame*)&s->picture[i];
pic->reference= 3;
- alloc_picture(s, (Picture*)pic, 0);
+ ff_alloc_picture(s, (Picture*)pic, 0);
if( pic->data[0] + INPLACE_OFFSET == pic_arg->data[0]
&& pic->data[1] + INPLACE_OFFSET == pic_arg->data[1]
Picture *pic= &s->picture[i];
pic->reference = s->reordered_input_picture[0]->reference;
- alloc_picture(s, pic, 0);
+ ff_alloc_picture(s, pic, 0);
/* mark us unused / free shared pic */
if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_INTERNAL)
if (encode_picture(s, s->picture_number) < 0)
return -1;
- avctx->real_pict_num = s->picture_number;
avctx->header_bits = s->header_bits;
avctx->mv_bits = s->mv_bits;
avctx->misc_bits = s->misc_bits;
case CODEC_ID_FLV1:
case CODEC_ID_RV10:
case CODEC_ID_RV20:
- if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER ||
- CONFIG_FLV_ENCODER || CONFIG_RV10_ENCODER || CONFIG_RV20_ENCODER)
+ if (CONFIG_H263_ENCODER)
h263_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MJPEG:
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
- if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER || CONFIG_FLV_ENCODER)
+ if (CONFIG_H263_ENCODER)
s->gob_index = ff_h263_get_gob_height(s);
break;
case CODEC_ID_MPEG4:
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
- if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER)
+ if (CONFIG_H263_ENCODER)
h263_encode_gob_header(s, mb_y);
break;
}
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
- if (CONFIG_H263_ENCODER||CONFIG_H263P_ENCODER||CONFIG_FLV_ENCODER)
+ if (CONFIG_H263_ENCODER)
ff_clean_h263_qscales(s);
break;
+ default:
+ ff_init_qscale_tab(s);
}
s->lambda= s->lambda_table[0];
s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){
if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){
- s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
+ s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
}
}
- s->avctx->execute(s->avctx, estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
+ s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
}else /* if(s->pict_type == FF_I_TYPE) */{
/* I-Frame */
for(i=0; i<s->mb_stride*s->mb_height; i++)
if(!s->fixed_qscale){
/* finding spatial complexity for I-frame rate control */
- s->avctx->execute(s->avctx, mb_var_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
+ s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
}
}
for(i=1; i<s->avctx->thread_count; i++){
for(i=1; i<s->avctx->thread_count; i++){
update_duplicate_context_after_me(s->thread_context[i], s);
}
- s->avctx->execute(s->avctx, encode_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
+ s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
for(i=1; i<s->avctx->thread_count; i++){
merge_context_after_encode(s, s->thread_context[i]);
}
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
};
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"),
};
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
- .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV)"),
-};
-
-AVCodec rv10_encoder = {
- "rv10",
- CODEC_TYPE_VIDEO,
- CODEC_ID_RV10,
- sizeof(MpegEncContext),
- MPV_encode_init,
- MPV_encode_picture,
- MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
- .long_name= NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
-};
-
-AVCodec rv20_encoder = {
- "rv20",
- CODEC_TYPE_VIDEO,
- CODEC_ID_RV20,
- sizeof(MpegEncContext),
- MPV_encode_init,
- MPV_encode_picture,
- MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
- .long_name= NULL_IF_CONFIG_SMALL("RealVideo 2.0"),
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
};
AVCodec mpeg4_encoder = {
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.capabilities= CODEC_CAP_DELAY,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
};
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
};
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
};
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
};
MPV_encode_init,
MPV_encode_picture,
MPV_encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
};