Originally committed as revision 4891 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -1982,7 +1982,7 @@ typedef struct AVCodecContext { | |||
| * - decoding: unused | |||
| */ | |||
| int directpred; | |||
| /** | |||
| * audio cutoff bandwidth (0 means "automatic") . Currently used only by FAAC | |||
| * - encoding: set by user. | |||
| @@ -4310,10 +4310,10 @@ static int decode_slice_header(H264Context *h){ | |||
| if(h->sps.timing_info_present_flag){ | |||
| s->avctx->time_base= (AVRational){h->sps.num_units_in_tick * 2, h->sps.time_scale}; | |||
| if(h->x264_build > 0 && h->x264_build < 44) | |||
| s->avctx->time_base.den *= 2; | |||
| av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den, | |||
| s->avctx->time_base.num, s->avctx->time_base.den, 1<<30); | |||
| if(h->x264_build > 0 && h->x264_build < 44) | |||
| s->avctx->time_base.den *= 2; | |||
| av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den, | |||
| s->avctx->time_base.num, s->avctx->time_base.den, 1<<30); | |||
| } | |||
| } | |||
| @@ -72,7 +72,7 @@ static void reset_ls_coding_parameters(MJpegDecodeContext *s, int reset_all){ | |||
| int factor; | |||
| if(s->maxval==0 || reset_all) s->maxval= (1<<s->bits) - 1; | |||
| if(s->maxval >=128){ | |||
| factor= (FFMIN(s->maxval, 4096) + 128)>>8; | |||
| @@ -103,7 +103,7 @@ static int decode_lse(MJpegDecodeContext *s) | |||
| /* XXX: verify len field validity */ | |||
| len = get_bits(&s->gb, 16); | |||
| id = get_bits(&s->gb, 8); | |||
| switch(id){ | |||
| case 1: | |||
| s->maxval= get_bits(&s->gb, 16); | |||
| @@ -111,7 +111,7 @@ static int decode_lse(MJpegDecodeContext *s) | |||
| s->t2= get_bits(&s->gb, 16); | |||
| s->t3= get_bits(&s->gb, 16); | |||
| s->reset= get_bits(&s->gb, 16); | |||
| reset_ls_coding_parameters(s, 0); | |||
| //FIXME quant table? | |||
| break; | |||
| @@ -145,15 +145,15 @@ static inline void update_vlc_state(VlcState * const state, const int v, int hal | |||
| if(drift <= -count){ | |||
| if(state->bias > -128) state->bias--; | |||
| drift += count; | |||
| if(drift <= -count) | |||
| drift= -count + 1; | |||
| }else if(drift > 0){ | |||
| if(state->bias < 127) state->bias++; | |||
| drift -= count; | |||
| if(drift > 0) | |||
| if(drift > 0) | |||
| drift= 0; | |||
| } | |||
| @@ -169,7 +169,7 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| for(x=0; x < w; x++){ | |||
| int l, t, lt, rt; | |||
| t= R(last, 0); | |||
| if(x){ | |||
| l = t; | |||
| @@ -181,11 +181,11 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| if(x<w-1) rt= R(last, x+1); | |||
| else rt= t; | |||
| hr_gradient= rt - t; | |||
| hl_gradient= t - lt; | |||
| v_gradient= lt - l; | |||
| context= quantize(s, v_gradient) + 9*(quantize(s, hl_gradient) + 9*quantize(s, hr_gradient)); | |||
| if(context){ | |||
| @@ -206,7 +206,7 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| k++; | |||
| i += i; | |||
| } | |||
| v= get_ur_golomb_jpegls(gb, k, LIMIT-qbpp, qbpp); | |||
| #if 1 | |||
| v++; | |||
| @@ -222,9 +222,9 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| #endif | |||
| update_vlc_state(state, v, half_count); | |||
| if(sign) v= -v; | |||
| if(is_uint8) ((uint8_t *)dst)[x]= (pred + v) & maxval; | |||
| else ((uint16_t*)dst)[x]= (pred + v) & maxval; | |||
| }else{ | |||
| @@ -234,28 +234,28 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| run_count = 1<<log2_run[run_index]; | |||
| if(x + run_count > w) run_count= w - x; | |||
| else run_index++; | |||
| for(; run_count; run_count--){ | |||
| if(is_uint8) ((uint8_t *)dst)[x++]= l; | |||
| else ((uint16_t*)dst)[x++]= l; | |||
| } | |||
| if(x >= w) return 0; | |||
| if(x >= w) return 0; | |||
| } | |||
| run_count= get_bits(&s->gb, log2_run[run_index]); | |||
| for(; run_count; run_count--){ | |||
| if(is_uint8) ((uint8_t *)dst)[x++]= l; | |||
| else ((uint16_t*)dst)[x++]= l; | |||
| } | |||
| if(run_index) run_index--; | |||
| if(x >= w) return 0; | |||
| t= R(last, 0); | |||
| RItype= (l==t); | |||
| if(l==t){ | |||
| state= 366; | |||
| @@ -264,21 +264,21 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| state= 365; | |||
| temp= state->error_sum; | |||
| } | |||
| pred= t; | |||
| sign= l > t; | |||
| i= state->count; | |||
| k=0; | |||
| while(i < temp){ //FIXME optimize | |||
| k++; | |||
| i += i; | |||
| } | |||
| assert(Errval != 0); | |||
| map = (k==0 && 2*Nn < state->count) == (Errval>0); | |||
| map = (k==0 && 2*Nn < state->count) == (Errval>0); | |||
| if(run_count==0 && run_mode==1){ | |||
| if(get_bits1(&s->gb)){ | |||
| run_count = 1<<log2_run[run_index]; | |||
| @@ -298,7 +298,7 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| if(diff>=0) diff++; | |||
| }else | |||
| diff=0; | |||
| } | |||
| } | |||
| @@ -316,7 +316,7 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| x = 0; | |||
| y = 0; | |||
| linesize= s->linesize[c]; | |||
| for(j=0; j<n; j++) { | |||
| int pred; | |||
| @@ -334,7 +334,7 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); | |||
| } | |||
| } | |||
| if (s->interlaced && s->bottom_field) | |||
| ptr += linesize >> 1; | |||
| *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform); | |||
| @@ -356,7 +356,7 @@ static inline int ls_decode_line(MJpegDecodeContext *s, void *lastv, void *dstv, | |||
| x = 0; | |||
| y = 0; | |||
| linesize= s->linesize[c]; | |||
| for(j=0; j<n; j++) { | |||
| int pred; | |||
| @@ -119,7 +119,7 @@ void *av_realloc(void *ptr, unsigned int size) | |||
| /** | |||
| * Free memory which has been allocated with av_malloc(z)() or av_realloc(). | |||
| * NOTE: ptr = NULL is explicetly allowed | |||
| * NOTE: ptr = NULL is explicetly allowed | |||
| * Note2: it is recommanded that you use av_freep() instead | |||
| */ | |||
| void av_free(void *ptr) | |||
| @@ -761,38 +761,38 @@ static const int ac3_sample_rates[4] = { | |||
| }; | |||
| static const int ac3_frame_sizes[64][3] = { | |||
| { 64, 69, 96 }, | |||
| { 64, 70, 96 }, | |||
| { 80, 87, 120 }, | |||
| { 80, 88, 120 }, | |||
| { 96, 104, 144 }, | |||
| { 96, 105, 144 }, | |||
| { 112, 121, 168 }, | |||
| { 112, 122, 168 }, | |||
| { 128, 139, 192 }, | |||
| { 128, 140, 192 }, | |||
| { 160, 174, 240 }, | |||
| { 160, 175, 240 }, | |||
| { 192, 208, 288 }, | |||
| { 192, 209, 288 }, | |||
| { 224, 243, 336 }, | |||
| { 224, 244, 336 }, | |||
| { 256, 278, 384 }, | |||
| { 256, 279, 384 }, | |||
| { 320, 348, 480 }, | |||
| { 320, 349, 480 }, | |||
| { 384, 417, 576 }, | |||
| { 384, 418, 576 }, | |||
| { 448, 487, 672 }, | |||
| { 448, 488, 672 }, | |||
| { 512, 557, 768 }, | |||
| { 512, 558, 768 }, | |||
| { 640, 696, 960 }, | |||
| { 640, 697, 960 }, | |||
| { 768, 835, 1152 }, | |||
| { 768, 836, 1152 }, | |||
| { 896, 975, 1344 }, | |||
| { 896, 976, 1344 }, | |||
| { 64, 69, 96 }, | |||
| { 64, 70, 96 }, | |||
| { 80, 87, 120 }, | |||
| { 80, 88, 120 }, | |||
| { 96, 104, 144 }, | |||
| { 96, 105, 144 }, | |||
| { 112, 121, 168 }, | |||
| { 112, 122, 168 }, | |||
| { 128, 139, 192 }, | |||
| { 128, 140, 192 }, | |||
| { 160, 174, 240 }, | |||
| { 160, 175, 240 }, | |||
| { 192, 208, 288 }, | |||
| { 192, 209, 288 }, | |||
| { 224, 243, 336 }, | |||
| { 224, 244, 336 }, | |||
| { 256, 278, 384 }, | |||
| { 256, 279, 384 }, | |||
| { 320, 348, 480 }, | |||
| { 320, 349, 480 }, | |||
| { 384, 417, 576 }, | |||
| { 384, 418, 576 }, | |||
| { 448, 487, 672 }, | |||
| { 448, 488, 672 }, | |||
| { 512, 557, 768 }, | |||
| { 512, 558, 768 }, | |||
| { 640, 696, 960 }, | |||
| { 640, 697, 960 }, | |||
| { 768, 835, 1152 }, | |||
| { 768, 836, 1152 }, | |||
| { 896, 975, 1344 }, | |||
| { 896, 976, 1344 }, | |||
| { 1024, 1114, 1536 }, | |||
| { 1024, 1115, 1536 }, | |||
| { 1152, 1253, 1728 }, | |||
| @@ -812,7 +812,7 @@ static const int ac3_channels[8] = { | |||
| }; | |||
| static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, | |||
| int *bit_rate) | |||
| int *bit_rate) | |||
| { | |||
| unsigned int fscod, frmsizecod, acmod, bsid, lfeon; | |||
| GetBitContext bits; | |||
| @@ -820,26 +820,26 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, | |||
| init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8); | |||
| if(get_bits(&bits, 16) != 0x0b77) | |||
| return 0; | |||
| return 0; | |||
| get_bits(&bits, 16); /* crc */ | |||
| get_bits(&bits, 16); /* crc */ | |||
| fscod = get_bits(&bits, 2); | |||
| frmsizecod = get_bits(&bits, 6); | |||
| if(!ac3_sample_rates[fscod]) | |||
| return 0; | |||
| return 0; | |||
| bsid = get_bits(&bits, 5); | |||
| if(bsid > 8) | |||
| return 0; | |||
| get_bits(&bits, 3); /* bsmod */ | |||
| return 0; | |||
| get_bits(&bits, 3); /* bsmod */ | |||
| acmod = get_bits(&bits, 3); | |||
| if(acmod & 1 && acmod != 1) | |||
| get_bits(&bits, 2); /* cmixlev */ | |||
| get_bits(&bits, 2); /* cmixlev */ | |||
| if(acmod & 4) | |||
| get_bits(&bits, 2); /* surmixlev */ | |||
| get_bits(&bits, 2); /* surmixlev */ | |||
| if(acmod & 2) | |||
| get_bits(&bits, 2); /* dsurmod */ | |||
| get_bits(&bits, 2); /* dsurmod */ | |||
| lfeon = get_bits(&bits, 1); | |||
| *sample_rate = ac3_sample_rates[fscod]; | |||
| @@ -881,7 +881,7 @@ static int ac3_parse(AVCodecParserContext *s1, | |||
| s->inbuf_ptr += len; | |||
| buf_size -= len; | |||
| if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) { | |||
| len = ac3_sync(s->inbuf, &channels, &sample_rate, &bit_rate); | |||
| len = ac3_sync(s->inbuf, &channels, &sample_rate, &bit_rate); | |||
| if (len == 0) { | |||
| /* no sync found : move by one byte (inefficient, but simple!) */ | |||
| memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1); | |||
| @@ -892,7 +892,7 @@ static int ac3_parse(AVCodecParserContext *s1, | |||
| avctx->sample_rate = sample_rate; | |||
| /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */ | |||
| if(avctx->channels!=1 && avctx->channels!=2){ | |||
| avctx->channels = channels; | |||
| avctx->channels = channels; | |||
| } | |||
| avctx->bit_rate = bit_rate; | |||
| avctx->frame_size = 6 * 256; | |||
| @@ -3021,7 +3021,7 @@ static int get_dc(SnowContext *s, int mb_x, int mb_y, int plane_index){ | |||
| int x= block_w*mb_x2 + block_w/2; | |||
| int y= block_w*mb_y2 + block_w/2; | |||
| add_yblock(s, dst + ((i&1)+(i>>1)*obmc_stride)*block_w, NULL, ref, obmc, | |||
| add_yblock(s, dst + ((i&1)+(i>>1)*obmc_stride)*block_w, NULL, ref, obmc, | |||
| x, y, block_w, block_w, w, h, obmc_stride, ref_stride, obmc_stride, mb_x2, mb_y2, 0, 0, plane_index); | |||
| for(y2= FFMAX(y, 0); y2<FFMIN(h, y+block_w); y2++){ | |||
| @@ -3177,7 +3177,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){ | |||
| int x= block_w*mb_x2 + block_w/2; | |||
| int y= block_w*mb_y2 + block_w/2; | |||
| add_yblock(s, zero_dst, dst, ref, obmc, | |||
| add_yblock(s, zero_dst, dst, ref, obmc, | |||
| x, y, block_w, block_w, w, h, /*dst_stride*/0, ref_stride, obmc_stride, mb_x2, mb_y2, 1, 1, plane_index); | |||
| //FIXME find a cleaner/simpler way to skip the outside stuff | |||
| @@ -225,7 +225,7 @@ X264_init(AVCodecContext *avctx) | |||
| if(avctx->level > 0) x4->params.i_level_idc = avctx->level; | |||
| x4->params.rc.f_rate_tolerance = | |||
| x4->params.rc.f_rate_tolerance = | |||
| (float)avctx->bit_rate_tolerance/avctx->bit_rate; | |||
| if((avctx->rc_buffer_size != 0) && | |||
| @@ -258,14 +258,14 @@ X264_init(AVCodecContext *avctx) | |||
| avctx->coded_frame = &x4->out_pic; | |||
| if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){ | |||
| x264_nal_t *nal; | |||
| int nnal, i, s = 0; | |||
| x264_nal_t *nal; | |||
| int nnal, i, s = 0; | |||
| x264_encoder_headers(x4->enc, &nal, &nnal); | |||
| x264_encoder_headers(x4->enc, &nal, &nnal); | |||
| /* 5 bytes NAL header + worst case escaping */ | |||
| for(i = 0; i < nnal; i++) | |||
| s += 5 + nal[i].i_payload * 4 / 3; | |||
| /* 5 bytes NAL header + worst case escaping */ | |||
| for(i = 0; i < nnal; i++) | |||
| s += 5 + nal[i].i_payload * 4 / 3; | |||
| avctx->extradata = av_malloc(s); | |||
| avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal); | |||
| @@ -153,24 +153,24 @@ static const CodecTag mov_audio_tags[] = { | |||
| /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */ | |||
| /* http://developer.apple.com/documentation/mac/Text/Text-368.html */ | |||
| /* deprecated by putting the code as 3*5bit ascii */ | |||
| static const char *mov_mdhd_language_map[] = { | |||
| static const char *mov_mdhd_language_map[] = { | |||
| /* 0-9 */ | |||
| "eng", "fra", "ger", "ita", "dut", "sve", "spa", "dan", "por", "nor", | |||
| "heb", "jpn", "ara", "fin", "gre", "ice", "mlt", "tur", "hr "/*scr*/, "chi"/*ace?*/, | |||
| "urd", "hin", "tha", "kor", "lit", "pol", "hun", "est", "lav", NULL, | |||
| "fo ", NULL, "rus", "chi", NULL, "iri", "alb", "ron", "ces", "slk", | |||
| "eng", "fra", "ger", "ita", "dut", "sve", "spa", "dan", "por", "nor", | |||
| "heb", "jpn", "ara", "fin", "gre", "ice", "mlt", "tur", "hr "/*scr*/, "chi"/*ace?*/, | |||
| "urd", "hin", "tha", "kor", "lit", "pol", "hun", "est", "lav", NULL, | |||
| "fo ", NULL, "rus", "chi", NULL, "iri", "alb", "ron", "ces", "slk", | |||
| "slv", "yid", "sr ", "mac", "bul", "ukr", "bel", "uzb", "kaz", "aze", | |||
| /*?*/ | |||
| /*?*/ | |||
| "aze", "arm", "geo", "mol", "kir", "tgk", "tuk", "mon", NULL, "pus", | |||
| "kur", "kas", "snd", "tib", "nep", "san", "mar", "ben", "asm", "guj", | |||
| "pa ", "ori", "mal", "kan", "tam", "tel", NULL, "bur", "khm", "lao", | |||
| /* roman? arabic? */ | |||
| "vie", "ind", "tgl", "may", "may", "amh", "tir", "orm", "som", "swa", | |||
| /*==rundi?*/ | |||
| NULL, "run", NULL, "mlg", "epo", NULL, NULL, NULL, NULL, NULL, | |||
| NULL, "run", NULL, "mlg", "epo", NULL, NULL, NULL, NULL, NULL, | |||
| /* 100 */ | |||
| NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |||
| NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |||
| NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |||
| NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |||
| NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "wel", "baq", | |||
| "cat", "lat", "que", "grn", "aym", "tat", "uig", "dzo", "jav" | |||
| }; | |||
| @@ -380,7 +380,7 @@ extern int ff_mov_iso639_to_lang(const char *lang, int mp4); /* for movenc.c */ | |||
| int ff_mov_iso639_to_lang(const char *lang, int mp4) | |||
| { | |||
| int i, code = 0; | |||
| /* old way, only for QT? */ | |||
| for (i = 0; !mp4 && (i < (sizeof(mov_mdhd_language_map)/sizeof(char *))); i++) { | |||
| if (mov_mdhd_language_map[i] && !strcmp(lang, mov_mdhd_language_map[i])) | |||