Browse Source

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  proresdsp: fix function prototypes.
  prores-idct: fix overflow in c code.
  fate: update prores-alpha ref after changing pix_fmt to yuv444p10le
  prores: add missing feature warning for alpha
  mov: 10l: Terminate string with 0 not '0'
  mov: Prevent illegal writes when chapter titles are very short.
  prores: add appropriate -fix_fmt parameter to FATE command
  riff: always generate a proper WAVEFORMATEX structure in ff_put_wav_header
  lavc: add a flag-based error_recognition field to AVCodecContext and deprecate non-flag-based ER field
  lavc: rename deprecation symbol FF_API_VERY_AGGRESSIVE to FF_API_ER

Conflicts:
	libavcodec/avcodec.h
	libavformat/mov.c
	tests/fate/prores.mak
	tests/ref/acodec/g726
	tests/ref/fate/prores-alpha

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer 13 years ago
parent
commit
bd4ebbbbed

+ 18 - 5
libavcodec/avcodec.h

@@ -1518,22 +1518,20 @@ typedef struct AVCodecContext {
      */
     float b_quant_offset;
 
+#if FF_API_ER
     /**
      * Error recognition; higher values will detect more errors but may
      * misdetect some more or less valid parts as errors.
      * - encoding: unused
      * - decoding: Set by user.
      */
-    int error_recognition;
+    attribute_deprecated int error_recognition;
 #define FF_ER_CAREFUL         1
 #define FF_ER_COMPLIANT       2
 #define FF_ER_AGGRESSIVE      3
-#if FF_API_VERY_AGGRESSIVE
 #define FF_ER_VERY_AGGRESSIVE 4
 #define FF_ER_EXPLODE         5
-#else
-#define FF_ER_EXPLODE         4
-#endif /* FF_API_VERY_AGGRESSIVE */
+#endif /* FF_API_ER */
 
     /**
      * Called at the beginning of each frame to get a buffer for it.
@@ -2960,6 +2958,21 @@ typedef struct AVCodecContext {
      */
     enum AVSampleFormat request_sample_fmt;
 
+    /**
+     * Error recognition; may misdetect some more or less valid parts as errors.
+     * - encoding: unused
+     * - decoding: Set by user.
+     */
+#if FF_API_ER
+    int error_recognition2;
+#else
+    int error_recognition;
+#endif /* FF_API_ER */
+#define AV_ER_CRCCHECK   (1<<0)
+#define AV_ER_BITSTREAM  (1<<1)
+#define AV_ER_AGGRESSIVE (1<<2)
+#define AV_ER_EXPLODE    (1<<3)
+
     /**
      * Current statistics for PTS correction.
      * - decoding: maintained and used by libavcodec, not intended to be used by user apps

+ 2 - 2
libavcodec/options.c

@@ -205,9 +205,9 @@ static const AVOption options[]={
 {"careful", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, V|D, "er"},
 {"compliant", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_COMPLIANT }, INT_MIN, INT_MAX, V|D, "er"},
 {"aggressive", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"},
-#if FF_API_VERY_AGGRESSIVE
+#if FF_API_ER
 {"very_aggressive", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"},
-#endif /* FF_API_VERY_AGGRESSIVE */
+#endif /* FF_API_ER */
 {"explode", "abort decoding on error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"},
 {"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
 {"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},

+ 5 - 0
libavcodec/proresdec_lgpl.c

@@ -71,6 +71,7 @@ typedef struct {
     int        slice_height_factor;
     int        num_x_mbs;
     int        num_y_mbs;
+    int        alpha_info;
 } ProresContext;
 
 
@@ -189,6 +190,10 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
         ctx->picture.top_field_first  = ctx->frame_type & 1;
     }
 
+    ctx->alpha_info = buf[17] & 0xf;
+    if (ctx->alpha_info)
+        av_log_missing_feature(avctx, "alpha channel", 0);
+
     ctx->qmat_changed = 0;
     ptr   = buf + 20;
     flags = buf[19];

+ 3 - 6
libavcodec/simple_idct.c

@@ -108,7 +108,7 @@ void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
 
     /* IDCT8 on each line */
     for(i=0; i<8; i++) {
-        idctRowCondDC_8(block + i*8);
+        idctRowCondDC_8(block + i*8, 0);
     }
 
     /* IDCT4 and store */
@@ -183,7 +183,7 @@ void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
 
     /* IDCT8 on each line */
     for(i=0; i<4; i++) {
-        idctRowCondDC_8(block + i*8);
+        idctRowCondDC_8(block + i*8, 0);
     }
 
     /* IDCT4 and store */
@@ -230,10 +230,7 @@ void ff_prores_idct(DCTELEM *block, const int16_t *qmat)
         block[i] *= qmat[i];
 
     for (i = 0; i < 8; i++)
-        idctRowCondDC_10(block + i*8);
-
-    for (i = 0; i < 64; i++)
-        block[i] >>= 2;
+        idctRowCondDC_10(block + i*8, 2);
 
     for (i = 0; i < 8; i++)
         idctSparseCol_10(block + i);

+ 24 - 14
libavcodec/simple_idct_template.c

@@ -85,14 +85,19 @@
 
 #endif
 
-static inline void FUNC(idctRowCondDC)(DCTELEM *row)
+static inline void FUNC(idctRowCondDC)(DCTELEM *row, int extra_shift)
 {
     int a0, a1, a2, a3, b0, b1, b2, b3;
 
 #if HAVE_FAST_64BIT
 #define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
     if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
-        uint64_t temp = (row[0] << DC_SHIFT) & 0xffff;
+        uint64_t temp;
+        if (DC_SHIFT - extra_shift > 0) {
+            temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
+        } else {
+            temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
+        }
         temp += temp << 16;
         temp += temp << 32;
         ((uint64_t *)row)[0] = temp;
@@ -104,7 +109,12 @@ static inline void FUNC(idctRowCondDC)(DCTELEM *row)
           ((uint32_t*)row)[2] |
           ((uint32_t*)row)[3] |
           row[1])) {
-        uint32_t temp = (row[0] << DC_SHIFT) & 0xffff;
+        uint32_t temp;
+        if (DC_SHIFT - extra_shift > 0) {
+            temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
+        } else {
+            temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
+        }
         temp += temp << 16;
         ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
             ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
@@ -150,14 +160,14 @@ static inline void FUNC(idctRowCondDC)(DCTELEM *row)
         MAC(b3, -W1, row[7]);
     }
 
-    row[0] = (a0 + b0) >> ROW_SHIFT;
-    row[7] = (a0 - b0) >> ROW_SHIFT;
-    row[1] = (a1 + b1) >> ROW_SHIFT;
-    row[6] = (a1 - b1) >> ROW_SHIFT;
-    row[2] = (a2 + b2) >> ROW_SHIFT;
-    row[5] = (a2 - b2) >> ROW_SHIFT;
-    row[3] = (a3 + b3) >> ROW_SHIFT;
-    row[4] = (a3 - b3) >> ROW_SHIFT;
+    row[0] = (a0 + b0) >> (ROW_SHIFT + extra_shift);
+    row[7] = (a0 - b0) >> (ROW_SHIFT + extra_shift);
+    row[1] = (a1 + b1) >> (ROW_SHIFT + extra_shift);
+    row[6] = (a1 - b1) >> (ROW_SHIFT + extra_shift);
+    row[2] = (a2 + b2) >> (ROW_SHIFT + extra_shift);
+    row[5] = (a2 - b2) >> (ROW_SHIFT + extra_shift);
+    row[3] = (a3 + b3) >> (ROW_SHIFT + extra_shift);
+    row[4] = (a3 - b3) >> (ROW_SHIFT + extra_shift);
 }
 
 #define IDCT_COLS do {                                  \
