~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavcodec/4xm.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-30 14:27:42 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430142742-quvblxk1tj6adlh5
Tags: 4:0.7~b1-1ubuntu1
* Merge from debian. Remaining changes:
  - don't build against libfaad, libdirac, librtmp and libopenjpeg
    (all in universe)
  - explicitly --enable-pic on powerpc, cf. LP #654666
  - different arm configure bits that should probably better be
    merged into debian
* Cherry-picked from git: 
  - install doc/APIChanges and refer to them in NEWS.Debian (Closes: #623682)
  - don't try to install non-existing documentation, fixes FTBFS on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * 4XM codec
3
3
 * Copyright (c) 2003 Michael Niedermayer
4
4
 *
5
 
 * This file is part of FFmpeg.
 
5
 * This file is part of Libav.
6
6
 *
7
 
 * FFmpeg is free software; you can redistribute it and/or
 
7
 * Libav is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU Lesser General Public
9
9
 * License as published by the Free Software Foundation; either
10
10
 * version 2.1 of the License, or (at your option) any later version.
11
11
 *
12
 
 * FFmpeg is distributed in the hope that it will be useful,
 
12
 * Libav is distributed in the hope that it will be useful,
13
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
15
 * Lesser General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with FFmpeg; if not, write to the Free Software
 
18
 * License along with Libav; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
 
260
260
    }
261
261
}
262
262
 
 
263
#if HAVE_BIGENDIAN
 
264
#define LE_CENTRIC_MUL(dst, src, scale, dc) \
 
265
    { \
 
266
        unsigned tmpval = AV_RN32(src);                 \
 
267
        tmpval = (tmpval <<  16) | (tmpval >>  16);     \
 
268
        tmpval = tmpval * (scale) + (dc);               \
 
269
        tmpval = (tmpval <<  16) | (tmpval >>  16);     \
 
270
        AV_WN32A(dst, tmpval);                          \
 
271
    }
 
272
#else
 
273
#define LE_CENTRIC_MUL(dst, src, scale, dc) \
 
274
    { \
 
275
        unsigned tmpval = AV_RN32(src) * (scale) + (dc); \
 
276
        AV_WN32A(dst, tmpval);                           \
 
277
    }
 
278
#endif
 
279
 
263
280
static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc){
264
281
   int i;
265
282
   dc*= 0x10001;
274
291
        break;
275
292
    case 1:
276
293
        for(i=0; i<h; i++){
277
 
            ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
 
294
            LE_CENTRIC_MUL(dst, src, scale, dc);
278
295
            if(scale) src += stride;
279
296
            dst += stride;
280
297
        }
281
298
        break;
282
299
    case 2:
283
300
        for(i=0; i<h; i++){
284
 
            ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
285
 
            ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc;
 
301
            LE_CENTRIC_MUL(dst,     src,     scale, dc);
 
302
            LE_CENTRIC_MUL(dst + 2, src + 2, scale, dc);
286
303
            if(scale) src += stride;
287
304
            dst += stride;
288
305
        }
289
306
        break;
290
307
    case 3:
291
308
        for(i=0; i<h; i++){
292
 
            ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
293
 
            ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc;
294
 
            ((uint32_t*)dst)[2] = scale*((uint32_t*)src)[2] + dc;
295
 
            ((uint32_t*)dst)[3] = scale*((uint32_t*)src)[3] + dc;
 
309
            LE_CENTRIC_MUL(dst,     src,     scale, dc);
 
310
            LE_CENTRIC_MUL(dst + 2, src + 2, scale, dc);
 
311
            LE_CENTRIC_MUL(dst + 4, src + 4, scale, dc);
 
312
            LE_CENTRIC_MUL(dst + 6, src + 6, scale, dc);
296
313
            if(scale) src += stride;
297
314
            dst += stride;
298
315
        }
333
350
            av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
334
351
            return;
335
352
        }
336
 
        mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++));
 
353
        mcdc(dst, src, log2w, h, stride, 1, av_le2ne16(*f->wordstream++));
337
354
    }else if(code == 5){
338
 
        mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++));
 
355
        mcdc(dst, src, log2w, h, stride, 0, av_le2ne16(*f->wordstream++));
339
356
    }else if(code == 6){
340
357
        if(log2w){
341
 
            dst[0] = le2me_16(*f->wordstream++);
342
 
            dst[1] = le2me_16(*f->wordstream++);
 
358
            dst[0] = av_le2ne16(*f->wordstream++);
 
359
            dst[1] = av_le2ne16(*f->wordstream++);
343
360
        }else{
344
 
            dst[0     ] = le2me_16(*f->wordstream++);
345
 
            dst[stride] = le2me_16(*f->wordstream++);
 
361
            dst[0     ] = av_le2ne16(*f->wordstream++);
 
362
            dst[stride] = av_le2ne16(*f->wordstream++);
346
363
        }
347
364
    }
348
365
}
774
791
        if(decode_i_frame(f, buf, frame_size) < 0)
775
792
            return -1;
776
793
    }else if(frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")){
 
794
        if(!f->last_picture.data[0]){
 
795
            f->last_picture.reference= 1;
 
796
            if(avctx->get_buffer(avctx, &f->last_picture) < 0){
 
797
                av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 
798
                return -1;
 
799
            }
 
800
        }
 
801
 
777
802
        p->pict_type= FF_P_TYPE;
778
803
        if(decode_p_frame(f, buf, frame_size) < 0)
779
804
            return -1;
840
865
    return 0;
841
866
}
842
867
 
843
 
AVCodec fourxm_decoder = {
 
868
AVCodec ff_fourxm_decoder = {
844
869
    "4xm",
845
870
    AVMEDIA_TYPE_VIDEO,
846
871
    CODEC_ID_4XM,