ma1 pushed to branch mullvad-browser-147.0a1-16.0-2 at The Tor Project / Applications / Mullvad Browser

Commits:

1 changed file:

Changes:

  • media/libvpx/libvpx/vp9/vp9_cx_iface.c
    ... ... @@ -8,7 +8,9 @@
    8 8
      *  be found in the AUTHORS file in the root of the source tree.
    
    9 9
      */
    
    10 10
     
    
    11
    +#include <assert.h>
    
    11 12
     #include <limits.h>
    
    13
    +#include <stddef.h>
    
    12 14
     #include <stdint.h>
    
    13 15
     #include <stdlib.h>
    
    14 16
     #include <string.h>
    
    ... ... @@ -122,6 +124,7 @@ struct vpx_codec_alg_priv {
    122 124
       VP9_COMP *cpi;
    
    123 125
       unsigned char *cx_data;
    
    124 126
       size_t cx_data_sz;
    
    127
    +  // pending_cx_data either is a null pointer or points into the cx_data buffer.
    
    125 128
       unsigned char *pending_cx_data;
    
    126 129
       size_t pending_cx_data_sz;
    
    127 130
       int pending_frame_count;
    
    ... ... @@ -1252,8 +1255,12 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) {
    1252 1255
     
    
    1253 1256
       // Write the index
    
    1254 1257
       index_sz = 2 + (mag + 1) * ctx->pending_frame_count;
    
    1255
    -  if (ctx->pending_cx_data_sz + index_sz < ctx->cx_data_sz) {
    
    1256
    -    uint8_t *x = ctx->pending_cx_data + ctx->pending_cx_data_sz;
    
    1258
    +  unsigned char *cx_data_end = ctx->cx_data + ctx->cx_data_sz;
    
    1259
    +  unsigned char *pending_cx_data_end =
    
    1260
    +      ctx->pending_cx_data + ctx->pending_cx_data_sz;
    
    1261
    +  ptrdiff_t space_remaining = cx_data_end - pending_cx_data_end;
    
    1262
    +  if (index_sz <= space_remaining) {
    
    1263
    +    uint8_t *x = pending_cx_data_end;
    
    1257 1264
         int i, j;
    
    1258 1265
     #ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA
    
    1259 1266
         uint8_t marker_test = 0xc0;
    
    ... ... @@ -1284,6 +1291,8 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) {
    1284 1291
     #ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA
    
    1285 1292
         index_sz += index_sz_test;
    
    1286 1293
     #endif
    
    1294
    +  } else {
    
    1295
    +    index_sz = 0;
    
    1287 1296
       }
    
    1288 1297
       return index_sz;
    
    1289 1298
     }
    
    ... ... @@ -1621,9 +1630,12 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
    1621 1630
                   ctx->pending_frame_sizes[ctx->pending_frame_count++] = size;
    
    1622 1631
                 ctx->pending_frame_magnitude |= size;
    
    1623 1632
                 ctx->pending_cx_data_sz += size;
    
    1624
    -            // write the superframe only for the case when
    
    1625
    -            if (!ctx->output_cx_pkt_cb.output_cx_pkt)
    
    1633
    +            // write the superframe only for the case when the callback function
    
    1634
    +            // for getting per-layer packets is not registered.
    
    1635
    +            if (!ctx->output_cx_pkt_cb.output_cx_pkt) {
    
    1626 1636
                   size += write_superframe_index(ctx);
    
    1637
    +              assert(size <= cx_data_sz);
    
    1638
    +            }
    
    1627 1639
                 pkt.data.frame.buf = ctx->pending_cx_data;
    
    1628 1640
                 pkt.data.frame.sz = ctx->pending_cx_data_sz;
    
    1629 1641
                 ctx->pending_cx_data = NULL;