@@ -284,7 +294,7 @@ void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block)
     line_size /= sizeof(pixel);
 
     for (i = 0; i < 8; i++)
-        FUNC(idctRowCondDC)(block + i*8);
+        FUNC(idctRowCondDC)(block + i*8, 0);
 
     for (i = 0; i < 8; i++)
         FUNC(idctSparseColPut)(dest + i, line_size, block + i);
@@ -298,7 +308,7 @@ void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block)
     line_size /= sizeof(pixel);
 
     for (i = 0; i < 8; i++)
-        FUNC(idctRowCondDC)(block + i*8);
+        FUNC(idctRowCondDC)(block + i*8, 0);
 
     for (i = 0; i < 8; i++)
         FUNC(idctSparseColAdd)(dest + i, line_size, block + i);
@@ -309,7 +319,7 @@ void FUNC(ff_simple_idct)(DCTELEM *block)
     int i;
 
     for (i = 0; i < 8; i++)
-        FUNC(idctRowCondDC)(block + i*8);
+        FUNC(idctRowCondDC)(block + i*8, 0);
 
     for (i = 0; i < 8; i++)
         FUNC(idctSparseCol)(block + i);

+ 2 - 2
libavcodec/version.h

@@ -77,8 +77,8 @@
 #ifndef FF_API_DRC_SCALE
 #define FF_API_DRC_SCALE        (LIBAVCODEC_VERSION_MAJOR < 54)
 #endif
