Просмотр исходного кода

Merge remote-tracking branch 'newdev/master'

* newdev/master: (33 commits)
  Fix an infinite loop when RoQ encoded generated a frame with a size greater than the maximum valid size.
  Add kbdwin.o to AC3 decoder
  Detect byte-swapped AC-3 and support decoding it directly.
  cosmetics: indentation
  Always copy input data for AC3 decoder.
  ac3enc: make sym_quant() branch-free
  cosmetics: indentation
  Add a CPU flag for the Atom processor.
  id3v2: skip broken tags with invalid size
  id3v2: don't explicitly skip padding
  Make sure kbhit() is in conio.h
  fate: update wmv8-drm reference
  vc1: make P-frame deblock filter bit-exact.
  configure: Add the -D parameter to the dlltool command
  amr: Set the AVFMT_GENERIC_INDEX flag
  amr: Set the pkt->pos field properly to the start of the packet
  amr: Set the codec->bit_rate field based on the last packet
  rtsp: Specify unicast for TCP interleaved streams, too
  Set the correct target for mingw64 dlltool
  applehttp: Change the variable for stream position in seconds into int64_t
  ...

Conflicts:
	ffmpeg.c
	ffplay.c
	libavcodec/ac3dec.c
	libavformat/avio.h
	libavformat/id3v2.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer 14 лет назад
Родитель
Сommit
4fa0e24736
10 измененных файлов с 44 добавлено и 95 удалено
  1. 4 6
      configure
  2. 6 54
      ffmpeg.c
  3. 1 1
      libavcodec/Makefile
  4. 14 18
      libavcodec/ac3dec.c
  5. 1 11
      libavcodec/ac3enc.c
  6. 2 0
      libavcodec/dct.h
  7. 0 1
      libavcodec/fft.h
  8. 1 1
      libavcodec/ffv1.c
  9. 14 3
      libavcodec/roqvideoenc.c
  10. 1 0
      libavcodec/vc1.c

+ 4 - 6
configure

@@ -1040,7 +1040,6 @@ HAVE_LIST="
     bswap
     bswap
     closesocket
     closesocket
     cmov
     cmov
-    conio_h
     dcbzl
     dcbzl
     dev_bktr_ioctl_bt848_h
     dev_bktr_ioctl_bt848_h
     dev_bktr_ioctl_meteor_h
     dev_bktr_ioctl_meteor_h
@@ -1070,6 +1069,7 @@ HAVE_LIST="
     inet_aton
     inet_aton
     inline_asm
     inline_asm
     isatty
     isatty
+    kbhit
     ldbrx
     ldbrx
     libdc1394_1
     libdc1394_1
     libdc1394_2
     libdc1394_2
@@ -1118,7 +1118,6 @@ HAVE_LIST="
     sys_soundcard_h
     sys_soundcard_h
     sys_videoio_h
     sys_videoio_h
     ten_operands
     ten_operands
-    termios_h
     threads
     threads
     truncf
     truncf
     vfp_args
     vfp_args
@@ -2423,7 +2422,7 @@ case $target_os in
         LIBTARGET=i386
         LIBTARGET=i386
         if enabled x86_64; then
         if enabled x86_64; then
             enable malloc_aligned
             enable malloc_aligned
-            LIBTARGET=x64
+            LIBTARGET="i386:x86-64"
         elif enabled arm; then
         elif enabled arm; then
             LIBTARGET=arm
             LIBTARGET=arm
         fi
         fi
@@ -2433,7 +2432,7 @@ case $target_os in
         SLIBSUF=".dll"
         SLIBSUF=".dll"
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
-        SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
+        SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
         SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
         SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
             install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
             install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
             install -d "$(LIBDIR)"; \
             install -d "$(LIBDIR)"; \
@@ -2794,6 +2793,7 @@ check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
 check_func  setrlimit
 check_func  setrlimit
 check_func  strerror_r
 check_func  strerror_r
 check_func  strtok_r
 check_func  strtok_r
+check_func_headers conio.h kbhit
 check_func_headers io.h setmode
 check_func_headers io.h setmode
 check_func_headers lzo/lzo1x.h lzo1x_999_compress
 check_func_headers lzo/lzo1x.h lzo1x_999_compress
 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
