42 9,10,11,12,13,14,15,16,
79 for(run=0; run<64; run++){
82 int alevel=
FFABS(level);
89 if (code < 111 /* rl->n */) {
117 for (ext.
num=1; ext.
num <= 4; ext.
num++) {
118 for (ext.
den=1; ext.
den <= 32; ext.
den++) {
173 else avctx->
level = 2;
176 av_log(avctx,
AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color sampling\n");
180 else if(avctx->
width <= 1440) avctx->
level = 6;
181 else avctx->
level = 4;
185 if ((avctx->
width & 0xFFF) == 0 && (avctx->
height & 0xFFF) == 1) {
191 if ((avctx->
width & 0xFFF) == 0 || (avctx->
height & 0xFFF) == 0) {
192 av_log(avctx,
AV_LOG_ERROR,
"Width or Height are not allowed to be multiplies of 4096\n"
202 av_log(avctx,
AV_LOG_ERROR,
"Drop frame time code only allowed with 1001/30000 fps\n");
229 unsigned int vbv_buffer_size;
233 float best_aspect_error= 1E10;
235 int constraint_parameter_flag;
237 if(aspect_ratio==0.0) aspect_ratio= 1.0;
249 float error= aspect_ratio;
257 if(error < best_aspect_error){
258 best_aspect_error= error;
278 vbv_buffer_size = (( 20 * s->
bit_rate) / (1151929 / 2)) * 8 * 1024;
279 vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
285 constraint_parameter_flag=
289 framerate.
num <= framerate.
den*30 &&
291 vbv_buffer_size <= 20 &&
295 put_bits(&s->
pb, 1, constraint_parameter_flag);
325 fps = (framerate.
num + framerate.
den/2)/ framerate.
den;
332 put_bits(&s->
pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
333 put_bits(&s->
pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
335 put_bits(&s->
pb, 6, (uint32_t)((time_code / fps) % 60));
336 put_bits(&s->
pb, 6, (uint32_t)((time_code % fps)));
462 int has_mv,
int field_motion)
473 int16_t
block[6][64],
474 int motion_x,
int motion_y,
478 const int mb_x = s->
mb_x;
479 const int mb_y = s->
mb_y;
484 for(i=0;i<mb_block_count;i++) {
486 cbp |= 1 << (mb_block_count - 1 - i);
535 if ((motion_x|motion_y) == 0) {
684 for(i=0;i<mb_block_count;i++) {
685 if (cbp & (1 << (mb_block_count - 1 - i))) {
712 int code, sign,
bits;
713 int bit_size = f_or_b_code - 1;
714 int range = 1 << bit_size;
720 code = (val >> bit_size) + 1;
721 bits = val & (range - 1);
726 code = (val >> bit_size) + 1;
727 bits = val & (range - 1);
770 for(i=-255; i<256; i++)
789 for(f_code=1; f_code<=
MAX_FCODE; f_code++){
795 int val, bit_size, code;
797 bit_size = f_code - 1;
803 code = (val >> bit_size) + 1;
816 for(f_code=
MAX_FCODE; f_code>0; f_code--){
817 for(mv=-(8<<f_code); mv<(8<<f_code); mv++){
844 if(((
unsigned) (diff+255)) >= 511){
853 if (component == 0) {
865 if (component == 0) {
883 int alevel,
level, last_non_zero,
dc,
diff, i, j,
run, last_index, sign;
891 component = (n <= 3 ? 0 : (n&1) + 1);
893 diff = dc - s->
last_dc[component];
903 if (abs(level) == 1) {
904 code = ((uint32_t)level >> 31);
915 last_non_zero = i - 1;
917 for(;i<=last_index;i++) {
923 run = i - last_non_zero - 1;
932 put_bits(&s->
pb, table_vlc[code][1]+1, (table_vlc[code][0]<<1) + sign);
935 put_bits(&s->
pb, table_vlc[111][1], table_vlc[111][0]);
956 put_bits(&s->
pb, table_vlc[112][1], table_vlc[112][0]);
959 #define OFFSET(x) offsetof(MpegEncContext, x)
960 #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
962 { "gop_timecode", "MPEG GOP Timecode in hh:mm:ss[:;.]ff format", OFFSET(tc_opt_str), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, VE },\
963 { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },\
964 { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE}, \
965 { "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
975 {
"non_linear_quant",
"Use nonlinear quantizer.",
OFFSET(q_scale_type),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
976 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(alternate_scan),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
981 #define mpeg12_class(x)\
982 static const AVClass mpeg## x ##_class = {\
983 .class_name = "mpeg" #x "video encoder",\
984 .item_name = av_default_item_name,\
985 .option = mpeg## x ##_options,\
986 .version = LIBAVUTIL_VERSION_INT,\
992 AVCodec ff_mpeg1video_encoder = {
993 .
name =
"mpeg1video",
1005 .priv_class = &mpeg1_class,
1009 .
name =
"mpeg2video",
1022 .priv_class = &mpeg2_class,