History

Merge remote-tracking branch 'qatar/master'

* 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

Michael Niedermayer committed 14 years ago

Commit ad1c8dd2 parents d6da16d fd16f5618 files · +767 −576Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t