@@ -2801,7 +2801,6 @@ check_func_headers windows.h GetProcessTimes
 check_func_headers windows.h MapViewOfFile
 check_func_headers windows.h MapViewOfFile
 check_func_headers windows.h VirtualAlloc
 check_func_headers windows.h VirtualAlloc
 
 
-check_header conio.h
 check_header dlfcn.h
 check_header dlfcn.h
 check_header dxva2api.h
 check_header dxva2api.h
 check_header libcrystalhd/libcrystalhd_if.h
 check_header libcrystalhd/libcrystalhd_if.h
@@ -2810,7 +2809,6 @@ check_header poll.h
 check_header sys/mman.h
 check_header sys/mman.h
 check_header sys/resource.h
 check_header sys/resource.h
 check_header sys/select.h
 check_header sys/select.h
-check_header termios.h
 check_header vdpau/vdpau.h
 check_header vdpau/vdpau.h
 check_header vdpau/vdpau_x11.h
 check_header vdpau/vdpau_x11.h
 check_header X11/extensions/XvMClib.h
 check_header X11/extensions/XvMClib.h

+ 6 - 54
ffmpeg.c

@@ -69,12 +69,7 @@
 #include <sys/select.h>
 #include <sys/select.h>
 #endif
 #endif
 
 
-#if HAVE_TERMIOS_H
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <termios.h>
-#elif HAVE_CONIO_H
+#if HAVE_KBHIT
 #include <conio.h>
 #include <conio.h>
 #endif
 #endif
 #include <time.h>
 #include <time.h>
@@ -343,12 +338,6 @@ typedef struct AVInputFile {
     int nb_streams;       /* nb streams we are aware of */
     int nb_streams;       /* nb streams we are aware of */
 } AVInputFile;
 } AVInputFile;
 
 
-#if HAVE_TERMIOS_H
-
-/* init terminal so that we can grab keys */
-static struct termios oldtty;
-#endif
-
 #if CONFIG_AVFILTER
 #if CONFIG_AVFILTER
 
 
 static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
 static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
@@ -436,9 +425,6 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
 static void term_exit(void)
 static void term_exit(void)
 {
 {
     av_log(NULL, AV_LOG_QUIET, "");
     av_log(NULL, AV_LOG_QUIET, "");
-#if HAVE_TERMIOS_H
-    tcsetattr (0, TCSANOW, &oldtty);
-#endif
 }
 }
 
 
 static volatile int received_sigterm = 0;
 static volatile int received_sigterm = 0;
