* 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
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -61,7 +61,8 @@ static FILE *report_file; |
| 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) |
| 75 | 75 |
av_dict_free(&codec_opts); |
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 |
-void log_callback_help(void* ptr, int level, const char* fmt, va_list vl) |
|
| 78 |
+void log_callback_help(void *ptr, int level, const char *fmt, va_list vl) |
|
| 79 | 79 |
{
|
| 80 | 80 |
vfprintf(stdout, fmt, vl); |
| 81 | 81 |
} |
| ... | ... |
@@ -94,19 +95,20 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v |
| 94 | 94 |
fflush(report_file); |
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 |
-double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max) |
|
| 97 |
+double parse_number_or_die(const char *context, const char *numstr, int type, |
|
| 98 |
+ double min, double max) |
|
| 98 | 99 |
{
|
| 99 | 100 |
char *tail; |
| 100 | 101 |
const char *error; |
| 101 | 102 |
double d = av_strtod(numstr, &tail); |
| 102 | 103 |
if (*tail) |
| 103 |
- error= "Expected number for %s but found: %s\n"; |
|
| 104 |
+ error = "Expected number for %s but found: %s\n"; |
|
| 104 | 105 |
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"; |
|
| 106 |
+ error = "The value for %s was %s which is not within %f - %f\n"; |
|
| 107 |
+ else if (type == OPT_INT64 && (int64_t)d != d) |
|
| 108 |
+ error = "Expected int64 for %s but found %s\n"; |
|
| 108 | 109 |
else if (type == OPT_INT && (int)d != d) |
| 109 |
- error= "Expected int for %s but found %s\n"; |
|
| 110 |
+ error = "Expected int for %s but found %s\n"; |
|
| 110 | 111 |
else |
| 111 | 112 |
return d; |
| 112 | 113 |
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 |
| 114 | 114 |
return 0; |
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 |
-int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration) |
|
| 117 |
+int64_t parse_time_or_die(const char *context, const char *timestr, |
|
| 118 |
+ int is_duration) |
|
| 118 | 119 |
{
|
| 119 | 120 |
int64_t us; |
| 120 | 121 |
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 |
| 125 | 125 |
return us; |
| 126 | 126 |
} |
| 127 | 127 |
|
| 128 |
-void show_help_options(const OptionDef *options, const char *msg, int mask, int value) |
|
| 128 |
+void show_help_options(const OptionDef *options, const char *msg, int mask, |
|
| 129 |
+ int value) |
|
| 129 | 130 |
{
|
| 130 | 131 |
const OptionDef *po; |
| 131 | 132 |
int first; |
| 132 | 133 |
|
| 133 | 134 |
first = 1; |
| 134 |
- for(po = options; po->name != NULL; po++) {
|
|
| 135 |
+ for (po = options; po->name != NULL; po++) {
|
|
| 135 | 136 |
char buf[64]; |
| 136 | 137 |
if ((po->flags & mask) == value) {
|
| 137 | 138 |
if (first) {
|
| ... | ... |
@@ -158,7 +162,8 @@ void show_help_children(const AVClass *class, int flags) |
| 158 | 158 |
show_help_children(child, flags); |
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 |
-static const OptionDef* find_option(const OptionDef *po, const char *name){
|
|
| 161 |
+static const OptionDef *find_option(const OptionDef *po, const char *name) |
|
| 162 |
+{
|
|
| 162 | 163 |
const char *p = strchr(name, ':'); |
| 163 | 164 |
int len = p ? p - name : strlen(name); |
| 164 | 165 |
|
| ... | ... |
@@ -205,8 +210,8 @@ static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) |
| 205 | 205 |
buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, |
| 206 | 206 |
NULL, 0, NULL, NULL); |
| 207 | 207 |
|
| 208 |
- win32_argv_utf8 = av_mallocz(sizeof(char*) * (win32_argc + 1) + buffsize); |
|
| 209 |
- argstr_flat = (char*)win32_argv_utf8 + sizeof(char*) * (win32_argc + 1); |
|
| 208 |
+ win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize); |
|
| 209 |
+ argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1); |
|
| 210 | 210 |
if (win32_argv_utf8 == NULL) {
|
| 211 | 211 |
LocalFree(argv_w); |
| 212 | 212 |
return; |
| ... | ... |
@@ -231,8 +236,8 @@ static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) |
| 231 | 231 |
} |
| 232 | 232 |
#endif /* WIN32 && !__MINGW32CE__ */ |
| 233 | 233 |
|
| 234 |
- |
|
| 235 |
-int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options) |
|
| 234 |
+int parse_option(void *optctx, const char *opt, const char *arg, |
|
| 235 |
+ const OptionDef *options) |
|
| 236 | 236 |
{
|
| 237 | 237 |
const OptionDef *po; |
| 238 | 238 |
int bool_val = 1; |
| ... | ... |
@@ -261,13 +266,14 @@ unknown_opt: |
| 261 | 261 |
|
| 262 | 262 |
/* new-style options contain an offset into optctx, old-style address of |
| 263 | 263 |
* a global var*/ |
| 264 |
- dst = po->flags & (OPT_OFFSET|OPT_SPEC) ? (uint8_t*)optctx + po->u.off : po->u.dst_ptr; |
|
| 264 |
+ dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? (uint8_t *)optctx + po->u.off |
|
| 265 |
+ : po->u.dst_ptr; |
|
| 265 | 266 |
|
| 266 | 267 |
if (po->flags & OPT_SPEC) {
|
| 267 | 268 |
SpecifierOpt **so = dst; |
| 268 | 269 |
char *p = strchr(opt, ':'); |
| 269 | 270 |
|
| 270 |
- dstcount = (int*)(so + 1); |
|
| 271 |
+ dstcount = (int *)(so + 1); |
|
| 271 | 272 |
*so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1); |
| 272 | 273 |
(*so)[*dstcount - 1].specifier = av_strdup(p ? p + 1 : ""); |
| 273 | 274 |
dst = &(*so)[*dstcount - 1].u; |
| ... | ... |
@@ -276,24 +282,25 @@ unknown_opt: |
| 276 | 276 |
if (po->flags & OPT_STRING) {
|
| 277 | 277 |
char *str; |
| 278 | 278 |
str = av_strdup(arg); |
| 279 |
- *(char**)dst = str; |
|
| 279 |
+ *(char **)dst = str; |
|
| 280 | 280 |
} else if (po->flags & OPT_BOOL) {
|
| 281 |
- *(int*)dst = bool_val; |
|
| 281 |
+ *(int *)dst = bool_val; |
|
| 282 | 282 |
} else if (po->flags & OPT_INT) {
|
| 283 |
- *(int*)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); |
|
| 283 |
+ *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); |
|
| 284 | 284 |
} else if (po->flags & OPT_INT64) {
|
| 285 |
- *(int64_t*)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); |
|
| 285 |
+ *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); |
|
| 286 | 286 |
} else if (po->flags & OPT_TIME) {
|
| 287 |
- *(int64_t*)dst = parse_time_or_die(opt, arg, 1); |
|
| 287 |
+ *(int64_t *)dst = parse_time_or_die(opt, arg, 1); |
|
| 288 | 288 |
} else if (po->flags & OPT_FLOAT) {
|
| 289 |
- *(float*)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); |
|
| 289 |
+ *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); |
|
| 290 | 290 |
} else if (po->flags & OPT_DOUBLE) {
|
| 291 |
- *(double*)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); |
|
| 291 |
+ *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); |
|
| 292 | 292 |
} 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); |
|
| 293 |
+ int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) |
|
| 294 |
+ : po->u.func_arg(opt, arg); |
|
| 295 | 295 |
if (ret < 0) {
|
| 296 |
- av_log(NULL, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", arg, opt); |
|
| 296 |
+ av_log(NULL, AV_LOG_ERROR, |
|
| 297 |
+ "Failed to set value '%s' for option '%s'\n", arg, opt); |
|
| 297 | 298 |
return ret; |
| 298 | 299 |
} |
| 299 | 300 |
} |
| ... | ... |
@@ -303,7 +310,7 @@ unknown_opt: |
| 303 | 303 |
} |
| 304 | 304 |
|
| 305 | 305 |
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, |
| 306 |
- void (* parse_arg_function)(void *, const char*)) |
|
| 306 |
+ void (*parse_arg_function)(void *, const char*)) |
|
| 307 | 307 |
{
|
| 308 | 308 |
const char *opt; |
| 309 | 309 |
int optindex, handleoptions = 1, ret; |
| ... | ... |
@@ -336,7 +343,8 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options |
| 336 | 336 |
/* |
| 337 | 337 |
* Return index of option opt in argv or 0 if not found. |
| 338 | 338 |
*/ |
| 339 |
-static int locate_option(int argc, char **argv, const OptionDef *options, const char *optname) |
|
| 339 |
+static int locate_option(int argc, char **argv, const OptionDef *options, |
|
| 340 |
+ const char *optname) |
|
| 340 | 341 |
{
|
| 341 | 342 |
const OptionDef *po; |
| 342 | 343 |
int i; |
| ... | ... |
@@ -419,15 +427,18 @@ int opt_default(const char *opt, const char *arg) |
| 419 | 419 |
p = opt + strlen(opt); |
| 420 | 420 |
av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); |
| 421 | 421 |
|
| 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)))) |
|
| 422 |
+ if ((oc = av_opt_find(&cc, opt_stripped, NULL, 0, |
|
| 423 |
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || |
|
| 424 |
+ ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && |
|
| 425 |
+ (oc = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) |
|
| 425 | 426 |
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))) |
|
| 427 |
+ if ((of = av_opt_find(&fc, opt, NULL, 0, |
|
| 428 |
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) |
|
| 427 | 429 |
av_dict_set(&format_opts, opt, arg, FLAGS(of)); |
| 428 | 430 |
#if CONFIG_SWSCALE |
| 429 | 431 |
sc = sws_get_class(); |
| 430 |
- if ((os = av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
|
|
| 432 |
+ if ((os = av_opt_find(&sc, opt, NULL, 0, |
|
| 433 |
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
|
|
| 431 | 434 |
// XXX we only support sws_flags, not arbitrary sws options |
| 432 | 435 |
int ret = av_opt_set(sws_opts, opt, arg, 0); |
| 433 | 436 |
if (ret < 0) {
|
| ... | ... |
@@ -604,7 +615,8 @@ void show_banner(int argc, char **argv, const OptionDef *options) |
| 604 | 604 |
if (idx) |
| 605 | 605 |
return; |
| 606 | 606 |
|
| 607 |
- av_log(NULL, AV_LOG_INFO, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n", |
|
| 607 |
+ av_log(NULL, AV_LOG_INFO, |
|
| 608 |
+ "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n", |
|
| 608 | 609 |
program_name, program_birth_year, this_year); |
| 609 | 610 |
av_log(NULL, AV_LOG_INFO, " built on %s %s with %s %s\n", |
| 610 | 611 |
__DATE__, __TIME__, CC_TYPE, CC_VERSION); |
| ... | ... |
@@ -692,49 +704,47 @@ int opt_license(const char *opt, const char *arg) |
| 692 | 692 |
|
| 693 | 693 |
int opt_formats(const char *opt, const char *arg) |
| 694 | 694 |
{
|
| 695 |
- AVInputFormat *ifmt=NULL; |
|
| 696 |
- AVOutputFormat *ofmt=NULL; |
|
| 695 |
+ AVInputFormat *ifmt = NULL; |
|
| 696 |
+ AVOutputFormat *ofmt = NULL; |
|
| 697 | 697 |
const char *last_name; |
| 698 | 698 |
|
| 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; |
|
| 699 |
+ printf("File formats:\n"
|
|
| 700 |
+ " D. = Demuxing supported\n" |
|
| 701 |
+ " .E = Muxing supported\n" |
|
| 702 |
+ " --\n"); |
|
| 703 |
+ last_name = "000"; |
|
| 704 |
+ for (;;) {
|
|
| 705 |
+ int decode = 0; |
|
| 706 |
+ int encode = 0; |
|
| 707 |
+ const char *name = NULL; |
|
| 708 |
+ const char *long_name = NULL; |
|
| 709 |
+ |
|
| 710 |
+ while ((ofmt = av_oformat_next(ofmt))) {
|
|
| 711 |
+ if ((name == NULL || strcmp(ofmt->name, name) < 0) && |
|
| 712 |
+ strcmp(ofmt->name, last_name) > 0) {
|
|
| 713 |
+ name = ofmt->name; |
|
| 714 |
+ long_name = ofmt->long_name; |
|
| 715 |
+ encode = 1; |
|
| 717 | 716 |
} |
| 718 | 717 |
} |
| 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; |
|
| 718 |
+ while ((ifmt = av_iformat_next(ifmt))) {
|
|
| 719 |
+ if ((name == NULL || strcmp(ifmt->name, name) < 0) && |
|
| 720 |
+ strcmp(ifmt->name, last_name) > 0) {
|
|
| 721 |
+ name = ifmt->name; |
|
| 722 |
+ long_name = ifmt->long_name; |
|
| 723 |
+ encode = 0; |
|
| 725 | 724 |
} |
| 726 |
- if(name && strcmp(ifmt->name, name)==0) |
|
| 727 |
- decode=1; |
|
| 725 |
+ if (name && strcmp(ifmt->name, name) == 0) |
|
| 726 |
+ decode = 1; |
|
| 728 | 727 |
} |
| 729 |
- if(name==NULL) |
|
| 728 |
+ if (name == NULL) |
|
| 730 | 729 |
break; |
| 731 |
- last_name= name; |
|
| 730 |
+ last_name = name; |
|
| 732 | 731 |
|
| 733 |
- printf( |
|
| 734 |
- " %s%s %-15s %s\n", |
|
| 735 |
- decode ? "D":" ", |
|
| 736 |
- encode ? "E":" ", |
|
| 737 |
- name, |
|
| 732 |
+ printf(" %s%s %-15s %s\n",
|
|
| 733 |
+ decode ? "D" : " ", |
|
| 734 |
+ encode ? "E" : " ", |
|
| 735 |
+ name, |
|
| 738 | 736 |
long_name ? long_name:" "); |
| 739 | 737 |
} |
| 740 | 738 |
return 0; |
| ... | ... |
@@ -742,44 +752,45 @@ int opt_formats(const char *opt, const char *arg) |
| 742 | 742 |
|
| 743 | 743 |
int opt_codecs(const char *opt, const char *arg) |
| 744 | 744 |
{
|
| 745 |
- AVCodec *p=NULL, *p2; |
|
| 745 |
+ AVCodec *p = NULL, *p2; |
|
| 746 | 746 |
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"); |
|
| 747 |
+ printf("Codecs:\n"
|
|
| 748 |
+ " D..... = Decoding supported\n" |
|
| 749 |
+ " .E.... = Encoding supported\n" |
|
| 750 |
+ " ..V... = Video codec\n" |
|
| 751 |
+ " ..A... = Audio codec\n" |
|
| 752 |
+ " ..S... = Subtitle codec\n" |
|
| 753 |
+ " ...S.. = Supports draw_horiz_band\n" |
|
| 754 |
+ " ....D. = Supports direct rendering method 1\n" |
|
| 755 |
+ " .....T = Supports weird frame truncation\n" |
|
| 756 |
+ " ------\n"); |
|
| 758 | 757 |
last_name= "000"; |
| 759 |
- for(;;){
|
|
| 760 |
- int decode=0; |
|
| 761 |
- int encode=0; |
|
| 762 |
- int cap=0; |
|
| 758 |
+ for (;;) {
|
|
| 759 |
+ int decode = 0; |
|
| 760 |
+ int encode = 0; |
|
| 761 |
+ int cap = 0; |
|
| 763 | 762 |
const char *type_str; |
| 764 | 763 |
|
| 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; |
|
| 764 |
+ p2 = NULL; |
|
| 765 |
+ while ((p = av_codec_next(p))) {
|
|
| 766 |
+ if ((p2 == NULL || strcmp(p->name, p2->name) < 0) && |
|
| 767 |
+ strcmp(p->name, last_name) > 0) {
|
|
| 768 |
+ p2 = p; |
|
| 769 |
+ decode = encode = cap = 0; |
|
| 771 | 770 |
} |
| 772 |
- if(p2 && strcmp(p->name, p2->name)==0){
|
|
| 773 |
- if(p->decode) decode=1; |
|
| 774 |
- if(p->encode) encode=1; |
|
| 771 |
+ if (p2 && strcmp(p->name, p2->name) == 0) {
|
|
| 772 |
+ if (p->decode) |
|
| 773 |
+ decode = 1; |
|
| 774 |
+ if (p->encode) |
|
| 775 |
+ encode = 1; |
|
| 775 | 776 |
cap |= p->capabilities; |
| 776 | 777 |
} |
| 777 | 778 |
} |
| 778 |
- if(p2==NULL) |
|
| 779 |
+ if (p2 == NULL) |
|
| 779 | 780 |
break; |
| 780 |
- last_name= p2->name; |
|
| 781 |
+ last_name = p2->name; |
|
| 781 | 782 |
|
| 782 |
- switch(p2->type) {
|
|
| 783 |
+ switch (p2->type) {
|
|
| 783 | 784 |
case AVMEDIA_TYPE_VIDEO: |
| 784 | 785 |
type_str = "V"; |
| 785 | 786 |
break; |
| ... | ... |
@@ -793,36 +804,36 @@ int opt_codecs(const char *opt, const char *arg) |
| 793 | 793 |
type_str = "?"; |
| 794 | 794 |
break; |
| 795 | 795 |
} |
| 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);*/
|
|
| 796 |
+ printf(" %s%s%s%s%s%s %-15s %s",
|
|
| 797 |
+ decode ? "D" : (/* p2->decoder ? "d" : */ " "), |
|
| 798 |
+ encode ? "E" : " ", |
|
| 799 |
+ type_str, |
|
| 800 |
+ cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S" : " ", |
|
| 801 |
+ cap & CODEC_CAP_DR1 ? "D" : " ", |
|
| 802 |
+ cap & CODEC_CAP_TRUNCATED ? "T" : " ", |
|
| 803 |
+ p2->name, |
|
| 804 |
+ p2->long_name ? p2->long_name : ""); |
|
| 805 |
+#if 0 |
|
| 806 |
+ if (p2->decoder && decode == 0) |
|
| 807 |
+ printf(" use %s for decoding", p2->decoder->name);
|
|
| 808 |
+#endif |
|
| 808 | 809 |
printf("\n");
|
| 809 | 810 |
} |
| 810 | 811 |
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"); |
|
| 812 |
+ printf("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"); |
|
| 817 | 817 |
return 0; |
| 818 | 818 |
} |
| 819 | 819 |
|
| 820 | 820 |
int opt_bsfs(const char *opt, const char *arg) |
| 821 | 821 |
{
|
| 822 |
- AVBitStreamFilter *bsf=NULL; |
|
| 822 |
+ AVBitStreamFilter *bsf = NULL; |
|
| 823 | 823 |
|
| 824 | 824 |
printf("Bitstream filters:\n");
|
| 825 |
- while((bsf = av_bitstream_filter_next(bsf))) |
|
| 825 |
+ while ((bsf = av_bitstream_filter_next(bsf))) |
|
| 826 | 826 |
printf("%s\n", bsf->name);
|
| 827 | 827 |
printf("\n");
|
| 828 | 828 |
return 0; |
| ... | ... |
@@ -863,15 +874,14 @@ int opt_pix_fmts(const char *opt, const char *arg) |
| 863 | 863 |
{
|
| 864 | 864 |
enum PixelFormat pix_fmt; |
| 865 | 865 |
|
| 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"); |
|
| 866 |
+ printf("Pixel formats:\n"
|
|
| 867 |
+ "I.... = Supported Input format for conversion\n" |
|
| 868 |
+ ".O... = Supported Output format for conversion\n" |
|
| 869 |
+ "..H.. = Hardware accelerated format\n" |
|
| 870 |
+ "...P. = Paletted format\n" |
|
| 871 |
+ "....B = Bitstream format\n" |
|
| 872 |
+ "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n" |
|
| 873 |
+ "-----\n"); |
|
| 875 | 874 |
|
| 876 | 875 |
#if !CONFIG_SWSCALE |
| 877 | 876 |
# define sws_isSupportedInput(x) 0 |
| ... | ... |
@@ -921,7 +931,8 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) |
| 921 | 921 |
FILE *f = fopen(filename, "rb"); |
| 922 | 922 |
|
| 923 | 923 |
if (!f) {
|
| 924 |
- av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, strerror(errno)); |
|
| 924 |
+ av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, |
|
| 925 |
+ strerror(errno)); |
|
| 925 | 926 |
return AVERROR(errno); |
| 926 | 927 |
} |
| 927 | 928 |
fseek(f, 0, SEEK_END); |
| ... | ... |
@@ -952,14 +963,14 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) |
| 952 | 952 |
} |
| 953 | 953 |
|
| 954 | 954 |
FILE *get_preset_file(char *filename, size_t filename_size, |
| 955 |
- const char *preset_name, int is_path, const char *codec_name) |
|
| 955 |
+ const char *preset_name, int is_path, |
|
| 956 |
+ const char *codec_name) |
|
| 956 | 957 |
{
|
| 957 | 958 |
FILE *f = NULL; |
| 958 | 959 |
int i; |
| 959 |
- const char *base[3]= { getenv("FFMPEG_DATADIR"),
|
|
| 960 |
- getenv("HOME"),
|
|
| 961 |
- FFMPEG_DATADIR, |
|
| 962 |
- }; |
|
| 960 |
+ const char *base[3] = { getenv("FFMPEG_DATADIR"),
|
|
| 961 |
+ getenv("HOME"),
|
|
| 962 |
+ FFMPEG_DATADIR, }; |
|
| 963 | 963 |
|
| 964 | 964 |
if (is_path) {
|
| 965 | 965 |
av_strlcpy(filename, preset_name, filename_size); |
| ... | ... |
@@ -985,11 +996,14 @@ FILE *get_preset_file(char *filename, size_t filename_size, |
| 985 | 985 |
for (i = 0; i < 3 && !f; i++) {
|
| 986 | 986 |
if (!base[i]) |
| 987 | 987 |
continue; |
| 988 |
- snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", preset_name); |
|
| 988 |
+ snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], |
|
| 989 |
+ i != 1 ? "" : "/.ffmpeg", preset_name); |
|
| 989 | 990 |
f = fopen(filename, "r"); |
| 990 | 991 |
if (!f && codec_name) {
|
| 991 | 992 |
snprintf(filename, filename_size, |
| 992 |
- "%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec_name, preset_name); |
|
| 993 |
+ "%s%s/%s-%s.ffpreset", |
|
| 994 |
+ base[i], i != 1 ? "" : "/.ffmpeg", codec_name, |
|
| 995 |
+ preset_name); |
|
| 993 | 996 |
f = fopen(filename, "r"); |
| 994 | 997 |
} |
| 995 | 998 |
} |
| ... | ... |
@@ -1000,22 +1014,23 @@ FILE *get_preset_file(char *filename, size_t filename_size, |
| 1000 | 1000 |
|
| 1001 | 1001 |
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) |
| 1002 | 1002 |
{
|
| 1003 |
- if (*spec <= '9' && *spec >= '0') /* opt:index */ |
|
| 1003 |
+ if (*spec <= '9' && *spec >= '0') /* opt:index */ |
|
| 1004 | 1004 |
return strtol(spec, NULL, 0) == st->index; |
| 1005 |
- else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || *spec == 't') { /* opt:[vasdt] */
|
|
| 1005 |
+ else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || |
|
| 1006 |
+ *spec == 't') { /* opt:[vasdt] */
|
|
| 1006 | 1007 |
enum AVMediaType type; |
| 1007 | 1008 |
|
| 1008 | 1009 |
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; |
|
| 1010 |
+ case 'v': type = AVMEDIA_TYPE_VIDEO; break; |
|
| 1011 |
+ case 'a': type = AVMEDIA_TYPE_AUDIO; break; |
|
| 1012 |
+ case 's': type = AVMEDIA_TYPE_SUBTITLE; break; |
|
| 1013 |
+ case 'd': type = AVMEDIA_TYPE_DATA; break; |
|
| 1013 | 1014 |
case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; |
| 1014 | 1015 |
default: abort(); // never reached, silence warning |
| 1015 | 1016 |
} |
| 1016 | 1017 |
if (type != st->codec->codec_type) |
| 1017 | 1018 |
return 0; |
| 1018 |
- if (*spec++ == ':') { /* possibly followed by :index */
|
|
| 1019 |
+ if (*spec++ == ':') { /* possibly followed by :index */
|
|
| 1019 | 1020 |
int i, index = strtol(spec, NULL, 0); |
| 1020 | 1021 |
for (i = 0; i < s->nb_streams; i++) |
| 1021 | 1022 |
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) |
| 1051 | 1051 |
return AVERROR(EINVAL); |
| 1052 | 1052 |
} |
| 1053 | 1053 |
|
| 1054 |
-AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatContext *s, AVStream *st) |
|
| 1054 |
+AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, |
|
| 1055 |
+ AVFormatContext *s, AVStream *st) |
|
| 1055 | 1056 |
{
|
| 1056 | 1057 |
AVDictionary *ret = NULL; |
| 1057 | 1058 |
AVDictionaryEntry *t = NULL; |
| 1058 |
- int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM; |
|
| 1059 |
+ int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM |
|
| 1060 |
+ : AV_OPT_FLAG_DECODING_PARAM; |
|
| 1059 | 1061 |
char prefix = 0; |
| 1060 | 1062 |
const AVClass *cc = avcodec_get_class(); |
| 1061 | 1063 |
|
| ... | ... |
@@ -1063,9 +1080,18 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont |
| 1063 | 1063 |
return NULL; |
| 1064 | 1064 |
|
| 1065 | 1065 |
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; |
|
| 1066 |
+ case AVMEDIA_TYPE_VIDEO: |
|
| 1067 |
+ prefix = 'v'; |
|
| 1068 |
+ flags |= AV_OPT_FLAG_VIDEO_PARAM; |
|
| 1069 |
+ break; |
|
| 1070 |
+ case AVMEDIA_TYPE_AUDIO: |
|
| 1071 |
+ prefix = 'a'; |
|
| 1072 |
+ flags |= AV_OPT_FLAG_AUDIO_PARAM; |
|
| 1073 |
+ break; |
|
| 1074 |
+ case AVMEDIA_TYPE_SUBTITLE: |
|
| 1075 |
+ prefix = 's'; |
|
| 1076 |
+ flags |= AV_OPT_FLAG_SUBTITLE_PARAM; |
|
| 1077 |
+ break; |
|
| 1069 | 1078 |
} |
| 1070 | 1079 |
|
| 1071 | 1080 |
while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) {
|
| ... | ... |
@@ -1080,10 +1106,14 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont |
| 1080 | 1080 |
} |
| 1081 | 1081 |
|
| 1082 | 1082 |
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))) |
|
| 1083 |
+ (codec && codec->priv_class && |
|
| 1084 |
+ av_opt_find(&codec->priv_class, t->key, NULL, flags, |
|
| 1085 |
+ AV_OPT_SEARCH_FAKE_OBJ))) |
|
| 1084 | 1086 |
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); |
|
| 1087 |
+ else if (t->key[0] == prefix && |
|
| 1088 |
+ av_opt_find(&cc, t->key + 1, NULL, flags, |
|
| 1089 |
+ AV_OPT_SEARCH_FAKE_OBJ)) |
|
| 1090 |
+ av_dict_set(&ret, t->key + 1, t->value, 0); |
|
| 1087 | 1091 |
|
| 1088 | 1092 |
if (p) |
| 1089 | 1093 |
*p = ':'; |
| ... | ... |
@@ -1091,7 +1121,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont |
| 1091 | 1091 |
return ret; |
| 1092 | 1092 |
} |
| 1093 | 1093 |
|
| 1094 |
-AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts) |
|
| 1094 |
+AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, |
|
| 1095 |
+ AVDictionary *codec_opts) |
|
| 1095 | 1096 |
{
|
| 1096 | 1097 |
int i; |
| 1097 | 1098 |
AVDictionary **opts; |
| ... | ... |
@@ -1100,11 +1131,13 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *cod |
| 1100 | 1100 |
return NULL; |
| 1101 | 1101 |
opts = av_mallocz(s->nb_streams * sizeof(*opts)); |
| 1102 | 1102 |
if (!opts) {
|
| 1103 |
- av_log(NULL, AV_LOG_ERROR, "Could not alloc memory for stream options.\n"); |
|
| 1103 |
+ av_log(NULL, AV_LOG_ERROR, |
|
| 1104 |
+ "Could not alloc memory for stream options.\n"); |
|
| 1104 | 1105 |
return NULL; |
| 1105 | 1106 |
} |
| 1106 | 1107 |
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]); |
|
| 1108 |
+ opts[i] = filter_codec_opts(codec_opts, avcodec_find_decoder(s->streams[i]->codec->codec_id), |
|
| 1109 |
+ s, s->streams[i]); |
|
| 1108 | 1110 |
return opts; |
| 1109 | 1111 |
} |
| 1110 | 1112 |
|
| ... | ... |
@@ -1175,9 +1175,9 @@ HAVE_LIST=" |
| 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 |
| 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: |
| 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, |
| 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, |
| 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) |
| 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, |
| 106 | 106 |
return buf_size; |
| 107 | 107 |
} |
| 108 | 108 |
|
| 109 |
- if(AV_RB16(buf) == 0x8000){
|
|
| 109 |
+ if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) {
|
|
| 110 | 110 |
int header_size; |
| 111 |
- if ((ret = avpriv_adx_decode_header(avctx, buf, |
|
| 112 |
- buf_size, &header_size, |
|
| 111 |
+ if ((ret = avpriv_adx_decode_header(avctx, buf, buf_size, &header_size, |
|
| 113 | 112 |
c->coeff)) < 0) {
|
| 114 | 113 |
av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); |
| 115 | 114 |
return AVERROR_INVALIDDATA; |
| 116 | 115 |
} |
| 117 |
- c->channels = avctx->channels; |
|
| 118 |
- if(buf_size < header_size) |
|
| 116 |
+ c->channels = avctx->channels; |
|
| 117 |
+ c->header_parsed = 1; |
|
| 118 |
+ if (buf_size < header_size) |
|
| 119 | 119 |
return AVERROR_INVALIDDATA; |
| 120 |
- buf += header_size; |
|
| 120 |
+ buf += header_size; |
|
| 121 | 121 |
buf_size -= header_size; |
| 122 | 122 |
} |
| 123 |
- if(c->channels <= 0) |
|
| 123 |
+ if (!c->header_parsed) |
|
| 124 | 124 |
return AVERROR_INVALIDDATA; |
| 125 | 125 |
|
| 126 | 126 |
/* calculate number of blocks in the packet */ |
| ... | ... |
@@ -25,27 +25,23 @@ |
| 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, |
| 464 | 464 |
if(ret<0) |
| 465 | 465 |
return ret; |
| 466 | 466 |
|
| 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.. |
|
| 467 |
+ /* adaptive FIR filter */ |
|
| 468 |
+ if (prediction_type[ch] == 15) {
|
|
| 469 |
+ /* Prediction type 15 runs the adaptive FIR twice. |
|
| 470 |
+ * The first pass uses the special-case coef_num = 31, while |
|
| 471 |
+ * the second pass uses the coefs from the bitstream. |
|
| 472 |
+ * |
|
| 473 |
+ * However, this prediction type is not currently used by the |
|
| 474 |
+ * reference encoder. |
|
| 483 | 475 |
*/ |
| 476 |
+ predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], |
|
| 477 |
+ alac->predicterror_buffer[ch], |
|
| 478 |
+ outputsamples, readsamplesize, |
|
| 479 |
+ NULL, 31, 0); |
|
| 480 |
+ } else if (prediction_type[ch] > 0) {
|
|
| 481 |
+ av_log(avctx, AV_LOG_WARNING, "unknown prediction type: %i\n", |
|
| 482 |
+ prediction_type[ch]); |
|
| 484 | 483 |
} |
| 484 |
+ predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], |
|
| 485 |
+ alac->outputsamples_buffer[ch], |
|
| 486 |
+ outputsamples, readsamplesize, |
|
| 487 |
+ predictor_coef_table[ch], |
|
| 488 |
+ predictor_coef_num[ch], |
|
| 489 |
+ prediction_quantitization[ch]); |
|
| 485 | 490 |
} |
| 486 | 491 |
} else {
|
| 487 | 492 |
/* not compressed, easy case */ |
| ... | ... |
@@ -584,7 +585,7 @@ static int alac_set_info(ALACContext *alac) |
| 584 | 584 |
|
| 585 | 585 |
ptr += 4; /* size */ |
| 586 | 586 |
ptr += 4; /* alac */ |
| 587 |
- ptr += 4; /* 0 ? */ |
|
| 587 |
+ ptr += 4; /* version */ |
|
| 588 | 588 |
|
| 589 | 589 |
if(AV_RB32(ptr) >= UINT_MAX/4){
|
| 590 | 590 |
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) |
| 593 | 593 |
|
| 594 | 594 |
/* buffer size / 2 ? */ |
| 595 | 595 |
alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr); |
| 596 |
- ptr++; /* ??? */ |
|
| 596 |
+ ptr++; /* compatible version */ |
|
| 597 | 597 |
alac->setinfo_sample_size = *ptr++; |
| 598 | 598 |
alac->setinfo_rice_historymult = *ptr++; |
| 599 | 599 |
alac->setinfo_rice_initialhistory = *ptr++; |
| 600 | 600 |
alac->setinfo_rice_kmodifier = *ptr++; |
| 601 | 601 |
alac->numchannels = *ptr++; |
| 602 |
- bytestream_get_be16(&ptr); /* ??? */ |
|
| 602 |
+ bytestream_get_be16(&ptr); /* maxRun */ |
|
| 603 | 603 |
bytestream_get_be32(&ptr); /* max coded frame size */ |
| 604 |
- bytestream_get_be32(&ptr); /* bitrate ? */ |
|
| 604 |
+ bytestream_get_be32(&ptr); /* average bitrate */ |
|
| 605 | 605 |
bytestream_get_be32(&ptr); /* samplerate */ |
| 606 | 606 |
|
| 607 | 607 |
return 0; |
| ... | ... |
@@ -348,6 +348,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) |
| 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) |
| 358 | 358 |
|
| 359 | 359 |
calc_predictor_params(s, i); |
| 360 | 360 |
|
| 361 |
- put_bits(&s->pbctx, 4, 0); // prediction type : currently only type 0 has been RE'd |
|
| 361 |
+ put_bits(&s->pbctx, 4, prediction_type); |
|
| 362 | 362 |
put_bits(&s->pbctx, 4, s->lpc[i].lpc_quant); |
| 363 | 363 |
|
| 364 | 364 |
put_bits(&s->pbctx, 3, s->rc.rice_modifier); |
| ... | ... |
@@ -373,6 +374,14 @@ static void write_compressed_frame(AlacEncodeContext *s) |
| 373 | 373 |
|
| 374 | 374 |
for (i = 0; i < s->avctx->channels; i++) {
|
| 375 | 375 |
alac_linear_predictor(s, i); |
| 376 |
+ |
|
| 377 |
+ // TODO: determine when this will actually help. for now it's not used. |
|
| 378 |
+ if (prediction_type == 15) {
|
|
| 379 |
+ // 2nd pass 1st order filter |
|
| 380 |
+ for (j = s->avctx->frame_size - 1; j > 0; j--) |
|
| 381 |
+ s->predictor_buf[j] -= s->predictor_buf[j - 1]; |
|
| 382 |
+ } |
|
| 383 |
+ |
|
| 376 | 384 |
alac_entropy_coder(s); |
| 377 | 385 |
} |
| 378 | 386 |
} |
| ... | ... |
@@ -391,8 +400,11 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) |
| 391 | 391 |
return -1; |
| 392 | 392 |
} |
| 393 | 393 |
|
| 394 |
- if(avctx->channels > 2) {
|
|
| 395 |
- av_log(avctx, AV_LOG_ERROR, "channels > 2 not supported\n"); |
|
| 394 |
+ /* TODO: Correctly implement multi-channel ALAC. |
|
| 395 |
+ It is similar to multi-channel AAC, in that it has a series of |
|
| 396 |
+ single-channel (SCE), channel-pair (CPE), and LFE elements. */ |
|
| 397 |
+ if (avctx->channels > 2) {
|
|
| 398 |
+ av_log(avctx, AV_LOG_ERROR, "only mono or stereo input is currently supported\n"); |
|
| 396 | 399 |
return AVERROR_PATCHWELCOME; |
| 397 | 400 |
} |
| 398 | 401 |
|
| ... | ... |
@@ -48,13 +48,13 @@ |
| 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[] = {
|
| 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] = {
|
| 227 | 227 |
{ 3, 2, 4, 0, 1, 5, 8, 7, 6},
|
| 228 | 228 |
}; |
| 229 | 229 |
|
| 230 |
-#define DCA_DOLBY 101 /* FIXME */ |
|
| 230 |
+#define DCA_DOLBY 101 /* FIXME */ |
|
| 231 | 231 |
|
| 232 |
-#define DCA_CHANNEL_BITS 6 |
|
| 233 |
-#define DCA_CHANNEL_MASK 0x3F |
|
| 232 |
+#define DCA_CHANNEL_BITS 6 |
|
| 233 |
+#define DCA_CHANNEL_MASK 0x3F |
|
| 234 | 234 |
|
| 235 |
-#define DCA_LFE 0x80 |
|
| 235 |
+#define DCA_LFE 0x80 |
|
| 236 | 236 |
|
| 237 |
-#define HEADER_SIZE 14 |
|
| 237 |
+#define HEADER_SIZE 14 |
|
| 238 | 238 |
|
| 239 |
-#define DCA_MAX_FRAME_SIZE 16384 |
|
| 240 |
-#define DCA_MAX_EXSS_HEADER_SIZE 4096 |
|
| 239 |
+#define DCA_MAX_FRAME_SIZE 16384 |
|
| 240 |
+#define DCA_MAX_EXSS_HEADER_SIZE 4096 |
|
| 241 | 241 |
|
| 242 |
-#define DCA_BUFFER_PADDING_SIZE 1024 |
|
| 242 |
+#define DCA_BUFFER_PADDING_SIZE 1024 |
|
| 243 | 243 |
|
| 244 | 244 |
/** Bit allocation */ |
| 245 | 245 |
typedef struct {
|
| ... | ... |
@@ -254,9 +271,11 @@ static BitAlloc dca_tmode; ///< transition mode VLCs |
| 254 | 254 |
static BitAlloc dca_scalefactor; ///< scalefactor VLCs |
| 255 | 255 |
static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs |
| 256 | 256 |
|
| 257 |
-static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx) |
|
| 257 |
+static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, |
|
| 258 |
+ int idx) |
|
| 258 | 259 |
{
|
| 259 |
- return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + ba->offset; |
|
| 260 |
+ return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + |
|
| 261 |
+ ba->offset; |
|
| 260 | 262 |
} |
| 261 | 263 |
|
| 262 | 264 |
typedef struct {
|
| ... | ... |
@@ -306,8 +325,8 @@ typedef struct {
|
| 306 | 306 |
float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment |
| 307 | 307 |
|
| 308 | 308 |
/* 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 |
|
| 309 |
+ int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes |
|
| 310 |
+ int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count |
|
| 311 | 311 |
int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not) |
| 312 | 312 |
int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs |
| 313 | 313 |
int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index |
| ... | ... |
@@ -334,13 +353,13 @@ typedef struct {
|
| 334 | 334 |
float scale_bias; ///< output scale |
| 335 | 335 |
|
| 336 | 336 |
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]; |
|
| 337 |
+ DECLARE_ALIGNED(32, float, samples)[(DCA_PRIM_CHANNELS_MAX + 1) * 256]; |
|
| 338 |
+ const float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1]; |
|
| 339 | 339 |
|
| 340 | 340 |
uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE]; |
| 341 | 341 |
int dca_buffer_size; ///< how much data is in the dca_buffer |
| 342 | 342 |
|
| 343 |
- const int8_t* channel_order_tab; ///< channel reordering table, lfe and non lfe |
|
| 343 |
+ const int8_t *channel_order_tab; ///< channel reordering table, lfe and non lfe |
|
| 344 | 344 |
GetBitContext gb; |
| 345 | 345 |
/* Current position in DCA frame */ |
| 346 | 346 |
int current_subframe; |
| ... | ... |
@@ -415,13 +434,15 @@ static av_cold void dca_init_vlcs(void) |
| 415 | 415 |
} |
| 416 | 416 |
|
| 417 | 417 |
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], |
|
| 418 |
+ for (j = 0; j < 7; j++) {
|
|
| 419 |
+ if (!bitalloc_codes[i][j]) |
|
| 420 |
+ break; |
|
| 421 |
+ dca_smpl_bitalloc[i + 1].offset = bitalloc_offsets[i]; |
|
| 422 |
+ dca_smpl_bitalloc[i + 1].wrap = 1 + (j > 4); |
|
| 423 |
+ dca_smpl_bitalloc[i + 1].vlc[j].table = &dca_table[dca_vlc_offs[c]]; |
|
| 424 |
+ dca_smpl_bitalloc[i + 1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c]; |
|
| 425 |
+ |
|
| 426 |
+ init_vlc(&dca_smpl_bitalloc[i + 1].vlc[j], bitalloc_maxbits[i][j], |
|
| 425 | 427 |
bitalloc_sizes[i], |
| 426 | 428 |
bitalloc_bits[i][j], 1, 1, |
| 427 | 429 |
bitalloc_codes[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC); |
| ... | ... |
@@ -432,19 +453,19 @@ static av_cold void dca_init_vlcs(void) |
| 432 | 432 |
|
| 433 | 433 |
static inline void get_array(GetBitContext *gb, int *dst, int len, int bits) |
| 434 | 434 |
{
|
| 435 |
- while(len--) |
|
| 435 |
+ while (len--) |
|
| 436 | 436 |
*dst++ = get_bits(gb, bits); |
| 437 | 437 |
} |
| 438 | 438 |
|
| 439 |
-static int dca_parse_audio_coding_header(DCAContext * s, int base_channel) |
|
| 439 |
+static int dca_parse_audio_coding_header(DCAContext *s, int base_channel) |
|
| 440 | 440 |
{
|
| 441 | 441 |
int i, j; |
| 442 | 442 |
static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
|
| 443 | 443 |
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 };
|
|
| 444 |
+ static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
|
|
| 445 | 445 |
|
| 446 |
- s->total_channels = get_bits(&s->gb, 3) + 1 + base_channel; |
|
| 447 |
- s->prim_channels = s->total_channels; |
|
| 446 |
+ s->total_channels = get_bits(&s->gb, 3) + 1 + base_channel; |
|
| 447 |
+ s->prim_channels = s->total_channels; |
|
| 448 | 448 |
|
| 449 | 449 |
if (s->prim_channels > DCA_PRIM_CHANNELS_MAX) |
| 450 | 450 |
s->prim_channels = DCA_PRIM_CHANNELS_MAX; |
| ... | ... |
@@ -487,23 +508,28 @@ static int dca_parse_audio_coding_header(DCAContext * s, int base_channel) |
| 487 | 487 |
get_bits(&s->gb, 16); |
| 488 | 488 |
} |
| 489 | 489 |
|
| 490 |
- s->current_subframe = 0; |
|
| 490 |
+ s->current_subframe = 0; |
|
| 491 | 491 |
s->current_subsubframe = 0; |
| 492 | 492 |
|
| 493 | 493 |
#ifdef TRACE |
| 494 | 494 |
av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes); |
| 495 | 495 |
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]); |
|
| 496 |
+ for (i = base_channel; i < s->prim_channels; i++) {
|
|
| 497 |
+ av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", |
|
| 498 |
+ s->subband_activity[i]); |
|
| 499 |
+ av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", |
|
| 500 |
+ s->vq_start_subband[i]); |
|
| 501 |
+ av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", |
|
| 502 |
+ s->joint_intensity[i]); |
|
| 503 |
+ av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", |
|
| 504 |
+ s->transient_huffman[i]); |
|
| 505 |
+ av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", |
|
| 506 |
+ s->scalefactor_huffman[i]); |
|
| 507 |
+ av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", |
|
| 508 |
+ s->bitalloc_huffman[i]); |
|
| 503 | 509 |
av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:"); |
| 504 | 510 |
for (j = 0; j < 11; j++) |
| 505 |
- av_log(s->avctx, AV_LOG_DEBUG, " %i", |
|
| 506 |
- s->quant_index_huffman[i][j]); |
|
| 511 |
+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->quant_index_huffman[i][j]); |
|
| 507 | 512 |
av_log(s->avctx, AV_LOG_DEBUG, "\n"); |
| 508 | 513 |
av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:"); |
| 509 | 514 |
for (j = 0; j < 11; j++) |
| ... | ... |
@@ -512,10 +538,10 @@ static int dca_parse_audio_coding_header(DCAContext * s, int base_channel) |
| 512 | 512 |
} |
| 513 | 513 |
#endif |
| 514 | 514 |
|
| 515 |
- return 0; |
|
| 515 |
+ return 0; |
|
| 516 | 516 |
} |
| 517 | 517 |
|
| 518 |
-static int dca_parse_frame_header(DCAContext * s) |
|
| 518 |
+static int dca_parse_frame_header(DCAContext *s) |
|
| 519 | 519 |
{
|
| 520 | 520 |
init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); |
| 521 | 521 |
|
| ... | ... |
@@ -564,7 +590,8 @@ static int dca_parse_frame_header(DCAContext * s) |
| 564 | 564 |
|
| 565 | 565 |
/* FIXME: channels mixing levels */ |
| 566 | 566 |
s->output = s->amode; |
| 567 |
- if (s->lfe) s->output |= DCA_LFE; |
|
| 567 |
+ if (s->lfe) |
|
| 568 |
+ s->output |= DCA_LFE; |
|
| 568 | 569 |
|
| 569 | 570 |
#ifdef TRACE |
| 570 | 571 |
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) |
| 613 | 613 |
|
| 614 | 614 |
static inline int get_scale(GetBitContext *gb, int level, int value) |
| 615 | 615 |
{
|
| 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; |
|
| 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; |
|
| 622 | 622 |
} |
| 623 | 623 |
|
| 624 |
-static int dca_subframe_header(DCAContext * s, int base_channel, int block_index) |
|
| 624 |
+static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) |
|
| 625 | 625 |
{
|
| 626 | 626 |
/* Primary audio coding side information */ |
| 627 | 627 |
int j, k; |
| ... | ... |
@@ -630,7 +657,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index |
| 630 | 630 |
return AVERROR_INVALIDDATA; |
| 631 | 631 |
|
| 632 | 632 |
if (!base_channel) {
|
| 633 |
- s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; |
|
| 633 |
+ s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; |
|
| 634 | 634 |
s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3); |
| 635 | 635 |
} |
| 636 | 636 |
|
| ... | ... |
@@ -666,8 +693,8 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index |
| 666 | 666 |
} |
| 667 | 667 |
|
| 668 | 668 |
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]); |
|
| 669 |
+ // av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index [%i][%i] too big (%i)\n", |
|
| 670 |
+ // j, k, s->bitalloc[j][k]); |
|
| 671 | 671 |
return AVERROR_INVALIDDATA; |
| 672 | 672 |
} |
| 673 | 673 |
} |
| ... | ... |
@@ -692,7 +719,8 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index |
| 692 | 692 |
const uint32_t *scale_table; |
| 693 | 693 |
int scale_sum; |
| 694 | 694 |
|
| 695 |
- memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); |
|
| 695 |
+ memset(s->scale_factor[j], 0, |
|
| 696 |
+ s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); |
|
| 696 | 697 |
|
| 697 | 698 |
if (s->scalefactor_huffman[j] == 6) |
| 698 | 699 |
scale_table = scale_factor_quant7; |
| ... | ... |
@@ -810,9 +838,11 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index |
| 810 | 810 |
} |
| 811 | 811 |
|
| 812 | 812 |
#ifdef TRACE |
| 813 |
- av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes[s->current_subframe]); |
|
| 813 |
+ av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", |
|
| 814 |
+ s->subsubframes[s->current_subframe]); |
|
| 814 | 815 |
av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n", |
| 815 | 816 |
s->partial_samples[s->current_subframe]); |
| 817 |
+ |
|
| 816 | 818 |
for (j = base_channel; j < s->prim_channels; j++) {
|
| 817 | 819 |
av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:"); |
| 818 | 820 |
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 |
| 821 | 821 |
} |
| 822 | 822 |
for (j = base_channel; j < s->prim_channels; j++) {
|
| 823 | 823 |
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); |
|
| 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); |
|
| 830 | 830 |
} |
| 831 | 831 |
for (j = base_channel; j < s->prim_channels; j++) {
|
| 832 | 832 |
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 |
| 862 | 862 |
if (!base_channel && s->prim_channels > 2 && s->downmix) {
|
| 863 | 863 |
av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n"); |
| 864 | 864 |
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]]); |
|
| 865 |
+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j, |
|
| 866 |
+ dca_downmix_coeffs[s->downmix_coef[j][0]]); |
|
| 867 |
+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j, |
|
| 868 |
+ dca_downmix_coeffs[s->downmix_coef[j][1]]); |
|
| 867 | 869 |
} |
| 868 | 870 |
av_log(s->avctx, AV_LOG_DEBUG, "\n"); |
| 869 | 871 |
} |
| ... | ... |
@@ -884,7 +916,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index |
| 884 | 884 |
return 0; |
| 885 | 885 |
} |
| 886 | 886 |
|
| 887 |
-static void qmf_32_subbands(DCAContext * s, int chans, |
|
| 887 |
+static void qmf_32_subbands(DCAContext *s, int chans, |
|
| 888 | 888 |
float samples_in[32][8], float *samples_out, |
| 889 | 889 |
float scale) |
| 890 | 890 |
{
|
| ... | ... |
@@ -894,7 +926,7 @@ static void qmf_32_subbands(DCAContext * s, int chans, |
| 894 | 894 |
int sb_act = s->subband_activity[chans]; |
| 895 | 895 |
int subindex; |
| 896 | 896 |
|
| 897 |
- scale *= sqrt(1/8.0); |
|
| 897 |
+ scale *= sqrt(1 / 8.0); |
|
| 898 | 898 |
|
| 899 | 899 |
/* Select filter */ |
| 900 | 900 |
if (!s->multirate_inter) /* Non-perfect reconstruction */ |
| ... | ... |
@@ -908,18 +940,18 @@ static void qmf_32_subbands(DCAContext * s, int chans, |
| 908 | 908 |
/* Reconstructed channel sample index */ |
| 909 | 909 |
for (subindex = 0; subindex < 8; subindex++) {
|
| 910 | 910 |
/* Load in one sample from each subband and clear inactive subbands */ |
| 911 |
- for (i = 0; i < sb_act; i++){
|
|
| 911 |
+ for (i = 0; i < sb_act; i++) {
|
|
| 912 | 912 |
unsigned sign = (i - 1) & 2; |
| 913 |
- uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30; |
|
| 913 |
+ uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30; |
|
| 914 | 914 |
AV_WN32A(&s->raXin[i], v); |
| 915 | 915 |
} |
| 916 | 916 |
|
| 917 | 917 |
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 |
- |
|
| 918 |
+ s->subband_fir_hist[chans], |
|
| 919 |
+ &s->hist_index[chans], |
|
| 920 |
+ s->subband_fir_noidea[chans], prCoeff, |
|
| 921 |
+ samples_out, s->raXin, scale); |
|
| 922 |
+ samples_out += 32; |
|
| 923 | 923 |
} |
| 924 | 924 |
} |
| 925 | 925 |
|
| ... | ... |
@@ -949,45 +981,44 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, |
| 949 | 949 |
} |
| 950 | 950 |
/* Interpolation */ |
| 951 | 951 |
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
|
| 952 |
- s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, |
|
| 953 |
- scale); |
|
| 952 |
+ s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale); |
|
| 954 | 953 |
samples_in++; |
| 955 | 954 |
samples_out += 2 * decifactor; |
| 956 | 955 |
} |
| 957 | 956 |
} |
| 958 | 957 |
|
| 959 | 958 |
/* 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]; \ |
|
| 959 |
+#define MIX_REAR1(samples, si1, rs, coef) \ |
|
| 960 |
+ samples[i] += samples[si1] * coef[rs][0]; \ |
|
| 961 |
+ samples[i+256] += samples[si1] * coef[rs][1]; |
|
| 962 |
+ |
|
| 963 |
+#define MIX_REAR2(samples, si1, si2, rs, coef) \ |
|
| 964 |
+ samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs + 1][0]; \ |
|
| 965 |
+ samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs + 1][1]; |
|
| 966 |
+ |
|
| 967 |
+#define MIX_FRONT3(samples, coef) \ |
|
| 968 |
+ t = samples[i + c]; \ |
|
| 969 |
+ u = samples[i + l]; \ |
|
| 970 |
+ v = samples[i + r]; \ |
|
| 972 | 971 |
samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \ |
| 973 | 972 |
samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1]; |
| 974 | 973 |
|
| 975 |
-#define DOWNMIX_TO_STEREO(op1, op2) \ |
|
| 976 |
- for (i = 0; i < 256; i++){ \
|
|
| 977 |
- op1 \ |
|
| 978 |
- op2 \ |
|
| 974 |
+#define DOWNMIX_TO_STEREO(op1, op2) \ |
|
| 975 |
+ for (i = 0; i < 256; i++) { \
|
|
| 976 |
+ op1 \ |
|
| 977 |
+ op2 \ |
|
| 979 | 978 |
} |
| 980 | 979 |
|
| 981 | 980 |
static void dca_downmix(float *samples, int srcfmt, |
| 982 | 981 |
int downmix_coef[DCA_PRIM_CHANNELS_MAX][2], |
| 983 | 982 |
const int8_t *channel_mapping) |
| 984 | 983 |
{
|
| 985 |
- int c,l,r,sl,sr,s; |
|
| 984 |
+ int c, l, r, sl, sr, s; |
|
| 986 | 985 |
int i; |
| 987 | 986 |
float t, u, v; |
| 988 | 987 |
float coef[DCA_PRIM_CHANNELS_MAX][2]; |
| 989 | 988 |
|
| 990 |
- for (i=0; i<DCA_PRIM_CHANNELS_MAX; i++) {
|
|
| 989 |
+ for (i = 0; i < DCA_PRIM_CHANNELS_MAX; i++) {
|
|
| 991 | 990 |
coef[i][0] = dca_downmix_coeffs[downmix_coef[i][0]]; |
| 992 | 991 |
coef[i][1] = dca_downmix_coeffs[downmix_coef[i][1]]; |
| 993 | 992 |
} |
| ... | ... |
@@ -1006,11 +1037,11 @@ static void dca_downmix(float *samples, int srcfmt, |
| 1006 | 1006 |
c = channel_mapping[0] * 256; |
| 1007 | 1007 |
l = channel_mapping[1] * 256; |
| 1008 | 1008 |
r = channel_mapping[2] * 256; |
| 1009 |
- DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),); |
|
| 1009 |
+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), ); |
|
| 1010 | 1010 |
break; |
| 1011 | 1011 |
case DCA_2F1R: |
| 1012 | 1012 |
s = channel_mapping[2] * 256; |
| 1013 |
- DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + s, 2, coef),); |
|
| 1013 |
+ DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + s, 2, coef), ); |
|
| 1014 | 1014 |
break; |
| 1015 | 1015 |
case DCA_3F1R: |
| 1016 | 1016 |
c = channel_mapping[0] * 256; |
| ... | ... |
@@ -1023,12 +1054,12 @@ static void dca_downmix(float *samples, int srcfmt, |
| 1023 | 1023 |
case DCA_2F2R: |
| 1024 | 1024 |
sl = channel_mapping[2] * 256; |
| 1025 | 1025 |
sr = channel_mapping[3] * 256; |
| 1026 |
- DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + sl, i + sr, 2, coef),); |
|
| 1026 |
+ DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + sl, i + sr, 2, coef), ); |
|
| 1027 | 1027 |
break; |
| 1028 | 1028 |
case DCA_3F2R: |
| 1029 |
- c = channel_mapping[0] * 256; |
|
| 1030 |
- l = channel_mapping[1] * 256; |
|
| 1031 |
- r = channel_mapping[2] * 256; |
|
| 1029 |
+ c = channel_mapping[0] * 256; |
|
| 1030 |
+ l = channel_mapping[1] * 256; |
|
| 1031 |
+ r = channel_mapping[2] * 256; |
|
| 1032 | 1032 |
sl = channel_mapping[3] * 256; |
| 1033 | 1033 |
sr = channel_mapping[4] * 256; |
| 1034 | 1034 |
DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), |
| ... | ... |
@@ -1048,7 +1079,7 @@ static int decode_blockcode(int code, int levels, int *values) |
| 1048 | 1048 |
|
| 1049 | 1049 |
for (i = 0; i < 4; i++) {
|
| 1050 | 1050 |
int div = FASTDIV(code, levels); |
| 1051 |
- values[i] = code - offset - div*levels; |
|
| 1051 |
+ values[i] = code - offset - div * levels; |
|
| 1052 | 1052 |
code = div; |
| 1053 | 1053 |
} |
| 1054 | 1054 |
|
| ... | ... |
@@ -1062,8 +1093,8 @@ static int decode_blockcodes(int code1, int code2, int levels, int *values) |
| 1062 | 1062 |
} |
| 1063 | 1063 |
#endif |
| 1064 | 1064 |
|
| 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 };
|
|
| 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 };
|
|
| 1067 | 1067 |
|
| 1068 | 1068 |
#ifndef int8x8_fmul_int32 |
| 1069 | 1069 |
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) |
| 1075 | 1075 |
} |
| 1076 | 1076 |
#endif |
| 1077 | 1077 |
|
| 1078 |
-static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) |
|
| 1078 |
+static int dca_subsubframe(DCAContext *s, int base_channel, int block_index) |
|
| 1079 | 1079 |
{
|
| 1080 | 1080 |
int k, l; |
| 1081 | 1081 |
int subsubframe = s->current_subsubframe; |
| ... | ... |
@@ -1118,20 +1149,21 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) |
| 1118 | 1118 |
/* |
| 1119 | 1119 |
* Extract bits from the bit stream |
| 1120 | 1120 |
*/ |
| 1121 |
- if (!abits){
|
|
| 1121 |
+ if (!abits) {
|
|
| 1122 | 1122 |
memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0])); |
| 1123 | 1123 |
} else {
|
| 1124 | 1124 |
/* Deal with transients */ |
| 1125 | 1125 |
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]; |
|
| 1126 |
+ float rscale = quant_step_size * s->scale_factor[k][l][sfi] * |
|
| 1127 |
+ s->scalefactor_adj[k][sel]; |
|
| 1127 | 1128 |
|
| 1128 |
- if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){
|
|
| 1129 |
- if (abits <= 7){
|
|
| 1129 |
+ if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
|
|
| 1130 |
+ if (abits <= 7) {
|
|
| 1130 | 1131 |
/* Block code */ |
| 1131 | 1132 |
int block_code1, block_code2, size, levels, err; |
| 1132 | 1133 |
|
| 1133 |
- size = abits_sizes[abits-1]; |
|
| 1134 |
- levels = abits_levels[abits-1]; |
|
| 1134 |
+ size = abits_sizes[abits - 1]; |
|
| 1135 |
+ levels = abits_levels[abits - 1]; |
|
| 1135 | 1136 |
|
| 1136 | 1137 |
block_code1 = get_bits(&s->gb, size); |
| 1137 | 1138 |
block_code2 = get_bits(&s->gb, size); |
| ... | ... |
@@ -1142,19 +1174,20 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) |
| 1142 | 1142 |
"ERROR: block code look-up failed\n"); |
| 1143 | 1143 |
return AVERROR_INVALIDDATA; |
| 1144 | 1144 |
} |
| 1145 |
- }else{
|
|
| 1145 |
+ } else {
|
|
| 1146 | 1146 |
/* no coding */ |
| 1147 | 1147 |
for (m = 0; m < 8; m++) |
| 1148 | 1148 |
block[m] = get_sbits(&s->gb, abits - 3); |
| 1149 | 1149 |
} |
| 1150 |
- }else{
|
|
| 1150 |
+ } else {
|
|
| 1151 | 1151 |
/* Huffman coded */ |
| 1152 | 1152 |
for (m = 0; m < 8; m++) |
| 1153 |
- block[m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel); |
|
| 1153 |
+ block[m] = get_bitalloc(&s->gb, |
|
| 1154 |
+ &dca_smpl_bitalloc[abits], sel); |
|
| 1154 | 1155 |
} |
| 1155 | 1156 |
|
| 1156 | 1157 |
s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l], |
| 1157 |
- block, rscale, 8); |
|
| 1158 |
+ block, rscale, 8); |
|
| 1158 | 1159 |
} |
| 1159 | 1160 |
|
| 1160 | 1161 |
/* |
| ... | ... |
@@ -1171,8 +1204,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) |
| 1171 | 1171 |
else if (s->predictor_history) |
| 1172 | 1172 |
subband_samples[k][l][m] += |
| 1173 | 1173 |
(adpcm_vb[s->prediction_vq[k][l]][n - 1] * |
| 1174 |
- s->subband_samples_hist[k][l][m - n + |
|
| 1175 |
- 4] / 8192); |
|
| 1174 |
+ s->subband_samples_hist[k][l][m - n + 4] / 8192); |
|
| 1176 | 1175 |
} |
| 1177 | 1176 |
} |
| 1178 | 1177 |
} |
| ... | ... |
@@ -1186,7 +1218,8 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) |
| 1186 | 1186 |
int hfvq = s->high_freq_vq[k][l]; |
| 1187 | 1187 |
|
| 1188 | 1188 |
if (!s->debug_flag & 0x01) {
|
| 1189 |
- av_log(s->avctx, AV_LOG_DEBUG, "Stream with high frequencies VQ coding\n"); |
|
| 1189 |
+ av_log(s->avctx, AV_LOG_DEBUG, |
|
| 1190 |
+ "Stream with high frequencies VQ coding\n"); |
|
| 1190 | 1191 |
s->debug_flag |= 0x01; |
| 1191 | 1192 |
} |
| 1192 | 1193 |
|
| ... | ... |
@@ -1210,23 +1243,25 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) |
| 1210 | 1210 |
/* Backup predictor history for adpcm */ |
| 1211 | 1211 |
for (k = base_channel; k < s->prim_channels; k++) |
| 1212 | 1212 |
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])); |
|
| 1213 |
+ memcpy(s->subband_samples_hist[k][l], |
|
| 1214 |
+ &subband_samples[k][l][4], |
|
| 1215 |
+ 4 * sizeof(subband_samples[0][0][0])); |
|
| 1215 | 1216 |
|
| 1216 | 1217 |
return 0; |
| 1217 | 1218 |
} |
| 1218 | 1219 |
|
| 1219 |
-static int dca_filter_channels(DCAContext * s, int block_index) |
|
| 1220 |
+static int dca_filter_channels(DCAContext *s, int block_index) |
|
| 1220 | 1221 |
{
|
| 1221 | 1222 |
float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index]; |
| 1222 | 1223 |
int k; |
| 1223 | 1224 |
|
| 1224 | 1225 |
/* 32 subbands QMF */ |
| 1225 | 1226 |
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] */ ); |
|
| 1227 |
+/* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0,
|
|
| 1228 |
+ 0, 8388608.0, 8388608.0 };*/ |
|
| 1229 |
+ qmf_32_subbands(s, k, subband_samples[k], |
|
| 1230 |
+ &s->samples[256 * s->channel_order_tab[k]], |
|
| 1231 |
+ M_SQRT1_2 * s->scale_bias /* pcm_to_double[s->source_pcm_res] */); |
|
| 1230 | 1232 |
} |
| 1231 | 1233 |
|
| 1232 | 1234 |
/* Down mixing */ |
| ... | ... |
@@ -1239,7 +1274,7 @@ static int dca_filter_channels(DCAContext * s, int block_index) |
| 1239 | 1239 |
lfe_interpolation_fir(s, s->lfe, 2 * s->lfe, |
| 1240 | 1240 |
s->lfe_data + 2 * s->lfe * (block_index + 4), |
| 1241 | 1241 |
&s->samples[256 * dca_lfe_index[s->amode]], |
| 1242 |
- (1.0/256.0)*s->scale_bias); |
|
| 1242 |
+ (1.0 / 256.0) * s->scale_bias); |
|
| 1243 | 1243 |
/* Outputs 20bits pcm samples */ |
| 1244 | 1244 |
} |
| 1245 | 1245 |
|
| ... | ... |
@@ -1247,7 +1282,7 @@ static int dca_filter_channels(DCAContext * s, int block_index) |
| 1247 | 1247 |
} |
| 1248 | 1248 |
|
| 1249 | 1249 |
|
| 1250 |
-static int dca_subframe_footer(DCAContext * s, int base_channel) |
|
| 1250 |
+static int dca_subframe_footer(DCAContext *s, int base_channel) |
|
| 1251 | 1251 |
{
|
| 1252 | 1252 |
int aux_data_count = 0, i; |
| 1253 | 1253 |
|
| ... | ... |
@@ -1279,7 +1314,7 @@ static int dca_subframe_footer(DCAContext * s, int base_channel) |
| 1279 | 1279 |
* @param s pointer to the DCAContext |
| 1280 | 1280 |
*/ |
| 1281 | 1281 |
|
| 1282 |
-static int dca_decode_block(DCAContext * s, int base_channel, int block_index) |
|
| 1282 |
+static int dca_decode_block(DCAContext *s, int base_channel, int block_index) |
|
| 1283 | 1283 |
{
|
| 1284 | 1284 |
int ret; |
| 1285 | 1285 |
|
| ... | ... |
@@ -1327,8 +1362,8 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index) |
| 1327 | 1327 |
/** |
| 1328 | 1328 |
* Convert bitstream to one representation based on sync marker |
| 1329 | 1329 |
*/ |
| 1330 |
-static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * dst, |
|
| 1331 |
- int max_size) |
|
| 1330 |
+static int dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, |
|
| 1331 |
+ int max_size) |
|
| 1332 | 1332 |
{
|
| 1333 | 1333 |
uint32_t mrk; |
| 1334 | 1334 |
int i, tmp; |
| ... | ... |
@@ -1336,7 +1371,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds |
| 1336 | 1336 |
uint16_t *sdst = (uint16_t *) dst; |
| 1337 | 1337 |
PutBitContext pb; |
| 1338 | 1338 |
|
| 1339 |
- if ((unsigned)src_size > (unsigned)max_size) {
|
|
| 1339 |
+ if ((unsigned) src_size > (unsigned) max_size) {
|
|
| 1340 | 1340 |
// av_log(NULL, AV_LOG_ERROR, "Input frame size larger than DCA_MAX_FRAME_SIZE!\n"); |
| 1341 | 1341 |
// return -1; |
| 1342 | 1342 |
src_size = max_size; |
| ... | ... |
@@ -1371,18 +1406,16 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds |
| 1371 | 1371 |
static int dca_exss_mask2count(int mask) |
| 1372 | 1372 |
{
|
| 1373 | 1373 |
/* 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 |
- )); |
|
| 1374 |
+ return av_popcount(mask) + |
|
| 1375 |
+ av_popcount(mask & (DCA_EXSS_CENTER_LEFT_RIGHT | |
|
| 1376 |
+ DCA_EXSS_FRONT_LEFT_RIGHT | |
|
| 1377 |
+ DCA_EXSS_FRONT_HIGH_LEFT_RIGHT | |
|
| 1378 |
+ DCA_EXSS_WIDE_LEFT_RIGHT | |
|
| 1379 |
+ DCA_EXSS_SIDE_LEFT_RIGHT | |
|
| 1380 |
+ DCA_EXSS_SIDE_HIGH_LEFT_RIGHT | |
|
| 1381 |
+ DCA_EXSS_SIDE_REAR_LEFT_RIGHT | |
|
| 1382 |
+ DCA_EXSS_REAR_LEFT_RIGHT | |
|
| 1383 |
+ DCA_EXSS_REAR_HIGH_LEFT_RIGHT)); |
|
| 1386 | 1384 |
} |
| 1387 | 1385 |
|
| 1388 | 1386 |
/** |
| ... | ... |
@@ -1408,7 +1441,7 @@ static int dca_exss_parse_asset_header(DCAContext *s) |
| 1408 | 1408 |
int header_size; |
| 1409 | 1409 |
int channels; |
| 1410 | 1410 |
int embedded_stereo = 0; |
| 1411 |
- int embedded_6ch = 0; |
|
| 1411 |
+ int embedded_6ch = 0; |
|
| 1412 | 1412 |
int drc_code_present; |
| 1413 | 1413 |
int extensions_mask; |
| 1414 | 1414 |
int i, j; |
| ... | ... |
@@ -1543,7 +1576,8 @@ static int dca_exss_parse_asset_header(DCAContext *s) |
| 1543 | 1543 |
if (!(extensions_mask & DCA_EXT_CORE)) |
| 1544 | 1544 |
av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n"); |
| 1545 | 1545 |
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", |
|
| 1546 |
+ av_log(s->avctx, AV_LOG_WARNING, |
|
| 1547 |
+ "DTS extensions detection mismatch (%d, %d)\n", |
|
| 1547 | 1548 |
extensions_mask & DCA_CORE_EXTS, s->core_ext_mask); |
| 1548 | 1549 |
|
| 1549 | 1550 |
return 0; |
| ... | ... |
@@ -1568,7 +1602,7 @@ static void dca_exss_parse_header(DCAContext *s) |
| 1568 | 1568 |
ss_index = get_bits(&s->gb, 2); |
| 1569 | 1569 |
|
| 1570 | 1570 |
blownup = get_bits1(&s->gb); |
| 1571 |
- skip_bits(&s->gb, 8 + 4 * blownup); // header_size |
|
| 1571 |
+ skip_bits(&s->gb, 8 + 4 * blownup); // header_size |
|
| 1572 | 1572 |
skip_bits(&s->gb, 16 + 4 * blownup); // hd_size |
| 1573 | 1573 |
|
| 1574 | 1574 |
s->static_fields = get_bits1(&s->gb); |
| ... | ... |
@@ -1609,18 +1643,18 @@ static void dca_exss_parse_header(DCAContext *s) |
| 1609 | 1609 |
int mix_out_mask_size; |
| 1610 | 1610 |
|
| 1611 | 1611 |
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; |
|
| 1612 |
+ mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2; |
|
| 1613 |
+ s->num_mix_configs = get_bits(&s->gb, 2) + 1; |
|
| 1614 | 1614 |
|
| 1615 | 1615 |
for (i = 0; i < s->num_mix_configs; i++) {
|
| 1616 |
- int mix_out_mask = get_bits(&s->gb, mix_out_mask_size); |
|
| 1616 |
+ int mix_out_mask = get_bits(&s->gb, mix_out_mask_size); |
|
| 1617 | 1617 |
s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask); |
| 1618 | 1618 |
} |
| 1619 | 1619 |
} |
| 1620 | 1620 |
} |
| 1621 | 1621 |
|
| 1622 | 1622 |
for (i = 0; i < num_assets; i++) |
| 1623 |
- skip_bits_long(&s->gb, 16 + 4 * blownup); // asset size |
|
| 1623 |
+ skip_bits_long(&s->gb, 16 + 4 * blownup); // asset size |
|
| 1624 | 1624 |
|
| 1625 | 1625 |
for (i = 0; i < num_assets; i++) {
|
| 1626 | 1626 |
if (dca_exss_parse_asset_header(s)) |
| ... | ... |
@@ -1667,8 +1701,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
| 1667 | 1667 |
} |
| 1668 | 1668 |
//set AVCodec values with parsed data |
| 1669 | 1669 |
avctx->sample_rate = s->sample_rate; |
| 1670 |
- avctx->bit_rate = s->bit_rate; |
|
| 1671 |
- avctx->frame_size = s->sample_blocks * 32; |
|
| 1670 |
+ avctx->bit_rate = s->bit_rate; |
|
| 1671 |
+ avctx->frame_size = s->sample_blocks * 32; |
|
| 1672 | 1672 |
|
| 1673 | 1673 |
s->profile = FF_PROFILE_DTS; |
| 1674 | 1674 |
|
| ... | ... |
@@ -1700,72 +1734,71 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
| 1700 | 1700 |
/* extensions start at 32-bit boundaries into bitstream */ |
| 1701 | 1701 |
skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); |
| 1702 | 1702 |
|
| 1703 |
- while(core_ss_end - get_bits_count(&s->gb) >= 32) {
|
|
| 1704 |
- uint32_t bits = get_bits_long(&s->gb, 32); |
|
| 1703 |
+ while (core_ss_end - get_bits_count(&s->gb) >= 32) {
|
|
| 1704 |
+ uint32_t bits = get_bits_long(&s->gb, 32); |
|
| 1705 | 1705 |
|
| 1706 |
- switch(bits) {
|
|
| 1707 |
- case 0x5a5a5a5a: {
|
|
| 1708 |
- int ext_amode, xch_fsize; |
|
| 1706 |
+ switch (bits) {
|
|
| 1707 |
+ case 0x5a5a5a5a: {
|
|
| 1708 |
+ int ext_amode, xch_fsize; |
|
| 1709 | 1709 |
|
| 1710 |
- s->xch_base_channel = s->prim_channels; |
|
| 1710 |
+ s->xch_base_channel = s->prim_channels; |
|
| 1711 | 1711 |
|
| 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; |
|
| 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; |
|
| 1722 | 1717 |
|
| 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 |
- } |
|
| 1718 |
+ /* skip length-to-end-of-frame field for the moment */ |
|
| 1719 |
+ skip_bits(&s->gb, 10); |
|
| 1730 | 1720 |
|
| 1731 |
- /* much like core primary audio coding header */ |
|
| 1732 |
- dca_parse_audio_coding_header(s, s->xch_base_channel); |
|
| 1721 |
+ s->core_ext_mask |= DCA_EXT_XCH; |
|
| 1733 | 1722 |
|
| 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"); |
|
| 1723 |
+ /* extension amode(number of channels in extension) should be 1 */ |
|
| 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); |
|
| 1737 | 1728 |
continue; |
| 1738 | 1729 |
} |
| 1730 |
+ |
|
| 1731 |
+ /* much like core primary audio coding header */ |
|
| 1732 |
+ dca_parse_audio_coding_header(s, s->xch_base_channel); |
|
| 1733 |
+ |
|
| 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"); |
|
| 1737 |
+ continue; |
|
| 1738 |
+ } |
|
| 1739 |
+ |
|
| 1740 |
+ s->xch_present = 1; |
|
| 1741 |
+ break; |
|
| 1739 | 1742 |
} |
| 1743 |
+ case 0x47004a03: |
|
| 1744 |
+ /* XXCh: extended channels */ |
|
| 1745 |
+ /* usually found either in core or HD part in DTS-HD HRA streams, |
|
| 1746 |
+ * but not in DTS-ES which contains XCh extensions instead */ |
|
| 1747 |
+ s->core_ext_mask |= DCA_EXT_XXCH; |
|
| 1748 |
+ break; |
|
| 1749 |
+ |
|
| 1750 |
+ case 0x1d95f262: {
|
|
| 1751 |
+ int fsize96 = show_bits(&s->gb, 12) + 1; |
|
| 1752 |
+ if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96) |
|
| 1753 |
+ continue; |
|
| 1740 | 1754 |
|
| 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 |
- } |
|
| 1755 |
+ av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n", |
|
| 1756 |
+ 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)); |
|
| 1765 | 1760 |
|
| 1766 |
- skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); |
|
| 1767 |
- } |
|
| 1761 |
+ s->core_ext_mask |= DCA_EXT_X96; |
|
| 1762 |
+ break; |
|
| 1763 |
+ } |
|
| 1764 |
+ } |
|
| 1768 | 1765 |
|
| 1766 |
+ skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); |
|
| 1767 |
+ } |
|
| 1769 | 1768 |
} else {
|
| 1770 | 1769 |
/* no supported extensions, skip the rest of the core substream */ |
| 1771 | 1770 |
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, |
| 1777 | 1777 |
s->profile = FF_PROFILE_DTS_ES; |
| 1778 | 1778 |
|
| 1779 | 1779 |
/* 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) |
|
| 1780 |
+ if (s->dca_buffer_size - s->frame_size > 32 && |
|
| 1781 |
+ get_bits_long(&s->gb, 32) == DCA_HD_MARKER) |
|
| 1782 | 1782 |
dca_exss_parse_header(s); |
| 1783 | 1783 |
|
| 1784 | 1784 |
avctx->profile = s->profile; |
| 1785 | 1785 |
|
| 1786 | 1786 |
channels = s->prim_channels + !!s->lfe; |
| 1787 | 1787 |
|
| 1788 |
- if (s->amode<16) {
|
|
| 1788 |
+ if (s->amode < 16) {
|
|
| 1789 | 1789 |
avctx->channel_layout = dca_core_channel_layout[s->amode]; |
| 1790 | 1790 |
|
| 1791 | 1791 |
if (s->xch_present && (!avctx->request_channels || |
| ... | ... |
@@ -1821,7 +1854,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
| 1821 | 1821 |
s->channel_order_tab = dca_channel_order_native; |
| 1822 | 1822 |
} |
| 1823 | 1823 |
} else {
|
| 1824 |
- av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode); |
|
| 1824 |
+ av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n", s->amode); |
|
| 1825 | 1825 |
return AVERROR_INVALIDDATA; |
| 1826 | 1826 |
} |
| 1827 | 1827 |
|
| ... | ... |
@@ -1837,8 +1870,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
| 1837 | 1837 |
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
| 1838 | 1838 |
return ret; |
| 1839 | 1839 |
} |
| 1840 |
- samples_flt = (float *)s->frame.data[0]; |
|
| 1841 |
- samples_s16 = (int16_t *)s->frame.data[0]; |
|
| 1840 |
+ samples_flt = (float *) s->frame.data[0]; |
|
| 1841 |
+ samples_s16 = (int16_t *) s->frame.data[0]; |
|
| 1842 | 1842 |
|
| 1843 | 1843 |
/* filter to get final output */ |
| 1844 | 1844 |
for (i = 0; i < (s->sample_blocks / 8); i++) {
|
| ... | ... |
@@ -1846,10 +1879,10 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
| 1846 | 1846 |
|
| 1847 | 1847 |
/* If this was marked as a DTS-ES stream we need to subtract back- */ |
| 1848 | 1848 |
/* 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; |
|
| 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; |
|
| 1853 | 1853 |
s->dsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256); |
| 1854 | 1854 |
s->dsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256); |
| 1855 | 1855 |
} |
| ... | ... |
@@ -1868,12 +1901,11 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
| 1868 | 1868 |
|
| 1869 | 1869 |
/* update lfe history */ |
| 1870 | 1870 |
lfe_samples = 2 * s->lfe * (s->sample_blocks / 8); |
| 1871 |
- for (i = 0; i < 2 * s->lfe * 4; i++) {
|
|
| 1871 |
+ for (i = 0; i < 2 * s->lfe * 4; i++) |
|
| 1872 | 1872 |
s->lfe_data[i] = s->lfe_data[i + lfe_samples]; |
| 1873 |
- } |
|
| 1874 | 1873 |
|
| 1875 |
- *got_frame_ptr = 1; |
|
| 1876 |
- *(AVFrame *)data = s->frame; |
|
| 1874 |
+ *got_frame_ptr = 1; |
|
| 1875 |
+ *(AVFrame *) data = s->frame; |
|
| 1877 | 1876 |
|
| 1878 | 1877 |
return buf_size; |
| 1879 | 1878 |
} |
| ... | ... |
@@ -1886,7 +1918,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
| 1886 | 1886 |
* @param avctx pointer to the AVCodecContext |
| 1887 | 1887 |
*/ |
| 1888 | 1888 |
|
| 1889 |
-static av_cold int dca_decode_init(AVCodecContext * avctx) |
|
| 1889 |
+static av_cold int dca_decode_init(AVCodecContext *avctx) |
|
| 1890 | 1890 |
{
|
| 1891 | 1891 |
DCAContext *s = avctx->priv_data; |
| 1892 | 1892 |
int i; |
| ... | ... |
@@ -1900,15 +1932,15 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) |
| 1900 | 1900 |
ff_dcadsp_init(&s->dcadsp); |
| 1901 | 1901 |
ff_fmt_convert_init(&s->fmt_conv, avctx); |
| 1902 | 1902 |
|
| 1903 |
- for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++) |
|
| 1903 |
+ for (i = 0; i < DCA_PRIM_CHANNELS_MAX + 1; i++) |
|
| 1904 | 1904 |
s->samples_chanptr[i] = s->samples + i * 256; |
| 1905 | 1905 |
|
| 1906 | 1906 |
if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) {
|
| 1907 | 1907 |
avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
| 1908 |
- s->scale_bias = 1.0 / 32768.0; |
|
| 1908 |
+ s->scale_bias = 1.0 / 32768.0; |
|
| 1909 | 1909 |
} else {
|
| 1910 | 1910 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 1911 |
- s->scale_bias = 1.0; |
|
| 1911 |
+ s->scale_bias = 1.0; |
|
| 1912 | 1912 |
} |
| 1913 | 1913 |
|
| 1914 | 1914 |
/* allow downmixing to stereo */ |
| ... | ... |
@@ -1923,7 +1955,7 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) |
| 1923 | 1923 |
return 0; |
| 1924 | 1924 |
} |
| 1925 | 1925 |
|
| 1926 |
-static av_cold int dca_decode_end(AVCodecContext * avctx) |
|
| 1926 |
+static av_cold int dca_decode_end(AVCodecContext *avctx) |
|
| 1927 | 1927 |
{
|
| 1928 | 1928 |
DCAContext *s = avctx->priv_data; |
| 1929 | 1929 |
ff_mdct_end(&s->imdct); |
| ... | ... |
@@ -1940,17 +1972,17 @@ static const AVProfile profiles[] = {
|
| 1940 | 1940 |
}; |
| 1941 | 1941 |
|
| 1942 | 1942 |
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), |
|
| 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[]) { AV_SAMPLE_FMT_FLT,
|
|
| 1953 |
+ AV_SAMPLE_FMT_S16, |
|
| 1954 |
+ AV_SAMPLE_FMT_NONE }, |
|
| 1955 |
+ .profiles = NULL_IF_CONFIG_SMALL(profiles), |
|
| 1956 | 1956 |
}; |
| ... | ... |
@@ -28,15 +28,16 @@ |
| 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) |
| 44 | 44 |
int i; |
| 45 | 45 |
|
| 46 | 46 |
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; |
|
| 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; |
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 |
- data[n/2] *= 2; |
|
| 58 |
+ data[n / 2] *= 2; |
|
| 59 | 59 |
ctx->rdft.rdft_calc(&ctx->rdft, data); |
| 60 | 60 |
|
| 61 | 61 |
data[0] *= 0.5f; |
| 62 | 62 |
|
| 63 |
- for(i = 1; i < n-2; i += 2) {
|
|
| 64 |
- data[i + 1] += data[i - 1]; |
|
| 65 |
- data[i ] = -data[i + 2]; |
|
| 63 |
+ for (i = 1; i < n - 2; i += 2) {
|
|
| 64 |
+ data[i + 1] += data[i - 1]; |
|
| 65 |
+ data[i] = -data[i + 2]; |
|
| 66 | 66 |
} |
| 67 | 67 |
|
| 68 |
- data[n-1] = 0; |
|
| 68 |
+ data[n - 1] = 0; |
|
| 69 | 69 |
} |
| 70 | 70 |
|
| 71 | 71 |
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) |
| 74 | 74 |
int i; |
| 75 | 75 |
float next = -0.5f * (data[0] - data[n]); |
| 76 | 76 |
|
| 77 |
- for(i = 0; i < n/2; i++) {
|
|
| 78 |
- float tmp1 = data[i ]; |
|
| 77 |
+ for (i = 0; i < n / 2; i++) {
|
|
| 78 |
+ float tmp1 = data[i]; |
|
| 79 | 79 |
float tmp2 = data[n - i]; |
| 80 |
- float s = SIN(ctx, n, 2*i); |
|
| 81 |
- float c = COS(ctx, n, 2*i); |
|
| 80 |
+ float s = SIN(ctx, n, 2 * i); |
|
| 81 |
+ float c = COS(ctx, n, 2 * i); |
|
| 82 | 82 |
|
| 83 | 83 |
c *= tmp1 - tmp2; |
| 84 | 84 |
s *= tmp1 - tmp2; |
| 85 | 85 |
|
| 86 | 86 |
next += c; |
| 87 | 87 |
|
| 88 |
- tmp1 = (tmp1 + tmp2) * 0.5f; |
|
| 89 |
- data[i ] = tmp1 - s; |
|
| 88 |
+ tmp1 = (tmp1 + tmp2) * 0.5f; |
|
| 89 |
+ data[i] = tmp1 - s; |
|
| 90 | 90 |
data[n - i] = tmp1 + s; |
| 91 | 91 |
} |
| 92 | 92 |
|
| ... | ... |
@@ -94,7 +95,7 @@ static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) |
| 94 | 94 |
data[n] = data[1]; |
| 95 | 95 |
data[1] = next; |
| 96 | 96 |
|
| 97 |
- for(i = 3; i <= n; i += 2) |
|
| 97 |
+ for (i = 3; i <= n; i += 2) |
|
| 98 | 98 |
data[i] = data[i - 2] - data[i]; |
| 99 | 99 |
} |
| 100 | 100 |
|
| ... | ... |
@@ -103,16 +104,16 @@ static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) |
| 103 | 103 |
int n = 1 << ctx->nbits; |
| 104 | 104 |
int i; |
| 105 | 105 |
|
| 106 |
- float next = data[n - 1]; |
|
| 106 |
+ float next = data[n - 1]; |
|
| 107 | 107 |
float inv_n = 1.0f / n; |
| 108 | 108 |
|
| 109 | 109 |
for (i = n - 2; i >= 2; i -= 2) {
|
| 110 |
- float val1 = data[i ]; |
|
| 110 |
+ float val1 = data[i]; |
|
| 111 | 111 |
float val2 = data[i - 1] - data[i + 1]; |
| 112 |
- float c = COS(ctx, n, i); |
|
| 113 |
- float s = SIN(ctx, n, i); |
|
| 112 |
+ float c = COS(ctx, n, i); |
|
| 113 |
+ float s = SIN(ctx, n, i); |
|
| 114 | 114 |
|
| 115 |
- data[i ] = c * val1 + s * val2; |
|
| 115 |
+ data[i] = c * val1 + s * val2; |
|
| 116 | 116 |
data[i + 1] = s * val1 - c * val2; |
| 117 | 117 |
} |
| 118 | 118 |
|
| ... | ... |
@@ -121,13 +122,13 @@ static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) |
| 121 | 121 |
ctx->rdft.rdft_calc(&ctx->rdft, data); |
| 122 | 122 |
|
| 123 | 123 |
for (i = 0; i < n / 2; i++) {
|
| 124 |
- float tmp1 = data[i ] * inv_n; |
|
| 124 |
+ float tmp1 = data[i] * inv_n; |
|
| 125 | 125 |
float tmp2 = data[n - i - 1] * inv_n; |
| 126 |
- float csc = ctx->csc2[i] * (tmp1 - tmp2); |
|
| 126 |
+ float csc = ctx->csc2[i] * (tmp1 - tmp2); |
|
| 127 | 127 |
|
| 128 |
- tmp1 += tmp2; |
|
| 129 |
- data[i ] = tmp1 + csc; |
|
| 130 |
- data[n - i - 1] = tmp1 - csc; |
|
| 128 |
+ tmp1 += tmp2; |
|
| 129 |
+ data[i] = tmp1 + csc; |
|
| 130 |
+ data[n - i - 1] = tmp1 - csc; |
|
| 131 | 131 |
} |
| 132 | 132 |
} |
| 133 | 133 |
|
| ... | ... |
@@ -137,34 +138,33 @@ static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data) |
| 137 | 137 |
int i; |
| 138 | 138 |
float next; |
| 139 | 139 |
|
| 140 |
- for (i=0; i < n/2; i++) {
|
|
| 141 |
- float tmp1 = data[i ]; |
|
| 140 |
+ for (i = 0; i < n / 2; i++) {
|
|
| 141 |
+ float tmp1 = data[i]; |
|
| 142 | 142 |
float tmp2 = data[n - i - 1]; |
| 143 |
- float s = SIN(ctx, n, 2*i + 1); |
|
| 143 |
+ float s = SIN(ctx, n, 2 * i + 1); |
|
| 144 | 144 |
|
| 145 |
- s *= tmp1 - tmp2; |
|
| 146 |
- tmp1 = (tmp1 + tmp2) * 0.5f; |
|
| 145 |
+ s *= tmp1 - tmp2; |
|
| 146 |
+ tmp1 = (tmp1 + tmp2) * 0.5f; |
|
| 147 | 147 |
|
| 148 |
- data[i ] = tmp1 + s; |
|
| 148 |
+ data[i] = tmp1 + s; |
|
| 149 | 149 |
data[n-i-1] = tmp1 - s; |
| 150 | 150 |
} |
| 151 | 151 |
|
| 152 | 152 |
ctx->rdft.rdft_calc(&ctx->rdft, data); |
| 153 | 153 |
|
| 154 |
- next = data[1] * 0.5; |
|
| 154 |
+ next = data[1] * 0.5; |
|
| 155 | 155 |
data[1] *= -1; |
| 156 | 156 |
|
| 157 | 157 |
for (i = n - 2; i >= 0; i -= 2) {
|
| 158 | 158 |
float inr = data[i ]; |
| 159 | 159 |
float ini = data[i + 1]; |
| 160 |
- float c = COS(ctx, n, i); |
|
| 161 |
- float s = SIN(ctx, n, i); |
|
| 160 |
+ float c = COS(ctx, n, i); |
|
| 161 |
+ float s = SIN(ctx, n, i); |
|
| 162 | 162 |
|
| 163 |
- data[i ] = c * inr + s * ini; |
|
| 163 |
+ data[i] = c * inr + s * ini; |
|
| 164 |
+ data[i + 1] = next; |
|
| 164 | 165 |
|
| 165 |
- data[i+1] = next; |
|
| 166 |
- |
|
| 167 |
- next += s * inr - c * ini; |
|
| 166 |
+ next += s * inr - c * ini; |
|
| 168 | 167 |
} |
| 169 | 168 |
} |
| 170 | 169 |
|
| ... | ... |
@@ -180,36 +180,36 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) |
| 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 @@ |
| 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) |
| 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 |
| 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, |
| 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 |
| 381 | 381 |
c->frame_pred == PRED_LEFT); |
| 382 | 382 |
if (ret) |
| 383 | 383 |
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); |
|
| 384 |
+ if (c->frame_pred == PRED_MEDIAN) {
|
|
| 385 |
+ if (!c->interlaced) {
|
|
| 386 |
+ restore_median(c->pic.data[i], 1, c->pic.linesize[i], |
|
| 387 |
+ avctx->width >> !!i, avctx->height >> !!i, |
|
| 388 |
+ c->slices, !i); |
|
| 389 |
+ } else {
|
|
| 390 |
+ restore_median_il(c->pic.data[i], 1, c->pic.linesize[i], |
|
| 391 |
+ avctx->width >> !!i, |
|
| 392 |
+ avctx->height >> !!i, |
|
| 393 |
+ c->slices, !i); |
|
| 394 |
+ } |
|
| 395 |
+ } |
|
| 388 | 396 |
} |
| 389 | 397 |
break; |
| 390 | 398 |
case PIX_FMT_YUV422P: |
| ... | ... |
@@ -395,9 +474,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 395 | 395 |
c->frame_pred == PRED_LEFT); |
| 396 | 396 |
if (ret) |
| 397 | 397 |
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); |
|
| 398 |
+ if (c->frame_pred == PRED_MEDIAN) {
|
|
| 399 |
+ if (!c->interlaced) {
|
|
| 400 |
+ restore_median(c->pic.data[i], 1, c->pic.linesize[i], |
|
| 401 |
+ avctx->width >> !!i, avctx->height, |
|
| 402 |
+ c->slices, 0); |
|
| 403 |
+ } else {
|
|
| 404 |
+ restore_median_il(c->pic.data[i], 1, c->pic.linesize[i], |
|
| 405 |
+ avctx->width >> !!i, avctx->height, |
|
| 406 |
+ c->slices, 0); |
|
| 407 |
+ } |
|
| 408 |
+ } |
|
| 401 | 409 |
} |
| 402 | 410 |
break; |
| 403 | 411 |
} |
| ... | ... |
@@ -2235,7 +2235,7 @@ static int has_decode_delay_been_guessed(AVStream *st) |
| 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 |
| 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) |
| 2377 | 2377 |
int i, count, ret, read_size, j; |
| 2378 | 2378 |
AVStream *st; |
| 2379 | 2379 |
AVPacket pkt1, *pkt; |
| 2380 |
- AVDictionary *one_thread_opt = NULL; |
|
| 2381 | 2380 |
int64_t old_offset = avio_tell(ic->pb); |
| 2382 | 2381 |
int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those |
| 2383 | 2382 |
|
| 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 | 2383 |
for(i=0;i<ic->nb_streams;i++) {
|
| 2389 | 2384 |
AVCodec *codec; |
| 2390 | 2385 |
st = ic->streams[i]; |
| ... | ... |
@@ -2406,21 +2402,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) |
| 2406 | 2406 |
assert(!st->codec->codec); |
| 2407 | 2407 |
codec = avcodec_find_decoder(st->codec->codec_id); |
| 2408 | 2408 |
|
| 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 | 2409 |
/* Ensure that subtitle_header is properly set. */ |
| 2415 | 2410 |
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE |
| 2416 | 2411 |
&& codec && !st->codec->codec) |
| 2417 |
- avcodec_open2(st->codec, codec, options ? &options[i] : &one_thread_opt); |
|
| 2412 |
+ avcodec_open2(st->codec, codec, options ? &options[i] : NULL); |
|
| 2418 | 2413 |
|
| 2419 | 2414 |
//try to just open decoders, in case this is enough to get parameters |
| 2420 | 2415 |
if(!has_codec_parameters(st->codec)){
|
| 2421 | 2416 |
if (codec && !st->codec->codec) |
| 2422 |
- avcodec_open2(st->codec, codec, options ? &options[i] |
|
| 2423 |
- : &one_thread_opt); |
|
| 2417 |
+ avcodec_open2(st->codec, codec, options ? &options[i] : NULL); |
|
| 2424 | 2418 |
} |
| 2425 | 2419 |
} |
| 2426 | 2420 |
|
| ... | ... |
@@ -2486,10 +2476,22 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) |
| 2486 | 2486 |
continue; |
| 2487 | 2487 |
|
| 2488 | 2488 |
if (ret < 0) {
|
| 2489 |
- /* EOF or error */ |
|
| 2489 |
+ /* EOF or error*/ |
|
| 2490 |
+ AVPacket empty_pkt = { 0 };
|
|
| 2491 |
+ int err; |
|
| 2492 |
+ av_init_packet(&empty_pkt); |
|
| 2493 |
+ |
|
| 2490 | 2494 |
ret = -1; /* we could not have all the codec parameters before EOF */ |
| 2491 | 2495 |
for(i=0;i<ic->nb_streams;i++) {
|
| 2492 | 2496 |
st = ic->streams[i]; |
| 2497 |
+ |
|
| 2498 |
+ /* flush the decoders */ |
|
| 2499 |
+ while ((err = try_decode_frame(st, &empty_pkt, |
|
| 2500 |
+ (options && i < orig_nb_streams) ? |
|
| 2501 |
+ &options[i] : NULL)) >= 0) |
|
| 2502 |
+ if (has_codec_parameters(st->codec)) |
|
| 2503 |
+ break; |
|
| 2504 |
+ |
|
| 2493 | 2505 |
if (!has_codec_parameters(st->codec)){
|
| 2494 | 2506 |
char buf[256]; |
| 2495 | 2507 |
avcodec_string(buf, sizeof(buf), st->codec, 0); |
| ... | ... |
@@ -2562,8 +2564,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) |
| 2562 | 2562 |
least one frame of codec data, this makes sure the codec initializes |
| 2563 | 2563 |
the channel configuration and does not only trust the values from the container. |
| 2564 | 2564 |
*/ |
| 2565 |
- try_decode_frame(st, pkt, (options && i < orig_nb_streams )? &options[i] |
|
| 2566 |
- : &one_thread_opt); |
|
| 2565 |
+ try_decode_frame(st, pkt, (options && i < orig_nb_streams ) ? &options[i] : NULL); |
|
| 2567 | 2566 |
|
| 2568 | 2567 |
st->codec_info_nb_frames++; |
| 2569 | 2568 |
count++; |
| ... | ... |
@@ -2689,7 +2690,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) |
| 2689 | 2689 |
ic->streams[i]->codec->thread_count = 0; |
| 2690 | 2690 |
av_freep(&ic->streams[i]->info); |
| 2691 | 2691 |
} |
| 2692 |
- av_dict_free(&one_thread_opt); |
|
| 2693 | 2692 |
return ret; |
| 2694 | 2693 |
} |
| 2695 | 2694 |
|
| ... | ... |
@@ -154,7 +154,7 @@ |
| 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) |
| 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) |
| 385 | 385 |
#ifndef av_popcount |
| 386 | 386 |
# define av_popcount av_popcount_c |
| 387 | 387 |
#endif |
| 388 |
+#ifndef av_popcount64 |
|
| 389 |
+# define av_popcount64 av_popcount64_c |
|
| 390 |
+#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 |
|