43 9,10,11,12,13,14,15,16,
80 for(run=0; run<64; run++){
83 int alevel=
FFABS(level);
90 if (code < 111 /* rl->n */) {
118 for (ext.
num=1; ext.
num <= 4; ext.
num++) {
119 for (ext.
den=1; ext.
den <= 32; ext.
den++) {
174 else avctx->
level = 2;
177 av_log(avctx,
AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color sampling\n");
181 else if(avctx->
width <= 1440) avctx->
level = 6;
182 else avctx->
level = 4;
186 if ((avctx->
width & 0xFFF) == 0 && (avctx->
height & 0xFFF) == 1) {
192 if ((avctx->
width & 0xFFF) == 0 || (avctx->
height & 0xFFF) == 0) {
193 av_log(avctx,
AV_LOG_ERROR,
"Width or Height are not allowed to be multiplies of 4096\n"
203 av_log(avctx,
AV_LOG_ERROR,
"Drop frame time code only allowed with 1001/30000 fps\n");
230 unsigned int vbv_buffer_size;
234 float best_aspect_error= 1E10;
236 int constraint_parameter_flag;
238 if(aspect_ratio==0.0) aspect_ratio= 1.0;
250 float error= aspect_ratio;
258 if(error < best_aspect_error){
259 best_aspect_error= error;
279 vbv_buffer_size = (( 20 * s->
bit_rate) / (1151929 / 2)) * 8 * 1024;
280 vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
286 constraint_parameter_flag=
290 framerate.
num <= framerate.
den*30 &&
292 vbv_buffer_size <= 20 &&
296 put_bits(&s->
pb, 1, constraint_parameter_flag);
326 fps = (framerate.
num + framerate.
den/2)/ framerate.
den;
333 put_bits(&s->
pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
334 put_bits(&s->
pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
336 put_bits(&s->
pb, 6, (uint32_t)((time_code / fps) % 60));
337 put_bits(&s->
pb, 6, (uint32_t)((time_code % fps)));
463 int has_mv,
int field_motion)
475 int motion_x,
int motion_y,
479 const int mb_x = s->
mb_x;
480 const int mb_y = s->
mb_y;
485 for(i=0;i<mb_block_count;i++) {
487 cbp |= 1 << (mb_block_count - 1 - i);
536 if ((motion_x|motion_y) == 0) {
685 for(i=0;i<mb_block_count;i++) {
686 if (cbp & (1 << (mb_block_count - 1 - i))) {
713 int code, sign,
bits;
714 int bit_size = f_or_b_code - 1;
715 int range = 1 << bit_size;
721 code = (val >> bit_size) + 1;
722 bits = val & (range - 1);
727 code = (val >> bit_size) + 1;
728 bits = val & (range - 1);
771 for(i=-255; i<256; i++)
790 for(f_code=1; f_code<=
MAX_FCODE; f_code++){
796 int val, bit_size, code;
798 bit_size = f_code - 1;
804 code = (val >> bit_size) + 1;
817 for(f_code=
MAX_FCODE; f_code>0; f_code--){
818 for(mv=-(8<<f_code); mv<(8<<f_code); mv++){
845 if(((
unsigned) (diff+255)) >= 511){
854 if (component == 0) {
866 if (component == 0) {
884 int alevel,
level, last_non_zero, dc,
diff, i, j,
run, last_index, sign;
892 component = (n <= 3 ? 0 : (n&1) + 1);
894 diff = dc - s->
last_dc[component];
904 if (abs(level) == 1) {
905 code = ((uint32_t)level >> 31);
916 last_non_zero = i - 1;
918 for(;i<=last_index;i++) {
924 run = i - last_non_zero - 1;
933 put_bits(&s->
pb, table_vlc[code][1]+1, (table_vlc[code][0]<<1) + sign);
936 put_bits(&s->
pb, table_vlc[111][1], table_vlc[111][0]);
957 put_bits(&s->
pb, table_vlc[112][1], table_vlc[112][0]);
960 #define OFFSET(x) offsetof(MpegEncContext, x)
961 #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
963 { "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 },\
964 { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },\
965 { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE}, \
966 { "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
976 {
"non_linear_quant",
"Use nonlinear quantizer.",
OFFSET(q_scale_type),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
977 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(alternate_scan),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
982 #define mpeg12_class(x)\
983 static const AVClass mpeg## x ##_class = {\
984 .class_name = "mpeg" #x "video encoder",\
985 .item_name = av_default_item_name,\
986 .option = mpeg## x ##_options,\
987 .version = LIBAVUTIL_VERSION_INT,\
993 AVCodec ff_mpeg1video_encoder = {
994 .
name =
"mpeg1video",
1006 .priv_class = &mpeg1_class,
1010 .
name =
"mpeg2video",
1023 .priv_class = &mpeg2_class,