Changeset 1bdc212 in ffmpeg


Ignore:
Timestamp:
Dec 18, 2011, 2:04:44 AM (13 years ago)
Author:
Michael Niedermayer <michaelni@gmx.at>
Branches:
master
Children:
38331d20
Parents:
1a2484fc (diff), 0ea5b442 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Michael Niedermayer <michaelni@gmx.at> (12/18/11 01:23:57)
git-committer:
Michael Niedermayer <michaelni@gmx.at> (12/18/11 02:04:44)
Message:

Merge remote-tracking branch 'qatar/master'

  • qatar/master: build: link test programs with static libraries dct-test: remove unused variable cropTbl swscale: fix overflow in gray16 vertical scaling. get_bits: remove LAST_SKIP_CACHE macro swscale: fix integer overflows in RGB pixel writing. swscale: add endian conversion for RGB555 and RGB444 pixel formats swscale: fix overflows in output of RGB48 pixels. get_bits: remove strange/obsolete comments get_bits: whitespace (mostly) cosmetics swscale: add rgb565 endianess conversion get_bits: remove unnecessary #includes mp3dec: hack: fix decoding with safe bitstream reader fate: fix eatqi test adpcm: Check for channels to be a non-zero integer swscale: fix overflows in RGB rounding constants. get_bits: introduce safe bitreading to prevent overreads.

Conflicts:

