Bug 1266129 - Upgrade ffvpx to 3.0.2. . r=ajones a=ritu
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 28 Apr 2016 21:31:18 +1000
changeset 332718 ec8ac20d8d26b41d8e383451bfc3e752e4d28c17
parent 332717 e6ca64925a10f789262cc3a8ef84a0b449187998
child 332719 372b3480067a80e47d4394aafe1e0e4f13427cfe
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersajones, ritu
bugs1266129
milestone48.0a2
Bug 1266129 - Upgrade ffvpx to 3.0.2. . r=ajones a=ritu
media/ffvpx/README_MOZILLA
media/ffvpx/libavcodec/avpacket.c
media/ffvpx/libavcodec/resample.c
media/ffvpx/libavutil/channel_layout.c
media/ffvpx/libavutil/colorspace.h
media/ffvpx/libavutil/internal.h
media/ffvpx/libavutil/pixdesc.c
--- a/media/ffvpx/README_MOZILLA
+++ b/media/ffvpx/README_MOZILLA
@@ -1,11 +1,11 @@
 This directory contains files used in gecko builds from FFmpeg
 (http://ffmpeg.org). The current files are from FFmpeg as of
-revision n3.0-1-g0aa2fbd
+revision n3.0.2
 All source files match their path from the library's source archive.
 
 Currently, we only use the vp8 and vp9 portion of the library, and only on x86
 based platforms. If this changes, configuration files will most likely
 need to be updated.
 
 AVX2 must be disabled on Linux due to the use of yasm 1.1 on the build bots.
 Once yasm is upgraded to 1.2 or later, AVX2 code could be re-enabled.
--- a/media/ffvpx/libavcodec/avpacket.c
+++ b/media/ffvpx/libavcodec/avpacket.c
@@ -396,31 +396,33 @@ int av_packet_split_side_data(AVPacket *
     if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
         int i;
         unsigned int size;
         uint8_t *p;
 
         p = pkt->data + pkt->size - 8 - 5;
         for (i=1; ; i++){
             size = AV_RB32(p);
-            if (size>INT_MAX || p - pkt->data < size)
+            if (size>INT_MAX - 5 || p - pkt->data < size)
                 return 0;
             if (p[4]&128)
                 break;
+            if (p - pkt->data < size + 5)
+                return 0;
             p-= size+5;
         }
 
         pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
         if (!pkt->side_data)
             return AVERROR(ENOMEM);
 
         p= pkt->data + pkt->size - 8 - 5;
         for (i=0; ; i++){
             size= AV_RB32(p);
-            av_assert0(size<=INT_MAX && p - pkt->data >= size);
+            av_assert0(size<=INT_MAX - 5 && p - pkt->data >= size);
             pkt->side_data[i].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
             pkt->side_data[i].size = size;
             pkt->side_data[i].type = p[4]&127;
             if (!pkt->side_data[i].data)
                 return AVERROR(ENOMEM);
             memcpy(pkt->side_data[i].data, p-size, size);
             pkt->size -= size + 5;
             if(p[4]&128)
--- a/media/ffvpx/libavcodec/resample.c
+++ b/media/ffvpx/libavcodec/resample.c
@@ -286,22 +286,16 @@ int audio_resample(ReSampleContext *s, s
 {
     int i, nb_samples1;
     short *bufin[MAX_CHANNELS];
     short *bufout[MAX_CHANNELS];
     short *buftmp2[MAX_CHANNELS], *buftmp3[MAX_CHANNELS];
     short *output_bak = NULL;
     int lenout;
 
-    if (s->input_channels == s->output_channels && s->ratio == 1.0 && 0) {
-        /* nothing to do */
-        memcpy(output, input, nb_samples * s->input_channels * sizeof(short));
-        return nb_samples;
-    }
-
     if (s->sample_fmt[0] != AV_SAMPLE_FMT_S16) {
         int istride[1] = { s->sample_size[0] };
         int ostride[1] = { 2 };
         const void *ibuf[1] = { input };
         void       *obuf[1];
         unsigned input_size = nb_samples * s->input_channels * 2;
 
         if (!s->buffer_size[0] || s->buffer_size[0] < input_size) {
--- a/media/ffvpx/libavutil/channel_layout.c
+++ b/media/ffvpx/libavutil/channel_layout.c
@@ -89,17 +89,17 @@ static const struct {
     { "5.0(side)",   5,  AV_CH_LAYOUT_5POINT0 },
     { "4.1",         5,  AV_CH_LAYOUT_4POINT1 },
     { "5.1",         6,  AV_CH_LAYOUT_5POINT1_BACK },
     { "5.1(side)",   6,  AV_CH_LAYOUT_5POINT1 },
     { "6.0",         6,  AV_CH_LAYOUT_6POINT0 },
     { "6.0(front)",  6,  AV_CH_LAYOUT_6POINT0_FRONT },
     { "hexagonal",   6,  AV_CH_LAYOUT_HEXAGONAL },
     { "6.1",         7,  AV_CH_LAYOUT_6POINT1 },
-    { "6.1",         7,  AV_CH_LAYOUT_6POINT1_BACK },
+    { "6.1(back)",   7,  AV_CH_LAYOUT_6POINT1_BACK },
     { "6.1(front)",  7,  AV_CH_LAYOUT_6POINT1_FRONT },
     { "7.0",         7,  AV_CH_LAYOUT_7POINT0 },
     { "7.0(front)",  7,  AV_CH_LAYOUT_7POINT0_FRONT },
     { "7.1",         8,  AV_CH_LAYOUT_7POINT1 },
     { "7.1(wide)",   8,  AV_CH_LAYOUT_7POINT1_WIDE_BACK },
     { "7.1(wide-side)",   8,  AV_CH_LAYOUT_7POINT1_WIDE },
     { "octagonal",   8,  AV_CH_LAYOUT_OCTAGONAL },
     { "hexadecagonal", 16, AV_CH_LAYOUT_HEXADECAGONAL },
--- a/media/ffvpx/libavutil/colorspace.h
+++ b/media/ffvpx/libavutil/colorspace.h
@@ -36,16 +36,26 @@
     cb = (cb1) - 128;\
     cr = (cr1) - 128;\
     r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
     g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
             ONE_HALF;\
     b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
 }
 
+#define YUV_TO_RGB1_CCIR_BT709(cb1, cr1)\
+{\
+    cb = (cb1) - 128;\
+    cr = (cr1) - 128;\
+    r_add = FIX(1.5747*255.0/224.0) * cr + ONE_HALF;\
+    g_add = - FIX(0.1873*255.0/224.0) * cb - FIX(0.4682*255.0/224.0) * cr + \
+            ONE_HALF;\
+    b_add = FIX(1.8556*255.0/224.0) * cb + ONE_HALF;\
+}
+
 #define YUV_TO_RGB2_CCIR(r, g, b, y1)\
 {\
     y = ((y1) - 16) * FIX(255.0/219.0);\
     r = cm[(y + r_add) >> SCALEBITS];\
     g = cm[(y + g_add) >> SCALEBITS];\
     b = cm[(y + b_add) >> SCALEBITS];\
 }
 
--- a/media/ffvpx/libavutil/internal.h
+++ b/media/ffvpx/libavutil/internal.h
@@ -309,16 +309,32 @@ static av_always_inline double ff_exp10(
 }
 
 static av_always_inline float ff_exp10f(float x)
 {
     return exp2f(M_LOG2_10 * x);
 }
 
 /**
+ * Compute x^y for floating point x, y. Note: this function is faster than the
+ * libm variant due to mainly 2 reasons:
+ * 1. It does not handle any edge cases. In particular, this is only guaranteed
+ * to work correctly for x > 0.
+ * 2. It is not as accurate as a standard nearly "correctly rounded" libm variant.
+ * @param x base
+ * @param y exponent
+ * @return x^y
+ */
+static av_always_inline float ff_fast_powf(float x, float y)
+{
+    return expf(logf(x) * y);
+}
+
+
+/**
  * A wrapper for open() setting O_CLOEXEC.
  */
 av_warn_unused_result
 int avpriv_open(const char *filename, int flags, ...);
 
 int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt);
 
 static av_always_inline av_const int avpriv_mirror(int x, int w)
--- a/media/ffvpx/libavutil/pixdesc.c
+++ b/media/ffvpx/libavutil/pixdesc.c
@@ -2270,31 +2270,35 @@ enum AVPixelFormat av_pix_fmt_swap_endia
     return get_pix_fmt_internal(name);
 }
 
 #define FF_COLOR_NA      -1
 #define FF_COLOR_RGB      0 /**< RGB color space */
 #define FF_COLOR_GRAY     1 /**< gray color space */
 #define FF_COLOR_YUV      2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
 #define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
+#define FF_COLOR_XYZ      4
 
 #define pixdesc_has_alpha(pixdesc) \
     ((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & AV_PIX_FMT_FLAG_PAL)
 
 
 static int get_color_type(const AVPixFmtDescriptor *desc) {
     if (desc->flags & AV_PIX_FMT_FLAG_PAL)
         return FF_COLOR_RGB;
 
     if(desc->nb_components == 1 || desc->nb_components == 2)
         return FF_COLOR_GRAY;
 
     if(desc->name && !strncmp(desc->name, "yuvj", 4))
         return FF_COLOR_YUV_JPEG;
 
+    if(desc->name && !strncmp(desc->name, "xyz", 3))
+        return FF_COLOR_XYZ;
+
     if(desc->flags & AV_PIX_FMT_FLAG_RGB)
         return  FF_COLOR_RGB;
 
     if(desc->nb_components == 0)
         return FF_COLOR_NA;
 
     return FF_COLOR_YUV;
 }