* qatar/master: fate: add dxtory test adx_parser: rewrite. adxdec: Validate channel count to fix a division by zero. adxdec: Do not require extradata. cmdutils: K&R reformatting cosmetics alacdec: implement the 2-pass prediction type. alacenc: implement the 2-pass prediction type. alacenc: do not generate invalid multi-channel ALAC files alacdec: fill in missing or guessed info about the extradata format. utvideo: proper median prediction for interlaced videos lavu: bump lavu minor for av_popcount64 dca: K&R formatting cosmetics dct: K&R formatting cosmetics lavf: flush decoders in avformat_find_stream_info(). win32: detect number of CPUs using affinity Add av_popcount64 snow: Restore three mistakenly removed casts. Conflicts: cmdutils.c doc/APIchanges libavcodec/adx_parser.c libavcodec/adxdec.c libavcodec/alacenc.c libavutil/avutil.h tests/fate/screen.mak
Unified · Split
| @@ -61,7 +61,8 @@ static FILE *report_file; · 60 unmodified lines | ||
| 61 | 61 | void init_opts(void) |
| 62 | 62 | { |
| 63 | 63 | #if CONFIG_SWSCALE |
| 64 | − sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NULL); | |
| 64 | + sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, | |
| 65 | + NULL, NULL, NULL); | |
| 65 | 66 | #endif |
| 66 | 67 | } |
| 67 | 68 | |
| @@ -75,7 +76,7 @@ void uninit_opts(void) · 7 unmodified lines | ||
| 75 | 76 | av_dict_free(&codec_opts); |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | −void log_callback_help(void* ptr, int level, const char* fmt, va_list vl) | |
| 79 | +void log_callback_help(void *ptr, int level, const char *fmt, va_list vl) | |
| 79 | 80 | { |
| 80 | 81 | vfprintf(stdout, fmt, vl); |
| 81 | 82 | } |
| @@ -94,19 +95,20 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v · 12 unmodified lines | ||
| 94 | 95 | fflush(report_file); |
| 95 | 96 | } |
| 96 | 97 | |
| 97 | −double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max) | |
| 98 | +double parse_number_or_die(const char *context, const char *numstr, int type, | |
| 99 | + double min, double max) | |
| 98 | 100 | { |
| 99 | 101 | char *tail; |
| 100 | 102 | const char *error; |
| 101 | 103 | double d = av_strtod(numstr, &tail); |
| 102 | 104 | if (*tail) |
| 103 | − error= "Expected number for %s but found: %s\n"; | |
| 105 | + error = "Expected number for %s but found: %s\n"; | |
| 104 | 106 | else if (d < min || d > max) |
| 105 | − error= "The value for %s was %s which is not within %f - %f\n"; | |
| 106 | − else if(type == OPT_INT64 && (int64_t)d != d) | |
| 107 | − error= "Expected int64 for %s but found %s\n"; | |
| 107 | + error = "The value for %s was %s which is not within %f - %f\n"; | |
| 108 | + else if (type == OPT_INT64 && (int64_t)d != d) | |
| 109 | + error = "Expected int64 for %s but found %s\n"; | |
| 108 | 110 | else if (type == OPT_INT && (int)d != d) |
| 109 | − error= "Expected int for %s but found %s\n"; | |
| 111 | + error = "Expected int for %s but found %s\n"; | |
| 110 | 112 | else |
| 111 | 113 | return d; |
| 112 | 114 | av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max); |
| @@ -114,7 +116,8 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do · 1 unmodified line | ||
| 114 | 116 | return 0; |
| 115 | 117 | } |
| 116 | 118 | |
| 117 | −int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration) | |
| 119 | +int64_t parse_time_or_die(const char *context, const char *timestr, | |
| 120 | + int is_duration) | |
| 118 | 121 | { |
| 119 | 122 | int64_t us; |
| 120 | 123 | if (av_parse_time(&us, timestr, is_duration) < 0) { |
| @@ -125,13 +128,14 @@ int64_t parse_time_or_die(const char *context, const char *timestr, int is_durat · 4 unmodified lines | ||
| 125 | 128 | return us; |
| 126 | 129 | } |
| 127 | 130 | |
| 128 | −void show_help_options(const OptionDef *options, const char *msg, int mask, int value) | |
| 131 | +void show_help_options(const OptionDef *options, const char *msg, int mask, | |
| 132 | + int value) | |
| 129 | 133 | { |
| 130 | 134 | const OptionDef *po; |
| 131 | 135 | int first; |
| 132 | 136 | |
| 133 | 137 | first = 1; |
| 134 | − for(po = options; po->name != NULL; po++) { | |
| 138 | + for (po = options; po->name != NULL; po++) { | |
| 135 | 139 | char buf[64]; |
| 136 | 140 | if ((po->flags & mask) == value) { |
| 137 | 141 | if (first) { |
| @@ -158,7 +162,8 @@ void show_help_children(const AVClass *class, int flags) · 20 unmodified lines | ||
| 158 | 162 | show_help_children(child, flags); |
| 159 | 163 | } |
| 160 | 164 | |
| 161 | −static const OptionDef* find_option(const OptionDef *po, const char *name){ | |
| 165 | +static const OptionDef *find_option(const OptionDef *po, const char *name) | |
| 166 | +{ | |
| 162 | 167 | const char *p = strchr(name, ':'); |
| 163 | 168 | int len = p ? p - name : strlen(name); |
| 164 | 169 | |
| @@ -205,8 +210,8 @@ static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) · 40 unmodified lines | ||
| 205 | 210 | buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, |
| 206 | 211 | NULL, 0, NULL, NULL); |
| 207 | 212 | |
| 208 | − win32_argv_utf8 = av_mallocz(sizeof(char*) * (win32_argc + 1) + buffsize); | |
| 209 | − argstr_flat = (char*)win32_argv_utf8 + sizeof(char*) * (win32_argc + 1); | |
| 213 | + win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize); | |
| 214 | + argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1); | |
| 210 | 215 | if (win32_argv_utf8 == NULL) { |
| 211 | 216 | LocalFree(argv_w); |
| 212 | 217 | return; |
| @@ -231,8 +236,8 @@ static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) · 18 unmodified lines | ||
| 231 | 236 | } |
| 232 | 237 | #endif /* WIN32 && !__MINGW32CE__ */ |
| 233 | 238 | |
| 234 | − | |
| 235 | −int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options) | |
| 239 | +int parse_option(void *optctx, const char *opt, const char *arg, | |
| 240 | + const OptionDef *options) | |
| 236 | 241 | { |
| 237 | 242 | const OptionDef *po; |
| 238 | 243 | int bool_val = 1; |
| @@ -261,13 +266,14 @@ unknown_opt: · 22 unmodified lines | ||
| 261 | 266 | |
| 262 | 267 | /* new-style options contain an offset into optctx, old-style address of |
| 263 | 268 | * a global var*/ |
| 264 | − dst = po->flags & (OPT_OFFSET|OPT_SPEC) ? (uint8_t*)optctx + po->u.off : po->u.dst_ptr; | |
| 269 | + dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? (uint8_t *)optctx + po->u.off | |
| 270 | + : po->u.dst_ptr; | |
| 265 | 271 | |
| 266 | 272 | if (po->flags & OPT_SPEC) { |
| 267 | 273 | SpecifierOpt **so = dst; |
| 268 | 274 | char *p = strchr(opt, ':'); |
| 269 | 275 | |
| 270 | − dstcount = (int*)(so + 1); | |
| 276 | + dstcount = (int *)(so + 1); | |
| 271 | 277 | *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1); |
| 272 | 278 | (*so)[*dstcount - 1].specifier = av_strdup(p ? p + 1 : ""); |
| 273 | 279 | dst = &(*so)[*dstcount - 1].u; |
| @@ -276,24 +282,25 @@ unknown_opt: · 2 unmodified lines | ||
| 276 | 282 | if (po->flags & OPT_STRING) { |
| 277 | 283 | char *str; |
| 278 | 284 | str = av_strdup(arg); |
| 279 | − *(char**)dst = str; | |
| 285 | + *(char **)dst = str; | |
| 280 | 286 | } else if (po->flags & OPT_BOOL) { |
| 281 | − *(int*)dst = bool_val; | |
| 287 | + *(int *)dst = bool_val; | |
| 282 | 288 | } else if (po->flags & OPT_INT) { |
| 283 | − *(int*)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); | |
| 289 | + *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); | |
| 284 | 290 | } else if (po->flags & OPT_INT64) { |
| 285 | − *(int64_t*)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); | |
| 291 | + *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); | |
| 286 | 292 | } else if (po->flags & OPT_TIME) { |
| 287 | − *(int64_t*)dst = parse_time_or_die(opt, arg, 1); | |
| 293 | + *(int64_t *)dst = parse_time_or_die(opt, arg, 1); | |
| 288 | 294 | } else if (po->flags & OPT_FLOAT) { |
| 289 | − *(float*)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); | |
| 295 | + *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); | |
| 290 | 296 | } else if (po->flags & OPT_DOUBLE) { |
| 291 | − *(double*)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); | |
| 297 | + *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); | |
| 292 | 298 | } else if (po->u.func_arg) { |
| 293 | − int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) : | |
| 294 | − po->u.func_arg(opt, arg); | |
| 299 | + int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) | |
| 300 | + : po->u.func_arg(opt, arg); | |
| 295 | 301 | if (ret < 0) { |
| 296 | − av_log(NULL, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", arg, opt); | |
| 302 | + av_log(NULL, AV_LOG_ERROR, | |
| 303 | + "Failed to set value '%s' for option '%s'\n", arg, opt); | |
| 297 | 304 | return ret; |
| 298 | 305 | } |
| 299 | 306 | } |
| @@ -303,7 +310,7 @@ unknown_opt: · 3 unmodified lines | ||
| 303 | 310 | } |
| 304 | 311 | |
| 305 | 312 | void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, |
| 306 | − void (* parse_arg_function)(void *, const char*)) | |
| 313 | + void (*parse_arg_function)(void *, const char*)) | |
| 307 | 314 | { |
| 308 | 315 | const char *opt; |
| 309 | 316 | int optindex, handleoptions = 1, ret; |
| @@ -336,7 +343,8 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options · 26 unmodified lines | ||
| 336 | 343 | /* |
| 337 | 344 | * Return index of option opt in argv or 0 if not found. |
| 338 | 345 | */ |
| 339 | −static int locate_option(int argc, char **argv, const OptionDef *options, const char *optname) | |
| 346 | +static int locate_option(int argc, char **argv, const OptionDef *options, | |
| 347 | + const char *optname) | |
| 340 | 348 | { |
| 341 | 349 | const OptionDef *po; |
| 342 | 350 | int i; |
| @@ -419,15 +427,18 @@ int opt_default(const char *opt, const char *arg) · 76 unmodified lines | ||
| 419 | 427 | p = opt + strlen(opt); |
| 420 | 428 | av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); |
| 421 | 429 | |
| 422 | − if ((oc = av_opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN|AV_OPT_SEARCH_FAKE_OBJ)) || | |
| 423 | − ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && | |
| 424 | − (oc = av_opt_find(&cc, opt+1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) | |
| 430 | + if ((oc = av_opt_find(&cc, opt_stripped, NULL, 0, | |
| 431 | + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || | |
| 432 | + ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && | |
| 433 | + (oc = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) | |
| 425 | 434 | av_dict_set(&codec_opts, opt, arg, FLAGS(oc)); |
| 426 | − if ((of = av_opt_find(&fc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) | |
| 435 | + if ((of = av_opt_find(&fc, opt, NULL, 0, | |
| 436 | + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) | |
| 427 | 437 | av_dict_set(&format_opts, opt, arg, FLAGS(of)); |
| 428 | 438 | #if CONFIG_SWSCALE |
| 429 | 439 | sc = sws_get_class(); |
| 430 | − if ((os = av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { | |
| 440 | + if ((os = av_opt_find(&sc, opt, NULL, 0, | |
| 441 | + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { | |
| 431 | 442 | // XXX we only support sws_flags, not arbitrary sws options |
| 432 | 443 | int ret = av_opt_set(sws_opts, opt, arg, 0); |
| 433 | 444 | if (ret < 0) { |
| @@ -604,7 +615,8 @@ void show_banner(int argc, char **argv, const OptionDef *options) · 170 unmodified lines | ||
| 604 | 615 | if (idx) |
| 605 | 616 | return; |
| 606 | 617 | |
| 607 | − av_log(NULL, AV_LOG_INFO, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n", | |
| 618 | + av_log(NULL, AV_LOG_INFO, | |
| 619 | + "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n", | |
| 608 | 620 | program_name, program_birth_year, this_year); |
| 609 | 621 | av_log(NULL, AV_LOG_INFO, " built on %s %s with %s %s\n", |
| 610 | 622 | __DATE__, __TIME__, CC_TYPE, CC_VERSION); |
| @@ -692,49 +704,47 @@ int opt_license(const char *opt, const char *arg) · 81 unmodified lines | ||
| 692 | 704 | |
| 693 | 705 | int opt_formats(const char *opt, const char *arg) |
| 694 | 706 | { |
| 695 | − AVInputFormat *ifmt=NULL; | |
| 696 | − AVOutputFormat *ofmt=NULL; | |
| 707 | + AVInputFormat *ifmt = NULL; | |
| 708 | + AVOutputFormat *ofmt = NULL; | |
| 697 | 709 | const char *last_name; |
| 698 | 710 | |
| 699 | − printf( | |
| 700 | − "File formats:\n" | |
| 701 | − " D. = Demuxing supported\n" | |
| 702 | − " .E = Muxing supported\n" | |
| 703 | − " --\n"); | |
| 704 | − last_name= "000"; | |
| 705 | − for(;;){ | |
| 706 | − int decode=0; | |
| 707 | − int encode=0; | |
| 708 | − const char *name=NULL; | |
| 709 | − const char *long_name=NULL; | |
| 710 | − | |
| 711 | − while((ofmt= av_oformat_next(ofmt))) { | |
| 712 | − if((name == NULL || strcmp(ofmt->name, name)<0) && | |
| 713 | − strcmp(ofmt->name, last_name)>0){ | |
| 714 | − name= ofmt->name; | |
| 715 | − long_name= ofmt->long_name; | |
| 716 | − encode=1; | |
| 711 | + printf("File formats:\n" | |
| 712 | + " D. = Demuxing supported\n" | |
| 713 | + " .E = Muxing supported\n" | |
| 714 | + " --\n"); | |
| 715 | + last_name = "000"; | |
| 716 | + for (;;) { | |
| 717 | + int decode = 0; | |
| 718 | + int encode = 0; | |
| 719 | + const char *name = NULL; | |
| 720 | + const char *long_name = NULL; | |
| 721 | + | |
| 722 | + while ((ofmt = av_oformat_next(ofmt))) { | |
| 723 | + if ((name == NULL || strcmp(ofmt->name, name) < 0) && | |
| 724 | + strcmp(ofmt->name, last_name) > 0) { | |
| 725 | + name = ofmt->name; | |
| 726 | + long_name = ofmt->long_name; | |
| 727 | + encode = 1; | |
| 717 | 728 | } |
| 718 | 729 | } |
| 719 | − while((ifmt= av_iformat_next(ifmt))) { | |
| 720 | − if((name == NULL || strcmp(ifmt->name, name)<0) && | |
| 721 | − strcmp(ifmt->name, last_name)>0){ | |
| 722 | − name= ifmt->name; | |
| 723 | − long_name= ifmt->long_name; | |
| 724 | − encode=0; | |
| 730 | + while ((ifmt = av_iformat_next(ifmt))) { | |
| 731 | + if ((name == NULL || strcmp(ifmt->name, name) < 0) && | |
| 732 | + strcmp(ifmt->name, last_name) > 0) { | |
| 733 | + name = ifmt->name; | |
| 734 | + long_name = ifmt->long_name; | |
| 735 | + encode = 0; | |
| 725 | 736 | } |
| 726 | − if(name && strcmp(ifmt->name, name)==0) | |
| 727 | − decode=1; | |
| 737 | + if (name && strcmp(ifmt->name, name) == 0) | |
| 738 | + decode = 1; | |
| 728 | 739 | } |
| 729 | − if(name==NULL) | |
| 740 | + if (name == NULL) | |
| 730 | 741 | break; |
| 731 | − last_name= name; | |
| 742 | + last_name = name; | |
| 732 | 743 | |
| 733 | − printf( | |
| 734 | − " %s%s %-15s %s\n", | |
| 735 | − decode ? "D":" ", | |
| 736 | − encode ? "E":" ", | |
| 737 | − name, | |
| 744 | + printf(" %s%s %-15s %s\n", | |
| 745 | + decode ? "D" : " ", | |
| 746 | + encode ? "E" : " ", | |
| 747 | + name, | |
| 738 | 748 | long_name ? long_name:" "); |
| 739 | 749 | } |
| 740 | 750 | return 0; |
| @@ -742,44 +752,45 @@ int opt_formats(const char *opt, const char *arg) · 1 unmodified line | ||
| 742 | 752 | |
| 743 | 753 | int opt_codecs(const char *opt, const char *arg) |
| 744 | 754 | { |
| 745 | − AVCodec *p=NULL, *p2; | |
| 755 | + AVCodec *p = NULL, *p2; | |
| 746 | 756 | const char *last_name; |
| 747 | − printf( | |
| 748 | − "Codecs:\n" | |
| 749 | − " D..... = Decoding supported\n" | |
| 750 | − " .E.... = Encoding supported\n" | |
| 751 | − " ..V... = Video codec\n" | |
| 752 | − " ..A... = Audio codec\n" | |
| 753 | − " ..S... = Subtitle codec\n" | |
| 754 | − " ...S.. = Supports draw_horiz_band\n" | |
| 755 | − " ....D. = Supports direct rendering method 1\n" | |
| 756 | − " .....T = Supports weird frame truncation\n" | |
| 757 | − " ------\n"); | |
| 757 | + printf("Codecs:\n" | |
| 758 | + " D..... = Decoding supported\n" | |
| 759 | + " .E.... = Encoding supported\n" | |
| 760 | + " ..V... = Video codec\n" | |
| 761 | + " ..A... = Audio codec\n" | |
| 762 | + " ..S... = Subtitle codec\n" | |
| 763 | + " ...S.. = Supports draw_horiz_band\n" | |
| 764 | + " ....D. = Supports direct rendering method 1\n" | |
| 765 | + " .....T = Supports weird frame truncation\n" | |
| 766 | + " ------\n"); | |
| 758 | 767 | last_name= "000"; |
| 759 | − for(;;){ | |
| 760 | − int decode=0; | |
| 761 | − int encode=0; | |
| 762 | − int cap=0; | |
| 768 | + for (;;) { | |
| 769 | + int decode = 0; | |
| 770 | + int encode = 0; | |
| 771 | + int cap = 0; | |
| 763 | 772 | const char *type_str; |
| 764 | 773 | |
| 765 | − p2=NULL; | |
| 766 | − while((p= av_codec_next(p))) { | |
| 767 | − if((p2==NULL || strcmp(p->name, p2->name)<0) && | |
| 768 | − strcmp(p->name, last_name)>0){ | |
| 769 | − p2= p; | |
| 770 | − decode= encode= cap=0; | |
| 774 | + p2 = NULL; | |
| 775 | + while ((p = av_codec_next(p))) { | |
| 776 | + if ((p2 == NULL || strcmp(p->name, p2->name) < 0) && | |
| 777 | + strcmp(p->name, last_name) > 0) { | |
| 778 | + p2 = p; | |
| 779 | + decode = encode = cap = 0; | |
| 771 | 780 | } |
| 772 | − if(p2 && strcmp(p->name, p2->name)==0){ | |
| 773 | − if(p->decode) decode=1; | |
| 774 | − if(p->encode) encode=1; | |
| 781 | + if (p2 && strcmp(p->name, p2->name) == 0) { | |
| 782 | + if (p->decode) | |
| 783 | + decode = 1; | |
| 784 | + if (p->encode) | |
| 785 | + encode = 1; | |
| 775 | 786 | cap |= p->capabilities; |
| 776 | 787 | } |
| 777 | 788 | } |
| 778 | − if(p2==NULL) | |
| 789 | + if (p2 == NULL) | |
| 779 | 790 | break; |
| 780 | − last_name= p2->name; | |
| 791 | + last_name = p2->name; | |
| 781 | 792 | |
| 782 | − switch(p2->type) { | |
| 793 | + switch (p2->type) { | |
| 783 | 794 | case AVMEDIA_TYPE_VIDEO: |
| 784 | 795 | type_str = "V"; |
| 785 | 796 | break; |
| @@ -793,36 +804,36 @@ int opt_codecs(const char *opt, const char *arg) · 7 unmodified lines | ||
| 793 | 804 | type_str = "?"; |
| 794 | 805 | break; |
| 795 | 806 | } |
| 796 | − printf( | |
| 797 | − " %s%s%s%s%s%s %-15s %s", | |
| 798 | − decode ? "D": (/*p2->decoder ? "d":*/" "), | |
| 799 | − encode ? "E":" ", | |
| 800 | − type_str, | |
| 801 | − cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S":" ", | |
| 802 | − cap & CODEC_CAP_DR1 ? "D":" ", | |
| 803 | − cap & CODEC_CAP_TRUNCATED ? "T":" ", | |
| 804 | − p2->name, | |
| 805 | − p2->long_name ? p2->long_name : ""); | |
| 806 | − /* if(p2->decoder && decode==0) | |
| 807 | − printf(" use %s for decoding", p2->decoder->name);*/ | |
| 807 | + printf(" %s%s%s%s%s%s %-15s %s", | |
| 808 | + decode ? "D" : (/* p2->decoder ? "d" : */ " "), | |
| 809 | + encode ? "E" : " ", | |
| 810 | + type_str, | |
| 811 | + cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S" : " ", | |
| 812 | + cap & CODEC_CAP_DR1 ? "D" : " ", | |
| 813 | + cap & CODEC_CAP_TRUNCATED ? "T" : " ", | |
| 814 | + p2->name, | |
| 815 | + p2->long_name ? p2->long_name : ""); | |
| 816 | +#if 0 | |
| 817 | + if (p2->decoder && decode == 0) | |
| 818 | + printf(" use %s for decoding", p2->decoder->name); | |
| 819 | +#endif | |
| 808 | 820 | printf("\n"); |
| 809 | 821 | } |
| 810 | 822 | printf("\n"); |
| 811 | − printf( | |
| 812 | −"Note, the names of encoders and decoders do not always match, so there are\n" | |
| 813 | −"several cases where the above table shows encoder only or decoder only entries\n" | |
| 814 | −"even though both encoding and decoding are supported. For example, the h263\n" | |
| 815 | −"decoder corresponds to the h263 and h263p encoders, for file formats it is even\n" | |
| 816 | −"worse.\n"); | |
| 823 | + printf("Note, the names of encoders and decoders do not always match, so there are\n" | |
| 824 | + "several cases where the above table shows encoder only or decoder only entries\n" | |
| 825 | + "even though both encoding and decoding are supported. For example, the h263\n" | |
| 826 | + "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n" | |
| 827 | + "worse.\n"); | |
| 817 | 828 | return 0; |
| 818 | 829 | } |
| 819 | 830 | |
| 820 | 831 | int opt_bsfs(const char *opt, const char *arg) |
| 821 | 832 | { |
| 822 | − AVBitStreamFilter *bsf=NULL; | |
| 833 | + AVBitStreamFilter *bsf = NULL; | |
| 823 | 834 | |
| 824 | 835 | printf("Bitstream filters:\n"); |
| 825 | − while((bsf = av_bitstream_filter_next(bsf))) | |
| 836 | + while ((bsf = av_bitstream_filter_next(bsf))) | |
| 826 | 837 | printf("%s\n", bsf->name); |
| 827 | 838 | printf("\n"); |
| 828 | 839 | return 0; |
| @@ -863,15 +874,14 @@ int opt_pix_fmts(const char *opt, const char *arg) · 34 unmodified lines | ||
| 863 | 874 | { |
| 864 | 875 | enum PixelFormat pix_fmt; |
| 865 | 876 | |
| 866 | − printf( | |
| 867 | − "Pixel formats:\n" | |
| 868 | − "I.... = Supported Input format for conversion\n" | |
| 869 | − ".O... = Supported Output format for conversion\n" | |
| 870 | − "..H.. = Hardware accelerated format\n" | |
| 871 | − "...P. = Paletted format\n" | |
| 872 | − "....B = Bitstream format\n" | |
| 873 | − "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n" | |
| 874 | − "-----\n"); | |
| 877 | + printf("Pixel formats:\n" | |
| 878 | + "I.... = Supported Input format for conversion\n" | |
| 879 | + ".O... = Supported Output format for conversion\n" | |
| 880 | + "..H.. = Hardware accelerated format\n" | |
| 881 | + "...P. = Paletted format\n" | |
| 882 | + "....B = Bitstream format\n" | |
| 883 | + "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n" | |
| 884 | + "-----\n"); | |
| 875 | 885 | |
| 876 | 886 | #if !CONFIG_SWSCALE |
| 877 | 887 | # define sws_isSupportedInput(x) 0 |
| @@ -921,7 +931,8 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) · 43 unmodified lines | ||
| 921 | 931 | FILE *f = fopen(filename, "rb"); |
| 922 | 932 | |
| 923 | 933 | if (!f) { |
| 924 | − av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, strerror(errno)); | |
| 934 | + av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, | |
| 935 | + strerror(errno)); | |
| 925 | 936 | return AVERROR(errno); |
| 926 | 937 | } |
| 927 | 938 | fseek(f, 0, SEEK_END); |
| @@ -952,14 +963,14 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) · 24 unmodified lines | ||
| 952 | 963 | } |
| 953 | 964 | |
| 954 | 965 | FILE *get_preset_file(char *filename, size_t filename_size, |
| 955 | − const char *preset_name, int is_path, const char *codec_name) | |
| 966 | + const char *preset_name, int is_path, | |
| 967 | + const char *codec_name) | |
| 956 | 968 | { |
| 957 | 969 | FILE *f = NULL; |
| 958 | 970 | int i; |
| 959 | − const char *base[3]= { getenv("FFMPEG_DATADIR"), | |
| 960 | − getenv("HOME"), | |
| 961 | − FFMPEG_DATADIR, | |
| 962 | − }; | |
| 971 | + const char *base[3] = { getenv("FFMPEG_DATADIR"), | |
| 972 | + getenv("HOME"), | |
| 973 | + FFMPEG_DATADIR, }; | |
| 963 | 974 | |
| 964 | 975 | if (is_path) { |
| 965 | 976 | av_strlcpy(filename, preset_name, filename_size); |
| @@ -985,11 +996,14 @@ FILE *get_preset_file(char *filename, size_t filename_size, · 19 unmodified lines | ||
| 985 | 996 | for (i = 0; i < 3 && !f; i++) { |
| 986 | 997 | if (!base[i]) |
| 987 | 998 | continue; |
| 988 | − snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", preset_name); | |
| 999 | + snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], | |
| 1000 | + i != 1 ? "" : "/.ffmpeg", preset_name); | |
| 989 | 1001 | f = fopen(filename, "r"); |
| 990 | 1002 | if (!f && codec_name) { |
| 991 | 1003 | snprintf(filename, filename_size, |
| 992 | − "%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec_name, preset_name); | |
| 1004 | + "%s%s/%s-%s.ffpreset", | |
| 1005 | + base[i], i != 1 ? "" : "/.ffmpeg", codec_name, | |
| 1006 | + preset_name); | |
| 993 | 1007 | f = fopen(filename, "r"); |
| 994 | 1008 | } |
| 995 | 1009 | } |
| @@ -1000,22 +1014,23 @@ FILE *get_preset_file(char *filename, size_t filename_size, · 4 unmodified lines | ||
| 1000 | 1014 | |
| 1001 | 1015 | int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) |
| 1002 | 1016 | { |
| 1003 | − if (*spec <= '9' && *spec >= '0') /* opt:index */ | |
| 1017 | + if (*spec <= '9' && *spec >= '0') /* opt:index */ | |
| 1004 | 1018 | return strtol(spec, NULL, 0) == st->index; |
| 1005 | − else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || *spec == 't') { /* opt:[vasdt] */ | |
| 1019 | + else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || | |
| 1020 | + *spec == 't') { /* opt:[vasdt] */ | |
| 1006 | 1021 | enum AVMediaType type; |
| 1007 | 1022 | |
| 1008 | 1023 | switch (*spec++) { |
| 1009 | − case 'v': type = AVMEDIA_TYPE_VIDEO; break; | |
| 1010 | − case 'a': type = AVMEDIA_TYPE_AUDIO; break; | |
| 1011 | − case 's': type = AVMEDIA_TYPE_SUBTITLE; break; | |
| 1012 | − case 'd': type = AVMEDIA_TYPE_DATA; break; | |
| 1024 | + case 'v': type = AVMEDIA_TYPE_VIDEO; break; | |
| 1025 | + case 'a': type = AVMEDIA_TYPE_AUDIO; break; | |
| 1026 | + case 's': type = AVMEDIA_TYPE_SUBTITLE; break; | |
| 1027 | + case 'd': type = AVMEDIA_TYPE_DATA; break; | |
| 1013 | 1028 | case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; |
| 1014 | 1029 | default: abort(); // never reached, silence warning |
| 1015 | 1030 | } |
| 1016 | 1031 | if (type != st->codec->codec_type) |
| 1017 | 1032 | return 0; |
| 1018 | − if (*spec++ == ':') { /* possibly followed by :index */ | |
| 1033 | + if (*spec++ == ':') { /* possibly followed by :index */ | |
| 1019 | 1034 | int i, index = strtol(spec, NULL, 0); |
| 1020 | 1035 | for (i = 0; i < s->nb_streams; i++) |
| 1021 | 1036 | if (s->streams[i]->codec->codec_type == type && index-- == 0) |
| @@ -1051,11 +1066,13 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) · 29 unmodified lines | ||
| 1051 | 1066 | return AVERROR(EINVAL); |
| 1052 | 1067 | } |
| 1053 | 1068 | |
| 1054 | −AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatContext *s, AVStream *st) | |
| 1069 | +AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, | |
| 1070 | + AVFormatContext *s, AVStream *st) | |
| 1055 | 1071 | { |
| 1056 | 1072 | AVDictionary *ret = NULL; |
| 1057 | 1073 | AVDictionaryEntry *t = NULL; |
| 1058 | − int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM; | |
| 1074 | + int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM | |
| 1075 | + : AV_OPT_FLAG_DECODING_PARAM; | |
| 1059 | 1076 | char prefix = 0; |
| 1060 | 1077 | const AVClass *cc = avcodec_get_class(); |
| 1061 | 1078 | |
| @@ -1063,9 +1080,18 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont · 1 unmodified line | ||
| 1063 | 1080 | return NULL; |
| 1064 | 1081 | |
| 1065 | 1082 | switch (codec->type) { |
| 1066 | − case AVMEDIA_TYPE_VIDEO: prefix = 'v'; flags |= AV_OPT_FLAG_VIDEO_PARAM; break; | |
| 1067 | − case AVMEDIA_TYPE_AUDIO: prefix = 'a'; flags |= AV_OPT_FLAG_AUDIO_PARAM; break; | |
| 1068 | − case AVMEDIA_TYPE_SUBTITLE: prefix = 's'; flags |= AV_OPT_FLAG_SUBTITLE_PARAM; break; | |
| 1083 | + case AVMEDIA_TYPE_VIDEO: | |
| 1084 | + prefix = 'v'; | |
| 1085 | + flags |= AV_OPT_FLAG_VIDEO_PARAM; | |
| 1086 | + break; | |
| 1087 | + case AVMEDIA_TYPE_AUDIO: | |
| 1088 | + prefix = 'a'; | |
| 1089 | + flags |= AV_OPT_FLAG_AUDIO_PARAM; | |
| 1090 | + break; | |
| 1091 | + case AVMEDIA_TYPE_SUBTITLE: | |
| 1092 | + prefix = 's'; | |
| 1093 | + flags |= AV_OPT_FLAG_SUBTITLE_PARAM; | |
| 1094 | + break; | |
| 1069 | 1095 | } |
| 1070 | 1096 | |
| 1071 | 1097 | while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) { |
| @@ -1080,10 +1106,14 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont · 8 unmodified lines | ||
| 1080 | 1106 | } |
| 1081 | 1107 | |
| 1082 | 1108 | if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) || |
| 1083 | − (codec && codec->priv_class && av_opt_find(&codec->priv_class, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ))) | |
| 1109 | + (codec && codec->priv_class && | |
| 1110 | + av_opt_find(&codec->priv_class, t->key, NULL, flags, | |
| 1111 | + AV_OPT_SEARCH_FAKE_OBJ))) | |
| 1084 | 1112 | av_dict_set(&ret, t->key, t->value, 0); |
| 1085 | − else if (t->key[0] == prefix && av_opt_find(&cc, t->key+1, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ)) | |
| 1086 | − av_dict_set(&ret, t->key+1, t->value, 0); | |
| 1113 | + else if (t->key[0] == prefix && | |
| 1114 | + av_opt_find(&cc, t->key + 1, NULL, flags, | |
| 1115 | + AV_OPT_SEARCH_FAKE_OBJ)) | |
| 1116 | + av_dict_set(&ret, t->key + 1, t->value, 0); | |
| 1087 | 1117 | |
| 1088 | 1118 | if (p) |
| 1089 | 1119 | *p = ':'; |
| @@ -1091,7 +1121,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont · 1 unmodified line | ||
| 1091 | 1121 | return ret; |
| 1092 | 1122 | } |
| 1093 | 1123 | |
| 1094 | −AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts) | |
| 1124 | +AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, | |
| 1125 | + AVDictionary *codec_opts) | |
| 1095 | 1126 | { |
| 1096 | 1127 | int i; |
| 1097 | 1128 | AVDictionary **opts; |
| @@ -1100,11 +1131,13 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *cod · 2 unmodified lines | ||
| 1100 | 1131 | return NULL; |
| 1101 | 1132 | opts = av_mallocz(s->nb_streams * sizeof(*opts)); |
| 1102 | 1133 | if (!opts) { |
| 1103 | − av_log(NULL, AV_LOG_ERROR, "Could not alloc memory for stream options.\n"); | |
| 1134 | + av_log(NULL, AV_LOG_ERROR, | |
| 1135 | + "Could not alloc memory for stream options.\n"); | |
| 1104 | 1136 | return NULL; |
| 1105 | 1137 | } |
| 1106 | 1138 | for (i = 0; i < s->nb_streams; i++) |
| 1107 | − opts[i] = filter_codec_opts(codec_opts, avcodec_find_decoder(s->streams[i]->codec->codec_id), s, s->streams[i]); | |
| 1139 | + opts[i] = filter_codec_opts(codec_opts, avcodec_find_decoder(s->streams[i]->codec->codec_id), | |
| 1140 | + s, s->streams[i]); | |
| 1108 | 1141 | return opts; |
| 1109 | 1142 | } |
| 1110 | 1143 | |
| @@ -1175,9 +1175,9 @@ HAVE_LIST=" · 1174 unmodified lines | ||
| 1175 | 1175 | fork |
| 1176 | 1176 | getaddrinfo |
| 1177 | 1177 | gethrtime |
| 1178 | + GetProcessAffinityMask | |
| 1178 | 1179 | GetProcessMemoryInfo |
| 1179 | 1180 | GetProcessTimes |
| 1180 | − GetSystemInfo | |
| 1181 | 1181 | getrusage |
| 1182 | 1182 | gnu_as |
| 1183 | 1183 | ibm_asm |
| @@ -3016,8 +3016,8 @@ check_func_headers windows.h PeekNamedPipe · 1832 unmodified lines | ||
| 3016 | 3016 | check_func_headers io.h setmode |
| 3017 | 3017 | check_func_headers lzo/lzo1x.h lzo1x_999_compress |
| 3018 | 3018 | check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi |
| 3019 | +check_func_headers windows.h GetProcessAffinityMask | |
| 3019 | 3020 | check_func_headers windows.h GetProcessTimes |
| 3020 | −check_func_headers windows.h GetSystemInfo | |
| 3021 | 3021 | check_func_headers windows.h MapViewOfFile |
| 3022 | 3022 | check_func_headers windows.h VirtualAlloc |
| 3023 | 3023 | |
| @@ -31,21 +31,24 @@ API changes, most recent first: · 30 unmodified lines | ||
| 31 | 31 | 2011-10-20 - b35e9e1 - lavu 51.22.0 |
| 32 | 32 | Add av_strtok() to avstring.h. |
| 33 | 33 | |
| 34 | +2011-01-03 - b73ec05 - lavu 51.21.0 | |
| 35 | + Add av_popcount64 | |
| 36 | + | |
| 34 | 37 | 2011-12-18 - 8400b12 - lavc 53.28.1 |
| 35 | 38 | Deprecate AVFrame.age. The field is unused. |
| 36 | 39 | |
| 37 | −2011-xx-xx - xxxxxxx - lavf 53.17.0 | |
| 38 | − Add avformat_open_input(). | |
| 40 | +2011-12-12 - 5266045 - lavf 53.17.0 | |
| 41 | + Add avformat_close_input(). | |
| 39 | 42 | Deprecate av_close_input_file() and av_close_input_stream(). |
| 40 | 43 | |
| 41 | −2011-xx-xx - xxxxxxx - lavc 53.25.0 | |
| 44 | +2011-12-02 - 0eea212 - lavc 53.25.0 | |
| 42 | 45 | Add nb_samples and extended_data fields to AVFrame. |
| 43 | 46 | Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE. |
| 44 | 47 | Deprecate avcodec_decode_audio3() in favor of avcodec_decode_audio4(). |
| 45 | 48 | avcodec_decode_audio4() writes output samples to an AVFrame, which allows |
| 46 | 49 | audio decoders to use get_buffer(). |
| 47 | 50 | |
| 48 | −2011-xx-xx - xxxxxxx - lavc 53.24.0 | |
| 51 | +2011-12-04 - 560f773 - lavc 53.24.0 | |
| 49 | 52 | Change AVFrame.data[4]/base[4]/linesize[4]/error[4] to [8] at next major bump. |
| 50 | 53 | Change AVPicture.data[4]/linesize[4] to [8] at next major bump. |
| 51 | 54 | Change AVCodecContext.error[4] to [8] at next major bump. |
| @@ -58,7 +58,7 @@ int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf, · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | /* channels */ |
| 60 | 60 | avctx->channels = buf[7]; |
| 61 | − if (avctx->channels > 2) | |
| 61 | + if (avctx->channels <= 0 || avctx->channels > 2) | |
| 62 | 62 | return AVERROR_INVALIDDATA; |
| 63 | 63 | |
| 64 | 64 | /* sample rate */ |
| @@ -45,27 +45,31 @@ static int adx_parse(AVCodecParserContext *s1, · 44 unmodified lines | ||
| 45 | 45 | ParseContext *pc = &s->pc; |
| 46 | 46 | int next = END_NOT_FOUND; |
| 47 | 47 | int i; |
| 48 | − uint64_t state= pc->state64; | |
| 48 | + uint64_t state = pc->state64; | |
| 49 | 49 | |
| 50 | − if(!s->header_size){ | |
| 51 | − for(i=0; i<buf_size; i++){ | |
| 52 | − state= (state<<8) | buf[i]; | |
| 53 | − if((state&0xFFFF0000FFFFFF00) == 0x8000000003120400ULL && (state&0xFF) && ((state>>32)&0xFFFF)>=4){ | |
| 54 | − s->header_size= ((state>>32)&0xFFFF) + 4; | |
| 55 | − s->block_size = BLOCK_SIZE * (state&0xFF); | |
| 56 | − s->remaining = i - 7 + s->header_size + s->block_size; | |
| 57 | − break; | |
| 50 | + if (!s->header_size) { | |
| 51 | + for (i = 0; i < buf_size; i++) { | |
| 52 | + state = (state << 8) | buf[i]; | |
| 53 | + /* check for fixed fields in ADX header for possible match */ | |
| 54 | + if ((state & 0xFFFF0000FFFFFF00) == 0x8000000003120400ULL) { | |
| 55 | + int channels = state & 0xFF; | |
| 56 | + int header_size = ((state >> 32) & 0xFFFF) + 4; | |
| 57 | + if (channels > 0 && header_size >= 8) { | |
| 58 | + s->header_size = header_size; | |
| 59 | + s->block_size = BLOCK_SIZE * channels; | |
| 60 | + s->remaining = i - 7 + s->header_size + s->block_size; | |
| 61 | + break; | |
| 62 | + } | |
| 58 | 63 | } |
| 59 | 64 | } |
| 60 | − pc->state64= state; | |
| 65 | + pc->state64 = state; | |
| 61 | 66 | } |
| 62 | 67 | |
| 63 | 68 | if (s->header_size) { |
| 64 | − if (!s->remaining) { | |
| 69 | + if (!s->remaining) | |
| 65 | 70 | s->remaining = s->block_size; |
| 66 | − } | |
| 67 | − if (s->remaining<=buf_size) { | |
| 68 | − next= s->remaining; | |
| 71 | + if (s->remaining <= buf_size) { | |
| 72 | + next = s->remaining; | |
| 69 | 73 | s->remaining = 0; |
| 70 | 74 | } else |
| 71 | 75 | s->remaining -= buf_size; |
| @@ -45,7 +45,8 @@ static av_cold int adx_decode_init(AVCodecContext *avctx) · 44 unmodified lines | ||
| 45 | 45 | av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); |
| 46 | 46 | return AVERROR_INVALIDDATA; |
| 47 | 47 | } |
| 48 | − c->channels = avctx->channels; | |
| 48 | + c->channels = avctx->channels; | |
| 49 | + c->header_parsed = 1; | |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| @@ -106,21 +107,21 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, · 54 unmodified lines | ||
| 106 | 107 | return buf_size; |
| 107 | 108 | } |
| 108 | 109 | |
| 109 | − if(AV_RB16(buf) == 0x8000){ | |
| 110 | + if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) { | |
| 110 | 111 | int header_size; |
| 111 | − if ((ret = avpriv_adx_decode_header(avctx, buf, | |
| 112 | − buf_size, &header_size, | |
| 112 | + if ((ret = avpriv_adx_decode_header(avctx, buf, buf_size, &header_size, | |
| 113 | 113 | c->coeff)) < 0) { |
| 114 | 114 | av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); |
| 115 | 115 | return AVERROR_INVALIDDATA; |
| 116 | 116 | } |
| 117 | − c->channels = avctx->channels; | |
| 118 | − if(buf_size < header_size) | |
| 117 | + c->channels = avctx->channels; | |
| 118 | + c->header_parsed = 1; | |
| 119 | + if (buf_size < header_size) | |
| 119 | 120 | return AVERROR_INVALIDDATA; |
| 120 | − buf += header_size; | |
| 121 | + buf += header_size; | |
| 121 | 122 | buf_size -= header_size; |
| 122 | 123 | } |
| 123 | − if(c->channels <= 0) | |
| 124 | + if (!c->header_parsed) | |
| 124 | 125 | return AVERROR_INVALIDDATA; |
| 125 | 126 | |
| 126 | 127 | /* calculate number of blocks in the packet */ |
| @@ -25,27 +25,23 @@ · 24 unmodified lines | ||
| 25 | 25 | * @author 2005 David Hammerton |
| 26 | 26 | * @see http://crazney.net/programs/itunes/alac.html |
| 27 | 27 | * |
| 28 | − * Note: This decoder expects a 36- (0x24-)byte QuickTime atom to be | |
| 28 | + * Note: This decoder expects a 36-byte QuickTime atom to be | |
| 29 | 29 | * passed through the extradata[_size] fields. This atom is tacked onto |
| 30 | 30 | * the end of an 'alac' stsd atom and has the following format: |
| 31 | − * bytes 0-3 atom size (0x24), big-endian | |
| 32 | − * bytes 4-7 atom type ('alac', not the 'alac' tag from start of stsd) | |
| 33 | − * bytes 8-35 data bytes needed by decoder | |
| 34 | 31 | * |
| 35 | − * Extradata: | |
| 36 | − * 32bit size | |
| 37 | − * 32bit tag (=alac) | |
| 38 | − * 32bit zero? | |
| 39 | − * 32bit max sample per frame | |
| 40 | − * 8bit ?? (zero?) | |
| 32 | + * 32bit atom size | |
| 33 | + * 32bit tag ("alac") | |
| 34 | + * 32bit tag version (0) | |
| 35 | + * 32bit samples per frame (used when not set explicitly in the frames) | |
| 36 | + * 8bit compatible version (0) | |
| 41 | 37 | * 8bit sample size |
| 42 | − * 8bit history mult | |
| 43 | − * 8bit initial history | |
| 44 | − * 8bit kmodifier | |
| 45 | − * 8bit channels? | |
| 46 | − * 16bit ?? | |
| 47 | − * 32bit max coded frame size | |
| 48 | − * 32bit bitrate? | |
| 38 | + * 8bit history mult (40) | |
| 39 | + * 8bit initial history (14) | |
| 40 | + * 8bit kmodifier (10) | |
| 41 | + * 8bit channels | |
| 42 | + * 16bit maxRun (255) | |
| 43 | + * 32bit max coded frame size (0 means unknown) | |
| 44 | + * 32bit average bitrate (0 means unknown) | |
| 49 | 45 | * 32bit samplerate |
| 50 | 46 | */ |
| 51 | 47 | |
| @@ -464,24 +460,29 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data, · 412 unmodified lines | ||
| 464 | 460 | if(ret<0) |
| 465 | 461 | return ret; |
| 466 | 462 | |
| 467 | − if (prediction_type[ch] == 0) { | |
| 468 | − /* adaptive fir */ | |
| 469 | − predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], | |
| 470 | − alac->outputsamples_buffer[ch], | |
| 471 | − outputsamples, | |
| 472 | − readsamplesize, | |
| 473 | − predictor_coef_table[ch], | |
| 474 | − predictor_coef_num[ch], | |
| 475 | − prediction_quantitization[ch]); | |
| 476 | − } else { | |
| 477 | − av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[ch]); | |
| 478 | − /* I think the only other prediction type (or perhaps this is | |
| 479 | − * just a boolean?) runs adaptive fir twice.. like: | |
| 480 | − * predictor_decompress_fir_adapt(predictor_error, tempout, ...) | |
| 481 | − * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) | |
| 482 | − * little strange.. | |
| 463 | + /* adaptive FIR filter */ | |
| 464 | + if (prediction_type[ch] == 15) { | |
| 465 | + /* Prediction type 15 runs the adaptive FIR twice. | |
| 466 | + * The first pass uses the special-case coef_num = 31, while | |
| 467 | + * the second pass uses the coefs from the bitstream. | |
| 468 | + * | |
| 469 | + * However, this prediction type is not currently used by the | |
| 470 | + * reference encoder. | |
| 483 | 471 | */ |
| 472 | + predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], | |
| 473 | + alac->predicterror_buffer[ch], | |
| 474 | + outputsamples, readsamplesize, | |
| 475 | + NULL, 31, 0); | |
| 476 | + } else if (prediction_type[ch] > 0) { | |
| 477 | + av_log(avctx, AV_LOG_WARNING, "unknown prediction type: %i\n", | |
| 478 | + prediction_type[ch]); | |
| 484 | 479 | } |
| 480 | + predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], | |
| 481 | + alac->outputsamples_buffer[ch], | |
| 482 | + outputsamples, readsamplesize, | |
| 483 | + predictor_coef_table[ch], | |
| 484 | + predictor_coef_num[ch], | |
| 485 | + prediction_quantitization[ch]); | |
| 485 | 486 | } |
| 486 | 487 | } else { |
| 487 | 488 | /* not compressed, easy case */ |
| @@ -584,7 +585,7 @@ static int alac_set_info(ALACContext *alac) · 96 unmodified lines | ||
| 584 | 585 | |
| 585 | 586 | ptr += 4; /* size */ |
| 586 | 587 | ptr += 4; /* alac */ |
| 587 | − ptr += 4; /* 0 ? */ | |
| 588 | + ptr += 4; /* version */ | |
| 588 | 589 | |
| 589 | 590 | if(AV_RB32(ptr) >= UINT_MAX/4){ |
| 590 | 591 | av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n"); |
| @@ -593,15 +594,15 @@ static int alac_set_info(ALACContext *alac) · 2 unmodified lines | ||
| 593 | 594 | |
| 594 | 595 | /* buffer size / 2 ? */ |
| 595 | 596 | alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr); |
| 596 | − ptr++; /* ??? */ | |
| 597 | + ptr++; /* compatible version */ | |
| 597 | 598 | alac->setinfo_sample_size = *ptr++; |
| 598 | 599 | alac->setinfo_rice_historymult = *ptr++; |
| 599 | 600 | alac->setinfo_rice_initialhistory = *ptr++; |
| 600 | 601 | alac->setinfo_rice_kmodifier = *ptr++; |
| 601 | 602 | alac->numchannels = *ptr++; |
| 602 | − bytestream_get_be16(&ptr); /* ??? */ | |
| 603 | + bytestream_get_be16(&ptr); /* maxRun */ | |
| 603 | 604 | bytestream_get_be32(&ptr); /* max coded frame size */ |
| 604 | − bytestream_get_be32(&ptr); /* bitrate ? */ | |
| 605 | + bytestream_get_be32(&ptr); /* average bitrate */ | |
| 605 | 606 | bytestream_get_be32(&ptr); /* samplerate */ |
| 606 | 607 | |
| 607 | 608 | return 0; |
| @@ -348,6 +348,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 347 unmodified lines | ||
| 348 | 348 | static void write_compressed_frame(AlacEncodeContext *s) |
| 349 | 349 | { |
| 350 | 350 | int i, j; |
| 351 | + int prediction_type = 0; | |
| 351 | 352 | |
| 352 | 353 | if (s->avctx->channels == 2) |
| 353 | 354 | alac_stereo_decorrelation(s); |
| @@ -358,7 +359,7 @@ static void write_compressed_frame(AlacEncodeContext *s) · 4 unmodified lines | ||
| 358 | 359 | |
| 359 | 360 | calc_predictor_params(s, i); |
| 360 | 361 | |
| 361 | − put_bits(&s->pbctx, 4, 0); // prediction type : currently only type 0 has been RE'd | |
| 362 | + put_bits(&s->pbctx, 4, prediction_type); | |
| 362 | 363 | put_bits(&s->pbctx, 4, s->lpc[i].lpc_quant); |
| 363 | 364 | |
| 364 | 365 | put_bits(&s->pbctx, 3, s->rc.rice_modifier); |
| @@ -373,6 +374,14 @@ static void write_compressed_frame(AlacEncodeContext *s) · 8 unmodified lines | ||
| 373 | 374 | |
| 374 | 375 | for (i = 0; i < s->avctx->channels; i++) { |
| 375 | 376 | alac_linear_predictor(s, i); |
| 377 | + | |
| 378 | + // TODO: determine when this will actually help. for now it's not used. | |
| 379 | + if (prediction_type == 15) { | |
| 380 | + // 2nd pass 1st order filter | |
| 381 | + for (j = s->avctx->frame_size - 1; j > 0; j--) | |
| 382 | + s->predictor_buf[j] -= s->predictor_buf[j - 1]; | |
| 383 | + } | |
| 384 | + | |
| 376 | 385 | alac_entropy_coder(s); |
| 377 | 386 | } |
| 378 | 387 | } |
| @@ -391,8 +400,11 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 12 unmodified lines | ||
| 391 | 400 | return -1; |
| 392 | 401 | } |
| 393 | 402 | |
| 394 | − if(avctx->channels > 2) { | |
| 395 | − av_log(avctx, AV_LOG_ERROR, "channels > 2 not supported\n"); | |
| 403 | + /* TODO: Correctly implement multi-channel ALAC. | |
| 404 | + It is similar to multi-channel AAC, in that it has a series of | |
| 405 | + single-channel (SCE), channel-pair (CPE), and LFE elements. */ | |
| 406 | + if (avctx->channels > 2) { | |
| 407 | + av_log(avctx, AV_LOG_ERROR, "only mono or stereo input is currently supported\n"); | |
| 396 | 408 | return AVERROR_PATCHWELCOME; |
| 397 | 409 | } |
| 398 | 410 | |
| @@ -48,13 +48,13 @@ · 47 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | //#define TRACE |
| 50 | 50 | |
| 51 | −#define DCA_PRIM_CHANNELS_MAX (7) | |
| 52 | −#define DCA_SUBBANDS (32) | |
| 53 | −#define DCA_ABITS_MAX (32) /* Should be 28 */ | |
| 54 | −#define DCA_SUBSUBFRAMES_MAX (4) | |
| 55 | −#define DCA_SUBFRAMES_MAX (16) | |
| 56 | −#define DCA_BLOCKS_MAX (16) | |
| 57 | −#define DCA_LFE_MAX (3) | |
| 51 | +#define DCA_PRIM_CHANNELS_MAX (7) | |
| 52 | +#define DCA_SUBBANDS (32) | |
| 53 | +#define DCA_ABITS_MAX (32) /* Should be 28 */ | |
| 54 | +#define DCA_SUBSUBFRAMES_MAX (4) | |
| 55 | +#define DCA_SUBFRAMES_MAX (16) | |
| 56 | +#define DCA_BLOCKS_MAX (16) | |
| 57 | +#define DCA_LFE_MAX (3) | |
| 58 | 58 | |
| 59 | 59 | enum DCAMode { |
| 60 | 60 | DCA_MONO = 0, |
| @@ -127,28 +127,45 @@ static const int dca_ext_audio_descr_mask[] = { · 66 unmodified lines | ||
| 127 | 127 | * OV -> center back |
| 128 | 128 | * All 2 channel configurations -> AV_CH_LAYOUT_STEREO |
| 129 | 129 | */ |
| 130 | − | |
| 131 | 130 | static const uint64_t dca_core_channel_layout[] = { |
| 132 | − AV_CH_FRONT_CENTER, ///< 1, A | |
| 133 | − AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono) | |
| 134 | − AV_CH_LAYOUT_STEREO, ///< 2, L + R (stereo) | |
| 135 | − AV_CH_LAYOUT_STEREO, ///< 2, (L+R) + (L-R) (sum-difference) | |
| 136 | − AV_CH_LAYOUT_STEREO, ///< 2, LT +RT (left and right total) | |
| 137 | − AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER, ///< 3, C+L+R | |
| 138 | − AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER, ///< 3, L+R+S | |
| 139 | − AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, ///< 4, C + L + R+ S | |
| 140 | − AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 4, L + R +SL+ SR | |
| 141 | − AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 5, C + L + R+ SL+SR | |
| 142 | − AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR | |
| 143 | − AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, ///< 6, C + L + R+ LR + RR + OV | |
| 144 | − AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 6, CF+ CR+LF+ RF+LR + RR | |
| 145 | − AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR | |
| 146 | − AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2 | |
| 147 | − AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_BACK_CENTER|AV_CH_SIDE_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR | |
| 131 | + AV_CH_FRONT_CENTER, ///< 1, A | |
| 132 | + AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono) | |
| 133 | + AV_CH_LAYOUT_STEREO, ///< 2, L + R (stereo) | |
| 134 | + AV_CH_LAYOUT_STEREO, ///< 2, (L + R) + (L - R) (sum-difference) | |
| 135 | + AV_CH_LAYOUT_STEREO, ///< 2, LT + RT (left and right total) | |
| 136 | + AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER, ///< 3, C + L + R | |
| 137 | + AV_CH_LAYOUT_STEREO | AV_CH_BACK_CENTER, ///< 3, L + R + S | |
| 138 | + AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 4, C + L + R + S | |
| 139 | + AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 4, L + R + SL + SR | |
| 140 | + | |
| 141 | + AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_SIDE_LEFT | | |
| 142 | + AV_CH_SIDE_RIGHT, ///< 5, C + L + R + SL + SR | |
| 143 | + | |
| 144 | + AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT | | |
| 145 | + AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR | |
| 146 | + | |
| 147 | + AV_CH_LAYOUT_STEREO | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | | |
| 148 | + AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 6, C + L + R + LR + RR + OV | |
| 149 | + | |
| 150 | + AV_CH_FRONT_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER | | |
| 151 | + AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_BACK_CENTER | | |
| 152 | + AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 6, CF + CR + LF + RF + LR + RR | |
| 153 | + | |
| 154 | + AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER | | |
| 155 | + AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO | | |
| 156 | + AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR | |
| 157 | + | |
| 158 | + AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER | | |
| 159 | + AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT | | |
| 160 | + AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2 + SR1 + SR2 | |
| 161 | + | |
| 162 | + AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER | | |
| 163 | + AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO | | |
| 164 | + AV_CH_SIDE_LEFT | AV_CH_BACK_CENTER | AV_CH_SIDE_RIGHT, ///< 8, CL + C + CR + L + R + SL + S + SR | |
| 148 | 165 | }; |
| 149 | 166 | |
| 150 | 167 | static const int8_t dca_lfe_index[] = { |
| 151 | − 1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3 | |
| 168 | + 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3 | |
| 152 | 169 | }; |
| 153 | 170 | |
| 154 | 171 | static const int8_t dca_channel_reorder_lfe[][9] = { |
| @@ -227,19 +244,19 @@ static const int8_t dca_channel_reorder_nolfe_xch[][9] = { · 72 unmodified lines | ||
| 227 | 244 | { 3, 2, 4, 0, 1, 5, 8, 7, 6}, |
| 228 | 245 | }; |
| 229 | 246 | |
| 230 | −#define DCA_DOLBY 101 /* FIXME */ | |
| 247 | +#define DCA_DOLBY 101 /* FIXME */ | |
| 231 | 248 | |
| 232 | −#define DCA_CHANNEL_BITS 6 | |
| 233 | −#define DCA_CHANNEL_MASK 0x3F | |
| 249 | +#define DCA_CHANNEL_BITS 6 | |
| 250 | +#define DCA_CHANNEL_MASK 0x3F | |
| 234 | 251 | |
| 235 | −#define DCA_LFE 0x80 | |
| 252 | +#define DCA_LFE 0x80 | |
| 236 | 253 | |
| 237 | −#define HEADER_SIZE 14 | |
| 254 | +#define HEADER_SIZE 14 | |
| 238 | 255 | |
| 239 | −#define DCA_MAX_FRAME_SIZE 16384 | |
| 240 | −#define DCA_MAX_EXSS_HEADER_SIZE 4096 | |
| 256 | +#define DCA_MAX_FRAME_SIZE 16384 | |
| 257 | +#define DCA_MAX_EXSS_HEADER_SIZE 4096 | |
| 241 | 258 | |
| 242 | −#define DCA_BUFFER_PADDING_SIZE 1024 | |
| 259 | +#define DCA_BUFFER_PADDING_SIZE 1024 | |
| 243 | 260 | |
| 244 | 261 | /** Bit allocation */ |
| 245 | 262 | typedef struct { |
| @@ -254,9 +271,11 @@ static BitAlloc dca_tmode; ///< transition mode VLCs · 8 unmodified lines | ||
| 254 | 271 | static BitAlloc dca_scalefactor; ///< scalefactor VLCs |
| 255 | 272 | static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs |
| 256 | 273 | |
| 257 | −static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx) | |
| 274 | +static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, | |
| 275 | + int idx) | |
| 258 | 276 | { |
| 259 | − return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + ba->offset; | |
| 277 | + return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + | |
| 278 | + ba->offset; | |
| 260 | 279 | } |
| 261 | 280 | |
| 262 | 281 | typedef struct { |
| @@ -306,8 +325,8 @@ typedef struct { · 43 unmodified lines | ||
| 306 | 325 | float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment |
| 307 | 326 | |
| 308 | 327 | /* Primary audio coding side information */ |
| 309 | − int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes | |
| 310 | − int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count | |
| 328 | + int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes | |
| 329 | + int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count | |
| 311 | 330 | int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not) |
| 312 | 331 | int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs |
| 313 | 332 | int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index |
| @@ -334,13 +353,13 @@ typedef struct { · 20 unmodified lines | ||
| 334 | 353 | float scale_bias; ///< output scale |
| 335 | 354 | |
| 336 | 355 | DECLARE_ALIGNED(32, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; |
| 337 | − DECLARE_ALIGNED(32, float, samples)[(DCA_PRIM_CHANNELS_MAX+1)*256]; | |
| 338 | − const float *samples_chanptr[DCA_PRIM_CHANNELS_MAX+1]; | |
| 356 | + DECLARE_ALIGNED(32, float, samples)[(DCA_PRIM_CHANNELS_MAX + 1) * 256]; | |
| 357 | + const float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1]; | |
| 339 | 358 | |
| 340 | 359 | uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE]; |
| 341 | 360 | int dca_buffer_size; ///< how much data is in the dca_buffer |
| 342 | 361 | |
| 343 | − const int8_t* channel_order_tab; ///< channel reordering table, lfe and non lfe | |
| 362 | + const int8_t *channel_order_tab; ///< channel reordering table, lfe and non lfe | |
| 344 | 363 | GetBitContext gb; |
| 345 | 364 | /* Current position in DCA frame */ |
| 346 | 365 | int current_subframe; |
| @@ -415,13 +434,15 @@ static av_cold void dca_init_vlcs(void) · 68 unmodified lines | ||
| 415 | 434 | } |
| 416 | 435 | |
| 417 | 436 | for (i = 0; i < 10; i++) |
| 418 | − for (j = 0; j < 7; j++){ | |
| 419 | − if (!bitalloc_codes[i][j]) break; | |
| 420 | − dca_smpl_bitalloc[i+1].offset = bitalloc_offsets[i]; | |
| 421 | − dca_smpl_bitalloc[i+1].wrap = 1 + (j > 4); | |
| 422 | − dca_smpl_bitalloc[i+1].vlc[j].table = &dca_table[dca_vlc_offs[c]]; | |
| 423 | − dca_smpl_bitalloc[i+1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c]; | |
| 424 | − init_vlc(&dca_smpl_bitalloc[i+1].vlc[j], bitalloc_maxbits[i][j], | |
| 437 | + for (j = 0; j < 7; j++) { | |
| 438 | + if (!bitalloc_codes[i][j]) | |
| 439 | + break; | |
| 440 | + dca_smpl_bitalloc[i + 1].offset = bitalloc_offsets[i]; | |
| 441 | + dca_smpl_bitalloc[i + 1].wrap = 1 + (j > 4); | |
| 442 | + dca_smpl_bitalloc[i + 1].vlc[j].table = &dca_table[dca_vlc_offs[c]]; | |
| 443 | + dca_smpl_bitalloc[i + 1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c]; | |
| 444 | + | |
| 445 | + init_vlc(&dca_smpl_bitalloc[i + 1].vlc[j], bitalloc_maxbits[i][j], | |
| 425 | 446 | bitalloc_sizes[i], |
| 426 | 447 | bitalloc_bits[i][j], 1, 1, |
| 427 | 448 | bitalloc_codes[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC); |
| @@ -432,19 +453,19 @@ static av_cold void dca_init_vlcs(void) · 4 unmodified lines | ||
| 432 | 453 | |
| 433 | 454 | static inline void get_array(GetBitContext *gb, int *dst, int len, int bits) |
| 434 | 455 | { |
| 435 | − while(len--) | |
| 456 | + while (len--) | |
| 436 | 457 | *dst++ = get_bits(gb, bits); |
| 437 | 458 | } |
| 438 | 459 | |
| 439 | −static int dca_parse_audio_coding_header(DCAContext * s, int base_channel) | |
| 460 | +static int dca_parse_audio_coding_header(DCAContext *s, int base_channel) | |
| 440 | 461 | { |
| 441 | 462 | int i, j; |
| 442 | 463 | static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 }; |
| 443 | 464 | static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }; |
| 444 | − static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; | |
| 465 | + static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; | |
| 445 | 466 | |
| 446 | − s->total_channels = get_bits(&s->gb, 3) + 1 + base_channel; | |
| 447 | − s->prim_channels = s->total_channels; | |
| 467 | + s->total_channels = get_bits(&s->gb, 3) + 1 + base_channel; | |
| 468 | + s->prim_channels = s->total_channels; | |
| 448 | 469 | |
| 449 | 470 | if (s->prim_channels > DCA_PRIM_CHANNELS_MAX) |
| 450 | 471 | s->prim_channels = DCA_PRIM_CHANNELS_MAX; |
| @@ -487,23 +508,28 @@ static int dca_parse_audio_coding_header(DCAContext * s, int base_channel) · 36 unmodified lines | ||
| 487 | 508 | get_bits(&s->gb, 16); |
| 488 | 509 | } |
| 489 | 510 | |
| 490 | − s->current_subframe = 0; | |
| 511 | + s->current_subframe = 0; | |
| 491 | 512 | s->current_subsubframe = 0; |
| 492 | 513 | |
| 493 | 514 | #ifdef TRACE |
| 494 | 515 | av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes); |
| 495 | 516 | av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels); |
| 496 | − for (i = base_channel; i < s->prim_channels; i++){ | |
| 497 | − av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]); | |
| 498 | − av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]); | |
| 499 | − av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]); | |
| 500 | − av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]); | |
| 501 | − av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]); | |
| 502 | − av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]); | |
| 517 | + for (i = base_channel; i < s->prim_channels; i++) { | |
| 518 | + av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", | |
| 519 | + s->subband_activity[i]); | |
| 520 | + av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", | |
| 521 | + s->vq_start_subband[i]); | |
| 522 | + av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", | |
| 523 | + s->joint_intensity[i]); | |
| 524 | + av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", | |
| 525 | + s->transient_huffman[i]); | |
| 526 | + av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", | |
| 527 | + s->scalefactor_huffman[i]); | |
| 528 | + av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", | |
| 529 | + s->bitalloc_huffman[i]); | |
| 503 | 530 | av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:"); |
| 504 | 531 | for (j = 0; j < 11; j++) |
| 505 | − av_log(s->avctx, AV_LOG_DEBUG, " %i", | |
| 506 | − s->quant_index_huffman[i][j]); | |
| 532 | + av_log(s->avctx, AV_LOG_DEBUG, " %i", s->quant_index_huffman[i][j]); | |
| 507 | 533 | av_log(s->avctx, AV_LOG_DEBUG, "\n"); |
| 508 | 534 | av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:"); |
| 509 | 535 | for (j = 0; j < 11; j++) |
| @@ -512,10 +538,10 @@ static int dca_parse_audio_coding_header(DCAContext * s, int base_channel) · 2 unmodified lines | ||
| 512 | 538 | } |
| 513 | 539 | #endif |
| 514 | 540 | |
| 515 | − return 0; | |
| 541 | + return 0; | |
| 516 | 542 | } |
| 517 | 543 | |
| 518 | −static int dca_parse_frame_header(DCAContext * s) | |
| 544 | +static int dca_parse_frame_header(DCAContext *s) | |
| 519 | 545 | { |
| 520 | 546 | init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); |
| 521 | 547 | |
| @@ -564,7 +590,8 @@ static int dca_parse_frame_header(DCAContext * s) · 42 unmodified lines | ||
| 564 | 590 | |
| 565 | 591 | /* FIXME: channels mixing levels */ |
| 566 | 592 | s->output = s->amode; |
| 567 | − if (s->lfe) s->output |= DCA_LFE; | |
| 593 | + if (s->lfe) | |
| 594 | + s->output |= DCA_LFE; | |
| 568 | 595 | |
| 569 | 596 | #ifdef TRACE |
| 570 | 597 | av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type); |
| @@ -613,15 +640,15 @@ static int dca_parse_frame_header(DCAContext * s) · 42 unmodified lines | ||
| 613 | 640 | |
| 614 | 641 | static inline int get_scale(GetBitContext *gb, int level, int value) |
| 615 | 642 | { |
| 616 | − if (level < 5) { | |
| 617 | − /* huffman encoded */ | |
| 618 | − value += get_bitalloc(gb, &dca_scalefactor, level); | |
| 619 | − } else if (level < 8) | |
| 620 | − value = get_bits(gb, level + 1); | |
| 621 | − return value; | |
| 643 | + if (level < 5) { | |
| 644 | + /* huffman encoded */ | |
| 645 | + value += get_bitalloc(gb, &dca_scalefactor, level); | |
| 646 | + } else if (level < 8) | |
| 647 | + value = get_bits(gb, level + 1); | |
| 648 | + return value; | |
| 622 | 649 | } |
| 623 | 650 | |
| 624 | −static int dca_subframe_header(DCAContext * s, int base_channel, int block_index) | |
| 651 | +static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) | |
| 625 | 652 | { |
| 626 | 653 | /* Primary audio coding side information */ |
| 627 | 654 | int j, k; |
| @@ -630,7 +657,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 2 unmodified lines | ||
| 630 | 657 | return AVERROR_INVALIDDATA; |
| 631 | 658 | |
| 632 | 659 | if (!base_channel) { |
| 633 | − s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; | |
| 660 | + s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; | |
| 634 | 661 | s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3); |
| 635 | 662 | } |
| 636 | 663 | |
| @@ -666,8 +693,8 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 29 unmodified lines | ||
| 666 | 693 | } |
| 667 | 694 | |
| 668 | 695 | if (s->bitalloc[j][k] > 26) { |
| 669 | −// av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n", | |
| 670 | −// j, k, s->bitalloc[j][k]); | |
| 696 | + // av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index [%i][%i] too big (%i)\n", | |
| 697 | + // j, k, s->bitalloc[j][k]); | |
| 671 | 698 | return AVERROR_INVALIDDATA; |
| 672 | 699 | } |
| 673 | 700 | } |
| @@ -692,7 +719,8 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 18 unmodified lines | ||
| 692 | 719 | const uint32_t *scale_table; |
| 693 | 720 | int scale_sum; |
| 694 | 721 | |
| 695 | − memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); | |
| 722 | + memset(s->scale_factor[j], 0, | |
| 723 | + s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); | |
| 696 | 724 | |
| 697 | 725 | if (s->scalefactor_huffman[j] == 6) |
| 698 | 726 | scale_table = scale_factor_quant7; |
| @@ -810,9 +838,11 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 111 unmodified lines | ||
| 810 | 838 | } |
| 811 | 839 | |
| 812 | 840 | #ifdef TRACE |
| 813 | − av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes[s->current_subframe]); | |
| 841 | + av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", | |
| 842 | + s->subsubframes[s->current_subframe]); | |
| 814 | 843 | av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n", |
| 815 | 844 | s->partial_samples[s->current_subframe]); |
| 845 | + | |
| 816 | 846 | for (j = base_channel; j < s->prim_channels; j++) { |
| 817 | 847 | av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:"); |
| 818 | 848 | for (k = 0; k < s->subband_activity[j]; k++) |
| @@ -821,12 +851,12 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 2 unmodified lines | ||
| 821 | 851 | } |
| 822 | 852 | for (j = base_channel; j < s->prim_channels; j++) { |
| 823 | 853 | for (k = 0; k < s->subband_activity[j]; k++) |
| 824 | − av_log(s->avctx, AV_LOG_DEBUG, | |
| 825 | − "prediction coefs: %f, %f, %f, %f\n", | |
| 826 | − (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192, | |
| 827 | − (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192, | |
| 828 | − (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192, | |
| 829 | − (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192); | |
| 854 | + av_log(s->avctx, AV_LOG_DEBUG, | |
| 855 | + "prediction coefs: %f, %f, %f, %f\n", | |
| 856 | + (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192, | |
| 857 | + (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192, | |
| 858 | + (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192, | |
| 859 | + (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192); | |
| 830 | 860 | } |
| 831 | 861 | for (j = base_channel; j < s->prim_channels; j++) { |
| 832 | 862 | av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: "); |
| @@ -862,8 +892,10 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 29 unmodified lines | ||
| 862 | 892 | if (!base_channel && s->prim_channels > 2 && s->downmix) { |
| 863 | 893 | av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n"); |
| 864 | 894 | for (j = 0; j < s->prim_channels; j++) { |
| 865 | − av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]); | |
| 866 | − av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]); | |
| 895 | + av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j, | |
| 896 | + dca_downmix_coeffs[s->downmix_coef[j][0]]); | |
| 897 | + av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j, | |
| 898 | + dca_downmix_coeffs[s->downmix_coef[j][1]]); | |
| 867 | 899 | } |
| 868 | 900 | av_log(s->avctx, AV_LOG_DEBUG, "\n"); |
| 869 | 901 | } |
| @@ -884,7 +916,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 14 unmodified lines | ||
| 884 | 916 | return 0; |
| 885 | 917 | } |
| 886 | 918 | |
| 887 | −static void qmf_32_subbands(DCAContext * s, int chans, | |
| 919 | +static void qmf_32_subbands(DCAContext *s, int chans, | |
| 888 | 920 | float samples_in[32][8], float *samples_out, |
| 889 | 921 | float scale) |
| 890 | 922 | { |
| @@ -894,7 +926,7 @@ static void qmf_32_subbands(DCAContext * s, int chans, · 3 unmodified lines | ||
| 894 | 926 | int sb_act = s->subband_activity[chans]; |
| 895 | 927 | int subindex; |
| 896 | 928 | |
| 897 | − scale *= sqrt(1/8.0); | |
| 929 | + scale *= sqrt(1 / 8.0); | |
| 898 | 930 | |
| 899 | 931 | /* Select filter */ |
| 900 | 932 | if (!s->multirate_inter) /* Non-perfect reconstruction */ |
| @@ -908,18 +940,18 @@ static void qmf_32_subbands(DCAContext * s, int chans, · 7 unmodified lines | ||
| 908 | 940 | /* Reconstructed channel sample index */ |
| 909 | 941 | for (subindex = 0; subindex < 8; subindex++) { |
| 910 | 942 | /* Load in one sample from each subband and clear inactive subbands */ |
| 911 | − for (i = 0; i < sb_act; i++){ | |
| 943 | + for (i = 0; i < sb_act; i++) { | |
| 912 | 944 | unsigned sign = (i - 1) & 2; |
| 913 | − uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30; | |
| 945 | + uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30; | |
| 914 | 946 | AV_WN32A(&s->raXin[i], v); |
| 915 | 947 | } |
| 916 | 948 | |
| 917 | 949 | s->synth.synth_filter_float(&s->imdct, |
| 918 | − s->subband_fir_hist[chans], &s->hist_index[chans], | |
| 919 | − s->subband_fir_noidea[chans], prCoeff, | |
| 920 | − samples_out, s->raXin, scale); | |
| 921 | − samples_out+= 32; | |
| 922 | − | |
| 950 | + s->subband_fir_hist[chans], | |
| 951 | + &s->hist_index[chans], | |
| 952 | + s->subband_fir_noidea[chans], prCoeff, | |
| 953 | + samples_out, s->raXin, scale); | |
| 954 | + samples_out += 32; | |
| 923 | 955 | } |
| 924 | 956 | } |
| 925 | 957 | |
| @@ -949,45 +981,44 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, · 23 unmodified lines | ||
| 949 | 981 | } |
| 950 | 982 | /* Interpolation */ |
| 951 | 983 | for (deciindex = 0; deciindex < num_deci_sample; deciindex++) { |
| 952 | − s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, | |
| 953 | − scale); | |
| 984 | + s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale); | |
| 954 | 985 | samples_in++; |
| 955 | 986 | samples_out += 2 * decifactor; |
| 956 | 987 | } |
| 957 | 988 | } |
| 958 | 989 | |
| 959 | 990 | /* downmixing routines */ |
| 960 | −#define MIX_REAR1(samples, si1, rs, coef) \ | |
| 961 | − samples[i] += samples[si1] * coef[rs][0]; \ | |
| 962 | − samples[i+256] += samples[si1] * coef[rs][1]; | |
| 963 | − | |
| 964 | −#define MIX_REAR2(samples, si1, si2, rs, coef) \ | |
| 965 | − samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs+1][0]; \ | |
| 966 | − samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs+1][1]; | |
| 967 | − | |
| 968 | −#define MIX_FRONT3(samples, coef) \ | |
| 969 | − t = samples[i+c]; \ | |
| 970 | − u = samples[i+l]; \ | |
| 971 | − v = samples[i+r]; \ | |
| 991 | +#define MIX_REAR1(samples, si1, rs, coef) \ | |
| 992 | + samples[i] += samples[si1] * coef[rs][0]; \ | |
| 993 | + samples[i+256] += samples[si1] * coef[rs][1]; | |
| 994 | + | |
| 995 | +#define MIX_REAR2(samples, si1, si2, rs, coef) \ | |
| 996 | + samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs + 1][0]; \ | |
| 997 | + samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs + 1][1]; | |
| 998 | + | |
| 999 | +#define MIX_FRONT3(samples, coef) \ | |
| 1000 | + t = samples[i + c]; \ | |
| 1001 | + u = samples[i + l]; \ | |
| 1002 | + v = samples[i + r]; \ | |
| 972 | 1003 | samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \ |
| 973 | 1004 | samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1]; |
| 974 | 1005 | |
| 975 | −#define DOWNMIX_TO_STEREO(op1, op2) \ | |
| 976 | − for (i = 0; i < 256; i++){ \ | |
| 977 | − op1 \ | |
| 978 | − op2 \ | |
| 1006 | +#define DOWNMIX_TO_STEREO(op1, op2) \ | |
| 1007 | + for (i = 0; i < 256; i++) { \ | |
| 1008 | + op1 \ | |
| 1009 | + op2 \ | |
| 979 | 1010 | } |
| 980 | 1011 | |
| 981 | 1012 | static void dca_downmix(float *samples, int srcfmt, |
| 982 | 1013 | int downmix_coef[DCA_PRIM_CHANNELS_MAX][2], |
| 983 | 1014 | const int8_t *channel_mapping) |
| 984 | 1015 | { |
| 985 | − int c,l,r,sl,sr,s; | |
| 1016 | + int c, l, r, sl, sr, s; | |
| 986 | 1017 | int i; |
| 987 | 1018 | float t, u, v; |
| 988 | 1019 | float coef[DCA_PRIM_CHANNELS_MAX][2]; |
| 989 | 1020 | |
| 990 | − for (i=0; i<DCA_PRIM_CHANNELS_MAX; i++) { | |
| 1021 | + for (i = 0; i < DCA_PRIM_CHANNELS_MAX; i++) { | |
| 991 | 1022 | coef[i][0] = dca_downmix_coeffs[downmix_coef[i][0]]; |
| 992 | 1023 | coef[i][1] = dca_downmix_coeffs[downmix_coef[i][1]]; |
| 993 | 1024 | } |
| @@ -1006,11 +1037,11 @@ static void dca_downmix(float *samples, int srcfmt, · 12 unmodified lines | ||
| 1006 | 1037 | c = channel_mapping[0] * 256; |
| 1007 | 1038 | l = channel_mapping[1] * 256; |
| 1008 | 1039 | r = channel_mapping[2] * 256; |
| 1009 | − DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),); | |
| 1040 | + DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), ); | |
| 1010 | 1041 | break; |
| 1011 | 1042 | case DCA_2F1R: |
| 1012 | 1043 | s = channel_mapping[2] * 256; |
| 1013 | − DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + s, 2, coef),); | |
| 1044 | + DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + s, 2, coef), ); | |
| 1014 | 1045 | break; |
| 1015 | 1046 | case DCA_3F1R: |
| 1016 | 1047 | c = channel_mapping[0] * 256; |
| @@ -1023,12 +1054,12 @@ static void dca_downmix(float *samples, int srcfmt, · 6 unmodified lines | ||
| 1023 | 1054 | case DCA_2F2R: |
| 1024 | 1055 | sl = channel_mapping[2] * 256; |
| 1025 | 1056 | sr = channel_mapping[3] * 256; |
| 1026 | − DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + sl, i + sr, 2, coef),); | |
| 1057 | + DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + sl, i + sr, 2, coef), ); | |
| 1027 | 1058 | break; |
| 1028 | 1059 | case DCA_3F2R: |
| 1029 | − c = channel_mapping[0] * 256; | |
| 1030 | − l = channel_mapping[1] * 256; | |
| 1031 | − r = channel_mapping[2] * 256; | |
| 1060 | + c = channel_mapping[0] * 256; | |
| 1061 | + l = channel_mapping[1] * 256; | |
| 1062 | + r = channel_mapping[2] * 256; | |
| 1032 | 1063 | sl = channel_mapping[3] * 256; |
| 1033 | 1064 | sr = channel_mapping[4] * 256; |
| 1034 | 1065 | DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), |
| @@ -1048,7 +1079,7 @@ static int decode_blockcode(int code, int levels, int *values) · 13 unmodified lines | ||
| 1048 | 1079 | |
| 1049 | 1080 | for (i = 0; i < 4; i++) { |
| 1050 | 1081 | int div = FASTDIV(code, levels); |
| 1051 | − values[i] = code - offset - div*levels; | |
| 1082 | + values[i] = code - offset - div * levels; | |
| 1052 | 1083 | code = div; |
| 1053 | 1084 | } |
| 1054 | 1085 | |
| @@ -1062,8 +1093,8 @@ static int decode_blockcodes(int code1, int code2, int levels, int *values) · 7 unmodified lines | ||
| 1062 | 1093 | } |
| 1063 | 1094 | #endif |
| 1064 | 1095 | |
| 1065 | −static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }; | |
| 1066 | −static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }; | |
| 1096 | +static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }; | |
| 1097 | +static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }; | |
| 1067 | 1098 | |
| 1068 | 1099 | #ifndef int8x8_fmul_int32 |
| 1069 | 1100 | static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale) |
| @@ -1075,7 +1106,7 @@ static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale) · 5 unmodified lines | ||
| 1075 | 1106 | } |
| 1076 | 1107 | #endif |
| 1077 | 1108 | |
| 1078 | −static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) | |
| 1109 | +static int dca_subsubframe(DCAContext *s, int base_channel, int block_index) | |
| 1079 | 1110 | { |
| 1080 | 1111 | int k, l; |
| 1081 | 1112 | int subsubframe = s->current_subsubframe; |
| @@ -1118,20 +1149,21 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 36 unmodified lines | ||
| 1118 | 1149 | /* |
| 1119 | 1150 | * Extract bits from the bit stream |
| 1120 | 1151 | */ |
| 1121 | − if (!abits){ | |
| 1152 | + if (!abits) { | |
| 1122 | 1153 | memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0])); |
| 1123 | 1154 | } else { |
| 1124 | 1155 | /* Deal with transients */ |
| 1125 | 1156 | int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l]; |
| 1126 | − float rscale = quant_step_size * s->scale_factor[k][l][sfi] * s->scalefactor_adj[k][sel]; | |
| 1157 | + float rscale = quant_step_size * s->scale_factor[k][l][sfi] * | |
| 1158 | + s->scalefactor_adj[k][sel]; | |
| 1127 | 1159 | |
| 1128 | − if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){ | |
| 1129 | − if (abits <= 7){ | |
| 1160 | + if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) { | |
| 1161 | + if (abits <= 7) { | |
| 1130 | 1162 | /* Block code */ |
| 1131 | 1163 | int block_code1, block_code2, size, levels, err; |
| 1132 | 1164 | |
| 1133 | − size = abits_sizes[abits-1]; | |
| 1134 | − levels = abits_levels[abits-1]; | |
| 1165 | + size = abits_sizes[abits - 1]; | |
| 1166 | + levels = abits_levels[abits - 1]; | |
| 1135 | 1167 | |
| 1136 | 1168 | block_code1 = get_bits(&s->gb, size); |
| 1137 | 1169 | block_code2 = get_bits(&s->gb, size); |
| @@ -1142,19 +1174,20 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 4 unmodified lines | ||
| 1142 | 1174 | "ERROR: block code look-up failed\n"); |
| 1143 | 1175 | return AVERROR_INVALIDDATA; |
| 1144 | 1176 | } |
| 1145 | − }else{ | |
| 1177 | + } else { | |
| 1146 | 1178 | /* no coding */ |
| 1147 | 1179 | for (m = 0; m < 8; m++) |
| 1148 | 1180 | block[m] = get_sbits(&s->gb, abits - 3); |
| 1149 | 1181 | } |
| 1150 | − }else{ | |
| 1182 | + } else { | |
| 1151 | 1183 | /* Huffman coded */ |
| 1152 | 1184 | for (m = 0; m < 8; m++) |
| 1153 | − block[m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel); | |
| 1185 | + block[m] = get_bitalloc(&s->gb, | |
| 1186 | + &dca_smpl_bitalloc[abits], sel); | |
| 1154 | 1187 | } |
| 1155 | 1188 | |
| 1156 | 1189 | s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l], |
| 1157 | − block, rscale, 8); | |
| 1190 | + block, rscale, 8); | |
| 1158 | 1191 | } |
| 1159 | 1192 | |
| 1160 | 1193 | /* |
| @@ -1171,8 +1204,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 10 unmodified lines | ||
| 1171 | 1204 | else if (s->predictor_history) |
| 1172 | 1205 | subband_samples[k][l][m] += |
| 1173 | 1206 | (adpcm_vb[s->prediction_vq[k][l]][n - 1] * |
| 1174 | − s->subband_samples_hist[k][l][m - n + | |
| 1175 | − 4] / 8192); | |
| 1207 | + s->subband_samples_hist[k][l][m - n + 4] / 8192); | |
| 1176 | 1208 | } |
| 1177 | 1209 | } |
| 1178 | 1210 | } |
| @@ -1186,7 +1218,8 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 7 unmodified lines | ||
| 1186 | 1218 | int hfvq = s->high_freq_vq[k][l]; |
| 1187 | 1219 | |
| 1188 | 1220 | if (!s->debug_flag & 0x01) { |
| 1189 | − av_log(s->avctx, AV_LOG_DEBUG, "Stream with high frequencies VQ coding\n"); | |
| 1221 | + av_log(s->avctx, AV_LOG_DEBUG, | |
| 1222 | + "Stream with high frequencies VQ coding\n"); | |
| 1190 | 1223 | s->debug_flag |= 0x01; |
| 1191 | 1224 | } |
| 1192 | 1225 | |
| @@ -1210,23 +1243,25 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 17 unmodified lines | ||
| 1210 | 1243 | /* Backup predictor history for adpcm */ |
| 1211 | 1244 | for (k = base_channel; k < s->prim_channels; k++) |
| 1212 | 1245 | for (l = 0; l < s->vq_start_subband[k]; l++) |
| 1213 | − memcpy(s->subband_samples_hist[k][l], &subband_samples[k][l][4], | |
| 1214 | − 4 * sizeof(subband_samples[0][0][0])); | |
| 1246 | + memcpy(s->subband_samples_hist[k][l], | |
| 1247 | + &subband_samples[k][l][4], | |
| 1248 | + 4 * sizeof(subband_samples[0][0][0])); | |
| 1215 | 1249 | |
| 1216 | 1250 | return 0; |
| 1217 | 1251 | } |
| 1218 | 1252 | |
| 1219 | −static int dca_filter_channels(DCAContext * s, int block_index) | |
| 1253 | +static int dca_filter_channels(DCAContext *s, int block_index) | |
| 1220 | 1254 | { |
| 1221 | 1255 | float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index]; |
| 1222 | 1256 | int k; |
| 1223 | 1257 | |
| 1224 | 1258 | /* 32 subbands QMF */ |
| 1225 | 1259 | for (k = 0; k < s->prim_channels; k++) { |
| 1226 | −/* static float pcm_to_double[8] = | |
| 1227 | − {32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/ | |
| 1228 | − qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * s->channel_order_tab[k]], | |
| 1229 | − M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ ); | |
| 1260 | +/* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0, | |
| 1261 | + 0, 8388608.0, 8388608.0 };*/ | |
| 1262 | + qmf_32_subbands(s, k, subband_samples[k], | |
| 1263 | + &s->samples[256 * s->channel_order_tab[k]], | |
| 1264 | + M_SQRT1_2 * s->scale_bias /* pcm_to_double[s->source_pcm_res] */); | |
| 1230 | 1265 | } |
| 1231 | 1266 | |
| 1232 | 1267 | /* Down mixing */ |
| @@ -1239,7 +1274,7 @@ static int dca_filter_channels(DCAContext * s, int block_index) · 6 unmodified lines | ||
| 1239 | 1274 | lfe_interpolation_fir(s, s->lfe, 2 * s->lfe, |
| 1240 | 1275 | s->lfe_data + 2 * s->lfe * (block_index + 4), |
| 1241 | 1276 | &s->samples[256 * dca_lfe_index[s->amode]], |
| 1242 | − (1.0/256.0)*s->scale_bias); | |
| 1277 | + (1.0 / 256.0) * s->scale_bias); | |
| 1243 | 1278 | /* Outputs 20bits pcm samples */ |
| 1244 | 1279 | } |
| 1245 | 1280 | |
| @@ -1247,7 +1282,7 @@ static int dca_filter_channels(DCAContext * s, int block_index) · 1 unmodified line | ||
| 1247 | 1282 | } |
| 1248 | 1283 | |
| 1249 | 1284 | |
| 1250 | −static int dca_subframe_footer(DCAContext * s, int base_channel) | |
| 1285 | +static int dca_subframe_footer(DCAContext *s, int base_channel) | |
| 1251 | 1286 | { |
| 1252 | 1287 | int aux_data_count = 0, i; |
| 1253 | 1288 | |
| @@ -1279,7 +1314,7 @@ static int dca_subframe_footer(DCAContext * s, int base_channel) · 25 unmodified lines | ||
| 1279 | 1314 | * @param s pointer to the DCAContext |
| 1280 | 1315 | */ |
| 1281 | 1316 | |
| 1282 | −static int dca_decode_block(DCAContext * s, int base_channel, int block_index) | |
| 1317 | +static int dca_decode_block(DCAContext *s, int base_channel, int block_index) | |
| 1283 | 1318 | { |
| 1284 | 1319 | int ret; |
| 1285 | 1320 | |
| @@ -1327,8 +1362,8 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index) · 41 unmodified lines | ||
| 1327 | 1362 | /** |
| 1328 | 1363 | * Convert bitstream to one representation based on sync marker |
| 1329 | 1364 | */ |
| 1330 | −static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * dst, | |
| 1331 | − int max_size) | |
| 1365 | +static int dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, | |
| 1366 | + int max_size) | |
| 1332 | 1367 | { |
| 1333 | 1368 | uint32_t mrk; |
| 1334 | 1369 | int i, tmp; |
| @@ -1336,7 +1371,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds · 1 unmodified line | ||
| 1336 | 1371 | uint16_t *sdst = (uint16_t *) dst; |
| 1337 | 1372 | PutBitContext pb; |
| 1338 | 1373 | |
| 1339 | − if ((unsigned)src_size > (unsigned)max_size) { | |
| 1374 | + if ((unsigned) src_size > (unsigned) max_size) { | |
| 1340 | 1375 | // av_log(NULL, AV_LOG_ERROR, "Input frame size larger than DCA_MAX_FRAME_SIZE!\n"); |
| 1341 | 1376 | // return -1; |
| 1342 | 1377 | src_size = max_size; |
| @@ -1371,18 +1406,16 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds · 28 unmodified lines | ||
| 1371 | 1406 | static int dca_exss_mask2count(int mask) |
| 1372 | 1407 | { |
| 1373 | 1408 | /* count bits that mean speaker pairs twice */ |
| 1374 | − return av_popcount(mask) | |
| 1375 | − + av_popcount(mask & ( | |
| 1376 | − DCA_EXSS_CENTER_LEFT_RIGHT | |
| 1377 | − | DCA_EXSS_FRONT_LEFT_RIGHT | |
| 1378 | − | DCA_EXSS_FRONT_HIGH_LEFT_RIGHT | |
| 1379 | − | DCA_EXSS_WIDE_LEFT_RIGHT | |
| 1380 | − | DCA_EXSS_SIDE_LEFT_RIGHT | |
| 1381 | − | DCA_EXSS_SIDE_HIGH_LEFT_RIGHT | |
| 1382 | − | DCA_EXSS_SIDE_REAR_LEFT_RIGHT | |
| 1383 | − | DCA_EXSS_REAR_LEFT_RIGHT | |
| 1384 | − | DCA_EXSS_REAR_HIGH_LEFT_RIGHT | |
| 1385 | − )); | |
| 1409 | + return av_popcount(mask) + | |
| 1410 | + av_popcount(mask & (DCA_EXSS_CENTER_LEFT_RIGHT | | |
| 1411 | + DCA_EXSS_FRONT_LEFT_RIGHT | | |
| 1412 | + DCA_EXSS_FRONT_HIGH_LEFT_RIGHT | | |
| 1413 | + DCA_EXSS_WIDE_LEFT_RIGHT | | |
| 1414 | + DCA_EXSS_SIDE_LEFT_RIGHT | | |
| 1415 | + DCA_EXSS_SIDE_HIGH_LEFT_RIGHT | | |
| 1416 | + DCA_EXSS_SIDE_REAR_LEFT_RIGHT | | |
| 1417 | + DCA_EXSS_REAR_LEFT_RIGHT | | |
| 1418 | + DCA_EXSS_REAR_HIGH_LEFT_RIGHT)); | |
| 1386 | 1419 | } |
| 1387 | 1420 | |
| 1388 | 1421 | /** |
| @@ -1408,7 +1441,7 @@ static int dca_exss_parse_asset_header(DCAContext *s) · 19 unmodified lines | ||
| 1408 | 1441 | int header_size; |
| 1409 | 1442 | int channels; |
| 1410 | 1443 | int embedded_stereo = 0; |
| 1411 | − int embedded_6ch = 0; | |
| 1444 | + int embedded_6ch = 0; | |
| 1412 | 1445 | int drc_code_present; |
| 1413 | 1446 | int extensions_mask; |
| 1414 | 1447 | int i, j; |
| @@ -1543,7 +1576,8 @@ static int dca_exss_parse_asset_header(DCAContext *s) · 128 unmodified lines | ||
| 1543 | 1576 | if (!(extensions_mask & DCA_EXT_CORE)) |
| 1544 | 1577 | av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n"); |
| 1545 | 1578 | if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask) |
| 1546 | − av_log(s->avctx, AV_LOG_WARNING, "DTS extensions detection mismatch (%d, %d)\n", | |
| 1579 | + av_log(s->avctx, AV_LOG_WARNING, | |
| 1580 | + "DTS extensions detection mismatch (%d, %d)\n", | |
| 1547 | 1581 | extensions_mask & DCA_CORE_EXTS, s->core_ext_mask); |
| 1548 | 1582 | |
| 1549 | 1583 | return 0; |
| @@ -1568,7 +1602,7 @@ static void dca_exss_parse_header(DCAContext *s) · 18 unmodified lines | ||
| 1568 | 1602 | ss_index = get_bits(&s->gb, 2); |
| 1569 | 1603 | |
| 1570 | 1604 | blownup = get_bits1(&s->gb); |
| 1571 | − skip_bits(&s->gb, 8 + 4 * blownup); // header_size | |
| 1605 | + skip_bits(&s->gb, 8 + 4 * blownup); // header_size | |
| 1572 | 1606 | skip_bits(&s->gb, 16 + 4 * blownup); // hd_size |
| 1573 | 1607 | |
| 1574 | 1608 | s->static_fields = get_bits1(&s->gb); |
| @@ -1609,18 +1643,18 @@ static void dca_exss_parse_header(DCAContext *s) · 34 unmodified lines | ||
| 1609 | 1643 | int mix_out_mask_size; |
| 1610 | 1644 | |
| 1611 | 1645 | skip_bits(&s->gb, 2); // adjustment level |
| 1612 | − mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2; | |
| 1613 | − s->num_mix_configs = get_bits(&s->gb, 2) + 1; | |
| 1646 | + mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2; | |
| 1647 | + s->num_mix_configs = get_bits(&s->gb, 2) + 1; | |
| 1614 | 1648 | |
| 1615 | 1649 | for (i = 0; i < s->num_mix_configs; i++) { |
| 1616 | − int mix_out_mask = get_bits(&s->gb, mix_out_mask_size); | |
| 1650 | + int mix_out_mask = get_bits(&s->gb, mix_out_mask_size); | |
| 1617 | 1651 | s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask); |
| 1618 | 1652 | } |
| 1619 | 1653 | } |
| 1620 | 1654 | } |
| 1621 | 1655 | |
| 1622 | 1656 | for (i = 0; i < num_assets; i++) |
| 1623 | − skip_bits_long(&s->gb, 16 + 4 * blownup); // asset size | |
| 1657 | + skip_bits_long(&s->gb, 16 + 4 * blownup); // asset size | |
| 1624 | 1658 | |
| 1625 | 1659 | for (i = 0; i < num_assets; i++) { |
| 1626 | 1660 | if (dca_exss_parse_asset_header(s)) |
| @@ -1667,8 +1701,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 40 unmodified lines | ||
| 1667 | 1701 | } |
| 1668 | 1702 | //set AVCodec values with parsed data |
| 1669 | 1703 | avctx->sample_rate = s->sample_rate; |
| 1670 | − avctx->bit_rate = s->bit_rate; | |
| 1671 | − avctx->frame_size = s->sample_blocks * 32; | |
| 1704 | + avctx->bit_rate = s->bit_rate; | |
| 1705 | + avctx->frame_size = s->sample_blocks * 32; | |
| 1672 | 1706 | |
| 1673 | 1707 | s->profile = FF_PROFILE_DTS; |
| 1674 | 1708 | |
| @@ -1700,72 +1734,71 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 25 unmodified lines | ||
| 1700 | 1734 | /* extensions start at 32-bit boundaries into bitstream */ |
| 1701 | 1735 | skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); |
| 1702 | 1736 | |
| 1703 | − while(core_ss_end - get_bits_count(&s->gb) >= 32) { | |
| 1704 | − uint32_t bits = get_bits_long(&s->gb, 32); | |
| 1737 | + while (core_ss_end - get_bits_count(&s->gb) >= 32) { | |
| 1738 | + uint32_t bits = get_bits_long(&s->gb, 32); | |
| 1705 | 1739 | |
| 1706 | − switch(bits) { | |
| 1707 | − case 0x5a5a5a5a: { | |
| 1708 | − int ext_amode, xch_fsize; | |
| 1740 | + switch (bits) { | |
| 1741 | + case 0x5a5a5a5a: { | |
| 1742 | + int ext_amode, xch_fsize; | |
| 1709 | 1743 | |
| 1710 | − s->xch_base_channel = s->prim_channels; | |
| 1744 | + s->xch_base_channel = s->prim_channels; | |
| 1711 | 1745 | |
| 1712 | − /* validate sync word using XCHFSIZE field */ | |
| 1713 | − xch_fsize = show_bits(&s->gb, 10); | |
| 1714 | − if((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) && | |
| 1715 | − (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1)) | |
| 1716 | − continue; | |
| 1717 | − | |
| 1718 | − /* skip length-to-end-of-frame field for the moment */ | |
| 1719 | − skip_bits(&s->gb, 10); | |
| 1720 | − | |
| 1721 | − s->core_ext_mask |= DCA_EXT_XCH; | |
| 1746 | + /* validate sync word using XCHFSIZE field */ | |
| 1747 | + xch_fsize = show_bits(&s->gb, 10); | |
| 1748 | + if ((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) && | |
| 1749 | + (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1)) | |
| 1750 | + continue; | |
| 1722 | 1751 | |
| 1723 | − /* extension amode should == 1, number of channels in extension */ | |
| 1724 | − /* AFAIK XCh is not used for more channels */ | |
| 1725 | − if ((ext_amode = get_bits(&s->gb, 4)) != 1) { | |
| 1726 | − av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not" | |
| 1727 | − " supported!\n",ext_amode); | |
| 1728 | − continue; | |
| 1729 | − } | |
| 1752 | + /* skip length-to-end-of-frame field for the moment */ | |
| 1753 | + skip_bits(&s->gb, 10); | |
| 1730 | 1754 | |
| 1731 | − /* much like core primary audio coding header */ | |
| 1732 | − dca_parse_audio_coding_header(s, s->xch_base_channel); | |
| 1755 | + s->core_ext_mask |= DCA_EXT_XCH; | |
| 1733 | 1756 | |
| 1734 | − for (i = 0; i < (s->sample_blocks / 8); i++) { | |
| 1735 | − if ((ret = dca_decode_block(s, s->xch_base_channel, i))) { | |
| 1736 | − av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n"); | |
| 1757 | + /* extension amode(number of channels in extension) should be 1 */ | |
| 1758 | + /* AFAIK XCh is not used for more channels */ | |
| 1759 | + if ((ext_amode = get_bits(&s->gb, 4)) != 1) { | |
| 1760 | + av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not" | |
| 1761 | + " supported!\n", ext_amode); | |
| 1737 | 1762 | continue; |
| 1738 | 1763 | } |
| 1764 | + | |
| 1765 | + /* much like core primary audio coding header */ | |
| 1766 | + dca_parse_audio_coding_header(s, s->xch_base_channel); | |
| 1767 | + | |
| 1768 | + for (i = 0; i < (s->sample_blocks / 8); i++) | |
| 1769 | + if ((ret = dca_decode_block(s, s->xch_base_channel, i))) { | |
| 1770 | + av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n"); | |
| 1771 | + continue; | |
| 1772 | + } | |
| 1773 | + | |
| 1774 | + s->xch_present = 1; | |
| 1775 | + break; | |
| 1739 | 1776 | } |
| 1777 | + case 0x47004a03: | |
| 1778 | + /* XXCh: extended channels */ | |
| 1779 | + /* usually found either in core or HD part in DTS-HD HRA streams, | |
| 1780 | + * but not in DTS-ES which contains XCh extensions instead */ | |
| 1781 | + s->core_ext_mask |= DCA_EXT_XXCH; | |
| 1782 | + break; | |
| 1783 | + | |
| 1784 | + case 0x1d95f262: { | |
| 1785 | + int fsize96 = show_bits(&s->gb, 12) + 1; | |
| 1786 | + if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96) | |
| 1787 | + continue; | |
| 1740 | 1788 | |
| 1741 | − s->xch_present = 1; | |
| 1742 | − break; | |
| 1743 | − } | |
| 1744 | − case 0x47004a03: | |
| 1745 | − /* XXCh: extended channels */ | |
| 1746 | − /* usually found either in core or HD part in DTS-HD HRA streams, | |
| 1747 | − * but not in DTS-ES which contains XCh extensions instead */ | |
| 1748 | − s->core_ext_mask |= DCA_EXT_XXCH; | |
| 1749 | − break; | |
| 1750 | − | |
| 1751 | − case 0x1d95f262: { | |
| 1752 | − int fsize96 = show_bits(&s->gb, 12) + 1; | |
| 1753 | − if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96) | |
| 1754 | − continue; | |
| 1755 | − | |
| 1756 | − av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n", get_bits_count(&s->gb)); | |
| 1757 | − skip_bits(&s->gb, 12); | |
| 1758 | − av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96); | |
| 1759 | − av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4)); | |
| 1760 | − | |
| 1761 | − s->core_ext_mask |= DCA_EXT_X96; | |
| 1762 | − break; | |
| 1763 | − } | |
| 1764 | − } | |
| 1789 | + av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n", | |
| 1790 | + get_bits_count(&s->gb)); | |
| 1791 | + skip_bits(&s->gb, 12); | |
| 1792 | + av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96); | |
| 1793 | + av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4)); | |
| 1765 | 1794 | |
| 1766 | − skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); | |
| 1767 | − } | |
| 1795 | + s->core_ext_mask |= DCA_EXT_X96; | |
| 1796 | + break; | |
| 1797 | + } | |
| 1798 | + } | |
| 1768 | 1799 | |
| 1800 | + skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); | |
| 1801 | + } | |
| 1769 | 1802 | } else { |
| 1770 | 1803 | /* no supported extensions, skip the rest of the core substream */ |
| 1771 | 1804 | skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb)); |
| @@ -1777,15 +1810,15 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines | ||
| 1777 | 1810 | s->profile = FF_PROFILE_DTS_ES; |
| 1778 | 1811 | |
| 1779 | 1812 | /* check for ExSS (HD part) */ |
| 1780 | − if (s->dca_buffer_size - s->frame_size > 32 | |
| 1781 | − && get_bits_long(&s->gb, 32) == DCA_HD_MARKER) | |
| 1813 | + if (s->dca_buffer_size - s->frame_size > 32 && | |
| 1814 | + get_bits_long(&s->gb, 32) == DCA_HD_MARKER) | |
| 1782 | 1815 | dca_exss_parse_header(s); |
| 1783 | 1816 | |
| 1784 | 1817 | avctx->profile = s->profile; |
| 1785 | 1818 | |
| 1786 | 1819 | channels = s->prim_channels + !!s->lfe; |
| 1787 | 1820 | |
| 1788 | − if (s->amode<16) { | |
| 1821 | + if (s->amode < 16) { | |
| 1789 | 1822 | avctx->channel_layout = dca_core_channel_layout[s->amode]; |
| 1790 | 1823 | |
| 1791 | 1824 | if (s->xch_present && (!avctx->request_channels || |
| @@ -1821,7 +1854,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 29 unmodified lines | ||
| 1821 | 1854 | s->channel_order_tab = dca_channel_order_native; |
| 1822 | 1855 | } |
| 1823 | 1856 | } else { |
| 1824 | − av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode); | |
| 1857 | + av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n", s->amode); | |
| 1825 | 1858 | return AVERROR_INVALIDDATA; |
| 1826 | 1859 | } |
| 1827 | 1860 | |
| @@ -1837,8 +1870,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 9 unmodified lines | ||
| 1837 | 1870 | av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
| 1838 | 1871 | return ret; |
| 1839 | 1872 | } |
| 1840 | − samples_flt = (float *)s->frame.data[0]; | |
| 1841 | − samples_s16 = (int16_t *)s->frame.data[0]; | |
| 1873 | + samples_flt = (float *) s->frame.data[0]; | |
| 1874 | + samples_s16 = (int16_t *) s->frame.data[0]; | |
| 1842 | 1875 | |
| 1843 | 1876 | /* filter to get final output */ |
| 1844 | 1877 | for (i = 0; i < (s->sample_blocks / 8); i++) { |
| @@ -1846,10 +1879,10 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 1 unmodified line | ||
| 1846 | 1879 | |
| 1847 | 1880 | /* If this was marked as a DTS-ES stream we need to subtract back- */ |
| 1848 | 1881 | /* channel from SL & SR to remove matrixed back-channel signal */ |
| 1849 | − if((s->source_pcm_res & 1) && s->xch_present) { | |
| 1850 | − float* back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256; | |
| 1851 | − float* lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256; | |
| 1852 | − float* rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256; | |
| 1882 | + if ((s->source_pcm_res & 1) && s->xch_present) { | |
| 1883 | + float *back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256; | |
| 1884 | + float *lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256; | |
| 1885 | + float *rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256; | |
| 1853 | 1886 | s->dsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256); |
| 1854 | 1887 | s->dsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256); |
| 1855 | 1888 | } |
| @@ -1868,12 +1901,11 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 12 unmodified lines | ||
| 1868 | 1901 | |
| 1869 | 1902 | /* update lfe history */ |
| 1870 | 1903 | lfe_samples = 2 * s->lfe * (s->sample_blocks / 8); |
| 1871 | − for (i = 0; i < 2 * s->lfe * 4; i++) { | |
| 1904 | + for (i = 0; i < 2 * s->lfe * 4; i++) | |
| 1872 | 1905 | s->lfe_data[i] = s->lfe_data[i + lfe_samples]; |
| 1873 | − } | |
| 1874 | 1906 | |
| 1875 | − *got_frame_ptr = 1; | |
| 1876 | − *(AVFrame *)data = s->frame; | |
| 1907 | + *got_frame_ptr = 1; | |
| 1908 | + *(AVFrame *) data = s->frame; | |
| 1877 | 1909 | |
| 1878 | 1910 | return buf_size; |
| 1879 | 1911 | } |
| @@ -1886,7 +1918,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 6 unmodified lines | ||
| 1886 | 1918 | * @param avctx pointer to the AVCodecContext |
| 1887 | 1919 | */ |
| 1888 | 1920 | |
| 1889 | −static av_cold int dca_decode_init(AVCodecContext * avctx) | |
| 1921 | +static av_cold int dca_decode_init(AVCodecContext *avctx) | |
| 1890 | 1922 | { |
| 1891 | 1923 | DCAContext *s = avctx->priv_data; |
| 1892 | 1924 | int i; |
| @@ -1900,15 +1932,15 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) · 7 unmodified lines | ||
| 1900 | 1932 | ff_dcadsp_init(&s->dcadsp); |
| 1901 | 1933 | ff_fmt_convert_init(&s->fmt_conv, avctx); |
| 1902 | 1934 | |
| 1903 | − for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++) | |
| 1935 | + for (i = 0; i < DCA_PRIM_CHANNELS_MAX + 1; i++) | |
| 1904 | 1936 | s->samples_chanptr[i] = s->samples + i * 256; |
| 1905 | 1937 | |
| 1906 | 1938 | if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) { |
| 1907 | 1939 | avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
| 1908 | − s->scale_bias = 1.0 / 32768.0; | |
| 1940 | + s->scale_bias = 1.0 / 32768.0; | |
| 1909 | 1941 | } else { |
| 1910 | 1942 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 1911 | − s->scale_bias = 1.0; | |
| 1943 | + s->scale_bias = 1.0; | |
| 1912 | 1944 | } |
| 1913 | 1945 | |
| 1914 | 1946 | /* allow downmixing to stereo */ |
| @@ -1923,7 +1955,7 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) · 8 unmodified lines | ||
| 1923 | 1955 | return 0; |
| 1924 | 1956 | } |
| 1925 | 1957 | |
| 1926 | −static av_cold int dca_decode_end(AVCodecContext * avctx) | |
| 1958 | +static av_cold int dca_decode_end(AVCodecContext *avctx) | |
| 1927 | 1959 | { |
| 1928 | 1960 | DCAContext *s = avctx->priv_data; |
| 1929 | 1961 | ff_mdct_end(&s->imdct); |
| @@ -1940,17 +1972,17 @@ static const AVProfile profiles[] = { · 10 unmodified lines | ||
| 1940 | 1972 | }; |
| 1941 | 1973 | |
| 1942 | 1974 | AVCodec ff_dca_decoder = { |
| 1943 | − .name = "dca", | |
| 1944 | − .type = AVMEDIA_TYPE_AUDIO, | |
| 1945 | − .id = CODEC_ID_DTS, | |
| 1946 | − .priv_data_size = sizeof(DCAContext), | |
| 1947 | − .init = dca_decode_init, | |
| 1948 | − .decode = dca_decode_frame, | |
| 1949 | − .close = dca_decode_end, | |
| 1950 | − .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), | |
| 1951 | − .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, | |
| 1952 | − .sample_fmts = (const enum AVSampleFormat[]) { | |
| 1953 | − AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE | |
| 1954 | − }, | |
| 1955 | − .profiles = NULL_IF_CONFIG_SMALL(profiles), | |
| 1975 | + .name = "dca", | |
| 1976 | + .type = AVMEDIA_TYPE_AUDIO, | |
| 1977 | + .id = CODEC_ID_DTS, | |
| 1978 | + .priv_data_size = sizeof(DCAContext), | |
| 1979 | + .init = dca_decode_init, | |
| 1980 | + .decode = dca_decode_frame, | |
| 1981 | + .close = dca_decode_end, | |
| 1982 | + .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), | |
| 1983 | + .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, | |
| 1984 | + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, | |
| 1985 | + AV_SAMPLE_FMT_S16, | |
| 1986 | + AV_SAMPLE_FMT_NONE }, | |
| 1987 | + .profiles = NULL_IF_CONFIG_SMALL(profiles), | |
| 1956 | 1988 | }; |
| @@ -28,15 +28,16 @@ · 27 unmodified lines | ||
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include <math.h> |
| 31 | + | |
| 31 | 32 | #include "libavutil/mathematics.h" |
| 32 | 33 | #include "dct.h" |
| 33 | 34 | #include "dct32.h" |
| 34 | 35 | |
| 35 | −/* sin((M_PI * x / (2*n)) */ | |
| 36 | −#define SIN(s,n,x) (s->costab[(n) - (x)]) | |
| 36 | +/* sin((M_PI * x / (2 * n)) */ | |
| 37 | +#define SIN(s, n, x) (s->costab[(n) - (x)]) | |
| 37 | 38 | |
| 38 | −/* cos((M_PI * x / (2*n)) */ | |
| 39 | −#define COS(s,n,x) (s->costab[x]) | |
| 39 | +/* cos((M_PI * x / (2 * n)) */ | |
| 40 | +#define COS(s, n, x) (s->costab[x]) | |
| 40 | 41 | |
| 41 | 42 | static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data) |
| 42 | 43 | { |
| @@ -44,28 +45,28 @@ static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data) · 1 unmodified line | ||
| 44 | 45 | int i; |
| 45 | 46 | |
| 46 | 47 | data[0] = 0; |
| 47 | − for(i = 1; i < n/2; i++) { | |
| 48 | − float tmp1 = data[i ]; | |
| 49 | − float tmp2 = data[n - i]; | |
| 50 | − float s = SIN(ctx, n, 2*i); | |
| 51 | − | |
| 52 | − s *= tmp1 + tmp2; | |
| 53 | − tmp1 = (tmp1 - tmp2) * 0.5f; | |
| 54 | − data[i ] = s + tmp1; | |
| 55 | − data[n - i] = s - tmp1; | |
| 48 | + for (i = 1; i < n / 2; i++) { | |
| 49 | + float tmp1 = data[i ]; | |
| 50 | + float tmp2 = data[n - i]; | |
| 51 | + float s = SIN(ctx, n, 2 * i); | |
| 52 | + | |
| 53 | + s *= tmp1 + tmp2; | |
| 54 | + tmp1 = (tmp1 - tmp2) * 0.5f; | |
| 55 | + data[i] = s + tmp1; | |
| 56 | + data[n - i] = s - tmp1; | |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | − data[n/2] *= 2; | |
| 59 | + data[n / 2] *= 2; | |
| 59 | 60 | ctx->rdft.rdft_calc(&ctx->rdft, data); |
| 60 | 61 | |
| 61 | 62 | data[0] *= 0.5f; |
| 62 | 63 | |
| 63 | − for(i = 1; i < n-2; i += 2) { | |
| 64 | − data[i + 1] += data[i - 1]; | |
| 65 | − data[i ] = -data[i + 2]; | |
| 64 | + for (i = 1; i < n - 2; i += 2) { | |
| 65 | + data[i + 1] += data[i - 1]; | |
| 66 | + data[i] = -data[i + 2]; | |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | − data[n-1] = 0; | |
| 69 | + data[n - 1] = 0; | |
| 69 | 70 | } |
| 70 | 71 | |
| 71 | 72 | static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) |
| @@ -74,19 +75,19 @@ static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) · 2 unmodified lines | ||
| 74 | 75 | int i; |
| 75 | 76 | float next = -0.5f * (data[0] - data[n]); |
| 76 | 77 | |
| 77 | − for(i = 0; i < n/2; i++) { | |
| 78 | − float tmp1 = data[i ]; | |
| 78 | + for (i = 0; i < n / 2; i++) { | |
| 79 | + float tmp1 = data[i]; | |
| 79 | 80 | float tmp2 = data[n - i]; |
| 80 | − float s = SIN(ctx, n, 2*i); | |
| 81 | − float c = COS(ctx, n, 2*i); | |
| 81 | + float s = SIN(ctx, n, 2 * i); | |
| 82 | + float c = COS(ctx, n, 2 * i); | |
| 82 | 83 | |
| 83 | 84 | c *= tmp1 - tmp2; |
| 84 | 85 | s *= tmp1 - tmp2; |
| 85 | 86 | |
| 86 | 87 | next += c; |
| 87 | 88 | |
| 88 | − tmp1 = (tmp1 + tmp2) * 0.5f; | |
| 89 | − data[i ] = tmp1 - s; | |
| 89 | + tmp1 = (tmp1 + tmp2) * 0.5f; | |
| 90 | + data[i] = tmp1 - s; | |
| 90 | 91 | data[n - i] = tmp1 + s; |
| 91 | 92 | } |
| 92 | 93 | |
| @@ -94,7 +95,7 @@ static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) · 1 unmodified line | ||
| 94 | 95 | data[n] = data[1]; |
| 95 | 96 | data[1] = next; |
| 96 | 97 | |
| 97 | − for(i = 3; i <= n; i += 2) | |
| 98 | + for (i = 3; i <= n; i += 2) | |
| 98 | 99 | data[i] = data[i - 2] - data[i]; |
| 99 | 100 | } |
| 100 | 101 | |
| @@ -103,16 +104,16 @@ static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) · 2 unmodified lines | ||
| 103 | 104 | int n = 1 << ctx->nbits; |
| 104 | 105 | int i; |
| 105 | 106 | |
| 106 | − float next = data[n - 1]; | |
| 107 | + float next = data[n - 1]; | |
| 107 | 108 | float inv_n = 1.0f / n; |
| 108 | 109 | |
| 109 | 110 | for (i = n - 2; i >= 2; i -= 2) { |
| 110 | − float val1 = data[i ]; | |
| 111 | + float val1 = data[i]; | |
| 111 | 112 | float val2 = data[i - 1] - data[i + 1]; |
| 112 | − float c = COS(ctx, n, i); | |
| 113 | − float s = SIN(ctx, n, i); | |
| 113 | + float c = COS(ctx, n, i); | |
| 114 | + float s = SIN(ctx, n, i); | |
| 114 | 115 | |
| 115 | − data[i ] = c * val1 + s * val2; | |
| 116 | + data[i] = c * val1 + s * val2; | |
| 116 | 117 | data[i + 1] = s * val1 - c * val2; |
| 117 | 118 | } |
| 118 | 119 | |
| @@ -121,13 +122,13 @@ static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) · 2 unmodified lines | ||
| 121 | 122 | ctx->rdft.rdft_calc(&ctx->rdft, data); |
| 122 | 123 | |
| 123 | 124 | for (i = 0; i < n / 2; i++) { |
| 124 | − float tmp1 = data[i ] * inv_n; | |
| 125 | + float tmp1 = data[i] * inv_n; | |
| 125 | 126 | float tmp2 = data[n - i - 1] * inv_n; |
| 126 | − float csc = ctx->csc2[i] * (tmp1 - tmp2); | |
| 127 | + float csc = ctx->csc2[i] * (tmp1 - tmp2); | |
| 127 | 128 | |
| 128 | − tmp1 += tmp2; | |
| 129 | − data[i ] = tmp1 + csc; | |
| 130 | − data[n - i - 1] = tmp1 - csc; | |
| 129 | + tmp1 += tmp2; | |
| 130 | + data[i] = tmp1 + csc; | |
| 131 | + data[n - i - 1] = tmp1 - csc; | |
| 131 | 132 | } |
| 132 | 133 | } |
| 133 | 134 | |
| @@ -137,34 +138,33 @@ static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data) · 3 unmodified lines | ||
| 137 | 138 | int i; |
| 138 | 139 | float next; |
| 139 | 140 | |
| 140 | − for (i=0; i < n/2; i++) { | |
| 141 | − float tmp1 = data[i ]; | |
| 141 | + for (i = 0; i < n / 2; i++) { | |
| 142 | + float tmp1 = data[i]; | |
| 142 | 143 | float tmp2 = data[n - i - 1]; |
| 143 | − float s = SIN(ctx, n, 2*i + 1); | |
| 144 | + float s = SIN(ctx, n, 2 * i + 1); | |
| 144 | 145 | |
| 145 | − s *= tmp1 - tmp2; | |
| 146 | − tmp1 = (tmp1 + tmp2) * 0.5f; | |
| 146 | + s *= tmp1 - tmp2; | |
| 147 | + tmp1 = (tmp1 + tmp2) * 0.5f; | |
| 147 | 148 | |
| 148 | − data[i ] = tmp1 + s; | |
| 149 | + data[i] = tmp1 + s; | |
| 149 | 150 | data[n-i-1] = tmp1 - s; |
| 150 | 151 | } |
| 151 | 152 | |
| 152 | 153 | ctx->rdft.rdft_calc(&ctx->rdft, data); |
| 153 | 154 | |
| 154 | − next = data[1] * 0.5; | |
| 155 | + next = data[1] * 0.5; | |
| 155 | 156 | data[1] *= -1; |
| 156 | 157 | |
| 157 | 158 | for (i = n - 2; i >= 0; i -= 2) { |
| 158 | 159 | float inr = data[i ]; |
| 159 | 160 | float ini = data[i + 1]; |
| 160 | − float c = COS(ctx, n, i); | |
| 161 | − float s = SIN(ctx, n, i); | |
| 161 | + float c = COS(ctx, n, i); | |
| 162 | + float s = SIN(ctx, n, i); | |
| 162 | 163 | |
| 163 | − data[i ] = c * inr + s * ini; | |
| 164 | + data[i] = c * inr + s * ini; | |
| 165 | + data[i + 1] = next; | |
| 164 | 166 | |
| 165 | − data[i+1] = next; | |
| 166 | − | |
| 167 | − next += s * inr - c * ini; | |
| 167 | + next += s * inr - c * ini; | |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| @@ -180,36 +180,36 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) · 9 unmodified lines | ||
| 180 | 180 | |
| 181 | 181 | memset(s, 0, sizeof(*s)); |
| 182 | 182 | |
| 183 | − s->nbits = nbits; | |
| 184 | − s->inverse = inverse; | |
| 183 | + s->nbits = nbits; | |
| 184 | + s->inverse = inverse; | |
| 185 | 185 | |
| 186 | 186 | if (inverse == DCT_II && nbits == 5) { |
| 187 | 187 | s->dct_calc = dct32_func; |
| 188 | 188 | } else { |
| 189 | − ff_init_ff_cos_tabs(nbits+2); | |
| 190 | − | |
| 191 | − s->costab = ff_cos_tabs[nbits+2]; | |
| 189 | + ff_init_ff_cos_tabs(nbits + 2); | |
| 192 | 190 | |
| 193 | − s->csc2 = av_malloc(n/2 * sizeof(FFTSample)); | |
| 191 | + s->costab = ff_cos_tabs[nbits + 2]; | |
| 192 | + s->csc2 = av_malloc(n / 2 * sizeof(FFTSample)); | |
| 194 | 193 | |
| 195 | 194 | if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) { |
| 196 | 195 | av_free(s->csc2); |
| 197 | 196 | return -1; |
| 198 | 197 | } |
| 199 | 198 | |
| 200 | − for (i = 0; i < n/2; i++) | |
| 201 | − s->csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1))); | |
| 199 | + for (i = 0; i < n / 2; i++) | |
| 200 | + s->csc2[i] = 0.5 / sin((M_PI / (2 * n) * (2 * i + 1))); | |
| 202 | 201 | |
| 203 | − switch(inverse) { | |
| 204 | − case DCT_I : s->dct_calc = ff_dct_calc_I_c; break; | |
| 205 | − case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break; | |
| 202 | + switch (inverse) { | |
| 203 | + case DCT_I : s->dct_calc = ff_dct_calc_I_c; break; | |
| 204 | + case DCT_II : s->dct_calc = ff_dct_calc_II_c; break; | |
| 206 | 205 | case DCT_III: s->dct_calc = ff_dct_calc_III_c; break; |
| 207 | − case DST_I : s->dct_calc = ff_dst_calc_I_c; break; | |
| 206 | + case DST_I : s->dct_calc = ff_dst_calc_I_c; break; | |
| 208 | 207 | } |
| 209 | 208 | } |
| 210 | 209 | |
| 211 | 210 | s->dct32 = ff_dct32_float; |
| 212 | − if (HAVE_MMX) ff_dct_init_mmx(s); | |
| 211 | + if (HAVE_MMX) | |
| 212 | + ff_dct_init_mmx(s); | |
| 213 | 213 | |
| 214 | 214 | return 0; |
| 215 | 215 | } |
| @@ -35,7 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #define _GNU_SOURCE |
| 36 | 36 | #include <sched.h> |
| 37 | 37 | #endif |
| 38 | −#if HAVE_GETSYSTEMINFO | |
| 38 | +#if HAVE_GETPROCESSAFFINITYMASK | |
| 39 | 39 | #include <windows.h> |
| 40 | 40 | #endif |
| 41 | 41 | #if HAVE_SYSCTL |
| @@ -172,10 +172,11 @@ static int get_logical_cpus(AVCodecContext *avctx) · 130 unmodified lines | ||
| 172 | 172 | if (!ret) { |
| 173 | 173 | nb_cpus = CPU_COUNT(&cpuset); |
| 174 | 174 | } |
| 175 | −#elif HAVE_GETSYSTEMINFO | |
| 176 | − SYSTEM_INFO sysinfo; | |
| 177 | − GetSystemInfo(&sysinfo); | |
| 178 | − nb_cpus = sysinfo.dwNumberOfProcessors; | |
| 175 | +#elif HAVE_GETPROCESSAFFINITYMASK | |
| 176 | + DWORD_PTR proc_aff, sys_aff; | |
| 177 | + ret = GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff); | |
| 178 | + if (ret) | |
| 179 | + nb_cpus = av_popcount64(proc_aff); | |
| 179 | 180 | #elif HAVE_SYSCTL && defined(HW_NCPU) |
| 180 | 181 | int mib[2] = { CTL_HW, HW_NCPU }; |
| 181 | 182 | size_t len = sizeof(nb_cpus); |
| @@ -516,9 +516,9 @@ static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *fr · 515 unmodified lines | ||
| 516 | 516 | int ls= frame->linesize[p]; |
| 517 | 517 | uint8_t *src= frame->data[p]; |
| 518 | 518 | |
| 519 | − halfpel[1][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls); | |
| 520 | − halfpel[2][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls); | |
| 521 | − halfpel[3][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls); | |
| 519 | + halfpel[1][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls); | |
| 520 | + halfpel[2][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls); | |
| 521 | + halfpel[3][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls); | |
| 522 | 522 | |
| 523 | 523 | halfpel[0][p]= src; |
| 524 | 524 | for(y=0; y<h; y++){ |
| @@ -282,6 +282,77 @@ static void restore_median(uint8_t *src, int step, int stride, · 281 unmodified lines | ||
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | +/* UtVideo interlaced mode treats every two lines as a single one, | |
| 286 | + * so restoring function should take care of possible padding between | |
| 287 | + * two parts of the same "line". | |
| 288 | + */ | |
| 289 | +static void restore_median_il(uint8_t *src, int step, int stride, | |
| 290 | + int width, int height, int slices, int rmode) | |
| 291 | +{ | |
| 292 | + int i, j, slice; | |
| 293 | + int A, B, C; | |
| 294 | + uint8_t *bsrc; | |
| 295 | + int slice_start, slice_height; | |
| 296 | + const int cmask = ~(rmode ? 3 : 1); | |
| 297 | + const int stride2 = stride << 1; | |
| 298 | + | |
| 299 | + for (slice = 0; slice < slices; slice++) { | |
| 300 | + slice_start = ((slice * height) / slices) & cmask; | |
| 301 | + slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start; | |
| 302 | + slice_height >>= 1; | |
| 303 | + | |
| 304 | + bsrc = src + slice_start * stride; | |
| 305 | + | |
| 306 | + // first line - left neighbour prediction | |
| 307 | + bsrc[0] += 0x80; | |
| 308 | + A = bsrc[0]; | |
| 309 | + for (i = step; i < width * step; i += step) { | |
| 310 | + bsrc[i] += A; | |
| 311 | + A = bsrc[i]; | |
| 312 | + } | |
| 313 | + for (i = 0; i < width * step; i += step) { | |
| 314 | + bsrc[stride + i] += A; | |
| 315 | + A = bsrc[stride + i]; | |
| 316 | + } | |
| 317 | + bsrc += stride2; | |
| 318 | + if (slice_height == 1) | |
| 319 | + continue; | |
| 320 | + // second line - first element has top predition, the rest uses median | |
| 321 | + C = bsrc[-stride2]; | |
| 322 | + bsrc[0] += C; | |
| 323 | + A = bsrc[0]; | |
| 324 | + for (i = step; i < width * step; i += step) { | |
| 325 | + B = bsrc[i - stride2]; | |
| 326 | + bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); | |
| 327 | + C = B; | |
| 328 | + A = bsrc[i]; | |
| 329 | + } | |
| 330 | + for (i = 0; i < width * step; i += step) { | |
| 331 | + B = bsrc[i - stride]; | |
| 332 | + bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C)); | |
| 333 | + C = B; | |
| 334 | + A = bsrc[stride + i]; | |
| 335 | + } | |
| 336 | + bsrc += stride2; | |
| 337 | + // the rest of lines use continuous median prediction | |
| 338 | + for (j = 2; j < slice_height; j++) { | |
| 339 | + for (i = 0; i < width * step; i += step) { | |
| 340 | + B = bsrc[i - stride2]; | |
| 341 | + bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); | |
| 342 | + C = B; | |
| 343 | + A = bsrc[i]; | |
| 344 | + } | |
| 345 | + for (i = 0; i < width * step; i += step) { | |
| 346 | + B = bsrc[i - stride]; | |
| 347 | + bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C)); | |
| 348 | + C = B; | |
| 349 | + A = bsrc[i + stride]; | |
| 350 | + } | |
| 351 | + bsrc += stride2; | |
| 352 | + } | |
| 353 | + } | |
| 354 | +} | |
| 355 | + | |
| 285 | 356 | static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) |
| 286 | 357 | { |
| 287 | 358 | const uint8_t *buf = avpkt->data; |
| @@ -381,10 +452,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac · 93 unmodified lines | ||
| 381 | 452 | c->frame_pred == PRED_LEFT); |
| 382 | 453 | if (ret) |
| 383 | 454 | return ret; |
| 384 | − if (c->frame_pred == PRED_MEDIAN) | |
| 385 | − restore_median(c->pic.data[i], 1, c->pic.linesize[i], | |
| 386 | − avctx->width >> !!i, avctx->height >> !!i, | |
| 387 | − c->slices, !i); | |
| 455 | + if (c->frame_pred == PRED_MEDIAN) { | |
| 456 | + if (!c->interlaced) { | |
| 457 | + restore_median(c->pic.data[i], 1, c->pic.linesize[i], | |
| 458 | + avctx->width >> !!i, avctx->height >> !!i, | |
| 459 | + c->slices, !i); | |
| 460 | + } else { | |
| 461 | + restore_median_il(c->pic.data[i], 1, c->pic.linesize[i], | |
| 462 | + avctx->width >> !!i, | |
| 463 | + avctx->height >> !!i, | |
| 464 | + c->slices, !i); | |
| 465 | + } | |
| 466 | + } | |
| 388 | 467 | } |
| 389 | 468 | break; |
| 390 | 469 | case PIX_FMT_YUV422P: |
| @@ -395,9 +474,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac · 4 unmodified lines | ||
| 395 | 474 | c->frame_pred == PRED_LEFT); |
| 396 | 475 | if (ret) |
| 397 | 476 | return ret; |
| 398 | − if (c->frame_pred == PRED_MEDIAN) | |
| 399 | − restore_median(c->pic.data[i], 1, c->pic.linesize[i], | |
| 400 | − avctx->width >> !!i, avctx->height, c->slices, 0); | |
| 477 | + if (c->frame_pred == PRED_MEDIAN) { | |
| 478 | + if (!c->interlaced) { | |
| 479 | + restore_median(c->pic.data[i], 1, c->pic.linesize[i], | |
| 480 | + avctx->width >> !!i, avctx->height, | |
| 481 | + c->slices, 0); | |
| 482 | + } else { | |
| 483 | + restore_median_il(c->pic.data[i], 1, c->pic.linesize[i], | |
| 484 | + avctx->width >> !!i, avctx->height, | |
| 485 | + c->slices, 0); | |
| 486 | + } | |
| 487 | + } | |
| 401 | 488 | } |
| 402 | 489 | break; |
| 403 | 490 | } |
| @@ -2235,7 +2235,7 @@ static int has_decode_delay_been_guessed(AVStream *st) · 2234 unmodified lines | ||
| 2235 | 2235 | static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options) |
| 2236 | 2236 | { |
| 2237 | 2237 | AVCodec *codec; |
| 2238 | − int got_picture, ret = 0; | |
| 2238 | + int got_picture = 1, ret = 0; | |
| 2239 | 2239 | AVFrame picture; |
| 2240 | 2240 | AVPacket pkt = *avpkt; |
| 2241 | 2241 | |
| @@ -2248,7 +2248,8 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option · 6 unmodified lines | ||
| 2248 | 2248 | return ret; |
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | − while (pkt.size > 0 && ret >= 0 && | |
| 2251 | + while ((pkt.size > 0 || (!pkt.data && got_picture)) && | |
| 2252 | + ret >= 0 && | |
| 2252 | 2253 | (!has_codec_parameters(st->codec) || |
| 2253 | 2254 | !has_decode_delay_been_guessed(st) || |
| 2254 | 2255 | (!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) { |
| @@ -2377,14 +2378,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 122 unmodified lines | ||
| 2377 | 2378 | int i, count, ret, read_size, j; |
| 2378 | 2379 | AVStream *st; |
| 2379 | 2380 | AVPacket pkt1, *pkt; |
| 2380 | − AVDictionary *one_thread_opt = NULL; | |
| 2381 | 2381 | int64_t old_offset = avio_tell(ic->pb); |
| 2382 | 2382 | int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those |
| 2383 | 2383 | |
| 2384 | − /* this function doesn't flush the decoders, so force thread count | |
| 2385 | − * to 1 to fix behavior when thread count > number of frames in the file */ | |
| 2386 | − av_dict_set(&one_thread_opt, "threads", "1", 0); | |
| 2387 | − | |
| 2388 | 2384 | for(i=0;i<ic->nb_streams;i++) { |
| 2389 | 2385 | AVCodec *codec; |
| 2390 | 2386 | st = ic->streams[i]; |
| @@ -2406,21 +2402,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 15 unmodified lines | ||
| 2406 | 2402 | assert(!st->codec->codec); |
| 2407 | 2403 | codec = avcodec_find_decoder(st->codec->codec_id); |
| 2408 | 2404 | |
| 2409 | − /* this function doesn't flush the decoders, so force thread count | |
| 2410 | − * to 1 to fix behavior when thread count > number of frames in the file */ | |
| 2411 | − if (options) | |
| 2412 | − av_dict_set(&options[i], "threads", "1", 0); | |
| 2413 | − | |
| 2414 | 2405 | /* Ensure that subtitle_header is properly set. */ |
| 2415 | 2406 | if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE |
| 2416 | 2407 | && codec && !st->codec->codec) |
| 2417 | − avcodec_open2(st->codec, codec, options ? &options[i] : &one_thread_opt); | |
| 2408 | + avcodec_open2(st->codec, codec, options ? &options[i] : NULL); | |
| 2418 | 2409 | |
| 2419 | 2410 | //try to just open decoders, in case this is enough to get parameters |
| 2420 | 2411 | if(!has_codec_parameters(st->codec)){ |
| 2421 | 2412 | if (codec && !st->codec->codec) |
| 2422 | − avcodec_open2(st->codec, codec, options ? &options[i] | |
| 2423 | − : &one_thread_opt); | |
| 2413 | + avcodec_open2(st->codec, codec, options ? &options[i] : NULL); | |
| 2424 | 2414 | } |
| 2425 | 2415 | } |
| 2426 | 2416 | |
| @@ -2486,10 +2476,22 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 59 unmodified lines | ||
| 2486 | 2476 | continue; |
| 2487 | 2477 | |
| 2488 | 2478 | if (ret < 0) { |
| 2489 | − /* EOF or error */ | |
| 2479 | + /* EOF or error*/ | |
| 2480 | + AVPacket empty_pkt = { 0 }; | |
| 2481 | + int err; | |
| 2482 | + av_init_packet(&empty_pkt); | |
| 2483 | + | |
| 2490 | 2484 | ret = -1; /* we could not have all the codec parameters before EOF */ |
| 2491 | 2485 | for(i=0;i<ic->nb_streams;i++) { |
| 2492 | 2486 | st = ic->streams[i]; |
| 2487 | + | |
| 2488 | + /* flush the decoders */ | |
| 2489 | + while ((err = try_decode_frame(st, &empty_pkt, | |
| 2490 | + (options && i < orig_nb_streams) ? | |
| 2491 | + &options[i] : NULL)) >= 0) | |
| 2492 | + if (has_codec_parameters(st->codec)) | |
| 2493 | + break; | |
| 2494 | + | |
| 2493 | 2495 | if (!has_codec_parameters(st->codec)){ |
| 2494 | 2496 | char buf[256]; |
| 2495 | 2497 | avcodec_string(buf, sizeof(buf), st->codec, 0); |
| @@ -2562,8 +2564,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 66 unmodified lines | ||
| 2562 | 2564 | least one frame of codec data, this makes sure the codec initializes |
| 2563 | 2565 | the channel configuration and does not only trust the values from the container. |
| 2564 | 2566 | */ |
| 2565 | − try_decode_frame(st, pkt, (options && i < orig_nb_streams )? &options[i] | |
| 2566 | − : &one_thread_opt); | |
| 2567 | + try_decode_frame(st, pkt, (options && i < orig_nb_streams ) ? &options[i] : NULL); | |
| 2567 | 2568 | |
| 2568 | 2569 | st->codec_info_nb_frames++; |
| 2569 | 2570 | count++; |
| @@ -2689,7 +2690,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 119 unmodified lines | ||
| 2689 | 2690 | ic->streams[i]->codec->thread_count = 0; |
| 2690 | 2691 | av_freep(&ic->streams[i]->info); |
| 2691 | 2692 | } |
| 2692 | − av_dict_free(&one_thread_opt); | |
| 2693 | 2693 | return ret; |
| 2694 | 2694 | } |
| 2695 | 2695 | |
| @@ -154,7 +154,7 @@ · 153 unmodified lines | ||
| 154 | 154 | */ |
| 155 | 155 | |
| 156 | 156 | #define LIBAVUTIL_VERSION_MAJOR 51 |
| 157 | −#define LIBAVUTIL_VERSION_MINOR 33 | |
| 157 | +#define LIBAVUTIL_VERSION_MINOR 34 | |
| 158 | 158 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 159 | 159 | |
| 160 | 160 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -220,6 +220,16 @@ static av_always_inline av_const int av_popcount_c(uint32_t x) · 219 unmodified lines | ||
| 220 | 220 | return (x + (x >> 16)) & 0x3F; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | +/** | |
| 224 | + * Count number of bits set to one in x | |
| 225 | + * @param x value to count bits of | |
| 226 | + * @return the number of bits set to one in x | |
| 227 | + */ | |
| 228 | +static av_always_inline av_const int av_popcount64_c(uint64_t x) | |
| 229 | +{ | |
| 230 | + return av_popcount(x) + av_popcount(x >> 32); | |
| 231 | +} | |
| 232 | + | |
| 223 | 233 | #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) |
| 224 | 234 | #define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) |
| 225 | 235 | |
| @@ -385,3 +395,6 @@ static av_always_inline av_const int av_popcount_c(uint32_t x) · 159 unmodified lines | ||
| 385 | 395 | #ifndef av_popcount |
| 386 | 396 | # define av_popcount av_popcount_c |
| 387 | 397 | #endif |
| 398 | +#ifndef av_popcount64 | |
| 399 | +# define av_popcount64 av_popcount64_c | |
| 400 | +#endif | |
| @@ -1,6 +1,9 @@ | ||
| 1 | 1 | FATE_SCREEN += fate-cscd |
| 2 | 2 | fate-cscd: CMD = framecrc -i $(SAMPLES)/CSCD/sample_video.avi -an -vsync 0 -pix_fmt rgb24 |
| 3 | 3 | |
| 4 | +FATE_SCREEN += fate-dxtory | |
| 5 | +fate-dxtory: CMD = framecrc -i $(SAMPLES)/dxtory/dxtory_mic.avi | |
| 6 | + | |
| 4 | 7 | FATE_SCREEN += fate-fraps-v0 |
| 5 | 8 | fate-fraps-v0: CMD = framecrc -i $(SAMPLES)/fraps/Griffin_Ragdoll01-partial.avi |
| 6 | 9 | |
| @@ -0,0 +1 @@ | ||
| 1 | +0, 0, 1382400, 0x44373645 | |