diff options
author | Matt A. Tobin <email@mattatobin.com> | 2022-06-07 20:20:19 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2022-06-07 20:20:19 -0500 |
commit | 878ab758d5d4c1ef7badf2bc20ebc7c67dc2165b (patch) | |
tree | 3683d6df35e3618c0e7b456de7c749ca4c8c21a6 /libs/ffvpx/libavcodec/bitstream.c | |
parent | a621951327b0c19c0c24dfd9fd973f7bd13ae68f (diff) | |
parent | cfb9884423faf741de03c5fcc72bf9ac8c6ada4d (diff) | |
download | aura-central-878ab758d5d4c1ef7badf2bc20ebc7c67dc2165b.tar.gz |
Merge branch 'TRUNK' into ARE-5.0
Diffstat (limited to 'libs/ffvpx/libavcodec/bitstream.c')
-rw-r--r-- | libs/ffvpx/libavcodec/bitstream.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libs/ffvpx/libavcodec/bitstream.c b/libs/ffvpx/libavcodec/bitstream.c index ed528fe4a..53a2db745 100644 --- a/libs/ffvpx/libavcodec/bitstream.c +++ b/libs/ffvpx/libavcodec/bitstream.c @@ -162,9 +162,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, uint32_t code; volatile VLC_TYPE (* volatile table)[2]; // the double volatile is needed to prevent an internal compiler error in gcc 4.2 - table_size = 1 << table_nb_bits; if (table_nb_bits > 30) - return -1; + return AVERROR(EINVAL); + table_size = 1 << table_nb_bits; table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); if (table_index < 0) @@ -188,8 +188,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, } for (k = 0; k < nb; k++) { int bits = table[j][1]; + int oldsym = table[j][0]; ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); - if (bits != 0 && bits != n) { + if ((bits || oldsym) && (bits != n || oldsym != symbol)) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return AVERROR_INVALIDDATA; } @@ -226,6 +227,10 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, /* note: realloc has been done, so reload tables */ table = (volatile VLC_TYPE (*)[2])&vlc->table[table_index]; table[j][0] = index; //code + if (table[j][0] != index) { + avpriv_request_sample(NULL, "strange codes"); + return AVERROR_PATCHWELCOME; + } i = k-1; } } @@ -306,7 +311,7 @@ int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\ if (!(flags & INIT_VLC_USE_NEW_STATIC)) \ av_free(buf); \ - return -1; \ + return AVERROR(EINVAL); \ } \ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \ if (buf[j].code >= (1LL<<buf[j].bits)) { \ @@ -314,7 +319,7 @@ int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, "init_vlc\n", buf[j].code, i); \ if (!(flags & INIT_VLC_USE_NEW_STATIC)) \ av_free(buf); \ - return -1; \ + return AVERROR(EINVAL); \ } \ if (flags & INIT_VLC_LE) \ buf[j].code = bitswap_32(buf[j].code); \ |