@@ -452,26 +438,6 @@ sigterm_handler(int sig)
 
 
 static void term_init(void)
 static void term_init(void)
 {
 {
-#if HAVE_TERMIOS_H
-    struct termios tty;
-
-    tcgetattr (0, &tty);
-    oldtty = tty;
-    atexit(term_exit);
-
-    tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
-                          |INLCR|IGNCR|ICRNL|IXON);
-    tty.c_oflag |= OPOST;
-    tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
-    tty.c_cflag &= ~(CSIZE|PARENB);
-    tty.c_cflag |= CS8;
-    tty.c_cc[VMIN] = 1;
-    tty.c_cc[VTIME] = 0;
-
-    tcsetattr (0, TCSANOW, &tty);
-    signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
-#endif
-
     signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */
     signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */
     signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
     signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
 #ifdef SIGXCPU
 #ifdef SIGXCPU
@@ -482,25 +448,7 @@ static void term_init(void)
 /* read a key without blocking */
 /* read a key without blocking */
 static int read_key(void)
 static int read_key(void)
 {
 {
-#if HAVE_TERMIOS_H
-    int n = 1;
-    unsigned char ch;
-    struct timeval tv;
-    fd_set rfds;
-
-    FD_ZERO(&rfds);
-    FD_SET(0, &rfds);
-    tv.tv_sec = 0;
-    tv.tv_usec = 0;
-    n = select(1, &rfds, NULL, NULL, &tv);
-    if (n > 0) {
-        n = read(0, &ch, 1);
-        if (n == 1)
-            return ch;
-
-        return n;
-    }
-#elif HAVE_CONIO_H
+#if HAVE_KBHIT
     if(kbhit())
     if(kbhit())
         return(getch());
         return(getch());
 #endif
 #endif
@@ -2511,7 +2459,11 @@ static int transcode(AVFormatContext **output_files,
 
 
     if (!using_stdin) {
     if (!using_stdin) {
         if(verbose >= 0)
         if(verbose >= 0)
+#if HAVE_KBHIT
             fprintf(stderr, "Press [q] to stop encoding\n");
             fprintf(stderr, "Press [q] to stop encoding\n");
+#else
+            fprintf(stderr, "Press ctrl-c to stop encoding\n");
+#endif
         url_set_interrupt_cb(decode_interrupt_cb);
         url_set_interrupt_cb(decode_interrupt_cb);
     }
     }
     term_init();
     term_init();

+ 1 - 1
libavcodec/Makefile

@@ -57,7 +57,7 @@ OBJS-$(CONFIG_AAC_ENCODER)             += aacenc.o aaccoder.o    \
                                           psymodel.o iirfilter.o \
                                           psymodel.o iirfilter.o \
                                           mpeg4audio.o kbdwin.o
                                           mpeg4audio.o kbdwin.o
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
-OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3dec_data.o ac3.o
+OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3dec_data.o ac3.o kbdwin.o
 OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o kbdwin.o
 OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o kbdwin.o
 OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3tab.o ac3.o
 OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
 OBJS-$(CONFIG_ALAC_DECODER)            += alac.o

+ 14 - 18
libavcodec/ac3dec.c

@@ -208,6 +208,11 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
     }
     }
     s->downmixed = 1;
     s->downmixed = 1;
 
 
+    /* allocate context input buffer */
+        s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
+        if (!s->input_buffer)
+            return AVERROR(ENOMEM);
+
     avctx->sample_fmt = AV_SAMPLE_FMT_S16;
     avctx->sample_fmt = AV_SAMPLE_FMT_S16;
     return 0;
     return 0;
 }
 }
@@ -1306,26 +1311,17 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
     int blk, ch, err;
     int blk, ch, err;
     const uint8_t *channel_map;
     const uint8_t *channel_map;
     const float *output[AC3_MAX_CHANNELS];
     const float *output[AC3_MAX_CHANNELS];
-    // if it seems to be byte-swapped AC-3 (aka DNET)
-    int is_swapped = buf_size >= 2 && AV_RB16(buf) == 0x770B;
-
-    /* initialize the GetBitContext with the start of valid AC-3 Frame */
-    if (is_swapped || avctx->error_recognition >= FF_ER_CAREFUL) {
-        /* allocate context input buffer */
-        if (!s->input_buffer)
-            s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-        if (!s->input_buffer)
-            return AVERROR(ENOMEM);
 
 
-        /* copy input buffer to decoder context to avoid reading past the end
-           of the buffer, which can be caused by a damaged input stream. */
-        if (is_swapped) {
-            int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;
-            s->dsp.bswap16_buf((uint16_t *)s->input_buffer, (const uint16_t *)buf, cnt);
-        } else
+    /* copy input buffer to decoder context to avoid reading past the end
+       of the buffer, which can be caused by a damaged input stream. */
+    if (buf_size >= 2 && AV_RB16(buf) == 0x770B) {
+        // seems to be byte-swapped AC-3
+        int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;
+        s->dsp.bswap16_buf((uint16_t *)s->input_buffer, (const uint16_t *)buf, cnt);
+    } else
         memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
         memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
-        buf = s->input_buffer;
-    }
+    buf = s->input_buffer;
+    /* initialize the GetBitContext with the start of valid AC-3 Frame */
     init_get_bits(&s->gbc, buf, buf_size * 8);
     init_get_bits(&s->gbc, buf, buf_size * 8);
 
 
     /* parse the syncinfo */
     /* parse the syncinfo */

+ 1 - 11
libavcodec/ac3enc.c