libswscale/swscale.c
libswscale/swscale_unscaled.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • configure

    r1a2484fc r1bdc212  
    117117  --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
    118118  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
     119  --disable-safe-bitstream-reader
     120                           disable buffer boundary checking in bitreaders
     121                           (faster, but may crash)
    119122  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
    120123  --disable-everything     disable all components listed below
     
    10611064    rtpdec
    10621065    runtime_cpudetect
     1066    safe_bitstream_reader
    10631067    shared
    10641068    sinewin
     
    18131817enable network
    18141818enable optimizations
     1819enable safe_bitstream_reader
    18151820enable static
    18161821enable swscale_alpha
  • libavcodec/adpcm.c

    r1a2484fc r1bdc212  
    102102        break;
    103103    }
    104     if(avctx->channels > max_channels){
    105         return -1;
     104    if (avctx->channels <= 0 || avctx->channels > max_channels) {
     105        av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
     106        return AVERROR(EINVAL);
    106107    }
    107108
  • libavcodec/dct-test.c

    r1a2484fc r1bdc212  
    171171#define AANSCALE_BITS 12
    172172
    173 static uint8_t cropTbl[256 + 2 * MAX_NEG_CROP];
    174 
    175173static int64_t gettime(void)
    176174{
     
    557555    ff_ref_dct_init();
    558556    idct_mmx_init();
    559 
    560     for (i = 0; i < 256; i++)
    561         cropTbl[i + MAX_NEG_CROP] = i;
    562     for (i = 0; i < MAX_NEG_CROP; i++) {
    563         cropTbl[i] = 0;
    564         cropTbl[i + MAX_NEG_CROP + 256] = 255;
    565     }
    566557
    567558    for (;;) {
  • libavcodec/get_bits.h

    r1a2484fc r1bdc212  
    2828
    2929#include <stdint.h>
    30 #include <stdlib.h>
    31 #include <assert.h>
    32 #include "libavutil/bswap.h"
    3330#include "libavutil/common.h"
    3431#include "libavutil/intreadwrite.h"
     
    3633#include "mathops.h"
    3734
    38 /* bit input */
    39 /* buffer, buffer_end and size_in_bits must be present and used by every reader */
     35/*
     36 * Safe bitstream reading:
     37 * optionally, the get_bits API can check to ensure that we
     38 * don't read past input buffer boundaries. This is protected
     39 * with CONFIG_SAFE_BITSTREAM_READER at the global level, and
     40 * then below that with UNCHECKED_BITSTREAM_READER at the per-
     41 * decoder level. This means that decoders that check internally
     42 * can "#define UNCHECKED_BITSTREAM_READER 1" to disable
     43 * overread checks.
     44 * Boundary checking causes a minor performance penalty so for
     45 * applications that won't want/need this, it can be disabled
     46 * globally using "#define CONFIG_SAFE_BITSTREAM_READER 0".
     47 */
     48#ifndef UNCHECKED_BITSTREAM_READER
     49#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
     50#endif
     51
    4052typedef struct GetBitContext {
    4153    const uint8_t *buffer, *buffer_end;
    4254    int index;
    4355    int size_in_bits;
     56    int size_in_bits_plus8;
    4457} GetBitContext;
    4558
     
    94107    will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
    95108
    96 LAST_SKIP_CACHE(name, gb, num)
    97     will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
    98 
    99109LAST_SKIP_BITS(name, gb, num)
    100     is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER
     110    like SKIP_BITS, to be used if next call is UPDATE_CACHE or CLOSE_READER
    101111
    102112for examples see get_bits, show_bits, skip_bits, get_vlc
     
    109119#endif
    110120
    111 #   define OPEN_READER(name, gb)                \
     121#define OPEN_READER(name, gb)                   \
    112122    unsigned int name##_index = (gb)->index;    \
    113123    av_unused unsigned int name##_cache
    114124
    115 #   define CLOSE_READER(name, gb) (gb)->index = name##_index
    116 
    117 # ifdef ALT_BITSTREAM_READER_LE
     125#define CLOSE_READER(name, gb) (gb)->index = name##_index
     126
     127#ifdef ALT_BITSTREAM_READER_LE
     128
    118129# ifdef LONG_BITSTREAM_READER
    119 #   define UPDATE_CACHE(name, gb) \
    120     name##_cache = AV_RL64((gb)->buffer+(name##_index>>3)) >> (name##_index&0x07)
     130#   define UPDATE_CACHE(name, gb) name##_cache = \
     131        AV_RL64((gb)->buffer + (name##_index >> 3)) >> (name##_index & 7)
    121132# else
    122 #   define UPDATE_CACHE(name, gb) \
    123     name##_cache = AV_RL32((gb)->buffer+(name##_index>>3)) >> (name##_index&0x07)
     133#   define UPDATE_CACHE(name, gb) name##_cache = \
     134        AV_RL32((gb)->buffer + (name##_index >> 3)) >> (name##_index & 7)
    124135# endif
    125136
    126 #   define SKIP_CACHE(name, gb, num) name##_cache >>= (num)
     137# define SKIP_CACHE(name, gb, num) name##_cache >>= (num)
     138
     139#else
     140
     141# ifdef LONG_BITSTREAM_READER
     142#   define UPDATE_CACHE(name, gb) name##_cache = \
     143        AV_RB64((gb)->buffer + (name##_index >> 3)) >> (32 - (name##_index & 7))
    127144# else
    128 # ifdef LONG_BITSTREAM_READER
    129 #   define UPDATE_CACHE(name, gb) \
    130     name##_cache = AV_RB64((gb)->buffer+(name##_index >> 3)) >> (32 - (name##_index & 0x07))
    131 # else
    132 #   define UPDATE_CACHE(name, gb) \
    133     name##_cache = AV_RB32((gb)->buffer+(name##_index>>3)) << (name##_index&0x07)
     145#   define UPDATE_CACHE(name, gb) name##_cache = \
     146        AV_RB32((gb)->buffer + (name##_index >> 3)) << (name##_index & 7)
    134147# endif
    135148
    136 #   define SKIP_CACHE(name, gb, num) name##_cache <<= (num)
    137 # endif
    138 
    139 // FIXME name?
     149# define SKIP_CACHE(name, gb, num) name##_cache <<= (num)
     150
     151#endif
     152
     153#if UNCHECKED_BITSTREAM_READER
    140154#   define SKIP_COUNTER(name, gb, num) name##_index += (num)
    141 
    142 #   define SKIP_BITS(name, gb, num) do {        \
     155#else
     156#   define SKIP_COUNTER(name, gb, num) \
     157    name##_index = FFMIN((gb)->size_in_bits_plus8, name##_index + (num))
     158#endif
     159
     160#define SKIP_BITS(name, gb, num) do {           \
    143161        SKIP_CACHE(name, gb, num);              \
    144162        SKIP_COUNTER(name, gb, num);            \
    145163    } while (0)
    146164
    147 #   define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
    148 #   define LAST_SKIP_CACHE(name, gb, num)
    149 
    150 # ifdef ALT_BITSTREAM_READER_LE
     165#define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
     166
     167#ifdef ALT_BITSTREAM_READER_LE
    151168#   define SHOW_UBITS(name, gb, num) zero_extend(name##_cache, num)
    152 
    153169#   define SHOW_SBITS(name, gb, num) sign_extend(name##_cache, num)
    154 # else
     170#else
    155171#   define SHOW_UBITS(name, gb, num) NEG_USR32(name##_cache, num)
    156 
    157172#   define SHOW_SBITS(name, gb, num) NEG_SSR32(name##_cache, num)
    158 # endif
    159 
    160 #   define GET_CACHE(name, gb) ((uint32_t)name##_cache)
    161 
    162 static inline int get_bits_count(const GetBitContext *s){
     173#endif
     174
     175#define GET_CACHE(name, gb) ((uint32_t)name##_cache)
     176
     177static inline int get_bits_count(const GetBitContext *s)
     178{
    163179    return s->index;
    164180}
    165181
    166182static inline void skip_bits_long(GetBitContext *s, int n){
     183#if UNCHECKED_BITSTREAM_READER
    167184    s->index += n;
     185#else
     186    s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index);
     187#endif
    168188}
    169189
     
    172192 * if MSB not set it is negative
    173193 * @param n length in bits
    174  * @author BERO
    175  */
    176 static inline int get_xbits(GetBitContext *s, int n){
     194 */
     195static inline int get_xbits(GetBitContext *s, int n)
     196{
    177197    register int sign;
    178198    register int32_t cache;
     
    186206}
    187207
    188 static inline int get_sbits(GetBitContext *s, int n){
     208static inline int get_sbits(GetBitContext *s, int n)
     209{
    189210    register int tmp;
    190211    OPEN_READER(re, s);
     
    199220 * Read 1-25 bits.
    200221 */
    201 static inline unsigned int get_bits(GetBitContext *s, int n){
     222static inline unsigned int get_bits(GetBitContext *s, int n)
     223{
    202224    register int tmp;
    203225    OPEN_READER(re, s);
     
    212234 * Show 1-25 bits.
    213235 */
    214 static inline unsigned int show_bits(GetBitContext *s, int n){
     236static inline unsigned int show_bits(GetBitContext *s, int n)
     237{
    215238    register int tmp;
    216239    OPEN_READER(re, s);
     
    220243}
    221244
    222 static inline void skip_bits(GetBitContext *s, int n){
    223  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
     245static inline void skip_bits(GetBitContext *s, int n)
     246{
    224247    OPEN_READER(re, s);
    225248    UPDATE_CACHE(re, s);
     
    228251}
    229252
    230 static inline unsigned int get_bits1(GetBitContext *s){
     253static inline unsigned int get_bits1(GetBitContext *s)
     254{
    231255    unsigned int index = s->index;
    232256    uint8_t result = s->buffer[index>>3];
     
    238262    result >>= 8 - 1;
    239263#endif
    240     index++;
     264#if !UNCHECKED_BITSTREAM_READER
     265    if (s->index < s->size_in_bits_plus8)
     266#endif
     267        index++;
    241268    s->index = index;
    242269
     
    244271}
    245272
    246 static inline unsigned int show_bits1(GetBitContext *s){
     273static inline unsigned int show_bits1(GetBitContext *s)
     274{
    247275    return show_bits(s, 1);
    248276}
    249277
    250 static inline void skip_bits1(GetBitContext *s){
     278static inline void skip_bits1(GetBitContext *s)
     279{
    251280    skip_bits(s, 1);
    252281}
     
    255284 * Read 0-32 bits.
    256285 */
    257 static inline unsigned int get_bits_long(GetBitContext *s, int n){
    258     if (n <= MIN_CACHE_BITS) return get_bits(s, n);
     286static inline unsigned int get_bits_long(GetBitContext *s, int n)
     287{
     288    if (n <= MIN_CACHE_BITS)
     289        return get_bits(s, n);
    259290    else {
    260291#ifdef ALT_BITSTREAM_READER_LE
     
    271302 * Read 0-32 bits as a signed integer.
    272303 */
    273 static inline int get_sbits_long(GetBitContext *s, int n) {
     304static inline int get_sbits_long(GetBitContext *s, int n)
     305{
    274306    return sign_extend(get_bits_long(s, n), n);
    275307}
     
    278310 * Show 0-32 bits.
    279311 */
    280 static inline unsigned int show_bits_long(GetBitContext *s, int n){
    281     if (n <= MIN_CACHE_BITS) return show_bits(s, n);
     312static inline unsigned int show_bits_long(GetBitContext *s, int n)
     313{
     314    if (n <= MIN_CACHE_BITS)
     315        return show_bits(s, n);
    282316    else {
    283317        GetBitContext gb = *s;
     
    300334 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
    301335 * @param bit_size the size of the buffer in bits
    302  *
    303  * While GetBitContext stores the buffer size, for performance reasons you are
    304  * responsible for checking for the buffer end yourself (take advantage of the padding)!
    305  */
    306 static inline void init_get_bits(GetBitContext *s,
    307                    const uint8_t *buffer, int bit_size)
     336 */
     337static inline void init_get_bits(GetBitContext *s, const uint8_t *buffer,
     338                                 int bit_size)
    308339{
    309340    int buffer_size = (bit_size+7)>>3;
     
    315346    s->buffer       = buffer;
    316347    s->size_in_bits = bit_size;
     348    s->size_in_bits_plus8 = bit_size + 8;
    317349    s->buffer_end   = buffer + buffer_size;
    318350    s->index        = 0;
     
    356388 * is undefined.
    357389 */
    358 #define GET_VLC(code, name, gb, table, bits, max_depth) do {    \
     390#define GET_VLC(code, name, gb, table, bits, max_depth)         \
     391    do {                                                        \
    359392        int n, nb_bits;                                         \
    360393        unsigned int index;                                     \
     
    387420    } while (0)
    388421
    389 #define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update) do { \
     422#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update) \
     423    do {                                                                \
    390424        int n, nb_bits;                                                 \
    391425        unsigned int index;                                             \
     
    413447
    414448/**
    415  * Parse a vlc code, faster than get_vlc().
     449 * Parse a vlc code.
    416450 * @param bits is the number of bits which will be read at once, must be
    417451 *             identical to nb_bits in init_vlc()
     
    421455 */
    422456static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
    423                                   int bits, int max_depth)
     457                                     int bits, int max_depth)
    424458{
    425459    int code;
     
    434468}
    435469
    436 static inline int decode012(GetBitContext *gb){
     470static inline int decode012(GetBitContext *gb)
     471{
    437472    int n;
    438473    n = get_bits1(gb);
     
    443478}
    444479
    445 static inline int decode210(GetBitContext *gb){
     480static inline int decode210(GetBitContext *gb)
     481{
    446482    if (get_bits1(gb))
    447483        return 0;
     
    458494
    459495#ifdef TRACE
    460 static inline void print_bin(int bits, int n){
     496static inline void print_bin(int bits, int n)
     497{
    461498    int i;
    462499
     
    469506
    470507static inline int get_bits_trace(GetBitContext *s, int n, char *file,
    471                                  const char *func, int line){
     508                                 const char *func, int line)
     509{
    472510    int r = get_bits(s, n);
    473511
     
    479517static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
    480518                                int bits, int max_depth, char *file,
    481                                 const char *func, int line){
     519                                const char *func, int line)
     520{
    482521    int show  = show_bits(s, 24);
    483522    int pos   = get_bits_count(s);
     
    493532}
    494533static inline int get_xbits_trace(GetBitContext *s, int n, char *file,
    495                                   const char *func, int line){
     534                                  const char *func, int line)
     535{
    496536    int show = show_bits(s, n);
    497537    int r    = get_xbits(s, n);
  • libavcodec/mpeg4videodec.c

    r1a2484fc r1bdc212  
    931931
    932932                last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
    933                 run=   SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
     933                run=   SHOW_UBITS(re, &s->gb, 6);
    934934                SKIP_COUNTER(re, &s->gb, 1+1+6);
    935935                UPDATE_CACHE(re, &s->gb);
     
    948948
    949949                level=  level * qmul + qadd;
    950                 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_CACHE(re, &s->gb, 1);
     950                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
    951951                SKIP_COUNTER(re, &s->gb, 1+11+5+1);
    952952
     
    965965                    SKIP_CACHE(re, &s->gb, 2);
    966966                    last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
    967                     run=   SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
     967                    run=   SHOW_UBITS(re, &s->gb, 6);
    968968                    SKIP_COUNTER(re, &s->gb, 2+1+6);
    969969                    UPDATE_CACHE(re, &s->gb);
     
    982982                            av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in 3. esc\n");
    983983                            return -1;
    984                         }; LAST_SKIP_CACHE(re, &s->gb, 1);
     984                        }
    985985
    986986                        SKIP_COUNTER(re, &s->gb, 1+12+1);
  • libavcodec/mpegaudiodec.c

    r1a2484fc r1bdc212  
    2424 * MPEG Audio decoder
    2525 */
     26
     27#define UNCHECKED_BITSTREAM_READER 1
    2628
    2729#include "libavutil/audioconvert.h"
     
    14351437        s->in_gb = s->gb;
    14361438        init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8);
     1439#if CONFIG_SAFE_BITSTREAM_READER
     1440        s->gb.size_in_bits_plus8 += EXTRABYTES * 8;
     1441#endif
    14371442        skip_bits_long(&s->gb, 8*(s->last_buf_size - main_data_begin));
    14381443    }
  • libavcodec/msmpeg4.c

    r1a2484fc r1bdc212  
    16921692                        last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
    16931693                        run=   SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
    1694                         level= SHOW_SBITS(re, &s->gb, 8); LAST_SKIP_CACHE(re, &s->gb, 8);
     1694                        level= SHOW_SBITS(re, &s->gb, 8);
    16951695                        SKIP_COUNTER(re, &s->gb, 1+6+8);
    16961696                    }else{
  • libavcodec/wmavoice.c

    r1a2484fc r1bdc212  
    2525 * @author Ronald S. Bultje <rsbultje@gmail.com>
    2626 */
     27
     28#define UNCHECKED_BITSTREAM_READER 1
    2729
    2830#include <math.h>
  • library.mak

    r1a2484fc r1bdc212  
    9898
    9999$(EXAMPLES) $(TESTPROGS) $(TOOLS): $(THIS_LIB) $(DEP_LIBS)
     100$(TESTPROGS): $(SUBDIR)$(LIBNAME)
    100101
    101102examples: $(EXAMPLES)
  • libswscale/swscale.c

    r1a2484fc r1bdc212  
    484484    for (i = 0; i < (dstW >> 1); i++) {
    485485        int j;
    486         int Y1 = 1 << 14;
    487         int Y2 = 1 << 14;
     486        int Y1 = (1 << 14) - 0x40000000;
     487        int Y2 = (1 << 14) - 0x40000000;
    488488
    489489        for (j = 0; j < lumFilterSize; j++) {
     
    493493        Y1 >>= 15;
    494494        Y2 >>= 15;
    495         if ((Y1 | Y2) & 0x10000) {
    496             Y1 = av_clip_uint16(Y1);
    497             Y2 = av_clip_uint16(Y2);
    498         }
    499         output_pixel(&dest[i * 2 + 0], Y1);
    500         output_pixel(&dest[i * 2 + 1], Y2);
     495        Y1 = av_clip_int16(Y1);
     496        Y2 = av_clip_int16(Y2);
     497        output_pixel(&dest[i * 2 + 0], 0x8000 + Y1);
     498        output_pixel(&dest[i * 2 + 1], 0x8000 + Y2);
    501499    }
    502500}
     
    852850    for (i = 0; i < (dstW >> 1); i++) {
    853851        int j;
    854         int Y1 = 0;
    855         int Y2 = 0;
     852        int Y1 = -0x40000000;
     853        int Y2 = -0x40000000;
    856854        int U  = -128 << 23; // 19
    857855        int V  = -128 << 23;
     
    869867        // 8bit: 12+15=27; 16-bit: 12+19=31
    870868        Y1 >>= 14; // 10
     869        Y1 += 0x10000;
    871870        Y2 >>= 14;
     871        Y2 += 0x10000;
    872872        U  >>= 14;
    873873        V  >>= 14;
     
    10161016
    10171017static av_always_inline void
    1018 yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
    1019               int U, int V, int A1, int A2,
     1018yuv2rgb_write(uint8_t *_dest, int i, unsigned Y1, unsigned Y2,
     1019              unsigned U, unsigned V, unsigned A1, unsigned A2,
    10201020              const void *_r, const void *_g, const void *_b, int y,
    10211021              enum PixelFormat target, int hasAlpha)
     
    15541554                       int rsh,   int gsh,   int bsh, int S)
    15551555{
    1556     const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh,
    1557               rnd = (32<<((S)-1)) + (1<<(S-7));
     1556    const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh;
     1557    const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
    15581558    int i;
    15591559
     
    15771577{
    15781578    const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
    1579               rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
    1580               rnd = (256<<((S)-1)) + (1<<(S-7));
     1579              rv = RV << rsh, gv = GV << gsh, bv = BV << bsh;
     1580    const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
    15811581    int i;
    15821582
     
    16021602    const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
    16031603              rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
    1604               rnd = (256U<<(S)) + (1<<(S-6)), maskgx = ~(maskr | maskb);
     1604              maskgx = ~(maskr | maskb);
     1605    const unsigned rnd = (256U<<(S)) + (1<<(S-6));
    16051606    int i;
    16061607
  • libswscale/swscale_unscaled.c

    r1a2484fc r1bdc212  
    668668}
    669669
     670
     671#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt)          \
     672    ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) ||     \
     673     (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
     674
     675
    670676void ff_get_unscaled_swscale(SwsContext *c)
    671677{
     
    697703    if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND))
    698704        c->swScale= bgr24ToYv12Wrapper;
    699 
    700     /* bswap 16 bits per component packed formats */
    701     if ((srcFormat == PIX_FMT_RGB48LE  && dstFormat == PIX_FMT_RGB48BE)  ||
    702         (srcFormat == PIX_FMT_RGB48BE  && dstFormat == PIX_FMT_RGB48LE)  ||
    703         (srcFormat == PIX_FMT_BGR48LE  && dstFormat == PIX_FMT_BGR48BE)  ||
    704         (srcFormat == PIX_FMT_BGR48BE  && dstFormat == PIX_FMT_BGR48LE)  ||
    705         (srcFormat == PIX_FMT_GRAY16LE && dstFormat == PIX_FMT_GRAY16BE) ||
    706         (srcFormat == PIX_FMT_GRAY16BE && dstFormat == PIX_FMT_GRAY16LE))
    707         c->swScale = packed_16bpc_bswap;
    708705
    709706    /* RGB/BGR -> RGB/BGR (no dither needed forms) */
     
    735732    if (isAnyRGB(srcFormat) && isPlanar(srcFormat) && isByteRGB(dstFormat))
    736733        c->swScale= planarRgbToRgbWrapper;
     734
     735    /* bswap 16 bits per pixel/component packed formats */
     736    if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR444) ||
     737        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR48)  ||
     738        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR555) ||
     739        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR565) ||
     740        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_GRAY16) ||
     741        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB444) ||
     742        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB48)  ||
     743        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB555) ||
     744        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB565))
     745        c->swScale = packed_16bpc_bswap;
    737746
    738747    if (usePal(srcFormat) && isByteRGB(dstFormat))
  • tests/fate.mak

    r1a2484fc r1bdc212  
    9090fate-ea-tgv-ima-ea-sead: CMD = framecrc  -i $(SAMPLES)/ea-tgv/INTEL_S.TGV -pix_fmt rgb24
    9191FATE_TESTS += fate-ea-tqi-adpcm
    92 fate-ea-tqi-adpcm: CMD = framecrc  -i $(SAMPLES)/ea-wve/networkBackbone-partial.wve
     92fate-ea-tqi-adpcm: CMD = framecrc  -i $(SAMPLES)/ea-wve/networkBackbone-partial.wve -frames:v 26
    9393FATE_TESTS += fate-ea-vp60
    9494fate-ea-vp60: CMD = framecrc  -i $(SAMPLES)/ea-vp6/g36.vp6
  • tests/ref/fate/ea-tqi-adpcm

    r1a2484fc r1bdc212  
    50501, 144000, 5936, 0x2174304d
    51510, 150000, 115200, 0x0c256424
    52 0, 156000, 115200, 0xa9cdd8d2
Note: See TracChangeset for help on using the changeset viewer.