267
287
w+= EDGE_WIDTH*2;
268
288
h+= EDGE_WIDTH*2;
270
avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
271
pixel_size= picture.linesize[0]*8 / w;
272
//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", (int)picture.data[1], w, h, s->pix_fmt);
273
assert(pixel_size>=1);
274
//FIXME next ensures that linesize= 2^x uvlinesize, thats needed because some MC code assumes it
275
if(pixel_size == 3*8)
276
w= ALIGN(w, STRIDE_ALIGN<<h_chroma_shift);
278
w= ALIGN(pixel_size*w, STRIDE_ALIGN<<(h_chroma_shift+3)) / pixel_size;
279
size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
280
size[0] = picture.linesize[0] * h;
283
size[1]= size[2]= size[1]/2;
290
avcodec_align_dimensions(s, &w, &h);
292
ff_fill_linesize(&picture, s->pix_fmt, w);
295
picture.linesize[i] = ALIGN(picture.linesize[i], STRIDE_ALIGN);
297
tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h);
299
for (i=0; i<3 && picture.data[i+1]; i++)
300
size[i] = picture.data[i+1] - picture.data[i];
301
size[i] = tmpsize - (picture.data[i] - picture.data[0]);
287
303
buf->last_pic_num= -256*256*256*64;
288
304
memset(buf->base, 0, sizeof(buf->base));
289
305
memset(buf->data, 0, sizeof(buf->data));
291
for(i=0; i<3 && size[i]; i++){
307
for(i=0; i<4 && size[i]; i++){
292
308
const int h_shift= i==0 ? 0 : h_chroma_shift;
293
309
const int v_shift= i==0 ? 0 : v_chroma_shift;
411
430
#define AV_CODEC_DEFAULT_BITRATE 200*1000
413
432
static const AVOption options[]={
414
{"b", "set video bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE, INT_MIN, INT_MAX, V|A|E},
433
{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE, INT_MIN, INT_MAX, V|E},
434
{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, 64*1000, INT_MIN, INT_MAX, A|E},
415
435
{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE*20, 1, INT_MAX, V|E},
416
{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|A|E|D, "flags"},
436
{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, 0, UINT_MAX, V|A|E|D, "flags"},
417
437
{"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_4MV, INT_MIN, INT_MAX, V|E, "flags"},
418
438
{"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_OBMC, INT_MIN, INT_MAX, V|E, "flags"},
419
439
{"qpel", "use 1/4 pel motion compensation", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QPEL, INT_MIN, INT_MAX, V|E, "flags"},
452
472
{"local_header", "place global headers at every keyframe instead of in extradata", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_LOCAL_HEADER, INT_MIN, INT_MAX, V|E, "flags2"},
453
473
{"sub_id", NULL, OFFSET(sub_id), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
454
474
{"me_method", "set motion estimation method", OFFSET(me_method), FF_OPT_TYPE_INT, ME_EPZS, INT_MIN, INT_MAX, V|E, "me_method"},
475
#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
476
{"me", "set motion estimation method (deprecated, use me_method instead)", OFFSET(me_method), FF_OPT_TYPE_INT, ME_EPZS, INT_MIN, INT_MAX, V|E, "me_method"},
478
{"zero", "zero motion estimation (fastest)", 0, FF_OPT_TYPE_CONST, ME_ZERO, INT_MIN, INT_MAX, V|E, "me_method" },
479
{"full", "full motion estimation (slowest)", 0, FF_OPT_TYPE_CONST, ME_FULL, INT_MIN, INT_MAX, V|E, "me_method" },
480
{"epzs", "EPZS motion estimation (default)", 0, FF_OPT_TYPE_CONST, ME_EPZS, INT_MIN, INT_MAX, V|E, "me_method" },
481
{"log", "log motion estimation", 0, FF_OPT_TYPE_CONST, ME_LOG, INT_MIN, INT_MAX, V|E, "me_method" },
482
{"phods", "phods motion estimation", 0, FF_OPT_TYPE_CONST, ME_PHODS, INT_MIN, INT_MAX, V|E, "me_method" },
483
{"x1", "X1 motion estimation", 0, FF_OPT_TYPE_CONST, ME_X1, INT_MIN, INT_MAX, V|E, "me_method" },
484
{"hex", "hex motion estimation", 0, FF_OPT_TYPE_CONST, ME_HEX, INT_MIN, INT_MAX, V|E, "me_method" },
485
{"umh", "umh motion estimation", 0, FF_OPT_TYPE_CONST, ME_UMH, INT_MIN, INT_MAX, V|E, "me_method" },
486
{"iter", "iter motion estimation", 0, FF_OPT_TYPE_CONST, ME_ITER, INT_MIN, INT_MAX, V|E, "me_method" },
455
487
{"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
456
488
{"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, DEFAULT, INT_MIN, INT_MAX},
457
489
{"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, 12, INT_MIN, INT_MAX, V|E},
510
542
{"strict", "strictly conform to all the things in the spec no matter what consequences", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
511
543
{"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|E, "strict"},
512
544
{"inofficial", "allow inofficial extensions", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|E, "strict"},
513
{"experimental", "allow non standarized experimental things", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
514
{"b_qoffset", "qp offset between p and b frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
545
{"experimental", "allow non standardized experimental things", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
546
{"b_qoffset", "qp offset between P and B frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
515
547
{"er", "set error resilience strategy", OFFSET(error_resilience), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, A|V|D, "er"},
516
548
{"careful", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
517
549
{"compliant", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_COMPLIANT, INT_MIN, INT_MAX, V|D, "er"},
530
562
{"rc_eq", "set rate control equation", OFFSET(rc_eq), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E},
531
563
{"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
532
564
{"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
533
{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
565
{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|V|E},
534
566
{"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, 1.0, FLT_MIN, FLT_MAX, V|E},
535
{"i_qfactor", "qp factor between p and i frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, -0.8, -FLT_MAX, FLT_MAX, V|E},
536
{"i_qoffset", "qp offset between p and i frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, 0.0, -FLT_MAX, FLT_MAX, V|E},
567
{"i_qfactor", "qp factor between P and I frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, -0.8, -FLT_MAX, FLT_MAX, V|E},
568
{"i_qoffset", "qp offset between P and I frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, 0.0, -FLT_MAX, FLT_MAX, V|E},
537
569
{"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
538
570
{"dct", "DCT algorithm", OFFSET(dct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E, "dct"},
539
571
{"auto", "autoselect a good one (default)", 0, FF_OPT_TYPE_CONST, FF_DCT_AUTO, INT_MIN, INT_MAX, V|E, "dct"},
566
598
{"vp3", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_VP3, INT_MIN, INT_MAX, V|E|D, "idct"},
567
599
{"ipp", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_IPP, INT_MIN, INT_MAX, V|E|D, "idct"},
568
600
{"xvidmmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_XVIDMMX, INT_MIN, INT_MAX, V|E|D, "idct"},
601
{"faani", "floating point AAN IDCT", 0, FF_OPT_TYPE_CONST, FF_IDCT_FAAN, INT_MIN, INT_MAX, V|D|E, "idct"},
569
602
{"slice_count", NULL, OFFSET(slice_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
570
603
{"ec", "set error concealment strategy", OFFSET(error_concealment), FF_OPT_TYPE_FLAGS, 3, INT_MIN, INT_MAX, V|D, "ec"},
571
604
{"guess_mvs", "iterative motion vector (MV) search (slow)", 0, FF_OPT_TYPE_CONST, FF_EC_GUESS_MVS, INT_MIN, INT_MAX, V|D, "ec"},
635
668
{"coder", NULL, OFFSET(coder_type), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "coder"},
636
669
{"vlc", "variable length coder / huffman coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_VLC, INT_MIN, INT_MAX, V|E, "coder"},
637
670
{"ac", "arithmetic coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_AC, INT_MIN, INT_MAX, V|E, "coder"},
671
{"raw", "raw (no encoding)", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_RAW, INT_MIN, INT_MAX, V|E, "coder"},
672
{"rle", "run-length coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_RLE, INT_MIN, INT_MAX, V|E, "coder"},
673
{"deflate", "deflate-based coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_DEFLATE, INT_MIN, INT_MAX, V|E, "coder"},
638
674
{"context", "context model", OFFSET(context_model), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
639
675
{"slice_flags", NULL, OFFSET(slice_flags), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
640
676
{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
649
685
{"nr", "noise reduction", OFFSET(noise_reduction), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
650
686
{"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
651
687
{"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
652
{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|A|E|D, "flags2"},
688
{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP|CODEC_FLAG2_BIT_RESERVOIR, 0, UINT_MAX, V|A|E|D, "flags2"},
653
689
{"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
654
690
{"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"},
655
691
{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"},
666
702
{"skip_bottom", "number of macroblock rows at the bottom which are skipped", OFFSET(skip_bottom), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
667
703
{"profile", NULL, OFFSET(profile), FF_OPT_TYPE_INT, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
668
704
{"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
705
{"aac_main", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_MAIN, INT_MIN, INT_MAX, A|E, "profile"},
706
{"aac_low", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_LOW, INT_MIN, INT_MAX, A|E, "profile"},
707
{"aac_ssr", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_SSR, INT_MIN, INT_MAX, A|E, "profile"},
708
{"aac_ltp", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_AAC_LTP, INT_MIN, INT_MAX, A|E, "profile"},
669
709
{"level", NULL, OFFSET(level), FF_OPT_TYPE_INT, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
670
710
{"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
671
711
{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|D},
690
730
{"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BPYRAMID, INT_MIN, INT_MAX, V|E, "flags2"},
691
731
{"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_WPRED, INT_MIN, INT_MAX, V|E, "flags2"},
692
732
{"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MIXED_REFS, INT_MIN, INT_MAX, V|E, "flags2"},
693
{"8x8dct", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_8X8DCT, INT_MIN, INT_MAX, V|E, "flags2"},
733
{"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_8X8DCT, INT_MIN, INT_MAX, V|E, "flags2"},
694
734
{"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|E, "flags2"},
695
735
{"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_AUD, INT_MIN, INT_MAX, V|E, "flags2"},
696
736
{"brdo", "b-frame rate-distortion optimization", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BRDO, INT_MIN, INT_MAX, V|E, "flags2"},
697
{"skiprd", "RD optimal MB level residual skiping", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SKIP_RD, INT_MIN, INT_MAX, V|E, "flags2"},
737
{"skiprd", "RD optimal MB level residual skipping", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SKIP_RD, INT_MIN, INT_MAX, V|E, "flags2"},
698
738
{"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, 20.0, FLT_MIN, FLT_MAX, V|E},
699
739
{"deblockalpha", "in-loop deblocking filter alphac0 parameter", OFFSET(deblockalpha), FF_OPT_TYPE_INT, DEFAULT, -6, 6, V|E},
700
740
{"deblockbeta", "in-loop deblocking filter beta parameter", OFFSET(deblockbeta), FF_OPT_TYPE_INT, DEFAULT, -6, 6, V|E},
718
758
{"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
719
759
{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
720
760
{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
761
{"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"},
762
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
763
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D},
764
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
731
static AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
775
static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
733
void avcodec_get_context_defaults(AVCodecContext *s){
777
void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType codec_type){
734
779
memset(s, 0, sizeof(AVCodecContext));
736
781
s->av_class= &av_codec_context_class;
738
av_opt_set_defaults(s);
783
s->codec_type = codec_type;
784
if(codec_type == CODEC_TYPE_AUDIO)
785
flags= AV_OPT_FLAG_AUDIO_PARAM;
786
else if(codec_type == CODEC_TYPE_VIDEO)
787
flags= AV_OPT_FLAG_VIDEO_PARAM;
788
else if(codec_type == CODEC_TYPE_SUBTITLE)
789
flags= AV_OPT_FLAG_SUBTITLE_PARAM;
790
av_opt_set_defaults2(s, flags, flags);
740
792
s->rc_eq= "tex^qComp";
741
793
s->time_base= (AVRational){0,1};
751
803
s->reget_buffer= avcodec_default_reget_buffer;
754
AVCodecContext *avcodec_alloc_context(void){
806
AVCodecContext *avcodec_alloc_context2(enum CodecType codec_type){
755
807
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
757
809
if(avctx==NULL) return NULL;
759
avcodec_get_context_defaults(avctx);
811
avcodec_get_context_defaults2(avctx, codec_type);
816
void avcodec_get_context_defaults(AVCodecContext *s){
817
avcodec_get_context_defaults2(s, CODEC_TYPE_UNKNOWN);
820
AVCodecContext *avcodec_alloc_context(void){
821
return avcodec_alloc_context2(CODEC_TYPE_UNKNOWN);
764
824
void avcodec_get_frame_defaults(AVFrame *pic){
765
825
memset(pic, 0, sizeof(AVFrame));
1065
1132
snprintf(buf + strlen(buf), buf_size - strlen(buf),
1067
1134
enc->width, enc->height);
1068
if(av_log_level >= AV_LOG_DEBUG){
1135
if (enc->sample_aspect_ratio.num) {
1136
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
1137
enc->width*enc->sample_aspect_ratio.num,
1138
enc->height*enc->sample_aspect_ratio.den,
1140
snprintf(buf + strlen(buf), buf_size - strlen(buf),
1141
" [PAR %d:%d DAR %d:%d]",
1142
enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den,
1143
display_aspect_ratio.num, display_aspect_ratio.den);
1145
if(av_log_get_level() >= AV_LOG_DEBUG){
1069
1146
int g= ff_gcd(enc->time_base.num, enc->time_base.den);
1070
1147
snprintf(buf + strlen(buf), buf_size - strlen(buf),
1171
1253
return LIBAVCODEC_BUILD;
1174
static void init_crcs(void){
1175
av_crc04C11DB7= av_mallocz_static(sizeof(AVCRC) * 257);
1176
av_crc8005 = av_mallocz_static(sizeof(AVCRC) * 257);
1177
av_crc07 = av_mallocz_static(sizeof(AVCRC) * 257);
1178
av_crc_init(av_crc04C11DB7, 0, 32, 0x04c11db7, sizeof(AVCRC)*257);
1179
av_crc_init(av_crc8005 , 0, 16, 0x8005 , sizeof(AVCRC)*257);
1180
av_crc_init(av_crc07 , 0, 8, 0x07 , sizeof(AVCRC)*257);
1183
1256
void avcodec_init(void)
1185
static int inited = 0;
1258
static int initialized = 0;
1260
if (initialized != 0)
1191
1264
dsputil_static_init();
1195
1267
void avcodec_flush_buffers(AVCodecContext *avctx)
1318
1408
return fd; /* success */
1414
} VideoFrameSizeAbbr;
1418
int rate_num, rate_den;
1419
} VideoFrameRateAbbr;
1421
static VideoFrameSizeAbbr video_frame_size_abbrs[] = {
1422
{ "ntsc", 720, 480 },
1423
{ "pal", 720, 576 },
1424
{ "qntsc", 352, 240 }, /* VCD compliant NTSC */
1425
{ "qpal", 352, 288 }, /* VCD compliant PAL */
1426
{ "sntsc", 640, 480 }, /* square pixel NTSC */
1427
{ "spal", 768, 576 }, /* square pixel PAL */
1428
{ "film", 352, 240 },
1429
{ "ntsc-film", 352, 240 },
1430
{ "sqcif", 128, 96 },
1431
{ "qcif", 176, 144 },
1432
{ "cif", 352, 288 },
1433
{ "4cif", 704, 576 },
1434
{ "qqvga", 160, 120 },
1435
{ "qvga", 320, 240 },
1436
{ "vga", 640, 480 },
1437
{ "svga", 800, 600 },
1438
{ "xga", 1024, 768 },
1439
{ "uxga", 1600,1200 },
1440
{ "qxga", 2048,1536 },
1441
{ "sxga", 1280,1024 },
1442
{ "qsxga", 2560,2048 },
1443
{ "hsxga", 5120,4096 },
1444
{ "wvga", 852, 480 },
1445
{ "wxga", 1366, 768 },
1446
{ "wsxga", 1600,1024 },
1447
{ "wuxga", 1920,1200 },
1448
{ "woxga", 2560,1600 },
1449
{ "wqsxga", 3200,2048 },
1450
{ "wquxga", 3840,2400 },
1451
{ "whsxga", 6400,4096 },
1452
{ "whuxga", 7680,4800 },
1453
{ "cga", 320, 200 },
1454
{ "ega", 640, 350 },
1455
{ "hd480", 852, 480 },
1456
{ "hd720", 1280, 720 },
1457
{ "hd1080", 1920,1080 },
1460
static VideoFrameRateAbbr video_frame_rate_abbrs[]= {
1461
{ "ntsc", 30000, 1001 },
1463
{ "qntsc", 30000, 1001 }, /* VCD compliant NTSC */
1464
{ "qpal", 25, 1 }, /* VCD compliant PAL */
1465
{ "sntsc", 30000, 1001 }, /* square pixel NTSC */
1466
{ "spal", 25, 1 }, /* square pixel PAL */
1468
{ "ntsc-film", 24000, 1001 },
1471
int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str)
1474
int n = sizeof(video_frame_size_abbrs) / sizeof(VideoFrameSizeAbbr);
1476
int frame_width = 0, frame_height = 0;
1479
if (!strcmp(video_frame_size_abbrs[i].abbr, str)) {
1480
frame_width = video_frame_size_abbrs[i].width;
1481
frame_height = video_frame_size_abbrs[i].height;
1487
frame_width = strtol(p, (char **)&p, 10);
1490
frame_height = strtol(p, (char **)&p, 10);
1492
if (frame_width <= 0 || frame_height <= 0)
1494
*width_ptr = frame_width;
1495
*height_ptr = frame_height;
1499
int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg)
1502
int n = sizeof(video_frame_rate_abbrs) / sizeof(VideoFrameRateAbbr);
1505
/* First, we check our abbreviation table */
1506
for (i = 0; i < n; ++i)
1507
if (!strcmp(video_frame_rate_abbrs[i].abbr, arg)) {
1508
frame_rate->num = video_frame_rate_abbrs[i].rate_num;
1509
frame_rate->den = video_frame_rate_abbrs[i].rate_den;
1513
/* Then, we try to parse it as fraction */
1514
cp = strchr(arg, '/');
1516
cp = strchr(arg, ':');
1519
frame_rate->num = strtol(arg, &cpp, 10);
1520
if (cpp != arg || cpp == cp)
1521
frame_rate->den = strtol(cp+1, &cpp, 10);
1523
frame_rate->num = 0;
1526
/* Finally we give up and parse it as double */
1527
AVRational time_base = av_d2q(strtod(arg, 0), DEFAULT_FRAME_RATE_BASE);
1528
frame_rate->den = time_base.den;
1529
frame_rate->num = time_base.num;
1531
if (!frame_rate->num || !frame_rate->den)