-#ifndef FF_API_VERY_AGGRESSIVE
-#define FF_API_VERY_AGGRESSIVE  (LIBAVCODEC_VERSION_MAJOR < 54)
+#ifndef FF_API_ER
+#define FF_API_ER               (LIBAVCODEC_VERSION_MAJOR < 54)
 #endif
 #ifndef FF_API_AVCODEC_INIT
 #define FF_API_AVCODEC_INIT     (LIBAVCODEC_VERSION_MAJOR < 54)

+ 3 - 3
libavcodec/x86/proresdsp-init.c

@@ -23,11 +23,11 @@
 #include "libavcodec/proresdsp.h"
 
 void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
-                                DCTELEM *block);
+                                DCTELEM *block, const int16_t *qmat);
 void ff_prores_idct_put_10_sse4(uint16_t *dst, int linesize,
-                                DCTELEM *block);
+                                DCTELEM *block, const int16_t *qmat);
 void ff_prores_idct_put_10_avx (uint16_t *dst, int linesize,
-                                DCTELEM *block);
+                                DCTELEM *block, const int16_t *qmat);
 
 void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx)
 {

+ 0 - 4
libavformat/asfenc.c

@@ -434,10 +434,6 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
         if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
             /* WAVEFORMATEX header */
             int wavsize = ff_put_wav_header(pb, enc);
-            if ((enc->codec_id != CODEC_ID_MP3) && (enc->codec_id != CODEC_ID_MP2) && (enc->codec_id != CODEC_ID_ADPCM_IMA_WAV) && (enc->extradata_size==0)) {
-                wavsize += 2;
-                avio_wl16(pb, 0);
-            }
 
             if (wavsize < 0)
                 return -1;

+ 15 - 8
libavformat/mov.c

@@ -2433,14 +2433,21 @@ static void mov_read_chapters(AVFormatContext *s)
         // The samples could theoretically be in any encoding if there's an encd
         // atom following, but in practice are only utf-8 or utf-16, distinguished
         // instead by the presence of a BOM
-        ch = avio_rb16(sc->pb);
-        if (ch == 0xfeff)
-            avio_get_str16be(sc->pb, len, title, title_len);
-        else if (ch == 0xfffe)
-            avio_get_str16le(sc->pb, len, title, title_len);
-        else {
-            AV_WB16(title, ch);
-            get_strz(sc->pb, title + 2, len - 1);
+        if (!len) {
+            title[0] = 0;
+        } else {
+            ch = avio_rb16(sc->pb);
+            if (ch == 0xfeff)
+                avio_get_str16be(sc->pb, len, title, title_len);
+            else if (ch == 0xfffe)
+                avio_get_str16le(sc->pb, len, title, title_len);
+            else {
+                AV_WB16(title, ch);
+                if (len == 1 || len == 2)
+                    title[len] = 0;
+                else
+                    get_strz(sc->pb, title + 2, len - 1);
+            }
         }
 
         ff_new_chapter(s, i, st->time_base, sample->timestamp, end, title);

+ 2 - 4
libavformat/riff.c

@@ -452,8 +452,6 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
         riff_extradata_start= enc->extradata;
         riff_extradata= enc->extradata + enc->extradata_size;
         hdrsize += enc->extradata_size;
-    } else if (!waveformatextensible){
-        hdrsize -= 2;
     }
     if(waveformatextensible) {                                    /* write WAVEFORMATEXTENSIBLE extensions */
         hdrsize += 22;
@@ -464,8 +462,8 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
         avio_wl32(pb, 0x00100000);
         avio_wl32(pb, 0xAA000080);
         avio_wl32(pb, 0x719B3800);
-    } else if(riff_extradata - riff_extradata_start) {
-        avio_wl16(pb, riff_extradata - riff_extradata_start);
+    } else {
+        avio_wl16(pb, riff_extradata - riff_extradata_start); /* cbSize */
     }
     avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
     if(hdrsize&1){

Some files were not shown because too many files changed in this diff