44 9,10,11,12,13,14,15,16,
82 for(run=0; run<64; run++){
85 int alevel=
FFABS(level);
92 if (code < 111 /* rl->
n */) {
120 for (ext.
num=1; ext.
num <= 4; ext.
num++) {
121 for (ext.
den=1; ext.
den <= 32; ext.
den++) {
176 else avctx->
level = 2;
179 av_log(avctx,
AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color sampling\n");
183 else if(avctx->
width <= 1440) avctx->
level = 6;
184 else avctx->
level = 4;
188 if ((avctx->
width & 0xFFF) == 0 && (avctx->
height & 0xFFF) == 1) {
194 if ((avctx->
width & 0xFFF) == 0 || (avctx->
height & 0xFFF) == 0) {
195 av_log(avctx,
AV_LOG_ERROR,
"Width or Height are not allowed to be multiplies of 4096\n"
205 av_log(avctx,
AV_LOG_ERROR,
"Drop frame time code only allowed with 1001/30000 fps\n");
232 unsigned int vbv_buffer_size;
236 float best_aspect_error= 1E10;
238 int constraint_parameter_flag;
240 if(aspect_ratio==0.0) aspect_ratio= 1.0;
252 float error= aspect_ratio;
260 if(error < best_aspect_error){
261 best_aspect_error= error;
281 vbv_buffer_size = (( 20 * s->
bit_rate) / (1151929 / 2)) * 8 * 1024;
282 vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
288 constraint_parameter_flag=
292 framerate.
num <= framerate.
den*30 &&
294 vbv_buffer_size <= 20 &&
298 put_bits(&s->
pb, 1, constraint_parameter_flag);
328 fps = (framerate.
num + framerate.
den/2)/ framerate.
den;
335 put_bits(&s->
pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
336 put_bits(&s->
pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
338 put_bits(&s->
pb, 6, (uint32_t)((time_code / fps) % 60));
339 put_bits(&s->
pb, 6, (uint32_t)((time_code % fps)));
465 int has_mv,
int field_motion)
476 int16_t
block[6][64],
477 int motion_x,
int motion_y,
481 const int mb_x = s->
mb_x;
482 const int mb_y = s->
mb_y;
487 for(i=0;i<mb_block_count;i++) {
489 cbp |= 1 << (mb_block_count - 1 - i);
538 if ((motion_x|motion_y) == 0) {
687 for(i=0;i<mb_block_count;i++) {
688 if (cbp & (1 << (mb_block_count - 1 - i))) {
715 int code, sign,
bits;
716 int bit_size = f_or_b_code - 1;
717 int range = 1 << bit_size;
723 code = (val >> bit_size) + 1;
724 bits = val & (range - 1);
729 code = (val >> bit_size) + 1;
730 bits = val & (range - 1);
773 for(i=-255; i<256; i++)
792 for(f_code=1; f_code<=
MAX_FCODE; f_code++){
798 int val, bit_size, code;
800 bit_size = f_code - 1;
806 code = (val >> bit_size) + 1;
819 for(f_code=
MAX_FCODE; f_code>0; f_code--){
820 for(mv=-(8<<f_code); mv<(8<<f_code); mv++){
847 if(((
unsigned) (diff+255)) >= 511){
856 if (component == 0) {
868 if (component == 0) {
886 int alevel,
level, last_non_zero,
dc,
diff, i, j,
run, last_index, sign;
894 component = (n <= 3 ? 0 : (n&1) + 1);
896 diff = dc - s->
last_dc[component];
906 if (abs(level) == 1) {
907 code = ((uint32_t)level >> 31);
918 last_non_zero = i - 1;
920 for(;i<=last_index;i++) {
926 run = i - last_non_zero - 1;
935 put_bits(&s->
pb, table_vlc[code][1]+1, (table_vlc[code][0]<<1) + sign);
938 put_bits(&s->
pb, table_vlc[111][1], table_vlc[111][0]);
959 put_bits(&s->
pb, table_vlc[112][1], table_vlc[112][0]);
962 #define OFFSET(x) offsetof(MpegEncContext, x)
963 #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
965 { "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 },\
966 { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },\
967 { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE}, \
968 { "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
978 {
"non_linear_quant",
"Use nonlinear quantizer.",
OFFSET(q_scale_type),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
979 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(alternate_scan),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
984 #define mpeg12_class(x)\
985 static const AVClass mpeg## x ##_class = {\
986 .class_name = "mpeg" #x "video encoder",\
987 .item_name = av_default_item_name,\
988 .option = mpeg## x ##_options,\
989 .version = LIBAVUTIL_VERSION_INT,\
995 AVCodec ff_mpeg1video_encoder = {
996 .
name =
"mpeg1video",
1008 .priv_class = &mpeg1_class,
1012 .
name =
"mpeg2video",
1025 .priv_class = &mpeg2_class,