@@ -1096,17 +1096,7 @@ static int compute_bit_allocation(AC3EncodeContext *s)
  */
  */
 static inline int sym_quant(int c, int e, int levels)
 static inline int sym_quant(int c, int e, int levels)
 {
 {
-    int v;
-
-    if (c >= 0) {
-        v = (levels * (c << e)) >> 24;
-        v = (v + 1) >> 1;
-        v = (levels >> 1) + v;
-    } else {
-        v = (levels * ((-c) << e)) >> 24;
-        v = (v + 1) >> 1;
-        v = (levels >> 1) - v;
-    }
+    int v = ((((levels * c) >> (24 - e)) + 1) >> 1) + (levels >> 1);
     av_assert2(v >= 0 && v < levels);
     av_assert2(v >= 0 && v < levels);
     return v;
     return v;
 }
 }

+ 2 - 0
libavcodec/dct.h

@@ -47,4 +47,6 @@ struct DCTContext {
 int  ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
 int  ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
 void ff_dct_end (DCTContext *s);
 void ff_dct_end (DCTContext *s);
 
 
+void ff_dct_init_mmx(DCTContext *s);
+
 #endif
 #endif

+ 0 - 1
libavcodec/fft.h

@@ -99,7 +99,6 @@ int ff_fft_init(FFTContext *s, int nbits, int inverse);
 void ff_fft_init_altivec(FFTContext *s);
 void ff_fft_init_altivec(FFTContext *s);
 void ff_fft_init_mmx(FFTContext *s);
 void ff_fft_init_mmx(FFTContext *s);
 void ff_fft_init_arm(FFTContext *s);
 void ff_fft_init_arm(FFTContext *s);
-void ff_dct_init_mmx(DCTContext *s);
 
 
 void ff_fft_end(FFTContext *s);
 void ff_fft_end(FFTContext *s);
 
 

+ 1 - 1
libavcodec/ffv1.c

@@ -792,7 +792,7 @@ static av_cold int init_slice_contexts(FFV1Context *f){
         fs->slice_x     = sxs;
         fs->slice_x     = sxs;
         fs->slice_y     = sys;
         fs->slice_y     = sys;
 
 
-        fs->sample_buffer = av_malloc(6 * (fs->width+6) * sizeof(*fs->sample_buffer));
+        fs->sample_buffer = av_malloc(9 * (fs->width+6) * sizeof(*fs->sample_buffer));
         if (!fs->sample_buffer)
         if (!fs->sample_buffer)
             return AVERROR(ENOMEM);
             return AVERROR(ENOMEM);
     }
     }

+ 14 - 3
libavcodec/roqvideoenc.c

@@ -898,9 +898,20 @@ static void roq_encode_video(RoqContext *enc)
     for (i=0; i<enc->width*enc->height/64; i++)
     for (i=0; i<enc->width*enc->height/64; i++)
         gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
         gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
 
 
-    /* Quake 3 can't handle chunks bigger than 65536 bytes */
-    if (tempData->mainChunkSize/8 > 65536) {
-        enc->lambda *= .8;
+    /* Quake 3 can't handle chunks bigger than 65535 bytes */
+    if (tempData->mainChunkSize/8 > 65535) {
+        av_log(enc->avctx, AV_LOG_ERROR,
+               "Warning, generated a frame too big (%d > 65535), "
+               "try using a smaller qscale value.\n",
+               tempData->mainChunkSize/8);
+        enc->lambda *= 1.5;
+        tempData->mainChunkSize = 0;
+        memset(tempData->used_option, 0, sizeof(tempData->used_option));
+        memset(tempData->codebooks.usedCB4, 0,
+               sizeof(tempData->codebooks.usedCB4));
+        memset(tempData->codebooks.usedCB2, 0,
+               sizeof(tempData->codebooks.usedCB2));
+
         goto retry_encode;
         goto retry_encode;
     }
     }
 
 

+ 1 - 0
libavcodec/vc1.c

@@ -863,6 +863,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
         }
         }
     }
     }
     if(v->panscanflag) {
     if(v->panscanflag) {
+        av_log_missing_feature(v->s.avctx, "Pan-scan", 0);
         //...
         //...
     }
     }
     v->rnd = get_bits1(gb);
     v->rnd = get_bits1(gb);

Некоторые файлы не были показаны из-за большого количества измененных файлов