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
6161 void init_opts(void)
6262 {
6363 #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);
6566 #endif
6667 }
6768
@@ -75,7 +76,7 @@ void uninit_opts(void) · 7 unmodified lines
7576 av_dict_free(&codec_opts);
7677 }
7778
78−void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
79+void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
7980 {
8081 vfprintf(stdout, fmt, vl);
8182 }
@@ -94,19 +95,20 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v · 12 unmodified lines
9495 fflush(report_file);
9596 }
9697
97−double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
98+double parse_number_or_die(const char *context, const char *numstr, int type,
99+ double min, double max)
98100 {
99101 char *tail;
100102 const char *error;
101103 double d = av_strtod(numstr, &tail);
102104 if (*tail)
103− error= "Expected number for %s but found: %s\n";
105+ error = "Expected number for %s but found: %s\n";
104106 else if (d < min || d > max)
105− error= "The value for %s was %s which is not within %f - %f\n";
106− else if(type == OPT_INT64 && (int64_t)d != d)
107− error= "Expected int64 for %s but found %s\n";
107+ error = "The value for %s was %s which is not within %f - %f\n";
108+ else if (type == OPT_INT64 && (int64_t)d != d)
109+ error = "Expected int64 for %s but found %s\n";
108110 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";
110112 else
111113 return d;
112114 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
114116 return 0;
115117 }
116118
117−int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
119+int64_t parse_time_or_die(const char *context, const char *timestr,
120+ int is_duration)
118121 {
119122 int64_t us;
120123 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
125128 return us;
126129 }
127130
128−void show_help_options(const OptionDef *options, const char *msg, int mask, int value)
131+void show_help_options(const OptionDef *options, const char *msg, int mask,
132+ int value)
129133 {
130134 const OptionDef *po;
131135 int first;
132136
133137 first = 1;
134− for(po = options; po->name != NULL; po++) {
138+ for (po = options; po->name != NULL; po++) {
135139 char buf[64];
136140 if ((po->flags & mask) == value) {
137141 if (first) {
@@ -158,7 +162,8 @@ void show_help_children(const AVClass *class, int flags) · 20 unmodified lines
158162 show_help_children(child, flags);
159163 }
160164
161−static const OptionDef* find_option(const OptionDef *po, const char *name){
165+static const OptionDef *find_option(const OptionDef *po, const char *name)
166+{
162167 const char *p = strchr(name, ':');
163168 int len = p ? p - name : strlen(name);
164169
@@ -205,8 +210,8 @@ static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) · 40 unmodified lines
205210 buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
206211 NULL, 0, NULL, NULL);
207212
208− win32_argv_utf8 = av_mallocz(sizeof(char*) * (win32_argc + 1) + buffsize);
209− argstr_flat = (char*)win32_argv_utf8 + sizeof(char*) * (win32_argc + 1);
213+ win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize);
214+ argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1);
210215 if (win32_argv_utf8 == NULL) {
211216 LocalFree(argv_w);
212217 return;
@@ -231,8 +236,8 @@ static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) · 18 unmodified lines
231236 }
232237 #endif /* WIN32 && !__MINGW32CE__ */
233238
234−
235−int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
239+int parse_option(void *optctx, const char *opt, const char *arg,
240+ const OptionDef *options)
236241 {
237242 const OptionDef *po;
238243 int bool_val = 1;
@@ -261,13 +266,14 @@ unknown_opt: · 22 unmodified lines
261266
262267 /* new-style options contain an offset into optctx, old-style address of
263268 * 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;
265271
266272 if (po->flags & OPT_SPEC) {
267273 SpecifierOpt **so = dst;
268274 char *p = strchr(opt, ':');
269275
270− dstcount = (int*)(so + 1);
276+ dstcount = (int *)(so + 1);
271277 *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1);
272278 (*so)[*dstcount - 1].specifier = av_strdup(p ? p + 1 : "");
273279 dst = &(*so)[*dstcount - 1].u;
@@ -276,24 +282,25 @@ unknown_opt: · 2 unmodified lines
276282 if (po->flags & OPT_STRING) {
277283 char *str;
278284 str = av_strdup(arg);
279− *(char**)dst = str;
285+ *(char **)dst = str;
280286 } else if (po->flags & OPT_BOOL) {
281− *(int*)dst = bool_val;
287+ *(int *)dst = bool_val;
282288 } 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);
284290 } 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);
286292 } 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);
288294 } 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);
290296 } 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);
292298 } else if (po->u.func_arg) {
293− int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) :
294− po->u.func_arg(opt, arg);
299+ int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg)
300+ : po->u.func_arg(opt, arg);
295301 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);
297304 return ret;
298305 }
299306 }
@@ -303,7 +310,7 @@ unknown_opt: · 3 unmodified lines
303310 }
304311
305312 void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
306− void (* parse_arg_function)(void *, const char*))
313+ void (*parse_arg_function)(void *, const char*))
307314 {
308315 const char *opt;
309316 int optindex, handleoptions = 1, ret;
@@ -336,7 +343,8 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options · 26 unmodified lines
336343 /*
337344 * Return index of option opt in argv or 0 if not found.
338345 */
339−static int locate_option(int argc, char **argv, const OptionDef *options, const char *optname)
346+static int locate_option(int argc, char **argv, const OptionDef *options,
347+ const char *optname)
340348 {
341349 const OptionDef *po;
342350 int i;
@@ -419,15 +427,18 @@ int opt_default(const char *opt, const char *arg) · 76 unmodified lines
419427 p = opt + strlen(opt);
420428 av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
421429
422− if ((oc = av_opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN|AV_OPT_SEARCH_FAKE_OBJ)) ||
423− ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
424− (oc = av_opt_find(&cc, opt+1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ))))
430+ if ((oc = av_opt_find(&cc, opt_stripped, NULL, 0,
431+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||
432+ ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
433+ (oc = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ))))
425434 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)))
427437 av_dict_set(&format_opts, opt, arg, FLAGS(of));
428438 #if CONFIG_SWSCALE
429439 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))) {
431442 // XXX we only support sws_flags, not arbitrary sws options
432443 int ret = av_opt_set(sws_opts, opt, arg, 0);
433444 if (ret < 0) {
@@ -604,7 +615,8 @@ void show_banner(int argc, char **argv, const OptionDef *options) · 170 unmodified lines
604615 if (idx)
605616 return;
606617
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",
608620 program_name, program_birth_year, this_year);
609621 av_log(NULL, AV_LOG_INFO, " built on %s %s with %s %s\n",
610622 __DATE__, __TIME__, CC_TYPE, CC_VERSION);
@@ -692,49 +704,47 @@ int opt_license(const char *opt, const char *arg) · 81 unmodified lines
692704
693705 int opt_formats(const char *opt, const char *arg)
694706 {
695− AVInputFormat *ifmt=NULL;
696− AVOutputFormat *ofmt=NULL;
707+ AVInputFormat *ifmt = NULL;
708+ AVOutputFormat *ofmt = NULL;
697709 const char *last_name;
698710
699− printf(
700− "File formats:\n"
701− " D. = Demuxing supported\n"
702− " .E = Muxing supported\n"
703− " --\n");
704− last_name= "000";
705− for(;;){
706− int decode=0;
707− int encode=0;
708− const char *name=NULL;
709− const char *long_name=NULL;
710−
711− while((ofmt= av_oformat_next(ofmt))) {
712− if((name == NULL || strcmp(ofmt->name, name)<0) &&
713− strcmp(ofmt->name, last_name)>0){
714− name= ofmt->name;
715− long_name= ofmt->long_name;
716− encode=1;
711+ printf("File formats:\n"
712+ " D. = Demuxing supported\n"
713+ " .E = Muxing supported\n"
714+ " --\n");
715+ last_name = "000";
716+ for (;;) {
717+ int decode = 0;
718+ int encode = 0;
719+ const char *name = NULL;
720+ const char *long_name = NULL;
721+
722+ while ((ofmt = av_oformat_next(ofmt))) {
723+ if ((name == NULL || strcmp(ofmt->name, name) < 0) &&
724+ strcmp(ofmt->name, last_name) > 0) {
725+ name = ofmt->name;
726+ long_name = ofmt->long_name;
727+ encode = 1;
717728 }
718729 }
719− while((ifmt= av_iformat_next(ifmt))) {
720− if((name == NULL || strcmp(ifmt->name, name)<0) &&
721− strcmp(ifmt->name, last_name)>0){
722− name= ifmt->name;
723− long_name= ifmt->long_name;
724− encode=0;
730+ while ((ifmt = av_iformat_next(ifmt))) {
731+ if ((name == NULL || strcmp(ifmt->name, name) < 0) &&
732+ strcmp(ifmt->name, last_name) > 0) {
733+ name = ifmt->name;
734+ long_name = ifmt->long_name;
735+ encode = 0;
725736 }
726− if(name && strcmp(ifmt->name, name)==0)
727− decode=1;
737+ if (name && strcmp(ifmt->name, name) == 0)
738+ decode = 1;
728739 }
729− if(name==NULL)
740+ if (name == NULL)
730741 break;
731− last_name= name;
742+ last_name = name;
732743
733− printf(
734− " %s%s %-15s %s\n",
735− decode ? "D":" ",
736− encode ? "E":" ",
737− name,
744+ printf(" %s%s %-15s %s\n",
745+ decode ? "D" : " ",
746+ encode ? "E" : " ",
747+ name,
738748 long_name ? long_name:" ");
739749 }
740750 return 0;
@@ -742,44 +752,45 @@ int opt_formats(const char *opt, const char *arg) · 1 unmodified line
742752
743753 int opt_codecs(const char *opt, const char *arg)
744754 {
745− AVCodec *p=NULL, *p2;
755+ AVCodec *p = NULL, *p2;
746756 const char *last_name;
747− printf(
748− "Codecs:\n"
749− " D..... = Decoding supported\n"
750− " .E.... = Encoding supported\n"
751− " ..V... = Video codec\n"
752− " ..A... = Audio codec\n"
753− " ..S... = Subtitle codec\n"
754− " ...S.. = Supports draw_horiz_band\n"
755− " ....D. = Supports direct rendering method 1\n"
756− " .....T = Supports weird frame truncation\n"
757− " ------\n");
757+ printf("Codecs:\n"
758+ " D..... = Decoding supported\n"
759+ " .E.... = Encoding supported\n"
760+ " ..V... = Video codec\n"
761+ " ..A... = Audio codec\n"
762+ " ..S... = Subtitle codec\n"
763+ " ...S.. = Supports draw_horiz_band\n"
764+ " ....D. = Supports direct rendering method 1\n"
765+ " .....T = Supports weird frame truncation\n"
766+ " ------\n");
758767 last_name= "000";
759− for(;;){
760− int decode=0;
761− int encode=0;
762− int cap=0;
768+ for (;;) {
769+ int decode = 0;
770+ int encode = 0;
771+ int cap = 0;
763772 const char *type_str;
764773
765− p2=NULL;
766− while((p= av_codec_next(p))) {
767− if((p2==NULL || strcmp(p->name, p2->name)<0) &&
768− strcmp(p->name, last_name)>0){
769− p2= p;
770− decode= encode= cap=0;
774+ p2 = NULL;
775+ while ((p = av_codec_next(p))) {
776+ if ((p2 == NULL || strcmp(p->name, p2->name) < 0) &&
777+ strcmp(p->name, last_name) > 0) {
778+ p2 = p;
779+ decode = encode = cap = 0;
771780 }
772− if(p2 && strcmp(p->name, p2->name)==0){
773− if(p->decode) decode=1;
774− if(p->encode) encode=1;
781+ if (p2 && strcmp(p->name, p2->name) == 0) {
782+ if (p->decode)
783+ decode = 1;
784+ if (p->encode)
785+ encode = 1;
775786 cap |= p->capabilities;
776787 }
777788 }
778− if(p2==NULL)
789+ if (p2 == NULL)
779790 break;
780− last_name= p2->name;
791+ last_name = p2->name;
781792
782− switch(p2->type) {
793+ switch (p2->type) {
783794 case AVMEDIA_TYPE_VIDEO:
784795 type_str = "V";
785796 break;
@@ -793,36 +804,36 @@ int opt_codecs(const char *opt, const char *arg) · 7 unmodified lines
793804 type_str = "?";
794805 break;
795806 }
796− printf(
797− " %s%s%s%s%s%s %-15s %s",
798− decode ? "D": (/*p2->decoder ? "d":*/" "),
799− encode ? "E":" ",
800− type_str,
801− cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S":" ",
802− cap & CODEC_CAP_DR1 ? "D":" ",
803− cap & CODEC_CAP_TRUNCATED ? "T":" ",
804− p2->name,
805− p2->long_name ? p2->long_name : "");
806− /* if(p2->decoder && decode==0)
807− printf(" use %s for decoding", p2->decoder->name);*/
807+ printf(" %s%s%s%s%s%s %-15s %s",
808+ decode ? "D" : (/* p2->decoder ? "d" : */ " "),
809+ encode ? "E" : " ",
810+ type_str,
811+ cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S" : " ",
812+ cap & CODEC_CAP_DR1 ? "D" : " ",
813+ cap & CODEC_CAP_TRUNCATED ? "T" : " ",
814+ p2->name,
815+ p2->long_name ? p2->long_name : "");
816+#if 0
817+ if (p2->decoder && decode == 0)
818+ printf(" use %s for decoding", p2->decoder->name);
819+#endif
808820 printf("\n");
809821 }
810822 printf("\n");
811− printf(
812−"Note, the names of encoders and decoders do not always match, so there are\n"
813−"several cases where the above table shows encoder only or decoder only entries\n"
814−"even though both encoding and decoding are supported. For example, the h263\n"
815−"decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
816−"worse.\n");
823+ printf("Note, the names of encoders and decoders do not always match, so there are\n"
824+ "several cases where the above table shows encoder only or decoder only entries\n"
825+ "even though both encoding and decoding are supported. For example, the h263\n"
826+ "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
827+ "worse.\n");
817828 return 0;
818829 }
819830
820831 int opt_bsfs(const char *opt, const char *arg)
821832 {
822− AVBitStreamFilter *bsf=NULL;
833+ AVBitStreamFilter *bsf = NULL;
823834
824835 printf("Bitstream filters:\n");
825− while((bsf = av_bitstream_filter_next(bsf)))
836+ while ((bsf = av_bitstream_filter_next(bsf)))
826837 printf("%s\n", bsf->name);
827838 printf("\n");
828839 return 0;
@@ -863,15 +874,14 @@ int opt_pix_fmts(const char *opt, const char *arg) · 34 unmodified lines
863874 {
864875 enum PixelFormat pix_fmt;
865876
866− printf(
867− "Pixel formats:\n"
868− "I.... = Supported Input format for conversion\n"
869− ".O... = Supported Output format for conversion\n"
870− "..H.. = Hardware accelerated format\n"
871− "...P. = Paletted format\n"
872− "....B = Bitstream format\n"
873− "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
874− "-----\n");
877+ printf("Pixel formats:\n"
878+ "I.... = Supported Input format for conversion\n"
879+ ".O... = Supported Output format for conversion\n"
880+ "..H.. = Hardware accelerated format\n"
881+ "...P. = Paletted format\n"
882+ "....B = Bitstream format\n"
883+ "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
884+ "-----\n");
875885
876886 #if !CONFIG_SWSCALE
877887 # define sws_isSupportedInput(x) 0
@@ -921,7 +931,8 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) · 43 unmodified lines
921931 FILE *f = fopen(filename, "rb");
922932
923933 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));
925936 return AVERROR(errno);
926937 }
927938 fseek(f, 0, SEEK_END);
@@ -952,14 +963,14 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) · 24 unmodified lines
952963 }
953964
954965 FILE *get_preset_file(char *filename, size_t filename_size,
955− const char *preset_name, int is_path, const char *codec_name)
966+ const char *preset_name, int is_path,
967+ const char *codec_name)
956968 {
957969 FILE *f = NULL;
958970 int i;
959− const char *base[3]= { getenv("FFMPEG_DATADIR"),
960− getenv("HOME"),
961− FFMPEG_DATADIR,
962− };
971+ const char *base[3] = { getenv("FFMPEG_DATADIR"),
972+ getenv("HOME"),
973+ FFMPEG_DATADIR, };
963974
964975 if (is_path) {
965976 av_strlcpy(filename, preset_name, filename_size);
@@ -985,11 +996,14 @@ FILE *get_preset_file(char *filename, size_t filename_size, · 19 unmodified lines
985996 for (i = 0; i < 3 && !f; i++) {
986997 if (!base[i])
987998 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);
9891001 f = fopen(filename, "r");
9901002 if (!f && codec_name) {
9911003 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);
9931007 f = fopen(filename, "r");
9941008 }
9951009 }
@@ -1000,22 +1014,23 @@ FILE *get_preset_file(char *filename, size_t filename_size, · 4 unmodified lines
10001014
10011015 int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
10021016 {
1003− if (*spec <= '9' && *spec >= '0') /* opt:index */
1017+ if (*spec <= '9' && *spec >= '0') /* opt:index */
10041018 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] */
10061021 enum AVMediaType type;
10071022
10081023 switch (*spec++) {
1009− case 'v': type = AVMEDIA_TYPE_VIDEO; break;
1010− case 'a': type = AVMEDIA_TYPE_AUDIO; break;
1011− case 's': type = AVMEDIA_TYPE_SUBTITLE; break;
1012− case 'd': type = AVMEDIA_TYPE_DATA; break;
1024+ case 'v': type = AVMEDIA_TYPE_VIDEO; break;
1025+ case 'a': type = AVMEDIA_TYPE_AUDIO; break;
1026+ case 's': type = AVMEDIA_TYPE_SUBTITLE; break;
1027+ case 'd': type = AVMEDIA_TYPE_DATA; break;
10131028 case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
10141029 default: abort(); // never reached, silence warning
10151030 }
10161031 if (type != st->codec->codec_type)
10171032 return 0;
1018− if (*spec++ == ':') { /* possibly followed by :index */
1033+ if (*spec++ == ':') { /* possibly followed by :index */
10191034 int i, index = strtol(spec, NULL, 0);
10201035 for (i = 0; i < s->nb_streams; i++)
10211036 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
10511066 return AVERROR(EINVAL);
10521067 }
10531068
1054−AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatContext *s, AVStream *st)
1069+AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec,
1070+ AVFormatContext *s, AVStream *st)
10551071 {
10561072 AVDictionary *ret = NULL;
10571073 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;
10591076 char prefix = 0;
10601077 const AVClass *cc = avcodec_get_class();
10611078
@@ -1063,9 +1080,18 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont · 1 unmodified line
10631080 return NULL;
10641081
10651082 switch (codec->type) {
1066− case AVMEDIA_TYPE_VIDEO: prefix = 'v'; flags |= AV_OPT_FLAG_VIDEO_PARAM; break;
1067− case AVMEDIA_TYPE_AUDIO: prefix = 'a'; flags |= AV_OPT_FLAG_AUDIO_PARAM; break;
1068− case AVMEDIA_TYPE_SUBTITLE: prefix = 's'; flags |= AV_OPT_FLAG_SUBTITLE_PARAM; break;
1083+ case AVMEDIA_TYPE_VIDEO:
1084+ prefix = 'v';
1085+ flags |= AV_OPT_FLAG_VIDEO_PARAM;
1086+ break;
1087+ case AVMEDIA_TYPE_AUDIO:
1088+ prefix = 'a';
1089+ flags |= AV_OPT_FLAG_AUDIO_PARAM;
1090+ break;
1091+ case AVMEDIA_TYPE_SUBTITLE:
1092+ prefix = 's';
1093+ flags |= AV_OPT_FLAG_SUBTITLE_PARAM;
1094+ break;
10691095 }
10701096
10711097 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
10801106 }
10811107
10821108 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)))
10841112 av_dict_set(&ret, t->key, t->value, 0);
1085− else if (t->key[0] == prefix && av_opt_find(&cc, t->key+1, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ))
1086− av_dict_set(&ret, t->key+1, t->value, 0);
1113+ else if (t->key[0] == prefix &&
1114+ av_opt_find(&cc, t->key + 1, NULL, flags,
1115+ AV_OPT_SEARCH_FAKE_OBJ))
1116+ av_dict_set(&ret, t->key + 1, t->value, 0);
10871117
10881118 if (p)
10891119 *p = ':';
@@ -1091,7 +1121,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatCont · 1 unmodified line
10911121 return ret;
10921122 }
10931123
1094−AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
1124+AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
1125+ AVDictionary *codec_opts)
10951126 {
10961127 int i;
10971128 AVDictionary **opts;
@@ -1100,11 +1131,13 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *cod · 2 unmodified lines
11001131 return NULL;
11011132 opts = av_mallocz(s->nb_streams * sizeof(*opts));
11021133 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");
11041136 return NULL;
11051137 }
11061138 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]);
11081141 return opts;
11091142 }
11101143
configure+2−2
@@ -1175,9 +1175,9 @@ HAVE_LIST=" · 1174 unmodified lines
11751175 fork
11761176 getaddrinfo
11771177 gethrtime
1178+ GetProcessAffinityMask
11781179 GetProcessMemoryInfo
11791180 GetProcessTimes
1180− GetSystemInfo
11811181 getrusage
11821182 gnu_as
11831183 ibm_asm
@@ -3016,8 +3016,8 @@ check_func_headers windows.h PeekNamedPipe · 1832 unmodified lines
30163016 check_func_headers io.h setmode
30173017 check_func_headers lzo/lzo1x.h lzo1x_999_compress
30183018 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
3019+check_func_headers windows.h GetProcessAffinityMask
30193020 check_func_headers windows.h GetProcessTimes
3020−check_func_headers windows.h GetSystemInfo
30213021 check_func_headers windows.h MapViewOfFile
30223022 check_func_headers windows.h VirtualAlloc
30233023
doc/APIchanges+7−4
@@ -31,21 +31,24 @@ API changes, most recent first: · 30 unmodified lines
3131 2011-10-20 - b35e9e1 - lavu 51.22.0
3232 Add av_strtok() to avstring.h.
3333
34+2011-01-03 - b73ec05 - lavu 51.21.0
35+ Add av_popcount64
36+
3437 2011-12-18 - 8400b12 - lavc 53.28.1
3538 Deprecate AVFrame.age. The field is unused.
3639
37−2011-xx-xx - xxxxxxx - lavf 53.17.0
38− Add avformat_open_input().
40+2011-12-12 - 5266045 - lavf 53.17.0
41+ Add avformat_close_input().
3942 Deprecate av_close_input_file() and av_close_input_stream().
4043
41−2011-xx-xx - xxxxxxx - lavc 53.25.0
44+2011-12-02 - 0eea212 - lavc 53.25.0
4245 Add nb_samples and extended_data fields to AVFrame.
4346 Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE.
4447 Deprecate avcodec_decode_audio3() in favor of avcodec_decode_audio4().
4548 avcodec_decode_audio4() writes output samples to an AVFrame, which allows
4649 audio decoders to use get_buffer().
4750
48−2011-xx-xx - xxxxxxx - lavc 53.24.0
51+2011-12-04 - 560f773 - lavc 53.24.0
4952 Change AVFrame.data[4]/base[4]/linesize[4]/error[4] to [8] at next major bump.
5053 Change AVPicture.data[4]/linesize[4] to [8] at next major bump.
5154 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
5858
5959 /* channels */
6060 avctx->channels = buf[7];
61− if (avctx->channels > 2)
61+ if (avctx->channels <= 0 || avctx->channels > 2)
6262 return AVERROR_INVALIDDATA;
6363
6464 /* sample rate */
libavcodec/adx_parser.c+18−14
@@ -45,27 +45,31 @@ static int adx_parse(AVCodecParserContext *s1, · 44 unmodified lines
4545 ParseContext *pc = &s->pc;
4646 int next = END_NOT_FOUND;
4747 int i;
48− uint64_t state= pc->state64;
48+ uint64_t state = pc->state64;
4949
50− if(!s->header_size){
51− for(i=0; i<buf_size; i++){
52− state= (state<<8) | buf[i];
53− if((state&0xFFFF0000FFFFFF00) == 0x8000000003120400ULL && (state&0xFF) && ((state>>32)&0xFFFF)>=4){
54− s->header_size= ((state>>32)&0xFFFF) + 4;
55− s->block_size = BLOCK_SIZE * (state&0xFF);
56− s->remaining = i - 7 + s->header_size + s->block_size;
57− break;
50+ if (!s->header_size) {
51+ for (i = 0; i < buf_size; i++) {
52+ state = (state << 8) | buf[i];
53+ /* check for fixed fields in ADX header for possible match */
54+ if ((state & 0xFFFF0000FFFFFF00) == 0x8000000003120400ULL) {
55+ int channels = state & 0xFF;
56+ int header_size = ((state >> 32) & 0xFFFF) + 4;
57+ if (channels > 0 && header_size >= 8) {
58+ s->header_size = header_size;
59+ s->block_size = BLOCK_SIZE * channels;
60+ s->remaining = i - 7 + s->header_size + s->block_size;
61+ break;
62+ }
5863 }
5964 }
60− pc->state64= state;
65+ pc->state64 = state;
6166 }
6267
6368 if (s->header_size) {
64− if (!s->remaining) {
69+ if (!s->remaining)
6570 s->remaining = s->block_size;
66− }
67− if (s->remaining<=buf_size) {
68− next= s->remaining;
71+ if (s->remaining <= buf_size) {
72+ next = s->remaining;
6973 s->remaining = 0;
7074 } else
7175 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
4545 av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");
4646 return AVERROR_INVALIDDATA;
4747 }
48− c->channels = avctx->channels;
48+ c->channels = avctx->channels;
49+ c->header_parsed = 1;
4950 }
5051
5152 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
@@ -106,21 +107,21 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, · 54 unmodified lines
106107 return buf_size;
107108 }
108109
109− if(AV_RB16(buf) == 0x8000){
110+ if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) {
110111 int header_size;
111− if ((ret = avpriv_adx_decode_header(avctx, buf,
112− buf_size, &header_size,
112+ if ((ret = avpriv_adx_decode_header(avctx, buf, buf_size, &header_size,
113113 c->coeff)) < 0) {
114114 av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");
115115 return AVERROR_INVALIDDATA;
116116 }
117− c->channels = avctx->channels;
118− if(buf_size < header_size)
117+ c->channels = avctx->channels;
118+ c->header_parsed = 1;
119+ if (buf_size < header_size)
119120 return AVERROR_INVALIDDATA;
120− buf += header_size;
121+ buf += header_size;
121122 buf_size -= header_size;
122123 }
123− if(c->channels <= 0)
124+ if (!c->header_parsed)
124125 return AVERROR_INVALIDDATA;
125126
126127 /* calculate number of blocks in the packet */
libavcodec/alac.c+38−37
@@ -25,27 +25,23 @@ · 24 unmodified lines
2525 * @author 2005 David Hammerton
2626 * @see http://crazney.net/programs/itunes/alac.html
2727 *
28− * Note: This decoder expects a 36- (0x24-)byte QuickTime atom to be
28+ * Note: This decoder expects a 36-byte QuickTime atom to be
2929 * passed through the extradata[_size] fields. This atom is tacked onto
3030 * 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
3431 *
35− * Extradata:
36− * 32bit size
37− * 32bit tag (=alac)
38− * 32bit zero?
39− * 32bit max sample per frame
40− * 8bit ?? (zero?)
32+ * 32bit atom size
33+ * 32bit tag ("alac")
34+ * 32bit tag version (0)
35+ * 32bit samples per frame (used when not set explicitly in the frames)
36+ * 8bit compatible version (0)
4137 * 8bit sample size
42− * 8bit history mult
43− * 8bit initial history
44− * 8bit kmodifier
45− * 8bit channels?
46− * 16bit ??
47− * 32bit max coded frame size
48− * 32bit bitrate?
38+ * 8bit history mult (40)
39+ * 8bit initial history (14)
40+ * 8bit kmodifier (10)
41+ * 8bit channels
42+ * 16bit maxRun (255)
43+ * 32bit max coded frame size (0 means unknown)
44+ * 32bit average bitrate (0 means unknown)
4945 * 32bit samplerate
5046 */
5147
@@ -464,24 +460,29 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data, · 412 unmodified lines
464460 if(ret<0)
465461 return ret;
466462
467− if (prediction_type[ch] == 0) {
468− /* adaptive fir */
469− predictor_decompress_fir_adapt(alac->predicterror_buffer[ch],
470− alac->outputsamples_buffer[ch],
471− outputsamples,
472− readsamplesize,
473− predictor_coef_table[ch],
474− predictor_coef_num[ch],
475− prediction_quantitization[ch]);
476− } else {
477− av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[ch]);
478− /* I think the only other prediction type (or perhaps this is
479− * just a boolean?) runs adaptive fir twice.. like:
480− * predictor_decompress_fir_adapt(predictor_error, tempout, ...)
481− * predictor_decompress_fir_adapt(predictor_error, outputsamples ...)
482− * little strange..
463+ /* adaptive FIR filter */
464+ if (prediction_type[ch] == 15) {
465+ /* Prediction type 15 runs the adaptive FIR twice.
466+ * The first pass uses the special-case coef_num = 31, while
467+ * the second pass uses the coefs from the bitstream.
468+ *
469+ * However, this prediction type is not currently used by the
470+ * reference encoder.
483471 */
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]);
484479 }
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]);
485486 }
486487 } else {
487488 /* not compressed, easy case */
@@ -584,7 +585,7 @@ static int alac_set_info(ALACContext *alac) · 96 unmodified lines
584585
585586 ptr += 4; /* size */
586587 ptr += 4; /* alac */
587− ptr += 4; /* 0 ? */
588+ ptr += 4; /* version */
588589
589590 if(AV_RB32(ptr) >= UINT_MAX/4){
590591 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
593594
594595 /* buffer size / 2 ? */
595596 alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
596− ptr++; /* ??? */
597+ ptr++; /* compatible version */
597598 alac->setinfo_sample_size = *ptr++;
598599 alac->setinfo_rice_historymult = *ptr++;
599600 alac->setinfo_rice_initialhistory = *ptr++;
600601 alac->setinfo_rice_kmodifier = *ptr++;
601602 alac->numchannels = *ptr++;
602− bytestream_get_be16(&ptr); /* ??? */
603+ bytestream_get_be16(&ptr); /* maxRun */
603604 bytestream_get_be32(&ptr); /* max coded frame size */
604− bytestream_get_be32(&ptr); /* bitrate ? */
605+ bytestream_get_be32(&ptr); /* average bitrate */
605606 bytestream_get_be32(&ptr); /* samplerate */
606607
607608 return 0;
libavcodec/alacenc.c+15−3
@@ -348,6 +348,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 347 unmodified lines
348348 static void write_compressed_frame(AlacEncodeContext *s)
349349 {
350350 int i, j;
351+ int prediction_type = 0;
351352
352353 if (s->avctx->channels == 2)
353354 alac_stereo_decorrelation(s);
@@ -358,7 +359,7 @@ static void write_compressed_frame(AlacEncodeContext *s) · 4 unmodified lines
358359
359360 calc_predictor_params(s, i);
360361
361− put_bits(&s->pbctx, 4, 0); // prediction type : currently only type 0 has been RE'd
362+ put_bits(&s->pbctx, 4, prediction_type);
362363 put_bits(&s->pbctx, 4, s->lpc[i].lpc_quant);
363364
364365 put_bits(&s->pbctx, 3, s->rc.rice_modifier);
@@ -373,6 +374,14 @@ static void write_compressed_frame(AlacEncodeContext *s) · 8 unmodified lines
373374
374375 for (i = 0; i < s->avctx->channels; i++) {
375376 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+
376385 alac_entropy_coder(s);
377386 }
378387 }
@@ -391,8 +400,11 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 12 unmodified lines
391400 return -1;
392401 }
393402
394− if(avctx->channels > 2) {
395− av_log(avctx, AV_LOG_ERROR, "channels > 2 not supported\n");
403+ /* TODO: Correctly implement multi-channel ALAC.
404+ It is similar to multi-channel AAC, in that it has a series of
405+ single-channel (SCE), channel-pair (CPE), and LFE elements. */
406+ if (avctx->channels > 2) {
407+ av_log(avctx, AV_LOG_ERROR, "only mono or stereo input is currently supported\n");
396408 return AVERROR_PATCHWELCOME;
397409 }
398410
libavcodec/dca.c+289−257
@@ -48,13 +48,13 @@ · 47 unmodified lines
4848
4949 //#define TRACE
5050
51−#define DCA_PRIM_CHANNELS_MAX (7)
52−#define DCA_SUBBANDS (32)
53−#define DCA_ABITS_MAX (32) /* Should be 28 */
54−#define DCA_SUBSUBFRAMES_MAX (4)
55−#define DCA_SUBFRAMES_MAX (16)
56−#define DCA_BLOCKS_MAX (16)
57−#define DCA_LFE_MAX (3)
51+#define DCA_PRIM_CHANNELS_MAX (7)
52+#define DCA_SUBBANDS (32)
53+#define DCA_ABITS_MAX (32) /* Should be 28 */
54+#define DCA_SUBSUBFRAMES_MAX (4)
55+#define DCA_SUBFRAMES_MAX (16)
56+#define DCA_BLOCKS_MAX (16)
57+#define DCA_LFE_MAX (3)
5858
5959 enum DCAMode {
6060 DCA_MONO = 0,
@@ -127,28 +127,45 @@ static const int dca_ext_audio_descr_mask[] = { · 66 unmodified lines
127127 * OV -> center back
128128 * All 2 channel configurations -> AV_CH_LAYOUT_STEREO
129129 */
130−
131130 static const uint64_t dca_core_channel_layout[] = {
132− AV_CH_FRONT_CENTER, ///< 1, A
133− AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono)
134− AV_CH_LAYOUT_STEREO, ///< 2, L + R (stereo)
135− AV_CH_LAYOUT_STEREO, ///< 2, (L+R) + (L-R) (sum-difference)
136− AV_CH_LAYOUT_STEREO, ///< 2, LT +RT (left and right total)
137− AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER, ///< 3, C+L+R
138− AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER, ///< 3, L+R+S
139− AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, ///< 4, C + L + R+ S
140− AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 4, L + R +SL+ SR
141− AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 5, C + L + R+ SL+SR
142− AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
143− AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, ///< 6, C + L + R+ LR + RR + OV
144− AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 6, CF+ CR+LF+ RF+LR + RR
145− AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
146− AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2
147− AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_BACK_CENTER|AV_CH_SIDE_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR
131+ AV_CH_FRONT_CENTER, ///< 1, A
132+ AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono)
133+ AV_CH_LAYOUT_STEREO, ///< 2, L + R (stereo)
134+ AV_CH_LAYOUT_STEREO, ///< 2, (L + R) + (L - R) (sum-difference)
135+ AV_CH_LAYOUT_STEREO, ///< 2, LT + RT (left and right total)
136+ AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER, ///< 3, C + L + R
137+ AV_CH_LAYOUT_STEREO | AV_CH_BACK_CENTER, ///< 3, L + R + S
138+ AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 4, C + L + R + S
139+ AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 4, L + R + SL + SR
140+
141+ AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_SIDE_LEFT |
142+ AV_CH_SIDE_RIGHT, ///< 5, C + L + R + SL + SR
143+
144+ AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT |
145+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
146+
147+ AV_CH_LAYOUT_STEREO | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT |
148+ AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 6, C + L + R + LR + RR + OV
149+
150+ AV_CH_FRONT_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER |
151+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_BACK_CENTER |
152+ AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 6, CF + CR + LF + RF + LR + RR
153+
154+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER |
155+ AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO |
156+ AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
157+
158+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER |
159+ AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT |
160+ AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2 + SR1 + SR2
161+
162+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER |
163+ AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO |
164+ AV_CH_SIDE_LEFT | AV_CH_BACK_CENTER | AV_CH_SIDE_RIGHT, ///< 8, CL + C + CR + L + R + SL + S + SR
148165 };
149166
150167 static const int8_t dca_lfe_index[] = {
151− 1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3
168+ 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3
152169 };
153170
154171 static const int8_t dca_channel_reorder_lfe[][9] = {
@@ -227,19 +244,19 @@ static const int8_t dca_channel_reorder_nolfe_xch[][9] = { · 72 unmodified lines
227244 { 3, 2, 4, 0, 1, 5, 8, 7, 6},
228245 };
229246
230−#define DCA_DOLBY 101 /* FIXME */
247+#define DCA_DOLBY 101 /* FIXME */
231248
232−#define DCA_CHANNEL_BITS 6
233−#define DCA_CHANNEL_MASK 0x3F
249+#define DCA_CHANNEL_BITS 6
250+#define DCA_CHANNEL_MASK 0x3F
234251
235−#define DCA_LFE 0x80
252+#define DCA_LFE 0x80
236253
237−#define HEADER_SIZE 14
254+#define HEADER_SIZE 14
238255
239−#define DCA_MAX_FRAME_SIZE 16384
240−#define DCA_MAX_EXSS_HEADER_SIZE 4096
256+#define DCA_MAX_FRAME_SIZE 16384
257+#define DCA_MAX_EXSS_HEADER_SIZE 4096
241258
242−#define DCA_BUFFER_PADDING_SIZE 1024
259+#define DCA_BUFFER_PADDING_SIZE 1024
243260
244261 /** Bit allocation */
245262 typedef struct {
@@ -254,9 +271,11 @@ static BitAlloc dca_tmode; ///< transition mode VLCs · 8 unmodified lines
254271 static BitAlloc dca_scalefactor; ///< scalefactor VLCs
255272 static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs
256273
257−static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx)
274+static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba,
275+ int idx)
258276 {
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;
260279 }
261280
262281 typedef struct {
@@ -306,8 +325,8 @@ typedef struct { · 43 unmodified lines
306325 float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment
307326
308327 /* Primary audio coding side information */
309− int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes
310− int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count
328+ int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes
329+ int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count
311330 int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not)
312331 int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs
313332 int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index
@@ -334,13 +353,13 @@ typedef struct { · 20 unmodified lines
334353 float scale_bias; ///< output scale
335354
336355 DECLARE_ALIGNED(32, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8];
337− DECLARE_ALIGNED(32, float, samples)[(DCA_PRIM_CHANNELS_MAX+1)*256];
338− const float *samples_chanptr[DCA_PRIM_CHANNELS_MAX+1];
356+ DECLARE_ALIGNED(32, float, samples)[(DCA_PRIM_CHANNELS_MAX + 1) * 256];
357+ const float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1];
339358
340359 uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE];
341360 int dca_buffer_size; ///< how much data is in the dca_buffer
342361
343− const int8_t* channel_order_tab; ///< channel reordering table, lfe and non lfe
362+ const int8_t *channel_order_tab; ///< channel reordering table, lfe and non lfe
344363 GetBitContext gb;
345364 /* Current position in DCA frame */
346365 int current_subframe;
@@ -415,13 +434,15 @@ static av_cold void dca_init_vlcs(void) · 68 unmodified lines
415434 }
416435
417436 for (i = 0; i < 10; i++)
418− for (j = 0; j < 7; j++){
419− if (!bitalloc_codes[i][j]) break;
420− dca_smpl_bitalloc[i+1].offset = bitalloc_offsets[i];
421− dca_smpl_bitalloc[i+1].wrap = 1 + (j > 4);
422− dca_smpl_bitalloc[i+1].vlc[j].table = &dca_table[dca_vlc_offs[c]];
423− dca_smpl_bitalloc[i+1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c];
424− init_vlc(&dca_smpl_bitalloc[i+1].vlc[j], bitalloc_maxbits[i][j],
437+ for (j = 0; j < 7; j++) {
438+ if (!bitalloc_codes[i][j])
439+ break;
440+ dca_smpl_bitalloc[i + 1].offset = bitalloc_offsets[i];
441+ dca_smpl_bitalloc[i + 1].wrap = 1 + (j > 4);
442+ dca_smpl_bitalloc[i + 1].vlc[j].table = &dca_table[dca_vlc_offs[c]];
443+ dca_smpl_bitalloc[i + 1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c];
444+
445+ init_vlc(&dca_smpl_bitalloc[i + 1].vlc[j], bitalloc_maxbits[i][j],
425446 bitalloc_sizes[i],
426447 bitalloc_bits[i][j], 1, 1,
427448 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
432453
433454 static inline void get_array(GetBitContext *gb, int *dst, int len, int bits)
434455 {
435− while(len--)
456+ while (len--)
436457 *dst++ = get_bits(gb, bits);
437458 }
438459
439−static int dca_parse_audio_coding_header(DCAContext * s, int base_channel)
460+static int dca_parse_audio_coding_header(DCAContext *s, int base_channel)
440461 {
441462 int i, j;
442463 static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
443464 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 };
445466
446− s->total_channels = get_bits(&s->gb, 3) + 1 + base_channel;
447− s->prim_channels = s->total_channels;
467+ s->total_channels = get_bits(&s->gb, 3) + 1 + base_channel;
468+ s->prim_channels = s->total_channels;
448469
449470 if (s->prim_channels > DCA_PRIM_CHANNELS_MAX)
450471 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
487508 get_bits(&s->gb, 16);
488509 }
489510
490− s->current_subframe = 0;
511+ s->current_subframe = 0;
491512 s->current_subsubframe = 0;
492513
493514 #ifdef TRACE
494515 av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes);
495516 av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels);
496− for (i = base_channel; i < s->prim_channels; i++){
497− av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]);
498− av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]);
499− av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]);
500− av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]);
501− av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]);
502− av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]);
517+ for (i = base_channel; i < s->prim_channels; i++) {
518+ av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n",
519+ s->subband_activity[i]);
520+ av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n",
521+ s->vq_start_subband[i]);
522+ av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n",
523+ s->joint_intensity[i]);
524+ av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n",
525+ s->transient_huffman[i]);
526+ av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n",
527+ s->scalefactor_huffman[i]);
528+ av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n",
529+ s->bitalloc_huffman[i]);
503530 av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:");
504531 for (j = 0; j < 11; j++)
505− av_log(s->avctx, AV_LOG_DEBUG, " %i",
506− s->quant_index_huffman[i][j]);
532+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->quant_index_huffman[i][j]);
507533 av_log(s->avctx, AV_LOG_DEBUG, "\n");
508534 av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:");
509535 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
512538 }
513539 #endif
514540
515− return 0;
541+ return 0;
516542 }
517543
518−static int dca_parse_frame_header(DCAContext * s)
544+static int dca_parse_frame_header(DCAContext *s)
519545 {
520546 init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
521547
@@ -564,7 +590,8 @@ static int dca_parse_frame_header(DCAContext * s) · 42 unmodified lines
564590
565591 /* FIXME: channels mixing levels */
566592 s->output = s->amode;
567− if (s->lfe) s->output |= DCA_LFE;
593+ if (s->lfe)
594+ s->output |= DCA_LFE;
568595
569596 #ifdef TRACE
570597 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
613640
614641 static inline int get_scale(GetBitContext *gb, int level, int value)
615642 {
616− if (level < 5) {
617− /* huffman encoded */
618− value += get_bitalloc(gb, &dca_scalefactor, level);
619− } else if (level < 8)
620− value = get_bits(gb, level + 1);
621− return value;
643+ if (level < 5) {
644+ /* huffman encoded */
645+ value += get_bitalloc(gb, &dca_scalefactor, level);
646+ } else if (level < 8)
647+ value = get_bits(gb, level + 1);
648+ return value;
622649 }
623650
624−static int dca_subframe_header(DCAContext * s, int base_channel, int block_index)
651+static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
625652 {
626653 /* Primary audio coding side information */
627654 int j, k;
@@ -630,7 +657,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 2 unmodified lines
630657 return AVERROR_INVALIDDATA;
631658
632659 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;
634661 s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3);
635662 }
636663
@@ -666,8 +693,8 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 29 unmodified lines
666693 }
667694
668695 if (s->bitalloc[j][k] > 26) {
669−// av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n",
670−// j, k, s->bitalloc[j][k]);
696+ // av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index [%i][%i] too big (%i)\n",
697+ // j, k, s->bitalloc[j][k]);
671698 return AVERROR_INVALIDDATA;
672699 }
673700 }
@@ -692,7 +719,8 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 18 unmodified lines
692719 const uint32_t *scale_table;
693720 int scale_sum;
694721
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);
696724
697725 if (s->scalefactor_huffman[j] == 6)
698726 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
810838 }
811839
812840 #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]);
814843 av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
815844 s->partial_samples[s->current_subframe]);
845+
816846 for (j = base_channel; j < s->prim_channels; j++) {
817847 av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
818848 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
821851 }
822852 for (j = base_channel; j < s->prim_channels; j++) {
823853 for (k = 0; k < s->subband_activity[j]; k++)
824− av_log(s->avctx, AV_LOG_DEBUG,
825− "prediction coefs: %f, %f, %f, %f\n",
826− (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
827− (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
828− (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
829− (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
854+ av_log(s->avctx, AV_LOG_DEBUG,
855+ "prediction coefs: %f, %f, %f, %f\n",
856+ (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
857+ (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
858+ (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
859+ (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
830860 }
831861 for (j = base_channel; j < s->prim_channels; j++) {
832862 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
862892 if (!base_channel && s->prim_channels > 2 && s->downmix) {
863893 av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
864894 for (j = 0; j < s->prim_channels; j++) {
865− av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]);
866− av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]);
895+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j,
896+ dca_downmix_coeffs[s->downmix_coef[j][0]]);
897+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j,
898+ dca_downmix_coeffs[s->downmix_coef[j][1]]);
867899 }
868900 av_log(s->avctx, AV_LOG_DEBUG, "\n");
869901 }
@@ -884,7 +916,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index · 14 unmodified lines
884916 return 0;
885917 }
886918
887−static void qmf_32_subbands(DCAContext * s, int chans,
919+static void qmf_32_subbands(DCAContext *s, int chans,
888920 float samples_in[32][8], float *samples_out,
889921 float scale)
890922 {
@@ -894,7 +926,7 @@ static void qmf_32_subbands(DCAContext * s, int chans, · 3 unmodified lines
894926 int sb_act = s->subband_activity[chans];
895927 int subindex;
896928
897− scale *= sqrt(1/8.0);
929+ scale *= sqrt(1 / 8.0);
898930
899931 /* Select filter */
900932 if (!s->multirate_inter) /* Non-perfect reconstruction */
@@ -908,18 +940,18 @@ static void qmf_32_subbands(DCAContext * s, int chans, · 7 unmodified lines
908940 /* Reconstructed channel sample index */
909941 for (subindex = 0; subindex < 8; subindex++) {
910942 /* 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++) {
912944 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;
914946 AV_WN32A(&s->raXin[i], v);
915947 }
916948
917949 s->synth.synth_filter_float(&s->imdct,
918− s->subband_fir_hist[chans], &s->hist_index[chans],
919− s->subband_fir_noidea[chans], prCoeff,
920− samples_out, s->raXin, scale);
921− samples_out+= 32;
922−
950+ s->subband_fir_hist[chans],
951+ &s->hist_index[chans],
952+ s->subband_fir_noidea[chans], prCoeff,
953+ samples_out, s->raXin, scale);
954+ samples_out += 32;
923955 }
924956 }
925957
@@ -949,45 +981,44 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, · 23 unmodified lines
949981 }
950982 /* Interpolation */
951983 for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
952− s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor,
953− scale);
984+ s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale);
954985 samples_in++;
955986 samples_out += 2 * decifactor;
956987 }
957988 }
958989
959990 /* downmixing routines */
960−#define MIX_REAR1(samples, si1, rs, coef) \
961− samples[i] += samples[si1] * coef[rs][0]; \
962− samples[i+256] += samples[si1] * coef[rs][1];
963−
964−#define MIX_REAR2(samples, si1, si2, rs, coef) \
965− samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs+1][0]; \
966− samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs+1][1];
967−
968−#define MIX_FRONT3(samples, coef) \
969− t = samples[i+c]; \
970− u = samples[i+l]; \
971− v = samples[i+r]; \
991+#define MIX_REAR1(samples, si1, rs, coef) \
992+ samples[i] += samples[si1] * coef[rs][0]; \
993+ samples[i+256] += samples[si1] * coef[rs][1];
994+
995+#define MIX_REAR2(samples, si1, si2, rs, coef) \
996+ samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs + 1][0]; \
997+ samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs + 1][1];
998+
999+#define MIX_FRONT3(samples, coef) \
1000+ t = samples[i + c]; \
1001+ u = samples[i + l]; \
1002+ v = samples[i + r]; \
9721003 samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \
9731004 samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1];
9741005
975−#define DOWNMIX_TO_STEREO(op1, op2) \
976− for (i = 0; i < 256; i++){ \
977− op1 \
978− op2 \
1006+#define DOWNMIX_TO_STEREO(op1, op2) \
1007+ for (i = 0; i < 256; i++) { \
1008+ op1 \
1009+ op2 \
9791010 }
9801011
9811012 static void dca_downmix(float *samples, int srcfmt,
9821013 int downmix_coef[DCA_PRIM_CHANNELS_MAX][2],
9831014 const int8_t *channel_mapping)
9841015 {
985− int c,l,r,sl,sr,s;
1016+ int c, l, r, sl, sr, s;
9861017 int i;
9871018 float t, u, v;
9881019 float coef[DCA_PRIM_CHANNELS_MAX][2];
9891020
990− for (i=0; i<DCA_PRIM_CHANNELS_MAX; i++) {
1021+ for (i = 0; i < DCA_PRIM_CHANNELS_MAX; i++) {
9911022 coef[i][0] = dca_downmix_coeffs[downmix_coef[i][0]];
9921023 coef[i][1] = dca_downmix_coeffs[downmix_coef[i][1]];
9931024 }
@@ -1006,11 +1037,11 @@ static void dca_downmix(float *samples, int srcfmt, · 12 unmodified lines
10061037 c = channel_mapping[0] * 256;
10071038 l = channel_mapping[1] * 256;
10081039 r = channel_mapping[2] * 256;
1009− DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),);
1040+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), );
10101041 break;
10111042 case DCA_2F1R:
10121043 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), );
10141045 break;
10151046 case DCA_3F1R:
10161047 c = channel_mapping[0] * 256;
@@ -1023,12 +1054,12 @@ static void dca_downmix(float *samples, int srcfmt, · 6 unmodified lines
10231054 case DCA_2F2R:
10241055 sl = channel_mapping[2] * 256;
10251056 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), );
10271058 break;
10281059 case DCA_3F2R:
1029− c = channel_mapping[0] * 256;
1030− l = channel_mapping[1] * 256;
1031− r = channel_mapping[2] * 256;
1060+ c = channel_mapping[0] * 256;
1061+ l = channel_mapping[1] * 256;
1062+ r = channel_mapping[2] * 256;
10321063 sl = channel_mapping[3] * 256;
10331064 sr = channel_mapping[4] * 256;
10341065 DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
@@ -1048,7 +1079,7 @@ static int decode_blockcode(int code, int levels, int *values) · 13 unmodified lines
10481079
10491080 for (i = 0; i < 4; i++) {
10501081 int div = FASTDIV(code, levels);
1051− values[i] = code - offset - div*levels;
1082+ values[i] = code - offset - div * levels;
10521083 code = div;
10531084 }
10541085
@@ -1062,8 +1093,8 @@ static int decode_blockcodes(int code1, int code2, int levels, int *values) · 7 unmodified lines
10621093 }
10631094 #endif
10641095
1065−static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 };
1066−static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 };
1096+static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 };
1097+static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 };
10671098
10681099 #ifndef int8x8_fmul_int32
10691100 static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale)
@@ -1075,7 +1106,7 @@ static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale) · 5 unmodified lines
10751106 }
10761107 #endif
10771108
1078−static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
1109+static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
10791110 {
10801111 int k, l;
10811112 int subsubframe = s->current_subsubframe;
@@ -1118,20 +1149,21 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 36 unmodified lines
11181149 /*
11191150 * Extract bits from the bit stream
11201151 */
1121− if (!abits){
1152+ if (!abits) {
11221153 memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0]));
11231154 } else {
11241155 /* Deal with transients */
11251156 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];
11271159
1128− if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){
1129− if (abits <= 7){
1160+ if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
1161+ if (abits <= 7) {
11301162 /* Block code */
11311163 int block_code1, block_code2, size, levels, err;
11321164
1133− size = abits_sizes[abits-1];
1134− levels = abits_levels[abits-1];
1165+ size = abits_sizes[abits - 1];
1166+ levels = abits_levels[abits - 1];
11351167
11361168 block_code1 = get_bits(&s->gb, size);
11371169 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
11421174 "ERROR: block code look-up failed\n");
11431175 return AVERROR_INVALIDDATA;
11441176 }
1145− }else{
1177+ } else {
11461178 /* no coding */
11471179 for (m = 0; m < 8; m++)
11481180 block[m] = get_sbits(&s->gb, abits - 3);
11491181 }
1150− }else{
1182+ } else {
11511183 /* Huffman coded */
11521184 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);
11541187 }
11551188
11561189 s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
1157− block, rscale, 8);
1190+ block, rscale, 8);
11581191 }
11591192
11601193 /*
@@ -1171,8 +1204,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 10 unmodified lines
11711204 else if (s->predictor_history)
11721205 subband_samples[k][l][m] +=
11731206 (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
1174− s->subband_samples_hist[k][l][m - n +
1175− 4] / 8192);
1207+ s->subband_samples_hist[k][l][m - n + 4] / 8192);
11761208 }
11771209 }
11781210 }
@@ -1186,7 +1218,8 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 7 unmodified lines
11861218 int hfvq = s->high_freq_vq[k][l];
11871219
11881220 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");
11901223 s->debug_flag |= 0x01;
11911224 }
11921225
@@ -1210,23 +1243,25 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index) · 17 unmodified lines
12101243 /* Backup predictor history for adpcm */
12111244 for (k = base_channel; k < s->prim_channels; k++)
12121245 for (l = 0; l < s->vq_start_subband[k]; l++)
1213− memcpy(s->subband_samples_hist[k][l], &subband_samples[k][l][4],
1214− 4 * sizeof(subband_samples[0][0][0]));
1246+ memcpy(s->subband_samples_hist[k][l],
1247+ &subband_samples[k][l][4],
1248+ 4 * sizeof(subband_samples[0][0][0]));
12151249
12161250 return 0;
12171251 }
12181252
1219−static int dca_filter_channels(DCAContext * s, int block_index)
1253+static int dca_filter_channels(DCAContext *s, int block_index)
12201254 {
12211255 float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index];
12221256 int k;
12231257
12241258 /* 32 subbands QMF */
12251259 for (k = 0; k < s->prim_channels; k++) {
1226−/* static float pcm_to_double[8] =
1227− {32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/
1228− qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * s->channel_order_tab[k]],
1229− M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ );
1260+/* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0,
1261+ 0, 8388608.0, 8388608.0 };*/
1262+ qmf_32_subbands(s, k, subband_samples[k],
1263+ &s->samples[256 * s->channel_order_tab[k]],
1264+ M_SQRT1_2 * s->scale_bias /* pcm_to_double[s->source_pcm_res] */);
12301265 }
12311266
12321267 /* Down mixing */
@@ -1239,7 +1274,7 @@ static int dca_filter_channels(DCAContext * s, int block_index) · 6 unmodified lines
12391274 lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
12401275 s->lfe_data + 2 * s->lfe * (block_index + 4),
12411276 &s->samples[256 * dca_lfe_index[s->amode]],
1242− (1.0/256.0)*s->scale_bias);
1277+ (1.0 / 256.0) * s->scale_bias);
12431278 /* Outputs 20bits pcm samples */
12441279 }
12451280
@@ -1247,7 +1282,7 @@ static int dca_filter_channels(DCAContext * s, int block_index) · 1 unmodified line
12471282 }
12481283
12491284
1250−static int dca_subframe_footer(DCAContext * s, int base_channel)
1285+static int dca_subframe_footer(DCAContext *s, int base_channel)
12511286 {
12521287 int aux_data_count = 0, i;
12531288
@@ -1279,7 +1314,7 @@ static int dca_subframe_footer(DCAContext * s, int base_channel) · 25 unmodified lines
12791314 * @param s pointer to the DCAContext
12801315 */
12811316
1282−static int dca_decode_block(DCAContext * s, int base_channel, int block_index)
1317+static int dca_decode_block(DCAContext *s, int base_channel, int block_index)
12831318 {
12841319 int ret;
12851320
@@ -1327,8 +1362,8 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index) · 41 unmodified lines
13271362 /**
13281363 * Convert bitstream to one representation based on sync marker
13291364 */
1330−static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * dst,
1331− int max_size)
1365+static int dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
1366+ int max_size)
13321367 {
13331368 uint32_t mrk;
13341369 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
13361371 uint16_t *sdst = (uint16_t *) dst;
13371372 PutBitContext pb;
13381373
1339− if ((unsigned)src_size > (unsigned)max_size) {
1374+ if ((unsigned) src_size > (unsigned) max_size) {
13401375 // av_log(NULL, AV_LOG_ERROR, "Input frame size larger than DCA_MAX_FRAME_SIZE!\n");
13411376 // return -1;
13421377 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
13711406 static int dca_exss_mask2count(int mask)
13721407 {
13731408 /* count bits that mean speaker pairs twice */
1374− return av_popcount(mask)
1375− + av_popcount(mask & (
1376− DCA_EXSS_CENTER_LEFT_RIGHT
1377− | DCA_EXSS_FRONT_LEFT_RIGHT
1378− | DCA_EXSS_FRONT_HIGH_LEFT_RIGHT
1379− | DCA_EXSS_WIDE_LEFT_RIGHT
1380− | DCA_EXSS_SIDE_LEFT_RIGHT
1381− | DCA_EXSS_SIDE_HIGH_LEFT_RIGHT
1382− | DCA_EXSS_SIDE_REAR_LEFT_RIGHT
1383− | DCA_EXSS_REAR_LEFT_RIGHT
1384− | DCA_EXSS_REAR_HIGH_LEFT_RIGHT
1385− ));
1409+ return av_popcount(mask) +
1410+ av_popcount(mask & (DCA_EXSS_CENTER_LEFT_RIGHT |
1411+ DCA_EXSS_FRONT_LEFT_RIGHT |
1412+ DCA_EXSS_FRONT_HIGH_LEFT_RIGHT |
1413+ DCA_EXSS_WIDE_LEFT_RIGHT |
1414+ DCA_EXSS_SIDE_LEFT_RIGHT |
1415+ DCA_EXSS_SIDE_HIGH_LEFT_RIGHT |
1416+ DCA_EXSS_SIDE_REAR_LEFT_RIGHT |
1417+ DCA_EXSS_REAR_LEFT_RIGHT |
1418+ DCA_EXSS_REAR_HIGH_LEFT_RIGHT));
13861419 }
13871420
13881421 /**
@@ -1408,7 +1441,7 @@ static int dca_exss_parse_asset_header(DCAContext *s) · 19 unmodified lines
14081441 int header_size;
14091442 int channels;
14101443 int embedded_stereo = 0;
1411− int embedded_6ch = 0;
1444+ int embedded_6ch = 0;
14121445 int drc_code_present;
14131446 int extensions_mask;
14141447 int i, j;
@@ -1543,7 +1576,8 @@ static int dca_exss_parse_asset_header(DCAContext *s) · 128 unmodified lines
15431576 if (!(extensions_mask & DCA_EXT_CORE))
15441577 av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n");
15451578 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",
15471581 extensions_mask & DCA_CORE_EXTS, s->core_ext_mask);
15481582
15491583 return 0;
@@ -1568,7 +1602,7 @@ static void dca_exss_parse_header(DCAContext *s) · 18 unmodified lines
15681602 ss_index = get_bits(&s->gb, 2);
15691603
15701604 blownup = get_bits1(&s->gb);
1571− skip_bits(&s->gb, 8 + 4 * blownup); // header_size
1605+ skip_bits(&s->gb, 8 + 4 * blownup); // header_size
15721606 skip_bits(&s->gb, 16 + 4 * blownup); // hd_size
15731607
15741608 s->static_fields = get_bits1(&s->gb);
@@ -1609,18 +1643,18 @@ static void dca_exss_parse_header(DCAContext *s) · 34 unmodified lines
16091643 int mix_out_mask_size;
16101644
16111645 skip_bits(&s->gb, 2); // adjustment level
1612− mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2;
1613− s->num_mix_configs = get_bits(&s->gb, 2) + 1;
1646+ mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2;
1647+ s->num_mix_configs = get_bits(&s->gb, 2) + 1;
16141648
16151649 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);
16171651 s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask);
16181652 }
16191653 }
16201654 }
16211655
16221656 for (i = 0; i < num_assets; i++)
1623− skip_bits_long(&s->gb, 16 + 4 * blownup); // asset size
1657+ skip_bits_long(&s->gb, 16 + 4 * blownup); // asset size
16241658
16251659 for (i = 0; i < num_assets; i++) {
16261660 if (dca_exss_parse_asset_header(s))
@@ -1667,8 +1701,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 40 unmodified lines
16671701 }
16681702 //set AVCodec values with parsed data
16691703 avctx->sample_rate = s->sample_rate;
1670− avctx->bit_rate = s->bit_rate;
1671− avctx->frame_size = s->sample_blocks * 32;
1704+ avctx->bit_rate = s->bit_rate;
1705+ avctx->frame_size = s->sample_blocks * 32;
16721706
16731707 s->profile = FF_PROFILE_DTS;
16741708
@@ -1700,72 +1734,71 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 25 unmodified lines
17001734 /* extensions start at 32-bit boundaries into bitstream */
17011735 skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
17021736
1703− while(core_ss_end - get_bits_count(&s->gb) >= 32) {
1704− uint32_t bits = get_bits_long(&s->gb, 32);
1737+ while (core_ss_end - get_bits_count(&s->gb) >= 32) {
1738+ uint32_t bits = get_bits_long(&s->gb, 32);
17051739
1706− switch(bits) {
1707− case 0x5a5a5a5a: {
1708− int ext_amode, xch_fsize;
1740+ switch (bits) {
1741+ case 0x5a5a5a5a: {
1742+ int ext_amode, xch_fsize;
17091743
1710− s->xch_base_channel = s->prim_channels;
1744+ s->xch_base_channel = s->prim_channels;
17111745
1712− /* validate sync word using XCHFSIZE field */
1713− xch_fsize = show_bits(&s->gb, 10);
1714− if((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) &&
1715− (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1))
1716− continue;
1717−
1718− /* skip length-to-end-of-frame field for the moment */
1719− skip_bits(&s->gb, 10);
1720−
1721− s->core_ext_mask |= DCA_EXT_XCH;
1746+ /* validate sync word using XCHFSIZE field */
1747+ xch_fsize = show_bits(&s->gb, 10);
1748+ if ((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) &&
1749+ (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1))
1750+ continue;
17221751
1723− /* extension amode should == 1, number of channels in extension */
1724− /* AFAIK XCh is not used for more channels */
1725− if ((ext_amode = get_bits(&s->gb, 4)) != 1) {
1726− av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"
1727− " supported!\n",ext_amode);
1728− continue;
1729− }
1752+ /* skip length-to-end-of-frame field for the moment */
1753+ skip_bits(&s->gb, 10);
17301754
1731− /* much like core primary audio coding header */
1732− dca_parse_audio_coding_header(s, s->xch_base_channel);
1755+ s->core_ext_mask |= DCA_EXT_XCH;
17331756
1734− for (i = 0; i < (s->sample_blocks / 8); i++) {
1735− if ((ret = dca_decode_block(s, s->xch_base_channel, i))) {
1736− av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n");
1757+ /* extension amode(number of channels in extension) should be 1 */
1758+ /* AFAIK XCh is not used for more channels */
1759+ if ((ext_amode = get_bits(&s->gb, 4)) != 1) {
1760+ av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"
1761+ " supported!\n", ext_amode);
17371762 continue;
17381763 }
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;
17391776 }
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;
17401788
1741− s->xch_present = 1;
1742− break;
1743− }
1744− case 0x47004a03:
1745− /* XXCh: extended channels */
1746− /* usually found either in core or HD part in DTS-HD HRA streams,
1747− * but not in DTS-ES which contains XCh extensions instead */
1748− s->core_ext_mask |= DCA_EXT_XXCH;
1749− break;
1750−
1751− case 0x1d95f262: {
1752− int fsize96 = show_bits(&s->gb, 12) + 1;
1753− if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96)
1754− continue;
1755−
1756− av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n", get_bits_count(&s->gb));
1757− skip_bits(&s->gb, 12);
1758− av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
1759− av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
1760−
1761− s->core_ext_mask |= DCA_EXT_X96;
1762− break;
1763− }
1764− }
1789+ av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n",
1790+ get_bits_count(&s->gb));
1791+ skip_bits(&s->gb, 12);
1792+ av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
1793+ av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
17651794
1766− skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
1767− }
1795+ s->core_ext_mask |= DCA_EXT_X96;
1796+ break;
1797+ }
1798+ }
17681799
1800+ skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
1801+ }
17691802 } else {
17701803 /* no supported extensions, skip the rest of the core substream */
17711804 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
17771810 s->profile = FF_PROFILE_DTS_ES;
17781811
17791812 /* check for ExSS (HD part) */
1780− if (s->dca_buffer_size - s->frame_size > 32
1781− && get_bits_long(&s->gb, 32) == DCA_HD_MARKER)
1813+ if (s->dca_buffer_size - s->frame_size > 32 &&
1814+ get_bits_long(&s->gb, 32) == DCA_HD_MARKER)
17821815 dca_exss_parse_header(s);
17831816
17841817 avctx->profile = s->profile;
17851818
17861819 channels = s->prim_channels + !!s->lfe;
17871820
1788− if (s->amode<16) {
1821+ if (s->amode < 16) {
17891822 avctx->channel_layout = dca_core_channel_layout[s->amode];
17901823
17911824 if (s->xch_present && (!avctx->request_channels ||
@@ -1821,7 +1854,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 29 unmodified lines
18211854 s->channel_order_tab = dca_channel_order_native;
18221855 }
18231856 } 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);
18251858 return AVERROR_INVALIDDATA;
18261859 }
18271860
@@ -1837,8 +1870,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 9 unmodified lines
18371870 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
18381871 return ret;
18391872 }
1840− samples_flt = (float *)s->frame.data[0];
1841− samples_s16 = (int16_t *)s->frame.data[0];
1873+ samples_flt = (float *) s->frame.data[0];
1874+ samples_s16 = (int16_t *) s->frame.data[0];
18421875
18431876 /* filter to get final output */
18441877 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
18461879
18471880 /* If this was marked as a DTS-ES stream we need to subtract back- */
18481881 /* channel from SL & SR to remove matrixed back-channel signal */
1849− if((s->source_pcm_res & 1) && s->xch_present) {
1850− float* back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256;
1851− float* lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256;
1852− float* rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256;
1882+ if ((s->source_pcm_res & 1) && s->xch_present) {
1883+ float *back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256;
1884+ float *lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256;
1885+ float *rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256;
18531886 s->dsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256);
18541887 s->dsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);
18551888 }
@@ -1868,12 +1901,11 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 12 unmodified lines
18681901
18691902 /* update lfe history */
18701903 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++)
18721905 s->lfe_data[i] = s->lfe_data[i + lfe_samples];
1873− }
18741906
1875− *got_frame_ptr = 1;
1876− *(AVFrame *)data = s->frame;
1907+ *got_frame_ptr = 1;
1908+ *(AVFrame *) data = s->frame;
18771909
18781910 return buf_size;
18791911 }
@@ -1886,7 +1918,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 6 unmodified lines
18861918 * @param avctx pointer to the AVCodecContext
18871919 */
18881920
1889−static av_cold int dca_decode_init(AVCodecContext * avctx)
1921+static av_cold int dca_decode_init(AVCodecContext *avctx)
18901922 {
18911923 DCAContext *s = avctx->priv_data;
18921924 int i;
@@ -1900,15 +1932,15 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) · 7 unmodified lines
19001932 ff_dcadsp_init(&s->dcadsp);
19011933 ff_fmt_convert_init(&s->fmt_conv, avctx);
19021934
1903− for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++)
1935+ for (i = 0; i < DCA_PRIM_CHANNELS_MAX + 1; i++)
19041936 s->samples_chanptr[i] = s->samples + i * 256;
19051937
19061938 if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) {
19071939 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
1908− s->scale_bias = 1.0 / 32768.0;
1940+ s->scale_bias = 1.0 / 32768.0;
19091941 } else {
19101942 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
1911− s->scale_bias = 1.0;
1943+ s->scale_bias = 1.0;
19121944 }
19131945
19141946 /* allow downmixing to stereo */
@@ -1923,7 +1955,7 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) · 8 unmodified lines
19231955 return 0;
19241956 }
19251957
1926−static av_cold int dca_decode_end(AVCodecContext * avctx)
1958+static av_cold int dca_decode_end(AVCodecContext *avctx)
19271959 {
19281960 DCAContext *s = avctx->priv_data;
19291961 ff_mdct_end(&s->imdct);
@@ -1940,17 +1972,17 @@ static const AVProfile profiles[] = { · 10 unmodified lines
19401972 };
19411973
19421974 AVCodec ff_dca_decoder = {
1943− .name = "dca",
1944− .type = AVMEDIA_TYPE_AUDIO,
1945− .id = CODEC_ID_DTS,
1946− .priv_data_size = sizeof(DCAContext),
1947− .init = dca_decode_init,
1948− .decode = dca_decode_frame,
1949− .close = dca_decode_end,
1950− .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
1951− .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
1952− .sample_fmts = (const enum AVSampleFormat[]) {
1953− AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
1954− },
1955− .profiles = NULL_IF_CONFIG_SMALL(profiles),
1975+ .name = "dca",
1976+ .type = AVMEDIA_TYPE_AUDIO,
1977+ .id = CODEC_ID_DTS,
1978+ .priv_data_size = sizeof(DCAContext),
1979+ .init = dca_decode_init,
1980+ .decode = dca_decode_frame,
1981+ .close = dca_decode_end,
1982+ .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
1983+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
1984+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
1985+ AV_SAMPLE_FMT_S16,
1986+ AV_SAMPLE_FMT_NONE },
1987+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
19561988 };
libavcodec/dct.c+61−61
@@ -28,15 +28,16 @@ · 27 unmodified lines
2828 */
2929
3030 #include <math.h>
31+
3132 #include "libavutil/mathematics.h"
3233 #include "dct.h"
3334 #include "dct32.h"
3435
35−/* sin((M_PI * x / (2*n)) */
36−#define SIN(s,n,x) (s->costab[(n) - (x)])
36+/* sin((M_PI * x / (2 * n)) */
37+#define SIN(s, n, x) (s->costab[(n) - (x)])
3738
38−/* cos((M_PI * x / (2*n)) */
39−#define COS(s,n,x) (s->costab[x])
39+/* cos((M_PI * x / (2 * n)) */
40+#define COS(s, n, x) (s->costab[x])
4041
4142 static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data)
4243 {
@@ -44,28 +45,28 @@ static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data) · 1 unmodified line
4445 int i;
4546
4647 data[0] = 0;
47− for(i = 1; i < n/2; i++) {
48− float tmp1 = data[i ];
49− float tmp2 = data[n - i];
50− float s = SIN(ctx, n, 2*i);
51−
52− s *= tmp1 + tmp2;
53− tmp1 = (tmp1 - tmp2) * 0.5f;
54− data[i ] = s + tmp1;
55− data[n - i] = s - tmp1;
48+ for (i = 1; i < n / 2; i++) {
49+ float tmp1 = data[i ];
50+ float tmp2 = data[n - i];
51+ float s = SIN(ctx, n, 2 * i);
52+
53+ s *= tmp1 + tmp2;
54+ tmp1 = (tmp1 - tmp2) * 0.5f;
55+ data[i] = s + tmp1;
56+ data[n - i] = s - tmp1;
5657 }
5758
58− data[n/2] *= 2;
59+ data[n / 2] *= 2;
5960 ctx->rdft.rdft_calc(&ctx->rdft, data);
6061
6162 data[0] *= 0.5f;
6263
63− for(i = 1; i < n-2; i += 2) {
64− data[i + 1] += data[i - 1];
65− data[i ] = -data[i + 2];
64+ for (i = 1; i < n - 2; i += 2) {
65+ data[i + 1] += data[i - 1];
66+ data[i] = -data[i + 2];
6667 }
6768
68− data[n-1] = 0;
69+ data[n - 1] = 0;
6970 }
7071
7172 static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data)
@@ -74,19 +75,19 @@ static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) · 2 unmodified lines
7475 int i;
7576 float next = -0.5f * (data[0] - data[n]);
7677
77− for(i = 0; i < n/2; i++) {
78− float tmp1 = data[i ];
78+ for (i = 0; i < n / 2; i++) {
79+ float tmp1 = data[i];
7980 float tmp2 = data[n - i];
80− float s = SIN(ctx, n, 2*i);
81− float c = COS(ctx, n, 2*i);
81+ float s = SIN(ctx, n, 2 * i);
82+ float c = COS(ctx, n, 2 * i);
8283
8384 c *= tmp1 - tmp2;
8485 s *= tmp1 - tmp2;
8586
8687 next += c;
8788
88− tmp1 = (tmp1 + tmp2) * 0.5f;
89− data[i ] = tmp1 - s;
89+ tmp1 = (tmp1 + tmp2) * 0.5f;
90+ data[i] = tmp1 - s;
9091 data[n - i] = tmp1 + s;
9192 }
9293
@@ -94,7 +95,7 @@ static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) · 1 unmodified line
9495 data[n] = data[1];
9596 data[1] = next;
9697
97− for(i = 3; i <= n; i += 2)
98+ for (i = 3; i <= n; i += 2)
9899 data[i] = data[i - 2] - data[i];
99100 }
100101
@@ -103,16 +104,16 @@ static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) · 2 unmodified lines
103104 int n = 1 << ctx->nbits;
104105 int i;
105106
106− float next = data[n - 1];
107+ float next = data[n - 1];
107108 float inv_n = 1.0f / n;
108109
109110 for (i = n - 2; i >= 2; i -= 2) {
110− float val1 = data[i ];
111+ float val1 = data[i];
111112 float val2 = data[i - 1] - data[i + 1];
112− float c = COS(ctx, n, i);
113− float s = SIN(ctx, n, i);
113+ float c = COS(ctx, n, i);
114+ float s = SIN(ctx, n, i);
114115
115− data[i ] = c * val1 + s * val2;
116+ data[i] = c * val1 + s * val2;
116117 data[i + 1] = s * val1 - c * val2;
117118 }
118119
@@ -121,13 +122,13 @@ static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) · 2 unmodified lines
121122 ctx->rdft.rdft_calc(&ctx->rdft, data);
122123
123124 for (i = 0; i < n / 2; i++) {
124− float tmp1 = data[i ] * inv_n;
125+ float tmp1 = data[i] * inv_n;
125126 float tmp2 = data[n - i - 1] * inv_n;
126− float csc = ctx->csc2[i] * (tmp1 - tmp2);
127+ float csc = ctx->csc2[i] * (tmp1 - tmp2);
127128
128− tmp1 += tmp2;
129− data[i ] = tmp1 + csc;
130− data[n - i - 1] = tmp1 - csc;
129+ tmp1 += tmp2;
130+ data[i] = tmp1 + csc;
131+ data[n - i - 1] = tmp1 - csc;
131132 }
132133 }
133134
@@ -137,34 +138,33 @@ static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data) · 3 unmodified lines
137138 int i;
138139 float next;
139140
140− for (i=0; i < n/2; i++) {
141− float tmp1 = data[i ];
141+ for (i = 0; i < n / 2; i++) {
142+ float tmp1 = data[i];
142143 float tmp2 = data[n - i - 1];
143− float s = SIN(ctx, n, 2*i + 1);
144+ float s = SIN(ctx, n, 2 * i + 1);
144145
145− s *= tmp1 - tmp2;
146− tmp1 = (tmp1 + tmp2) * 0.5f;
146+ s *= tmp1 - tmp2;
147+ tmp1 = (tmp1 + tmp2) * 0.5f;
147148
148− data[i ] = tmp1 + s;
149+ data[i] = tmp1 + s;
149150 data[n-i-1] = tmp1 - s;
150151 }
151152
152153 ctx->rdft.rdft_calc(&ctx->rdft, data);
153154
154− next = data[1] * 0.5;
155+ next = data[1] * 0.5;
155156 data[1] *= -1;
156157
157158 for (i = n - 2; i >= 0; i -= 2) {
158159 float inr = data[i ];
159160 float ini = data[i + 1];
160− float c = COS(ctx, n, i);
161− float s = SIN(ctx, n, i);
161+ float c = COS(ctx, n, i);
162+ float s = SIN(ctx, n, i);
162163
163− data[i ] = c * inr + s * ini;
164+ data[i] = c * inr + s * ini;
165+ data[i + 1] = next;
164166
165− data[i+1] = next;
166−
167− next += s * inr - c * ini;
167+ next += s * inr - c * ini;
168168 }
169169 }
170170
@@ -180,36 +180,36 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) · 9 unmodified lines
180180
181181 memset(s, 0, sizeof(*s));
182182
183− s->nbits = nbits;
184− s->inverse = inverse;
183+ s->nbits = nbits;
184+ s->inverse = inverse;
185185
186186 if (inverse == DCT_II && nbits == 5) {
187187 s->dct_calc = dct32_func;
188188 } else {
189− ff_init_ff_cos_tabs(nbits+2);
190−
191− s->costab = ff_cos_tabs[nbits+2];
189+ ff_init_ff_cos_tabs(nbits + 2);
192190
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));
194193
195194 if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) {
196195 av_free(s->csc2);
197196 return -1;
198197 }
199198
200− for (i = 0; i < n/2; i++)
201− s->csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1)));
199+ for (i = 0; i < n / 2; i++)
200+ s->csc2[i] = 0.5 / sin((M_PI / (2 * n) * (2 * i + 1)));
202201
203− switch(inverse) {
204− case DCT_I : s->dct_calc = ff_dct_calc_I_c; break;
205− case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break;
202+ switch (inverse) {
203+ case DCT_I : s->dct_calc = ff_dct_calc_I_c; break;
204+ case DCT_II : s->dct_calc = ff_dct_calc_II_c; break;
206205 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;
208207 }
209208 }
210209
211210 s->dct32 = ff_dct32_float;
212− if (HAVE_MMX) ff_dct_init_mmx(s);
211+ if (HAVE_MMX)
212+ ff_dct_init_mmx(s);
213213
214214 return 0;
215215 }
libavcodec/pthread.c+6−5
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535 #define _GNU_SOURCE
3636 #include <sched.h>
3737 #endif
38−#if HAVE_GETSYSTEMINFO
38+#if HAVE_GETPROCESSAFFINITYMASK
3939 #include <windows.h>
4040 #endif
4141 #if HAVE_SYSCTL
@@ -172,10 +172,11 @@ static int get_logical_cpus(AVCodecContext *avctx) · 130 unmodified lines
172172 if (!ret) {
173173 nb_cpus = CPU_COUNT(&cpuset);
174174 }
175−#elif HAVE_GETSYSTEMINFO
176− SYSTEM_INFO sysinfo;
177− GetSystemInfo(&sysinfo);
178− nb_cpus = sysinfo.dwNumberOfProcessors;
175+#elif HAVE_GETPROCESSAFFINITYMASK
176+ DWORD_PTR proc_aff, sys_aff;
177+ ret = GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff);
178+ if (ret)
179+ nb_cpus = av_popcount64(proc_aff);
179180 #elif HAVE_SYSCTL && defined(HW_NCPU)
180181 int mib[2] = { CTL_HW, HW_NCPU };
181182 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
516516 int ls= frame->linesize[p];
517517 uint8_t *src= frame->data[p];
518518
519− halfpel[1][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
520− halfpel[2][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
521− halfpel[3][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
519+ halfpel[1][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
520+ halfpel[2][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
521+ halfpel[3][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
522522
523523 halfpel[0][p]= src;
524524 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
282282 }
283283 }
284284
285+/* UtVideo interlaced mode treats every two lines as a single one,
286+ * so restoring function should take care of possible padding between
287+ * two parts of the same "line".
288+ */
289+static void restore_median_il(uint8_t *src, int step, int stride,
290+ int width, int height, int slices, int rmode)
291+{
292+ int i, j, slice;
293+ int A, B, C;
294+ uint8_t *bsrc;
295+ int slice_start, slice_height;
296+ const int cmask = ~(rmode ? 3 : 1);
297+ const int stride2 = stride << 1;
298+
299+ for (slice = 0; slice < slices; slice++) {
300+ slice_start = ((slice * height) / slices) & cmask;
301+ slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start;
302+ slice_height >>= 1;
303+
304+ bsrc = src + slice_start * stride;
305+
306+ // first line - left neighbour prediction
307+ bsrc[0] += 0x80;
308+ A = bsrc[0];
309+ for (i = step; i < width * step; i += step) {
310+ bsrc[i] += A;
311+ A = bsrc[i];
312+ }
313+ for (i = 0; i < width * step; i += step) {
314+ bsrc[stride + i] += A;
315+ A = bsrc[stride + i];
316+ }
317+ bsrc += stride2;
318+ if (slice_height == 1)
319+ continue;
320+ // second line - first element has top predition, the rest uses median
321+ C = bsrc[-stride2];
322+ bsrc[0] += C;
323+ A = bsrc[0];
324+ for (i = step; i < width * step; i += step) {
325+ B = bsrc[i - stride2];
326+ bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
327+ C = B;
328+ A = bsrc[i];
329+ }
330+ for (i = 0; i < width * step; i += step) {
331+ B = bsrc[i - stride];
332+ bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C));
333+ C = B;
334+ A = bsrc[stride + i];
335+ }
336+ bsrc += stride2;
337+ // the rest of lines use continuous median prediction
338+ for (j = 2; j < slice_height; j++) {
339+ for (i = 0; i < width * step; i += step) {
340+ B = bsrc[i - stride2];
341+ bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
342+ C = B;
343+ A = bsrc[i];
344+ }
345+ for (i = 0; i < width * step; i += step) {
346+ B = bsrc[i - stride];
347+ bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C));
348+ C = B;
349+ A = bsrc[i + stride];
350+ }
351+ bsrc += stride2;
352+ }
353+ }
354+}
355+
285356 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
286357 {
287358 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
381452 c->frame_pred == PRED_LEFT);
382453 if (ret)
383454 return ret;
384− if (c->frame_pred == PRED_MEDIAN)
385− restore_median(c->pic.data[i], 1, c->pic.linesize[i],
386− avctx->width >> !!i, avctx->height >> !!i,
387− c->slices, !i);
455+ if (c->frame_pred == PRED_MEDIAN) {
456+ if (!c->interlaced) {
457+ restore_median(c->pic.data[i], 1, c->pic.linesize[i],
458+ avctx->width >> !!i, avctx->height >> !!i,
459+ c->slices, !i);
460+ } else {
461+ restore_median_il(c->pic.data[i], 1, c->pic.linesize[i],
462+ avctx->width >> !!i,
463+ avctx->height >> !!i,
464+ c->slices, !i);
465+ }
466+ }
388467 }
389468 break;
390469 case PIX_FMT_YUV422P:
@@ -395,9 +474,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac · 4 unmodified lines
395474 c->frame_pred == PRED_LEFT);
396475 if (ret)
397476 return ret;
398− if (c->frame_pred == PRED_MEDIAN)
399− restore_median(c->pic.data[i], 1, c->pic.linesize[i],
400− avctx->width >> !!i, avctx->height, c->slices, 0);
477+ if (c->frame_pred == PRED_MEDIAN) {
478+ if (!c->interlaced) {
479+ restore_median(c->pic.data[i], 1, c->pic.linesize[i],
480+ avctx->width >> !!i, avctx->height,
481+ c->slices, 0);
482+ } else {
483+ restore_median_il(c->pic.data[i], 1, c->pic.linesize[i],
484+ avctx->width >> !!i, avctx->height,
485+ c->slices, 0);
486+ }
487+ }
401488 }
402489 break;
403490 }
libavformat/utils.c+19−19
@@ -2235,7 +2235,7 @@ static int has_decode_delay_been_guessed(AVStream *st) · 2234 unmodified lines
22352235 static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options)
22362236 {
22372237 AVCodec *codec;
2238− int got_picture, ret = 0;
2238+ int got_picture = 1, ret = 0;
22392239 AVFrame picture;
22402240 AVPacket pkt = *avpkt;
22412241
@@ -2248,7 +2248,8 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option · 6 unmodified lines
22482248 return ret;
22492249 }
22502250
2251− while (pkt.size > 0 && ret >= 0 &&
2251+ while ((pkt.size > 0 || (!pkt.data && got_picture)) &&
2252+ ret >= 0 &&
22522253 (!has_codec_parameters(st->codec) ||
22532254 !has_decode_delay_been_guessed(st) ||
22542255 (!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
23772378 int i, count, ret, read_size, j;
23782379 AVStream *st;
23792380 AVPacket pkt1, *pkt;
2380− AVDictionary *one_thread_opt = NULL;
23812381 int64_t old_offset = avio_tell(ic->pb);
23822382 int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those
23832383
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−
23882384 for(i=0;i<ic->nb_streams;i++) {
23892385 AVCodec *codec;
23902386 st = ic->streams[i];
@@ -2406,21 +2402,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 15 unmodified lines
24062402 assert(!st->codec->codec);
24072403 codec = avcodec_find_decoder(st->codec->codec_id);
24082404
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−
24142405 /* Ensure that subtitle_header is properly set. */
24152406 if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
24162407 && 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);
24182409
24192410 //try to just open decoders, in case this is enough to get parameters
24202411 if(!has_codec_parameters(st->codec)){
24212412 if (codec && !st->codec->codec)
2422− avcodec_open2(st->codec, codec, options ? &options[i]
2423− : &one_thread_opt);
2413+ avcodec_open2(st->codec, codec, options ? &options[i] : NULL);
24242414 }
24252415 }
24262416
@@ -2486,10 +2476,22 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 59 unmodified lines
24862476 continue;
24872477
24882478 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+
24902484 ret = -1; /* we could not have all the codec parameters before EOF */
24912485 for(i=0;i<ic->nb_streams;i++) {
24922486 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+
24932495 if (!has_codec_parameters(st->codec)){
24942496 char buf[256];
24952497 avcodec_string(buf, sizeof(buf), st->codec, 0);
@@ -2562,8 +2564,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 66 unmodified lines
25622564 least one frame of codec data, this makes sure the codec initializes
25632565 the channel configuration and does not only trust the values from the container.
25642566 */
2565− try_decode_frame(st, pkt, (options && i < orig_nb_streams )? &options[i]
2566− : &one_thread_opt);
2567+ try_decode_frame(st, pkt, (options && i < orig_nb_streams ) ? &options[i] : NULL);
25672568
25682569 st->codec_info_nb_frames++;
25692570 count++;
@@ -2689,7 +2690,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 119 unmodified lines
26892690 ic->streams[i]->codec->thread_count = 0;
26902691 av_freep(&ic->streams[i]->info);
26912692 }
2692− av_dict_free(&one_thread_opt);
26932693 return ret;
26942694 }
26952695
libavutil/avutil.h+1−1
@@ -154,7 +154,7 @@ · 153 unmodified lines
154154 */
155155
156156 #define LIBAVUTIL_VERSION_MAJOR 51
157−#define LIBAVUTIL_VERSION_MINOR 33
157+#define LIBAVUTIL_VERSION_MINOR 34
158158 #define LIBAVUTIL_VERSION_MICRO 100
159159
160160 #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
220220 return (x + (x >> 16)) & 0x3F;
221221 }
222222
223+/**
224+ * Count number of bits set to one in x
225+ * @param x value to count bits of
226+ * @return the number of bits set to one in x
227+ */
228+static av_always_inline av_const int av_popcount64_c(uint64_t x)
229+{
230+ return av_popcount(x) + av_popcount(x >> 32);
231+}
232+
223233 #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
224234 #define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
225235
@@ -385,3 +395,6 @@ static av_always_inline av_const int av_popcount_c(uint32_t x) · 159 unmodified lines
385395 #ifndef av_popcount
386396 # define av_popcount av_popcount_c
387397 #endif
398+#ifndef av_popcount64
399+# define av_popcount64 av_popcount64_c
400+#endif
tests/fate/screen.mak+3−0
@@ -1,6 +1,9 @@
11 FATE_SCREEN += fate-cscd
22 fate-cscd: CMD = framecrc -i $(SAMPLES)/CSCD/sample_video.avi -an -vsync 0 -pix_fmt rgb24
33
4+FATE_SCREEN += fate-dxtory
5+fate-dxtory: CMD = framecrc -i $(SAMPLES)/dxtory/dxtory_mic.avi
6+
47 FATE_SCREEN += fate-fraps-v0
58 fate-fraps-v0: CMD = framecrc -i $(SAMPLES)/fraps/Griffin_Ragdoll01-partial.avi
69
tests/ref/fate/dxtory+1−0
@@ -0,0 +1 @@
1+0, 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