Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
mpegvideo_enc: only allocate output packet when we know there will be output
Add names for more channel layouts to the channel layout map.
sunrast: Add a sample request for RMP_RAW colormap.
avcodec: do not override pts or duration from the audio encoder
Add prores regression test.
Enable already existing rso regression test.
Add regression test for "sox" format muxer/demuxer.
Add dpx encoding regression test.
swscale: K&R formatting cosmetics for PowerPC code (part I/II)
img2: Use ff_guess_image2_codec(filename) shorthand where appropriate.
Clarify licensing information about files borrowed from libjpeg.
Mark mutable static data const where appropriate.
avplay: fix -threads option
dvbsubdec: avoid undefined signed left shift in RGBA macro
mlpdec: use av_log_ask_for_sample()
gif: K&R formatting cosmetics
png: make .long_name more descriptive
movdec: Adjust keyframe flagging in fragmented files
rv34: change most "int stride" into "ptrdiff_t stride".

Conflicts:
avprobe.c
ffplay.c
libavcodec/mlpdec.c
libavcodec/mpegvideo_enc.c
libavcodec/pngenc.c
libavcodec/x86/v210-init.c
libavfilter/vf_boxblur.c
libavfilter/vf_crop.c
libavfilter/vf_drawtext.c
libavfilter/vf_lut.c
libavfilter/vf_overlay.c
libavfilter/vf_pad.c
libavfilter/vf_scale.c
libavfilter/vf_select.c
libavfilter/vf_setpts.c
libavfilter/vf_settb.c
libavformat/img2.c
libavutil/audioconvert.c
tests/codec-regression.sh
tests/lavf-regression.sh
tests/ref/lavf/dpx
tests/ref/vsynth1/prores
tests/ref/vsynth2/prores

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

Michael Niedermayer authored on 2012/02/22 09:35:41
Showing 42 changed files
... ...
@@ -20,8 +20,12 @@ Specifically, the GPL parts of FFmpeg are
20 20
 
21 21
 There are a handful of files under other licensing terms, namely:
22 22
 
23
-* The files libavcodec/jfdctfst.c, libavcodec/jfdctint.c, libavcodec/jrevdct.c
24
-  are taken from libjpeg, see the top of the files for licensing details.
23
+* The files libavcodec/jfdctfst.c, libavcodec/jfdctint_template.c and
24
+  libavcodec/jrevdct.c are taken from libjpeg, see the top of the files for
25
+  licensing details. Specifically note that you must credit the IJG in the
26
+  documentation accompanying your program if you only distribute executables.
27
+  You must also indicate any changes including additions and deletions to
28
+  those three files in the documentation.
25 29
 
26 30
 Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then
27 31
 the configure parameter --enable-version3 will activate this licensing option
... ...
@@ -68,13 +68,13 @@ static const OptionDef options[];
68 68
 static const char *input_filename;
69 69
 static AVInputFormat *iformat = NULL;
70 70
 
71
-static const char *binary_unit_prefixes [] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
72
-static const char *decimal_unit_prefixes[] = { "", "K" , "M" , "G" , "T" , "P"  };
71
+static const char *const binary_unit_prefixes [] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
72
+static const char *const decimal_unit_prefixes[] = { "", "K" , "M" , "G" , "T" , "P"  };
73 73
 
74
-static const char *unit_second_str          = "s"    ;
75
-static const char *unit_hertz_str           = "Hz"   ;
76
-static const char *unit_byte_str            = "byte" ;
77
-static const char *unit_bit_per_second_str  = "bit/s";
74
+static const char unit_second_str[]         = "s"    ;
75
+static const char unit_hertz_str[]          = "Hz"   ;
76
+static const char unit_byte_str[]           = "byte" ;
77
+static const char unit_bit_per_second_str[] = "bit/s";
78 78
 static uint64_t *nb_streams_packets;
79 79
 static uint64_t *nb_streams_frames;
80 80
 
... ...
@@ -1872,7 +1872,7 @@ static int http_parse_request(HTTPContext *c)
1872 1872
 
1873 1873
 static void fmt_bytecount(AVIOContext *pb, int64_t count)
1874 1874
 {
1875
-    static const char *suffix = " kMGTP";
1875
+    static const char suffix[] = " kMGTP";
1876 1876
     const char *s;
1877 1877
 
1878 1878
     for (s = suffix; count >= 100000 && s[1]; count /= 1000, s++);
... ...
@@ -1036,7 +1036,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
1036 1036
     int offset[3] = { global_gain, global_gain - 90, 0 };
1037 1037
     int clipped_offset;
1038 1038
     int noise_flag = 1;
1039
-    static const char *sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" };
1039
+    static const char *const sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" };
1040 1040
     for (g = 0; g < ics->num_window_groups; g++) {
1041 1041
         for (i = 0; i < ics->max_sfb;) {
1042 1042
             int run_end = band_type_run_end[idx];
... ...
@@ -27,8 +27,8 @@ void ff_rv34_inv_transform_noround_neon(DCTELEM *block);
27 27
 
28 28
 void ff_rv34_inv_transform_noround_dc_neon(DCTELEM *block);
29 29
 
30
-void ff_rv34_idct_add_neon(uint8_t *dst, int stride, DCTELEM *block);
31
-void ff_rv34_idct_dc_add_neon(uint8_t *dst, int stride, int dc);
30
+void ff_rv34_idct_add_neon(uint8_t *dst, ptrdiff_t stride, DCTELEM *block);
31
+void ff_rv34_idct_dc_add_neon(uint8_t *dst, ptrdiff_t stride, int dc);
32 32
 
33 33
 void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext* dsp)
34 34
 {
... ...
@@ -51,20 +51,20 @@ void ff_put_rv40_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
51 51
 void ff_avg_rv40_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int);
52 52
 void ff_avg_rv40_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
53 53
 
54
-void ff_rv40_weight_func_16_neon(uint8_t *, uint8_t *, uint8_t *, int, int, int);
55
-void ff_rv40_weight_func_8_neon(uint8_t *, uint8_t *, uint8_t *, int, int, int);
54
+void ff_rv40_weight_func_16_neon(uint8_t *, uint8_t *, uint8_t *, int, int, ptrdiff_t);
55
+void ff_rv40_weight_func_8_neon(uint8_t *, uint8_t *, uint8_t *, int, int, ptrdiff_t);
56 56
 
57
-int ff_rv40_h_loop_filter_strength_neon(uint8_t *src, int stride,
57
+int ff_rv40_h_loop_filter_strength_neon(uint8_t *src, ptrdiff_t stride,
58 58
                                         int beta, int beta2, int edge,
59 59
                                         int *p1, int *q1);
60
-int ff_rv40_v_loop_filter_strength_neon(uint8_t *src, int stride,
60
+int ff_rv40_v_loop_filter_strength_neon(uint8_t *src, ptrdiff_t stride,
61 61
                                         int beta, int beta2, int edge,
62 62
                                         int *p1, int *q1);
63 63
 
64
-void ff_rv40_h_weak_loop_filter_neon(uint8_t *src, int stride, int filter_p1,
64
+void ff_rv40_h_weak_loop_filter_neon(uint8_t *src, ptrdiff_t stride, int filter_p1,
65 65
                                      int filter_q1, int alpha, int beta,
66 66
                                      int lim_p0q0, int lim_q1, int lim_p1);
67
-void ff_rv40_v_weak_loop_filter_neon(uint8_t *src, int stride, int filter_p1,
67
+void ff_rv40_v_weak_loop_filter_neon(uint8_t *src, ptrdiff_t stride, int filter_p1,
68 68
                                      int filter_q1, int alpha, int beta,
69 69
                                      int lim_p0q0, int lim_q1, int lim_p1);
70 70
 
... ...
@@ -150,7 +150,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
150 150
 }
151 151
 #endif
152 152
 
153
-#define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
153
+#define RGBA(r,g,b,a) (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
154 154
 
155 155
 typedef struct DVBSubCLUT {
156 156
     int id;
... ...
@@ -77,7 +77,7 @@ typedef struct VP8EncoderContext {
77 77
 } VP8Context;
78 78
 
79 79
 /** String mappings for enum vp8e_enc_control_id */
80
-static const char *ctlidstr[] = {
80
+static const char *const ctlidstr[] = {
81 81
     [VP8E_UPD_ENTROPY]           = "VP8E_UPD_ENTROPY",
82 82
     [VP8E_UPD_REFERENCE]         = "VP8E_UPD_REFERENCE",
83 83
     [VP8E_USE_REFERENCE]         = "VP8E_USE_REFERENCE",
... ...
@@ -48,7 +48,7 @@ int ff_xvid_rate_control_init(MpegEncContext *s){
48 48
     }
49 49
 
50 50
     for(i=0; i<s->rc_context.num_entries; i++){
51
-        static const char *frame_types = " ipbs";
51
+        static const char frame_types[] = " ipbs";
52 52
         char tmp[256];
53 53
         RateControlEntry *rce;
54 54
 
... ...
@@ -38,12 +38,6 @@
38 38
 /** number of bits used for VLC lookup - longest Huffman code is 9 */
39 39
 #define VLC_BITS            9
40 40
 
41
-
42
-static const char* sample_message =
43
-    "Please file a bug report following the instructions at "
44
-    "http://ffmpeg.org/bugreports.html and include "
45
-    "a sample of this file.";
46
-
47 41
 typedef struct SubStream {
48 42
     /// Set if a valid restart header has been read. Otherwise the substream cannot be decoded.
49 43
     uint8_t     restart_seen;
... ...
@@ -308,10 +302,10 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
308 308
         return AVERROR_INVALIDDATA;
309 309
     }
310 310
     if (mh.num_substreams > MAX_SUBSTREAMS) {
311
-        av_log(m->avctx, AV_LOG_ERROR,
311
+        av_log_ask_for_sample(m->avctx,
312 312
                "Number of substreams %d is larger than the maximum supported "
313
-               "by the decoder. %s\n", mh.num_substreams, sample_message);
314
-        return AVERROR_INVALIDDATA;
313
+               "by the decoder.\n", mh.num_substreams);
314
+        return AVERROR_PATCHWELCOME;
315 315
     }
316 316
 
317 317
     m->access_unit_size      = mh.access_unit_size;
... ...
@@ -410,10 +404,10 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
410 410
     /* This should happen for TrueHD streams with >6 channels and MLP's noise
411 411
      * type. It is not yet known if this is allowed. */
412 412
     if (s->max_channel > MAX_MATRIX_CHANNEL_MLP && !s->noise_type) {
413
-        av_log(m->avctx, AV_LOG_ERROR,
413
+        av_log_ask_for_sample(m->avctx,
414 414
                "Number of channels %d is larger than the maximum supported "
415
-               "by the decoder. %s\n", s->max_channel+2, sample_message);
416
-        return AVERROR_INVALIDDATA;
415
+               "by the decoder.\n", s->max_channel + 2);
416
+        return AVERROR_PATCHWELCOME;
417 417
     }
418 418
 
419 419
     if (s->min_channel > s->max_channel) {
... ...
@@ -455,10 +449,10 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
455 455
     for (ch = 0; ch <= s->max_matrix_channel; ch++) {
456 456
         int ch_assign = get_bits(gbp, 6);
457 457
         if (ch_assign > s->max_matrix_channel) {
458
-            av_log(m->avctx, AV_LOG_ERROR,
459
-                   "Assignment of matrix channel %d to invalid output channel %d. %s\n",
460
-                   ch, ch_assign, sample_message);
461
-            return AVERROR_INVALIDDATA;
458
+            av_log_ask_for_sample(m->avctx,
459
+                   "Assignment of matrix channel %d to invalid output channel %d.\n",
460
+                   ch, ch_assign);
461
+            return AVERROR_PATCHWELCOME;
462 462
         }
463 463
         s->ch_assign[ch_assign] = ch;
464 464
     }
... ...
@@ -813,8 +807,8 @@ static int read_block_data(MLPDecodeContext *m, GetBitContext *gbp,
813 813
     if (s->data_check_present) {
814 814
         expected_stream_pos  = get_bits_count(gbp);
815 815
         expected_stream_pos += get_bits(gbp, 16);
816
-        av_log(m->avctx, AV_LOG_WARNING, "This file contains some features "
817
-               "we have not tested yet. %s\n", sample_message);
816
+        av_log_ask_for_sample(m->avctx, "This file contains some features "
817
+                              "we have not tested yet.\n");
818 818
     }
819 819
 
820 820
     if (s->blockpos + s->blocksize > m->access_unit_size) {
... ...
@@ -1395,20 +1395,6 @@ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
1395 1395
     int i, stuffing_count, ret;
1396 1396
     int context_count = s->slice_context_count;
1397 1397
 
1398
-    if (!pkt->data &&
1399
-        (ret = ff_alloc_packet(pkt, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
1400
-        return ret;
1401
-
1402
-    for (i = 0; i < context_count; i++) {
1403
-        int start_y = s->thread_context[i]->start_mb_y;
1404
-        int   end_y = s->thread_context[i]->  end_mb_y;
1405
-        int h       = s->mb_height;
1406
-        uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h);
1407
-        uint8_t *end   = pkt->data + (size_t)(((int64_t) pkt->size) *   end_y / h);
1408
-
1409
-        init_put_bits(&s->thread_context[i]->pb, start, end - start);
1410
-    }
1411
-
1412 1398
     s->picture_in_gop_number++;
1413 1399
 
1414 1400
     if (load_input_picture(s, pic_arg) < 0)
... ...
@@ -1420,6 +1406,20 @@ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
1420 1420
 
1421 1421
     /* output? */
1422 1422
     if (s->new_picture.f.data[0]) {
1423
+        if (!pkt->data &&
1424
+            (ret = ff_alloc_packet(pkt, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
1425
+            return ret;
1426
+
1427
+        for (i = 0; i < context_count; i++) {
1428
+            int start_y = s->thread_context[i]->start_mb_y;
1429
+            int   end_y = s->thread_context[i]->  end_mb_y;
1430
+            int h       = s->mb_height;
1431
+            uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h);
1432
+            uint8_t *end   = pkt->data + (size_t)(((int64_t) pkt->size) *   end_y / h);
1433
+
1434
+            init_put_bits(&s->thread_context[i]->pb, start, end - start);
1435
+        }
1436
+
1423 1437
         s->pict_type = s->new_picture.f.pict_type;
1424 1438
         //emms_c();
1425 1439
         //printf("qs:%f %f %d\n", s->new_picture.quality,
... ...
@@ -732,5 +732,5 @@ AVCodec ff_png_decoder = {
732 732
     .close          = png_dec_end,
733 733
     .decode         = decode_frame,
734 734
     .capabilities   = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
735
-    .long_name = NULL_IF_CONFIG_SMALL("PNG image"),
735
+    .long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
736 736
 };
... ...
@@ -445,5 +445,5 @@ AVCodec ff_png_encoder = {
445 445
                                           PIX_FMT_GRAY8, PIX_FMT_GRAY8A,
446 446
                                           PIX_FMT_GRAY16BE,
447 447
                                           PIX_FMT_MONOBLACK, PIX_FMT_NONE},
448
-    .long_name= NULL_IF_CONFIG_SMALL("PNG image"),
448
+    .long_name= NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
449 449
 };
... ...
@@ -53,7 +53,7 @@ static av_always_inline void rv34_row_transform(int temp[16], DCTELEM *block)
53 53
  * Real Video 3.0/4.0 inverse transform + sample reconstruction
54 54
  * Code is almost the same as in SVQ3, only scaling is different.
55 55
  */
56
-static void rv34_idct_add_c(uint8_t *dst, int stride, DCTELEM *block){
56
+static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){
57 57
     int      temp[16];
58 58
     uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
59 59
     int      i;
... ...
@@ -101,7 +101,7 @@ static void rv34_inv_transform_noround_c(DCTELEM *block){
101 101
     }
102 102
 }
103 103
 
104
-static void rv34_idct_dc_add_c(uint8_t *dst, int stride, int dc)
104
+static void rv34_idct_dc_add_c(uint8_t *dst, ptrdiff_t stride, int dc)
105 105
 {
106 106
     const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
107 107
     int i, j;
... ...
@@ -32,24 +32,24 @@
32 32
 typedef void (*rv40_weight_func)(uint8_t *dst/*align width (8 or 16)*/,
33 33
                                  uint8_t *src1/*align width (8 or 16)*/,
34 34
                                  uint8_t *src2/*align width (8 or 16)*/,
35
-                                 int w1, int w2, int stride);
35
+                                 int w1, int w2, ptrdiff_t stride);
36 36
 
37 37
 typedef void (*rv34_inv_transform_func)(DCTELEM *block);
38 38
 
39
-typedef void (*rv34_idct_add_func)(uint8_t *dst, int stride, DCTELEM *block);
40
-typedef void (*rv34_idct_dc_add_func)(uint8_t *dst, int stride,
39
+typedef void (*rv34_idct_add_func)(uint8_t *dst, ptrdiff_t stride, DCTELEM *block);
40
+typedef void (*rv34_idct_dc_add_func)(uint8_t *dst, ptrdiff_t stride,
41 41
                                       int   dc);
42 42
 
43
-typedef void (*rv40_weak_loop_filter_func)(uint8_t *src, int stride,
43
+typedef void (*rv40_weak_loop_filter_func)(uint8_t *src, ptrdiff_t stride,
44 44
                                            int filter_p1, int filter_q1,
45 45
                                            int alpha, int beta,
46 46
                                            int lims, int lim_q1, int lim_p1);
47 47
 
48
-typedef void (*rv40_strong_loop_filter_func)(uint8_t *src, int stride,
48
+typedef void (*rv40_strong_loop_filter_func)(uint8_t *src, ptrdiff_t stride,
49 49
                                              int alpha, int lims,
50 50
                                              int dmode, int chroma);
51 51
 
52
-typedef int (*rv40_loop_filter_strength_func)(uint8_t *src, int stride,
52
+typedef int (*rv40_loop_filter_strength_func)(uint8_t *src, ptrdiff_t stride,
53 53
                                               int beta, int beta2, int edge,
54 54
                                               int *p1, int *q1);
55 55
 
... ...
@@ -278,7 +278,7 @@ RV40_CHROMA_MC(put_, op_put)
278 278
 RV40_CHROMA_MC(avg_, op_avg)
279 279
 
280 280
 #define RV40_WEIGHT_FUNC(size) \
281
-static void rv40_weight_func_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, int stride)\
281
+static void rv40_weight_func_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, ptrdiff_t stride)\
282 282
 {\
283 283
     int i, j;\
284 284
 \
... ...
@@ -316,7 +316,7 @@ static const uint8_t rv40_dither_r[16] = {
316 316
  */
317 317
 static av_always_inline void rv40_weak_loop_filter(uint8_t *src,
318 318
                                                    const int step,
319
-                                                   const int stride,
319
+                                                   const ptrdiff_t stride,
320 320
                                                    const int filter_p1,
321 321
                                                    const int filter_q1,
322 322
                                                    const int alpha,
... ...
@@ -362,7 +362,7 @@ static av_always_inline void rv40_weak_loop_filter(uint8_t *src,
362 362
     }
363 363
 }
364 364
 
365
-static void rv40_h_weak_loop_filter(uint8_t *src, const int stride,
365
+static void rv40_h_weak_loop_filter(uint8_t *src, const ptrdiff_t stride,
366 366
                                     const int filter_p1, const int filter_q1,
367 367
                                     const int alpha, const int beta,
368 368
                                     const int lim_p0q0, const int lim_q1,
... ...
@@ -372,7 +372,7 @@ static void rv40_h_weak_loop_filter(uint8_t *src, const int stride,
372 372
                           alpha, beta, lim_p0q0, lim_q1, lim_p1);
373 373
 }
374 374
 
375
-static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,
375
+static void rv40_v_weak_loop_filter(uint8_t *src, const ptrdiff_t stride,
376 376
                                     const int filter_p1, const int filter_q1,
377 377
                                     const int alpha, const int beta,
378 378
                                     const int lim_p0q0, const int lim_q1,
... ...
@@ -384,7 +384,7 @@ static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,
384 384
 
385 385
 static av_always_inline void rv40_strong_loop_filter(uint8_t *src,
386 386
                                                      const int step,
387
-                                                     const int stride,
387
+                                                     const ptrdiff_t stride,
388 388
                                                      const int alpha,
389 389
                                                      const int lims,
390 390
                                                      const int dmode,
... ...
@@ -440,14 +440,14 @@ static av_always_inline void rv40_strong_loop_filter(uint8_t *src,
440 440
     }
441 441
 }
442 442
 
443
-static void rv40_h_strong_loop_filter(uint8_t *src, const int stride,
443
+static void rv40_h_strong_loop_filter(uint8_t *src, const ptrdiff_t stride,
444 444
                                       const int alpha, const int lims,
445 445
                                       const int dmode, const int chroma)
446 446
 {
447 447
     rv40_strong_loop_filter(src, stride, 1, alpha, lims, dmode, chroma);
448 448
 }
449 449
 
450
-static void rv40_v_strong_loop_filter(uint8_t *src, const int stride,
450
+static void rv40_v_strong_loop_filter(uint8_t *src, const ptrdiff_t stride,
451 451
                                       const int alpha, const int lims,
452 452
                                       const int dmode, const int chroma)
453 453
 {
... ...
@@ -455,7 +455,7 @@ static void rv40_v_strong_loop_filter(uint8_t *src, const int stride,
455 455
 }
456 456
 
457 457
 static av_always_inline int rv40_loop_filter_strength(uint8_t *src,
458
-                                                      int step, int stride,
458
+                                                      int step, ptrdiff_t stride,
459 459
                                                       int beta, int beta2,
460 460
                                                       int edge,
461 461
                                                       int *p1, int *q1)
... ...
@@ -490,14 +490,14 @@ static av_always_inline int rv40_loop_filter_strength(uint8_t *src,
490 490
     return strong0 && strong1;
491 491
 }
492 492
 
493
-static int rv40_h_loop_filter_strength(uint8_t *src, int stride,
493
+static int rv40_h_loop_filter_strength(uint8_t *src, ptrdiff_t stride,
494 494
                                        int beta, int beta2, int edge,
495 495
                                        int *p1, int *q1)
496 496
 {
497 497
     return rv40_loop_filter_strength(src, stride, 1, beta, beta2, edge, p1, q1);
498 498
 }
499 499
 
500
-static int rv40_v_loop_filter_strength(uint8_t *src, int stride,
500
+static int rv40_v_loop_filter_strength(uint8_t *src, ptrdiff_t stride,
501 501
                                        int beta, int beta2, int edge,
502 502
                                        int *p1, int *q1)
503 503
 {
... ...
@@ -77,7 +77,11 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
77 77
         av_log(avctx, AV_LOG_ERROR, "invalid image size\n");
78 78
         return AVERROR_INVALIDDATA;
79 79
     }
80
-    if (maptype & ~1) {
80
+    if (maptype == RMT_RAW) {
81
+        av_log_ask_for_sample(avctx, "unsupported colormap type\n");
82
+        return AVERROR_PATCHWELCOME;
83
+    }
84
+    if (maptype > RMT_RAW) {
81 85
         av_log(avctx, AV_LOG_ERROR, "invalid colormap type\n");
82 86
         return AVERROR_INVALIDDATA;
83 87
     }
... ...
@@ -992,9 +992,11 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
992 992
         ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
993 993
         if (!ret && *got_packet_ptr) {
994 994
             if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) {
995
-                avpkt->pts = frame->pts;
996
-                avpkt->duration = ff_samples_to_time_base(avctx,
997
-                                                          frame->nb_samples);
995
+                if (avpkt->pts == AV_NOPTS_VALUE)
996
+                    avpkt->pts = frame->pts;
997
+                if (!avpkt->duration)
998
+                    avpkt->duration = ff_samples_to_time_base(avctx,
999
+                                                              frame->nb_samples);
998 1000
             }
999 1001
             avpkt->dts = avpkt->pts;
1000 1002
         } else {
... ...
@@ -26,8 +26,8 @@
26 26
 
27 27
 void ff_rv34_idct_dc_mmx2(DCTELEM *block);
28 28
 void ff_rv34_idct_dc_noround_mmx2(DCTELEM *block);
29
-void ff_rv34_idct_dc_add_mmx(uint8_t *dst, int stride, int dc);
30
-void ff_rv34_idct_dc_add_sse4(uint8_t *dst, int stride, int dc);
29
+void ff_rv34_idct_dc_add_mmx(uint8_t *dst, ptrdiff_t stride, int dc);
30
+void ff_rv34_idct_dc_add_sse4(uint8_t *dst, ptrdiff_t stride, int dc);
31 31
 
32 32
 av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c, DSPContext *dsp)
33 33
 {
... ...
@@ -42,9 +42,9 @@ void ff_avg_rv40_chroma_mc4_3dnow(uint8_t *dst, uint8_t *src,
42 42
 
43 43
 #define DECLARE_WEIGHT(opt) \
44 44
 void ff_rv40_weight_func_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
45
-                                  int w1, int w2, int stride); \
45
+                                  int w1, int w2, ptrdiff_t stride); \
46 46
 void ff_rv40_weight_func_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
47
-                                  int w1, int w2, int stride);
47
+                                  int w1, int w2, ptrdiff_t stride);
48 48
 DECLARE_WEIGHT(mmx)
49 49
 DECLARE_WEIGHT(sse2)
50 50
 DECLARE_WEIGHT(ssse3)
... ...
@@ -1,18 +1,18 @@
1 1
 /*
2
- * This file is part of Libav.
2
+ * This file is part of FFmpeg.
3 3
  *
4
- * Libav is free software; you can redistribute it and/or
4
+ * FFmpeg is free software; you can redistribute it and/or
5 5
  * modify it under the terms of the GNU Lesser General Public
6 6
  * License as published by the Free Software Foundation; either
7 7
  * version 2.1 of the License, or (at your option) any later version.
8 8
  *
9
- * Libav is distributed in the hope that it will be useful,
9
+ * FFmpeg is distributed in the hope that it will be useful,
10 10
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 12
  * Lesser General Public License for more details.
13 13
  *
14 14
  * You should have received a copy of the GNU Lesser General Public
15
- * License along with Libav; if not, write to the Free Software
15
+ * License along with FFmpeg; if not, write to the Free Software
16 16
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
  */
18 18
 
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/pixdesc.h"
31 31
 #include "avfilter.h"
32 32
 
33
-static const char * const var_names[] = {
33
+static const char *const var_names[] = {
34 34
     "w",
35 35
     "h",
36 36
     "cw",
... ...
@@ -32,7 +32,7 @@
32 32
 #include "libavutil/imgutils.h"
33 33
 #include "libavutil/mathematics.h"
34 34
 
35
-static const char * const var_names[] = {
35
+static const char *const var_names[] = {
36 36
     "in_w", "iw",   ///< width  of the input video
37 37
     "in_h", "ih",   ///< height of the input video
38 38
     "out_w", "ow",  ///< width  of the cropped video
... ...
@@ -51,7 +51,7 @@
51 51
 #include FT_FREETYPE_H
52 52
 #include FT_GLYPH_H
53 53
 
54
-static const char * const var_names[] = {
54
+static const char *const var_names[] = {
55 55
     "main_w", "w", "W",       ///< width  of the input video
56 56
     "main_h", "h", "H",       ///< height of the input video
57 57
     "tw", "text_w",           ///< width  of the rendered text
... ...
@@ -72,8 +72,8 @@ static const char * const var_names[] = {
72 72
     NULL
73 73
 };
74 74
 
75
-static const char *fun2_names[] = {
76
-    "rand",
75
+static const char *const fun2_names[] = {
76
+    "rand"
77 77
 };
78 78
 
79 79
 static double drand(void *opaque, double min, double max)
... ...
@@ -30,7 +30,7 @@
30 30
 #include "avfilter.h"
31 31
 #include "internal.h"
32 32
 
33
-static const char * const var_names[] = {
33
+static const char *const var_names[] = {
34 34
     "w",        ///< width of the input video
35 35
     "h",        ///< height of the input video
36 36
     "val",      ///< input value for the pixel
... ...
@@ -38,7 +38,7 @@
38 38
 #include "internal.h"
39 39
 #include "drawutils.h"
40 40
 
41
-static const char * const var_names[] = {
41
+static const char *const var_names[] = {
42 42
     "main_w",    "W", ///< width  of the main    video
43 43
     "main_h",    "H", ///< height of the main    video
44 44
     "overlay_w", "w", ///< width  of the overlay video
... ...
@@ -35,7 +35,7 @@
35 35
 #include "libavutil/mathematics.h"
36 36
 #include "drawutils.h"
37 37
 
38
-static const char * const var_names[] = {
38
+static const char *const var_names[] = {
39 39
     "in_w",   "iw",
40 40
     "in_h",   "ih",
41 41
     "out_w",  "ow",
... ...
@@ -31,7 +31,7 @@
31 31
 #include "libavutil/avassert.h"
32 32
 #include "libswscale/swscale.h"
33 33
 
34
-static const char * const var_names[] = {
34
+static const char *const var_names[] = {
35 35
     "in_w",   "iw",
36 36
     "in_h",   "ih",
37 37
     "out_w",  "ow",
... ...
@@ -27,7 +27,7 @@
27 27
 #include "libavutil/fifo.h"
28 28
 #include "avfilter.h"
29 29
 
30
-static const char * const var_names[] = {
30
+static const char *const var_names[] = {
31 31
     "TB",                ///< timebase
32 32
 
33 33
     "pts",               ///< original pts in the file of the frame
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/mathematics.h"
31 31
 #include "avfilter.h"
32 32
 
33
-static const char * const var_names[] = {
33
+static const char *const var_names[] = {
34 34
     "INTERLACED",  ///< tell if the current frame is interlaced
35 35
     "N",           ///< frame number (starting at zero)
36 36
     "POS",         ///< original position in the file of the frame
... ...
@@ -30,7 +30,7 @@
30 30
 #include "avfilter.h"
31 31
 #include "internal.h"
32 32
 
33
-static const char * const var_names[] = {
33
+static const char *const var_names[] = {
34 34
     "AVTB",   /* default timebase 1/AV_TIME_BASE */
35 35
     "intb",   /* input timebase */
36 36
     NULL
... ...
@@ -53,7 +53,9 @@
53 53
 #define GIF_CHUNKS 100
54 54
 
55 55
 /* slows down the decoding (and some browsers don't like it) */
56
-/* update on the 'some browsers don't like it issue from above: this was probably due to missing 'Data Sub-block Terminator' (byte 19) in the app_header */
56
+/* update on the 'some browsers don't like it issue from above:
57
+ * this was probably due to missing 'Data Sub-block Terminator'
58
+ * (byte 19) in the app_header */
57 59
 #define GIF_ADD_APP_HEADER // required to enable looping of animated gif
58 60
 
59 61
 typedef struct {
... ...
@@ -65,8 +67,15 @@ typedef struct {
65 65
 /* we use the standard 216 color palette */
66 66
 
67 67
 /* this script was used to create the palette:
68
- * for r in 00 33 66 99 cc ff; do for g in 00 33 66 99 cc ff; do echo -n "    "; for b in 00 33 66 99 cc ff; do
69
- *   echo -n "{ 0x$r, 0x$g, 0x$b }, "; done; echo ""; done; done
68
+ * for r in 00 33 66 99 cc ff; do
69
+ *     for g in 00 33 66 99 cc ff; do
70
+ *         echo -n "    "
71
+ *         for b in 00 33 66 99 cc ff; do
72
+ *             echo -n "{ 0x$r, 0x$g, 0x$b }, "
73
+ *         done
74
+ *         echo ""
75
+ *     done
76
+ * done
70 77
  */
71 78
 
72 79
 static const rgb_triplet gif_clut[216] = {
... ...
@@ -109,9 +118,8 @@ static const rgb_triplet gif_clut[216] = {
109 109
 };
110 110
 
111 111
 /* GIF header */
112
-static int gif_image_write_header(AVIOContext *pb,
113
-                                  int width, int height, int loop_count,
114
-                                  uint32_t *palette)
112
+static int gif_image_write_header(AVIOContext *pb, int width, int height,
113
+                                  int loop_count, uint32_t *palette)
115 114
 {
116 115
     int i;
117 116
     unsigned int v;
... ...
@@ -127,44 +135,45 @@ static int gif_image_write_header(AVIOContext *pb,
127 127
 
128 128
     /* the global palette */
129 129
     if (!palette) {
130
-        avio_write(pb, (const unsigned char *)gif_clut, 216*3);
131
-        for(i=0;i<((256-216)*3);i++)
130
+        avio_write(pb, (const unsigned char *)gif_clut, 216 * 3);
131
+        for (i = 0; i < ((256 - 216) * 3); i++)
132 132
             avio_w8(pb, 0);
133 133
     } else {
134
-        for(i=0;i<256;i++) {
134
+        for (i = 0; i < 256; i++) {
135 135
             v = palette[i];
136 136
             avio_w8(pb, (v >> 16) & 0xff);
137
-            avio_w8(pb, (v >> 8) & 0xff);
138
-            avio_w8(pb, (v) & 0xff);
137
+            avio_w8(pb, (v >>  8) & 0xff);
138
+            avio_w8(pb, (v)       & 0xff);
139 139
         }
140 140
     }
141 141
 
142
-        /*        update: this is the 'NETSCAPE EXTENSION' that allows for looped animated gif
143
-                see http://members.aol.com/royalef/gifabout.htm#net-extension
144
-
145
-                byte   1       : 33 (hex 0x21) GIF Extension code
146
-                byte   2       : 255 (hex 0xFF) Application Extension Label
147
-                byte   3       : 11 (hex (0x0B) Length of Application Block
148
-                                         (eleven bytes of data to follow)
149
-                bytes  4 to 11 : "NETSCAPE"
150
-                bytes 12 to 14 : "2.0"
151
-                byte  15       : 3 (hex 0x03) Length of Data Sub-Block
152
-                                         (three bytes of data to follow)
153
-                byte  16       : 1 (hex 0x01)
154
-                bytes 17 to 18 : 0 to 65535, an unsigned integer in
155
-                                         lo-hi byte format. This indicate the
156
-                                         number of iterations the loop should
157
-                                         be executed.
158
-                bytes 19       : 0 (hex 0x00) a Data Sub-block Terminator
159
-        */
142
+    /* update: this is the 'NETSCAPE EXTENSION' that allows for looped animated
143
+     * GIF, see http://members.aol.com/royalef/gifabout.htm#net-extension
144
+     *
145
+     * byte   1       : 33 (hex 0x21) GIF Extension code
146
+     * byte   2       : 255 (hex 0xFF) Application Extension Label
147
+     * byte   3       : 11 (hex (0x0B) Length of Application Block
148
+     *                          (eleven bytes of data to follow)
149
+     * bytes  4 to 11 : "NETSCAPE"
150
+     * bytes 12 to 14 : "2.0"
151
+     * byte  15       : 3 (hex 0x03) Length of Data Sub-Block
152
+     *                          (three bytes of data to follow)
153
+     * byte  16       : 1 (hex 0x01)
154
+     * bytes 17 to 18 : 0 to 65535, an unsigned integer in
155
+     *                          lo-hi byte format. This indicate the
156
+     *                          number of iterations the loop should
157
+     *                          be executed.
158
+     * bytes 19       : 0 (hex 0x00) a Data Sub-block Terminator
159
+     */
160 160
 
161 161
     /* application extension header */
162 162
 #ifdef GIF_ADD_APP_HEADER
163 163
     if (loop_count >= 0 && loop_count <= 65535) {
164
-    avio_w8(pb, 0x21);
165
-    avio_w8(pb, 0xff);
166
-    avio_w8(pb, 0x0b);
167
-        avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1);  // bytes 4 to 14
164
+        avio_w8(pb, 0x21);
165
+        avio_w8(pb, 0xff);
166
+        avio_w8(pb, 0x0b);
167
+        // bytes 4 to 14
168
+        avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1);
168 169
         avio_w8(pb, 0x03); // byte 15
169 170
         avio_w8(pb, 0x01); // byte 16
170 171
         avio_wl16(pb, (uint16_t)loop_count);
... ...
@@ -180,7 +189,6 @@ static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
180 180
     return (((r) / 47) % 6) * 6 * 6 + (((g) / 47) % 6) * 6 + (((b) / 47) % 6);
181 181
 }
182 182
 
183
-
184 183
 static int gif_image_write_image(AVIOContext *pb,
185 184
                                  int x1, int y1, int width, int height,
186 185
                                  const uint8_t *buf, int linesize, int pix_fmt)
... ...
@@ -201,45 +209,44 @@ static int gif_image_write_image(AVIOContext *pb,
201 201
 
202 202
     avio_w8(pb, 0x08);
203 203
 
204
-    left= width * height;
204
+    left = width * height;
205 205
 
206 206
     init_put_bits(&p, buffer, 130);
207 207
 
208 208
 /*
209
- * the thing here is the bitstream is written as little packets, with a size byte before
210
- * but it's still the same bitstream between packets (no flush !)
209
+ * the thing here is the bitstream is written as little packets, with a size
210
+ * byte before but it's still the same bitstream between packets (no flush !)
211 211
  */
212 212
     ptr = buf;
213
-    w = width;
214
-    while(left>0) {
215
-
213
+    w   = width;
214
+    while (left > 0) {
216 215
         put_bits(&p, 9, 0x0100); /* clear code */
217 216
 
218
-        for(i=(left<GIF_CHUNKS)?left:GIF_CHUNKS;i;i--) {
217
+        for (i = (left < GIF_CHUNKS) ? left : GIF_CHUNKS; i; i--) {
219 218
             if (pix_fmt == PIX_FMT_RGB24) {
220
-                v = gif_clut_index(ptr[0], ptr[1], ptr[2]);
221
-                ptr+=3;
219
+                v    = gif_clut_index(ptr[0], ptr[1], ptr[2]);
220
+                ptr += 3;
222 221
             } else {
223 222
                 v = *ptr++;
224 223
             }
225 224
             put_bits(&p, 9, v);
226 225
             if (--w == 0) {
227
-                w = width;
226
+                w    = width;
228 227
                 buf += linesize;
229
-                ptr = buf;
228
+                ptr  = buf;
230 229
             }
231 230
         }
232 231
 
233
-        if(left<=GIF_CHUNKS) {
232
+        if (left <= GIF_CHUNKS) {
234 233
             put_bits(&p, 9, 0x101); /* end of stream */
235 234
             flush_put_bits(&p);
236 235
         }
237
-        if(put_bits_ptr(&p) - p.buf > 0) {
236
+        if (put_bits_ptr(&p) - p.buf > 0) {
238 237
             avio_w8(pb, put_bits_ptr(&p) - p.buf); /* byte count of the packet */
239 238
             avio_write(pb, p.buf, put_bits_ptr(&p) - p.buf); /* the actual buffer */
240 239
             p.buf_ptr = p.buf; /* dequeue the bytes off the bitstream */
241 240
         }
242
-        left-=GIF_CHUNKS;
241
+        left -= GIF_CHUNKS;
243 242
     }
244 243
     avio_w8(pb, 0x00); /* end of image block */
245 244
 
... ...
@@ -261,14 +268,14 @@ static int gif_write_header(AVFormatContext *s)
261 261
     int i, width, height /*, rate*/;
262 262
 
263 263
 /* XXX: do we reject audio streams or just ignore them ?
264
-    if(s->nb_streams > 1)
265
-        return -1;
266
-*/
267
-    gif->time = 0;
264
+ *  if (s->nb_streams > 1)
265
+ *      return -1;
266
+ */
267
+    gif->time      = 0;
268 268
     gif->file_time = 0;
269 269
 
270 270
     video_enc = NULL;
271
-    for(i=0;i<s->nb_streams;i++) {
271
+    for (i = 0; i < s->nb_streams; i++) {
272 272
         enc = s->streams[i]->codec;
273 273
         if (enc->codec_type != AVMEDIA_TYPE_AUDIO)
274 274
             video_enc = enc;
... ...
@@ -278,13 +285,14 @@ static int gif_write_header(AVFormatContext *s)
278 278
         av_free(gif);
279 279
         return -1;
280 280
     } else {
281
-        width = video_enc->width;
281
+        width  = video_enc->width;
282 282
         height = video_enc->height;
283 283
 //        rate = video_enc->time_base.den;
284 284
     }
285 285
 
286 286
     if (video_enc->pix_fmt != PIX_FMT_RGB24) {
287
-        av_log(s, AV_LOG_ERROR, "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");
287
+        av_log(s, AV_LOG_ERROR,
288
+               "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");
288 289
         return AVERROR(EIO);
289 290
     }
290 291
 
... ...
@@ -294,8 +302,8 @@ static int gif_write_header(AVFormatContext *s)
294 294
     return 0;
295 295
 }
296 296
 
297
-static int gif_write_video(AVFormatContext *s,
298
-                           AVCodecContext *enc, const uint8_t *buf, int size)
297
+static int gif_write_video(AVFormatContext *s, AVCodecContext *enc,
298
+                           const uint8_t *buf, int size)
299 299
 {
300 300
     AVIOContext *pb = s->pb;
301 301
     int jiffies;
... ...
@@ -311,7 +319,7 @@ static int gif_write_video(AVFormatContext *s,
311 311
     /* XXX: should use delay, in order to be more accurate */
312 312
     /* instead of using the same rounded value each time */
313 313
     /* XXX: don't even remember if I really use it for now */
314
-    jiffies = (70*enc->time_base.num/enc->time_base.den) - 1;
314
+    jiffies = (70 * enc->time_base.num / enc->time_base.den) - 1;
315 315
 
316 316
     avio_wl16(pb, jiffies);
317 317
 
... ...
@@ -346,7 +354,8 @@ static int gif_write_trailer(AVFormatContext *s)
346 346
 #define OFFSET(x) offsetof(GIFContext, x)
347 347
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
348 348
 static const AVOption options[] = {
349
-    { "loop", "Number of times to loop the output.", OFFSET(loop), AV_OPT_TYPE_INT, {0}, 0, 65535, ENC },
349
+    { "loop", "Number of times to loop the output.", OFFSET(loop),
350
+      AV_OPT_TYPE_INT, { 0 }, 0, 65535, ENC },
350 351
     { NULL },
351 352
 };
352 353
 
... ...
@@ -358,15 +367,15 @@ static const AVClass gif_muxer_class = {
358 358
 };
359 359
 
360 360
 AVOutputFormat ff_gif_muxer = {
361
-    .name              = "gif",
362
-    .long_name         = NULL_IF_CONFIG_SMALL("GIF Animation"),
363
-    .mime_type         = "image/gif",
364
-    .extensions        = "gif",
365
-    .priv_data_size    = sizeof(GIFContext),
366
-    .audio_codec       = CODEC_ID_NONE,
367
-    .video_codec       = CODEC_ID_RAWVIDEO,
368
-    .write_header      = gif_write_header,
369
-    .write_packet      = gif_write_packet,
370
-    .write_trailer     = gif_write_trailer,
371
-    .priv_class = &gif_muxer_class,
361
+    .name           = "gif",
362
+    .long_name      = NULL_IF_CONFIG_SMALL("GIF Animation"),
363
+    .mime_type      = "image/gif",
364
+    .extensions     = "gif",
365
+    .priv_data_size = sizeof(GIFContext),
366
+    .audio_codec    = CODEC_ID_NONE,
367
+    .video_codec    = CODEC_ID_RAWVIDEO,
368
+    .write_header   = gif_write_header,
369
+    .write_packet   = gif_write_packet,
370
+    .write_trailer  = gif_write_trailer,
371
+    .priv_class     = &gif_muxer_class,
372 372
 };
... ...
@@ -138,6 +138,11 @@ static enum CodecID av_str2id(const IdStrMap *tags, const char *str)
138 138
     return CODEC_ID_NONE;
139 139
 }
140 140
 
141
+enum CodecID ff_guess_image2_codec(const char *filename)
142
+{
143
+    return av_str2id(img_tags, filename);
144
+}
145
+
141 146
 /* return -1 if no image found */
142 147
 static int find_image_range(int *pfirst_index, int *plast_index,
143 148
                             const char *path)
... ...
@@ -194,7 +199,7 @@ static int find_image_range(int *pfirst_index, int *plast_index,
194 194
 
195 195
 static int read_probe(AVProbeData *p)
196 196
 {
197
-    if (p->filename && av_str2id(img_tags, p->filename)) {
197
+    if (p->filename && ff_guess_image2_codec(p->filename)) {
198 198
         if (av_filename_number_test(p->filename))
199 199
             return AVPROBE_SCORE_MAX;
200 200
         else
... ...
@@ -203,11 +208,6 @@ static int read_probe(AVProbeData *p)
203 203
     return 0;
204 204
 }
205 205
 
206
-enum CodecID ff_guess_image2_codec(const char *filename)
207
-{
208
-    return av_str2id(img_tags, filename);
209
-}
210
-
211 206
 static int read_header(AVFormatContext *s1)
212 207
 {
213 208
     VideoData *s = s1->priv_data;
... ...
@@ -277,7 +277,7 @@ static int read_header(AVFormatContext *s1)
277 277
         const char *str= strrchr(s->path, '.');
278 278
         s->split_planes = str && !av_strcasecmp(str + 1, "y");
279 279
         st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
280
-        st->codec->codec_id = av_str2id(img_tags, s->path);
280
+        st->codec->codec_id   = ff_guess_image2_codec(s->path);
281 281
         if (st->codec->codec_id == CODEC_ID_LJPEG)
282 282
             st->codec->codec_id = CODEC_ID_MJPEG;
283 283
     }
... ...
@@ -419,7 +419,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
419 419
         avio_close(pb[1]);
420 420
         avio_close(pb[2]);
421 421
     }else{
422
-        if(av_str2id(img_tags, s->filename) == CODEC_ID_JPEG2000){
422
+        if (ff_guess_image2_codec(s->filename) == CODEC_ID_JPEG2000) {
423 423
             AVStream *st = s->streams[0];
424 424
             if(st->codec->extradata_size > 8 &&
425 425
                AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
... ...
@@ -542,7 +542,7 @@ static EbmlSyntax matroska_clusters[] = {
542 542
     { 0 }
543 543
 };
544 544
 
545
-static const char *matroska_doctypes[] = { "matroska", "webm" };
545
+static const char *const matroska_doctypes[] = { "matroska", "webm" };
546 546
 
547 547
 static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
548 548
 {
... ...
@@ -2311,7 +2311,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
2311 2311
     int64_t dts;
2312 2312
     int data_offset = 0;
2313 2313
     unsigned entries, first_sample_flags = frag->flags;
2314
-    int flags, distance, i;
2314
+    int flags, distance, i, found_keyframe = 0;
2315 2315
 
2316 2316
     for (i = 0; i < c->fc->nb_streams; i++) {
2317 2317
         if (c->fc->streams[i]->id == frag->track_id) {
... ...
@@ -2365,7 +2365,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
2365 2365
         unsigned sample_size = frag->size;
2366 2366
         int sample_flags = i ? frag->flags : first_sample_flags;
2367 2367
         unsigned sample_duration = frag->duration;
2368
-        int keyframe;
2368
+        int keyframe = 0;
2369 2369
 
2370 2370
         if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb);
2371 2371
         if (flags & MOV_TRUN_SAMPLE_SIZE)     sample_size     = avio_rb32(pb);
... ...
@@ -2374,8 +2374,13 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
2374 2374
         sc->ctts_data[sc->ctts_count].duration = (flags & MOV_TRUN_SAMPLE_CTS) ?
2375 2375
                                                   avio_rb32(pb) : 0;
2376 2376
         sc->ctts_count++;
2377
-        if ((keyframe = st->codec->codec_type == AVMEDIA_TYPE_AUDIO ||
2378
-             (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS && !i && !(sample_flags & ~MOV_FRAG_SAMPLE_FLAG_DEGRADATION_PRIORITY_MASK)) || sample_flags & MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO))
2377
+        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
2378
+            keyframe = 1;
2379
+        else if (!found_keyframe)
2380
+            keyframe = found_keyframe =
2381
+                !(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC |
2382
+                                  MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
2383
+        if (keyframe)
2379 2384
             distance = 0;
2380 2385
         av_add_index_entry(st, offset, dts, sample_size, distance,
2381 2386
                            keyframe ? AVINDEX_KEYFRAME : 0);
... ...
@@ -65,14 +65,31 @@ static const struct {
65 65
     { "mono",        1,  AV_CH_LAYOUT_MONO },
66 66
     { "stereo",      2,  AV_CH_LAYOUT_STEREO },
67 67
     { "2.1",         3,  AV_CH_LAYOUT_2POINT1 },
68
+    { "3.0",         3,  AV_CH_LAYOUT_SURROUND },
69
+    { "3.0(back)",   3,  AV_CH_LAYOUT_2_1 },
68 70
     { "4.0",         4,  AV_CH_LAYOUT_4POINT0 },
69 71
     { "quad",        4,  AV_CH_LAYOUT_QUAD },
72
+    { "quad(side)",  4,  AV_CH_LAYOUT_2_2 },
73
+    { "3.1",         4,  AV_CH_LAYOUT_3POINT1 },
70 74
     { "5.0",         5,  AV_CH_LAYOUT_5POINT0_BACK },
71 75
     { "5.0(side)",   5,  AV_CH_LAYOUT_5POINT0 },
76
+    { "4.1",         5,  AV_CH_LAYOUT_4POINT1 },
72 77
     { "5.1",         6,  AV_CH_LAYOUT_5POINT1_BACK },
73 78
     { "5.1(side)",   6,  AV_CH_LAYOUT_5POINT1 },
79
+//     { "5.1+downmix", 8,  AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
80
+    { "6.0",         6,  AV_CH_LAYOUT_6POINT0 },
81
+    { "6.0(front)",  6,  AV_CH_LAYOUT_6POINT0_FRONT },
82
+    { "hexagonal",   6,  AV_CH_LAYOUT_HEXAGONAL },
83
+    { "6.1",         7,  AV_CH_LAYOUT_6POINT1 },
84
+    { "6.1",         7,  AV_CH_LAYOUT_6POINT1_BACK },
85
+    { "6.1(front)",  7,  AV_CH_LAYOUT_6POINT1_FRONT },
86
+//     { "6.1+downmix", 9,  AV_CH_LAYOUT_6POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
87
+    { "7.0",         7,  AV_CH_LAYOUT_7POINT0 },
88
+    { "7.0(front)",  7,  AV_CH_LAYOUT_7POINT0_FRONT },
74 89
     { "7.1",         8,  AV_CH_LAYOUT_7POINT1 },
75 90
     { "7.1(wide)",   8,  AV_CH_LAYOUT_7POINT1_WIDE },
91
+//     { "7.1+downmix", 10, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
92
+    { "octagonal",   8,  AV_CH_LAYOUT_OCTAGONAL },
76 93
     { "downmix",     2,  AV_CH_LAYOUT_STEREO_DOWNMIX, },
77 94
 };
78 95
 
... ...
@@ -622,13 +622,13 @@ void av_free_expr(AVExpr *e)
622 622
 #undef printf
623 623
 #include <string.h>
624 624
 
625
-static double const_values[] = {
625
+static const double const_values[] = {
626 626
     M_PI,
627 627
     M_E,
628 628
     0
629 629
 };
630 630
 
631
-static const char *const_names[] = {
631
+static const char *const const_names[] = {
632 632
     "PI",
633 633
     "E",
634 634
     0
... ...
@@ -22,6 +22,7 @@
22 22
  */
23 23
 
24 24
 #include <inttypes.h>
25
+
25 26
 #include "config.h"
26 27
 #include "libswscale/swscale.h"
27 28
 #include "libswscale/swscale_internal.h"
... ...
@@ -30,8 +31,8 @@
30 30
 
31 31
 #define vzero vec_splat_s32(0)
32 32
 
33
-static inline void
34
-altivec_packIntArrayToCharArray(int *val, uint8_t* dest, int dstW)
33
+static inline void altivec_packIntArrayToCharArray(int *val, uint8_t *dest,
34
+                                                   int dstW)
35 35
 {
36 36
     register int i;
37 37
     vector unsigned int altivec_vectorShiftInt19 =
... ...
@@ -41,106 +42,104 @@ altivec_packIntArrayToCharArray(int *val, uint8_t* dest, int dstW)
41 41
         /* and will handle load misalignment on val w/ vec_perm */
42 42
         vector unsigned char perm1;
43 43
         vector signed int v1;
44
-        for (i = 0 ; (i < dstW) &&
45
-            (((uintptr_t)dest + i) % 16) ; i++) {
46
-                int t = val[i] >> 19;
47
-                dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t);
44
+        for (i = 0; (i < dstW) &&
45
+             (((uintptr_t)dest + i) % 16); i++) {
46
+            int t = val[i] >> 19;
47
+            dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t);
48 48
         }
49 49
         perm1 = vec_lvsl(i << 2, val);
50
-        v1 = vec_ld(i << 2, val);
51
-        for ( ; i < (dstW - 15); i+=16) {
50
+        v1    = vec_ld(i << 2, val);
51
+        for (; i < (dstW - 15); i += 16) {
52 52
             int offset = i << 2;
53
-            vector signed int v2 = vec_ld(offset + 16, val);
54
-            vector signed int v3 = vec_ld(offset + 32, val);
55
-            vector signed int v4 = vec_ld(offset + 48, val);
56
-            vector signed int v5 = vec_ld(offset + 64, val);
53
+            vector signed int v2  = vec_ld(offset + 16, val);
54
+            vector signed int v3  = vec_ld(offset + 32, val);
55
+            vector signed int v4  = vec_ld(offset + 48, val);
56
+            vector signed int v5  = vec_ld(offset + 64, val);
57 57
             vector signed int v12 = vec_perm(v1, v2, perm1);
58 58
             vector signed int v23 = vec_perm(v2, v3, perm1);
59 59
             vector signed int v34 = vec_perm(v3, v4, perm1);
60 60
             vector signed int v45 = vec_perm(v4, v5, perm1);
61 61
 
62
-            vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19);
63
-            vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19);
64
-            vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19);
65
-            vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19);
62
+            vector signed int vA      = vec_sra(v12, altivec_vectorShiftInt19);
63
+            vector signed int vB      = vec_sra(v23, altivec_vectorShiftInt19);
64
+            vector signed int vC      = vec_sra(v34, altivec_vectorShiftInt19);
65
+            vector signed int vD      = vec_sra(v45, altivec_vectorShiftInt19);
66 66
             vector unsigned short vs1 = vec_packsu(vA, vB);
67 67
             vector unsigned short vs2 = vec_packsu(vC, vD);
68
-            vector unsigned char vf = vec_packsu(vs1, vs2);
68
+            vector unsigned char vf   = vec_packsu(vs1, vs2);
69 69
             vec_st(vf, i, dest);
70 70
             v1 = v5;
71 71
         }
72 72
     } else { // dest is properly aligned, great
73
-        for (i = 0; i < (dstW - 15); i+=16) {
73
+        for (i = 0; i < (dstW - 15); i += 16) {
74 74
             int offset = i << 2;
75
-            vector signed int v1 = vec_ld(offset, val);
76
-            vector signed int v2 = vec_ld(offset + 16, val);
77
-            vector signed int v3 = vec_ld(offset + 32, val);
78
-            vector signed int v4 = vec_ld(offset + 48, val);
79
-            vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19);
80
-            vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19);
81
-            vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19);
82
-            vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19);
75
+            vector signed int v1      = vec_ld(offset, val);
76
+            vector signed int v2      = vec_ld(offset + 16, val);
77
+            vector signed int v3      = vec_ld(offset + 32, val);
78
+            vector signed int v4      = vec_ld(offset + 48, val);
79
+            vector signed int v5      = vec_sra(v1, altivec_vectorShiftInt19);
80
+            vector signed int v6      = vec_sra(v2, altivec_vectorShiftInt19);
81
+            vector signed int v7      = vec_sra(v3, altivec_vectorShiftInt19);
82
+            vector signed int v8      = vec_sra(v4, altivec_vectorShiftInt19);
83 83
             vector unsigned short vs1 = vec_packsu(v5, v6);
84 84
             vector unsigned short vs2 = vec_packsu(v7, v8);
85
-            vector unsigned char vf = vec_packsu(vs1, vs2);
85
+            vector unsigned char vf   = vec_packsu(vs1, vs2);
86 86
             vec_st(vf, i, dest);
87 87
         }
88 88
     }
89
-    for ( ; i < dstW ; i++) {
89
+    for (; i < dstW; i++) {
90 90
         int t = val[i] >> 19;
91 91
         dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t);
92 92
     }
93 93
 }
94 94
 
95
-//FIXME remove the usage of scratch buffers.
96
-static void
97
-yuv2planeX_altivec(const int16_t *filter, int filterSize,
98
-                   const int16_t **src, uint8_t *dest, int dstW,
99
-                   const uint8_t *dither, int offset)
95
+// FIXME remove the usage of scratch buffers.
96
+static void yuv2planeX_altivec(const int16_t *filter, int filterSize,
97
+                               const int16_t **src, uint8_t *dest, int dstW,
98
+                               const uint8_t *dither, int offset)
100 99
 {
101 100
     register int i, j;
102
-        DECLARE_ALIGNED(16, int, val)[dstW];
101
+    DECLARE_ALIGNED(16, int, val)[dstW];
103 102
 
104
-        for (i=0; i<dstW; i++)
105
-            val[i] = dither[(i + offset) & 7] << 12;
103
+    for (i = 0; i < dstW; i++)
104
+        val[i] = dither[(i + offset) & 7] << 12;
106 105
 
107
-        for (j = 0; j < filterSize; j++) {
108
-            vector signed short l1, vLumFilter = vec_ld(j << 1, filter);
109
-            vector unsigned char perm, perm0 = vec_lvsl(j << 1, filter);
110
-            vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
111
-            vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter
106
+    for (j = 0; j < filterSize; j++) {
107
+        vector signed short l1, vLumFilter = vec_ld(j << 1, filter);
108
+        vector unsigned char perm, perm0 = vec_lvsl(j << 1, filter);
109
+        vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
110
+        vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter
112 111
 
113
-            perm = vec_lvsl(0, src[j]);
114
-            l1 = vec_ld(0, src[j]);
112
+        perm = vec_lvsl(0, src[j]);
113
+        l1   = vec_ld(0, src[j]);
115 114
 
116
-            for (i = 0; i < (dstW - 7); i+=8) {
117
-                int offset = i << 2;
118
-                vector signed short l2 = vec_ld((i << 1) + 16, src[j]);
115
+        for (i = 0; i < (dstW - 7); i += 8) {
116
+            int offset = i << 2;
117
+            vector signed short l2 = vec_ld((i << 1) + 16, src[j]);
119 118
 
120
-                vector signed int v1 = vec_ld(offset, val);
121
-                vector signed int v2 = vec_ld(offset + 16, val);
119
+            vector signed int v1 = vec_ld(offset, val);
120
+            vector signed int v2 = vec_ld(offset + 16, val);
122 121
 
123
-                vector signed short ls = vec_perm(l1, l2, perm); // lumSrc[j][i] ... lumSrc[j][i+7]
122
+            vector signed short ls = vec_perm(l1, l2, perm); // lumSrc[j][i] ... lumSrc[j][i+7]
124 123
 
125
-                vector signed int i1 = vec_mule(vLumFilter, ls);
126
-                vector signed int i2 = vec_mulo(vLumFilter, ls);
124
+            vector signed int i1 = vec_mule(vLumFilter, ls);
125
+            vector signed int i2 = vec_mulo(vLumFilter, ls);
127 126
 
128
-                vector signed int vf1 = vec_mergeh(i1, i2);
129
-                vector signed int vf2 = vec_mergel(i1, i2); // lumSrc[j][i] * lumFilter[j] ... lumSrc[j][i+7] * lumFilter[j]
127
+            vector signed int vf1 = vec_mergeh(i1, i2);
128
+            vector signed int vf2 = vec_mergel(i1, i2); // lumSrc[j][i] * lumFilter[j] ... lumSrc[j][i+7] * lumFilter[j]
130 129
 
131
-                vector signed int vo1 = vec_add(v1, vf1);
132
-                vector signed int vo2 = vec_add(v2, vf2);
130
+            vector signed int vo1 = vec_add(v1, vf1);
131
+            vector signed int vo2 = vec_add(v2, vf2);
133 132
 
134
-                vec_st(vo1, offset, val);
135
-                vec_st(vo2, offset + 16, val);
133
+            vec_st(vo1, offset, val);
134
+            vec_st(vo2, offset + 16, val);
136 135
 
137
-                l1 = l2;
138
-            }
139
-            for ( ; i < dstW; i++) {
140
-                val[i] += src[j][i] * filter[j];
141
-            }
136
+            l1 = l2;
142 137
         }
143
-        altivec_packIntArrayToCharArray(val, dest, dstW);
138
+        for (; i < dstW; i++)
139
+            val[i] += src[j][i] * filter[j];
140
+    }
141
+    altivec_packIntArrayToCharArray(val, dest, dstW);
144 142
 }
145 143
 
146 144
 static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
... ...
@@ -151,167 +150,164 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
151 151
     DECLARE_ALIGNED(16, int, tempo)[4];
152 152
 
153 153
     if (filterSize % 4) {
154
-        for (i=0; i<dstW; i++) {
154
+        for (i = 0; i < dstW; i++) {
155 155
             register int j;
156 156
             register int srcPos = filterPos[i];
157
-            register int val = 0;
158
-            for (j=0; j<filterSize; j++) {
159
-                val += ((int)src[srcPos + j])*filter[filterSize*i + j];
160
-            }
161
-            dst[i] = FFMIN(val>>7, (1<<15)-1);
162
-        }
163
-    }
164
-    else
165
-    switch (filterSize) {
166
-    case 4:
167
-    for (i=0; i<dstW; i++) {
168
-        register int srcPos = filterPos[i];
169
-
170
-        vector unsigned char src_v0 = vec_ld(srcPos, src);
171
-        vector unsigned char src_v1, src_vF;
172
-        vector signed short src_v, filter_v;
173
-        vector signed int val_vEven, val_s;
174
-        if ((((uintptr_t)src + srcPos) % 16) > 12) {
175
-            src_v1 = vec_ld(srcPos + 16, src);
176
-        }
177
-        src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
178
-
179
-        src_v = // vec_unpackh sign-extends...
180
-            (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
181
-        // now put our elements in the even slots
182
-        src_v = vec_mergeh(src_v, (vector signed short)vzero);
183
-
184
-        filter_v = vec_ld(i << 3, filter);
185
-        // The 3 above is 2 (filterSize == 4) + 1 (sizeof(short) == 2).
186
-
187
-        // The neat trick: We only care for half the elements,
188
-        // high or low depending on (i<<3)%16 (it's 0 or 8 here),
189
-        // and we're going to use vec_mule, so we choose
190
-        // carefully how to "unpack" the elements into the even slots.
191
-        if ((i << 3) % 16)
192
-            filter_v = vec_mergel(filter_v, (vector signed short)vzero);
193
-        else
194
-            filter_v = vec_mergeh(filter_v, (vector signed short)vzero);
195
-
196
-        val_vEven = vec_mule(src_v, filter_v);
197
-        val_s = vec_sums(val_vEven, vzero);
198
-        vec_st(val_s, 0, tempo);
199
-        dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
200
-    }
201
-    break;
202
-
203
-    case 8:
204
-    for (i=0; i<dstW; i++) {
205
-        register int srcPos = filterPos[i];
206
-
207
-        vector unsigned char src_v0 = vec_ld(srcPos, src);
208
-        vector unsigned char src_v1, src_vF;
209
-        vector signed short src_v, filter_v;
210
-        vector signed int val_v, val_s;
211
-        if ((((uintptr_t)src + srcPos) % 16) > 8) {
212
-            src_v1 = vec_ld(srcPos + 16, src);
213
-        }
214
-        src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
215
-
216
-        src_v = // vec_unpackh sign-extends...
217
-            (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
218
-        filter_v = vec_ld(i << 4, filter);
219
-        // the 4 above is 3 (filterSize == 8) + 1 (sizeof(short) == 2)
220
-
221
-        val_v = vec_msums(src_v, filter_v, (vector signed int)vzero);
222
-        val_s = vec_sums(val_v, vzero);
223
-        vec_st(val_s, 0, tempo);
224
-        dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
225
-    }
226
-    break;
227
-
228
-    case 16:
229
-        for (i=0; i<dstW; i++) {
230
-            register int srcPos = filterPos[i];
231
-
232
-            vector unsigned char src_v0 = vec_ld(srcPos, src);
233
-            vector unsigned char src_v1 = vec_ld(srcPos + 16, src);
234
-            vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
235
-
236
-            vector signed short src_vA = // vec_unpackh sign-extends...
237
-                (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
238
-            vector signed short src_vB = // vec_unpackh sign-extends...
239
-                (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
240
-
241
-            vector signed short filter_v0 = vec_ld(i << 5, filter);
242
-            vector signed short filter_v1 = vec_ld((i << 5) + 16, filter);
243
-            // the 5 above are 4 (filterSize == 16) + 1 (sizeof(short) == 2)
244
-
245
-            vector signed int val_acc = vec_msums(src_vA, filter_v0, (vector signed int)vzero);
246
-            vector signed int val_v = vec_msums(src_vB, filter_v1, val_acc);
247
-
248
-            vector signed int val_s = vec_sums(val_v, vzero);
249
-
250
-            vec_st(val_s, 0, tempo);
251
-            dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
157
+            register int val    = 0;
158
+            for (j = 0; j < filterSize; j++)
159
+                val += ((int)src[srcPos + j]) * filter[filterSize * i + j];
160
+            dst[i] = FFMIN(val >> 7, (1 << 15) - 1);
252 161
         }
253
-    break;
254
-
255
-    default:
256
-    for (i=0; i<dstW; i++) {
257
-        register int j;
258
-        register int srcPos = filterPos[i];
259
-
260
-        vector signed int val_s, val_v = (vector signed int)vzero;
261
-        vector signed short filter_v0R = vec_ld(i * 2 * filterSize, filter);
262
-        vector unsigned char permF = vec_lvsl((i * 2 * filterSize), filter);
162
+    } else
163
+        switch (filterSize) {
164
+        case 4:
165
+            for (i = 0; i < dstW; i++) {
166
+                register int srcPos = filterPos[i];
167
+
168
+                vector unsigned char src_v0 = vec_ld(srcPos, src);
169
+                vector unsigned char src_v1, src_vF;
170
+                vector signed short src_v, filter_v;
171
+                vector signed int val_vEven, val_s;
172
+                if ((((uintptr_t)src + srcPos) % 16) > 12) {
173
+                    src_v1 = vec_ld(srcPos + 16, src);
174
+                }
175
+                src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
176
+
177
+                src_v = // vec_unpackh sign-extends...
178
+                        (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
179
+                // now put our elements in the even slots
180
+                src_v = vec_mergeh(src_v, (vector signed short)vzero);
181
+
182
+                filter_v = vec_ld(i << 3, filter);
183
+                // The 3 above is 2 (filterSize == 4) + 1 (sizeof(short) == 2).
184
+
185
+                // The neat trick: We only care for half the elements,
186
+                // high or low depending on (i<<3)%16 (it's 0 or 8 here),
187
+                // and we're going to use vec_mule, so we choose
188
+                // carefully how to "unpack" the elements into the even slots.
189
+                if ((i << 3) % 16)
190
+                    filter_v = vec_mergel(filter_v, (vector signed short)vzero);
191
+                else
192
+                    filter_v = vec_mergeh(filter_v, (vector signed short)vzero);
193
+
194
+                val_vEven = vec_mule(src_v, filter_v);
195
+                val_s     = vec_sums(val_vEven, vzero);
196
+                vec_st(val_s, 0, tempo);
197
+                dst[i] = FFMIN(tempo[3] >> 7, (1 << 15) - 1);
198
+            }
199
+        break;
200
+
201
+        case 8:
202
+            for (i = 0; i < dstW; i++) {
203
+                register int srcPos = filterPos[i];
204
+
205
+                vector unsigned char src_v0 = vec_ld(srcPos, src);
206
+                vector unsigned char src_v1, src_vF;
207
+                vector signed short src_v, filter_v;
208
+                vector signed int val_v, val_s;
209
+                if ((((uintptr_t)src + srcPos) % 16) > 8) {
210
+                    src_v1 = vec_ld(srcPos + 16, src);
211
+                }
212
+                src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
213
+
214
+                src_v = // vec_unpackh sign-extends...
215
+                        (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
216
+                filter_v = vec_ld(i << 4, filter);
217
+                // the 4 above is 3 (filterSize == 8) + 1 (sizeof(short) == 2)
218
+
219
+                val_v = vec_msums(src_v, filter_v, (vector signed int)vzero);
220
+                val_s = vec_sums(val_v, vzero);
221
+                vec_st(val_s, 0, tempo);
222
+                dst[i] = FFMIN(tempo[3] >> 7, (1 << 15) - 1);
223
+            }
224
+        break;
263 225
 
264
-        vector unsigned char src_v0 = vec_ld(srcPos, src);
265
-        vector unsigned char permS = vec_lvsl(srcPos, src);
226
+        case 16:
227
+            for (i = 0; i < dstW; i++) {
228
+                register int srcPos = filterPos[i];
266 229
 
267
-        for (j = 0 ; j < filterSize - 15; j += 16) {
268
-            vector unsigned char src_v1 = vec_ld(srcPos + j + 16, src);
269
-            vector unsigned char src_vF = vec_perm(src_v0, src_v1, permS);
230
+                vector unsigned char src_v0 = vec_ld(srcPos, src);
231
+                vector unsigned char src_v1 = vec_ld(srcPos + 16, src);
232
+                vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
270 233
 
271
-            vector signed short src_vA = // vec_unpackh sign-extends...
272
-                (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
273
-            vector signed short src_vB = // vec_unpackh sign-extends...
274
-                (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
234
+                vector signed short src_vA = // vec_unpackh sign-extends...
235
+                                             (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
236
+                vector signed short src_vB = // vec_unpackh sign-extends...
237
+                                             (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
275 238
 
276
-            vector signed short filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter);
277
-            vector signed short filter_v2R = vec_ld((i * 2 * filterSize) + (j * 2) + 32, filter);
278
-            vector signed short filter_v0  = vec_perm(filter_v0R, filter_v1R, permF);
279
-            vector signed short filter_v1  = vec_perm(filter_v1R, filter_v2R, permF);
239
+                vector signed short filter_v0 = vec_ld(i << 5, filter);
240
+                vector signed short filter_v1 = vec_ld((i << 5) + 16, filter);
241
+                // the 5 above are 4 (filterSize == 16) + 1 (sizeof(short) == 2)
280 242
 
281
-            vector signed int val_acc = vec_msums(src_vA, filter_v0, val_v);
282
-            val_v = vec_msums(src_vB, filter_v1, val_acc);
243
+                vector signed int val_acc = vec_msums(src_vA, filter_v0, (vector signed int)vzero);
244
+                vector signed int val_v   = vec_msums(src_vB, filter_v1, val_acc);
283 245
 
284
-            filter_v0R = filter_v2R;
285
-            src_v0 = src_v1;
286
-        }
246
+                vector signed int val_s = vec_sums(val_v, vzero);
287 247
 
288
-        if (j < filterSize-7) {
289
-            // loading src_v0 is useless, it's already done above
290
-            //vector unsigned char src_v0 = vec_ld(srcPos + j, src);
291
-            vector unsigned char src_v1, src_vF;
292
-            vector signed short src_v, filter_v1R, filter_v;
293
-            if ((((uintptr_t)src + srcPos) % 16) > 8) {
294
-                src_v1 = vec_ld(srcPos + j + 16, src);
248
+                vec_st(val_s, 0, tempo);
249
+                dst[i] = FFMIN(tempo[3] >> 7, (1 << 15) - 1);
250
+            }
251
+        break;
252
+
253
+        default:
254
+            for (i = 0; i < dstW; i++) {
255
+                register int j;
256
+                register int srcPos = filterPos[i];
257
+
258
+                vector signed int val_s, val_v = (vector signed int)vzero;
259
+                vector signed short filter_v0R = vec_ld(i * 2 * filterSize, filter);
260
+                vector unsigned char permF     = vec_lvsl((i * 2 * filterSize), filter);
261
+
262
+                vector unsigned char src_v0 = vec_ld(srcPos, src);
263
+                vector unsigned char permS  = vec_lvsl(srcPos, src);
264
+
265
+                for (j = 0; j < filterSize - 15; j += 16) {
266
+                    vector unsigned char src_v1 = vec_ld(srcPos + j + 16, src);
267
+                    vector unsigned char src_vF = vec_perm(src_v0, src_v1, permS);
268
+
269
+                    vector signed short src_vA = // vec_unpackh sign-extends...
270
+                                                 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
271
+                    vector signed short src_vB = // vec_unpackh sign-extends...
272
+                                                 (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
273
+
274
+                    vector signed short filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter);
275
+                    vector signed short filter_v2R = vec_ld((i * 2 * filterSize) + (j * 2) + 32, filter);
276
+                    vector signed short filter_v0  = vec_perm(filter_v0R, filter_v1R, permF);
277
+                    vector signed short filter_v1  = vec_perm(filter_v1R, filter_v2R, permF);
278
+
279
+                    vector signed int val_acc = vec_msums(src_vA, filter_v0, val_v);
280
+                    val_v = vec_msums(src_vB, filter_v1, val_acc);
281
+
282
+                    filter_v0R = filter_v2R;
283
+                    src_v0     = src_v1;
284
+                }
285
+
286
+                if (j < filterSize - 7) {
287
+                    // loading src_v0 is useless, it's already done above
288
+                    // vector unsigned char src_v0 = vec_ld(srcPos + j, src);
289
+                    vector unsigned char src_v1, src_vF;
290
+                    vector signed short src_v, filter_v1R, filter_v;
291
+                    if ((((uintptr_t)src + srcPos) % 16) > 8) {
292
+                        src_v1 = vec_ld(srcPos + j + 16, src);
293
+                    }
294
+                    src_vF = vec_perm(src_v0, src_v1, permS);
295
+
296
+                    src_v = // vec_unpackh sign-extends...
297
+                            (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
298
+                    // loading filter_v0R is useless, it's already done above
299
+                    // vector signed short filter_v0R = vec_ld((i * 2 * filterSize) + j, filter);
300
+                    filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter);
301
+                    filter_v   = vec_perm(filter_v0R, filter_v1R, permF);
302
+
303
+                    val_v = vec_msums(src_v, filter_v, val_v);
304
+                }
305
+
306
+                val_s = vec_sums(val_v, vzero);
307
+
308
+                vec_st(val_s, 0, tempo);
309
+                dst[i] = FFMIN(tempo[3] >> 7, (1 << 15) - 1);
295 310
             }
296
-            src_vF = vec_perm(src_v0, src_v1, permS);
297
-
298
-            src_v = // vec_unpackh sign-extends...
299
-                (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
300
-            // loading filter_v0R is useless, it's already done above
301
-            //vector signed short filter_v0R = vec_ld((i * 2 * filterSize) + j, filter);
302
-            filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter);
303
-            filter_v = vec_perm(filter_v0R, filter_v1R, permF);
304
-
305
-            val_v = vec_msums(src_v, filter_v, val_v);
306 311
         }
307
-
308
-        val_s = vec_sums(val_v, vzero);
309
-
310
-        vec_st(val_s, 0, tempo);
311
-        dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
312
-    }
313
-
314
-    }
315 312
 }
316 313
 
317 314
 void ff_sws_init_swScale_altivec(SwsContext *c)
... ...
@@ -334,12 +330,24 @@ void ff_sws_init_swScale_altivec(SwsContext *c)
334 334
      * match what's found in the body of ff_yuv2packedX_altivec() */
335 335
     if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf) {
336 336
         switch (c->dstFormat) {
337
-        case PIX_FMT_ABGR:  c->yuv2packedX = ff_yuv2abgr_X_altivec;  break;
338
-        case PIX_FMT_BGRA:  c->yuv2packedX = ff_yuv2bgra_X_altivec;  break;
339
-        case PIX_FMT_ARGB:  c->yuv2packedX = ff_yuv2argb_X_altivec;  break;
340
-        case PIX_FMT_RGBA:  c->yuv2packedX = ff_yuv2rgba_X_altivec;  break;
341
-        case PIX_FMT_BGR24: c->yuv2packedX = ff_yuv2bgr24_X_altivec; break;
342
-        case PIX_FMT_RGB24: c->yuv2packedX = ff_yuv2rgb24_X_altivec; break;
337
+        case PIX_FMT_ABGR:
338
+            c->yuv2packedX = ff_yuv2abgr_X_altivec;
339
+            break;
340
+        case PIX_FMT_BGRA:
341
+            c->yuv2packedX = ff_yuv2bgra_X_altivec;
342
+            break;
343
+        case PIX_FMT_ARGB:
344
+            c->yuv2packedX = ff_yuv2argb_X_altivec;
345
+            break;
346
+        case PIX_FMT_RGBA:
347
+            c->yuv2packedX = ff_yuv2rgba_X_altivec;
348
+            break;
349
+        case PIX_FMT_BGR24:
350
+            c->yuv2packedX = ff_yuv2bgr24_X_altivec;
351
+            break;
352
+        case PIX_FMT_RGB24:
353
+            c->yuv2packedX = ff_yuv2rgb24_X_altivec;
354
+            break;
343 355
         }
344 356
     }
345 357
 }
... ...
@@ -22,55 +22,57 @@
22 22
  */
23 23
 
24 24
 #include <inttypes.h>
25
+
25 26
 #include "config.h"
26 27
 #include "libswscale/swscale.h"
27 28
 #include "libswscale/swscale_internal.h"
28 29
 #include "libavutil/cpu.h"
29 30
 
30
-static int yv12toyuy2_unscaled_altivec(SwsContext *c, const uint8_t* src[],
31
+static int yv12toyuy2_unscaled_altivec(SwsContext *c, const uint8_t *src[],
31 32
                                        int srcStride[], int srcSliceY,
32
-                                       int srcSliceH, uint8_t* dstParam[],
33
+                                       int srcSliceH, uint8_t *dstParam[],
33 34
                                        int dstStride_a[])
34 35
 {
35
-    uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY;
36
-    // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]);
37
-    const uint8_t *ysrc = src[0];
38
-    const uint8_t *usrc = src[1];
39
-    const uint8_t *vsrc = src[2];
40
-    const int width = c->srcW;
41
-    const int height = srcSliceH;
42
-    const int lumStride = srcStride[0];
36
+    uint8_t *dst = dstParam[0] + dstStride_a[0] * srcSliceY;
37
+    // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH,
38
+    //            srcStride[0], srcStride[1], dstStride[0]);
39
+    const uint8_t *ysrc   = src[0];
40
+    const uint8_t *usrc   = src[1];
41
+    const uint8_t *vsrc   = src[2];
42
+    const int width       = c->srcW;
43
+    const int height      = srcSliceH;
44
+    const int lumStride   = srcStride[0];
43 45
     const int chromStride = srcStride[1];
44
-    const int dstStride = dstStride_a[0];
46
+    const int dstStride   = dstStride_a[0];
45 47
     const vector unsigned char yperm = vec_lvsl(0, ysrc);
46
-    const int vertLumPerChroma = 2;
48
+    const int vertLumPerChroma       = 2;
47 49
     register unsigned int y;
48 50
 
49 51
     /* This code assumes:
52
+     *
53
+     * 1) dst is 16 bytes-aligned
54
+     * 2) dstStride is a multiple of 16
55
+     * 3) width is a multiple of 16
56
+     * 4) lum & chrom stride are multiples of 8
57
+     */
50 58
 
51
-    1) dst is 16 bytes-aligned
52
-    2) dstStride is a multiple of 16
53
-    3) width is a multiple of 16
54
-    4) lum & chrom stride are multiples of 8
55
-    */
56
-
57
-    for (y=0; y<height; y++) {
59
+    for (y = 0; y < height; y++) {
58 60
         int i;
59
-        for (i = 0; i < width - 31; i+= 32) {
60
-            const unsigned int j = i >> 1;
61
-            vector unsigned char v_yA = vec_ld(i, ysrc);
62
-            vector unsigned char v_yB = vec_ld(i + 16, ysrc);
63
-            vector unsigned char v_yC = vec_ld(i + 32, ysrc);
64
-            vector unsigned char v_y1 = vec_perm(v_yA, v_yB, yperm);
65
-            vector unsigned char v_y2 = vec_perm(v_yB, v_yC, yperm);
66
-            vector unsigned char v_uA = vec_ld(j, usrc);
67
-            vector unsigned char v_uB = vec_ld(j + 16, usrc);
68
-            vector unsigned char v_u = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc));
69
-            vector unsigned char v_vA = vec_ld(j, vsrc);
70
-            vector unsigned char v_vB = vec_ld(j + 16, vsrc);
71
-            vector unsigned char v_v = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc));
72
-            vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
73
-            vector unsigned char v_uv_b = vec_mergel(v_u, v_v);
61
+        for (i = 0; i < width - 31; i += 32) {
62
+            const unsigned int j          = i >> 1;
63
+            vector unsigned char v_yA     = vec_ld(i, ysrc);
64
+            vector unsigned char v_yB     = vec_ld(i + 16, ysrc);
65
+            vector unsigned char v_yC     = vec_ld(i + 32, ysrc);
66
+            vector unsigned char v_y1     = vec_perm(v_yA, v_yB, yperm);
67
+            vector unsigned char v_y2     = vec_perm(v_yB, v_yC, yperm);
68
+            vector unsigned char v_uA     = vec_ld(j, usrc);
69
+            vector unsigned char v_uB     = vec_ld(j + 16, usrc);
70
+            vector unsigned char v_u      = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc));
71
+            vector unsigned char v_vA     = vec_ld(j, vsrc);
72
+            vector unsigned char v_vB     = vec_ld(j + 16, vsrc);
73
+            vector unsigned char v_v      = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc));
74
+            vector unsigned char v_uv_a   = vec_mergeh(v_u, v_v);
75
+            vector unsigned char v_uv_b   = vec_mergel(v_u, v_v);
74 76
             vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a);
75 77
             vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a);
76 78
             vector unsigned char v_yuy2_2 = vec_mergeh(v_y2, v_uv_b);
... ...
@@ -81,71 +83,72 @@ static int yv12toyuy2_unscaled_altivec(SwsContext *c, const uint8_t* src[],
81 81
             vec_st(v_yuy2_3, (i << 1) + 48, dst);
82 82
         }
83 83
         if (i < width) {
84
-            const unsigned int j = i >> 1;
85
-            vector unsigned char v_y1 = vec_ld(i, ysrc);
86
-            vector unsigned char v_u = vec_ld(j, usrc);
87
-            vector unsigned char v_v = vec_ld(j, vsrc);
88
-            vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
84
+            const unsigned int j          = i >> 1;
85
+            vector unsigned char v_y1     = vec_ld(i, ysrc);
86
+            vector unsigned char v_u      = vec_ld(j, usrc);
87
+            vector unsigned char v_v      = vec_ld(j, vsrc);
88
+            vector unsigned char v_uv_a   = vec_mergeh(v_u, v_v);
89 89
             vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a);
90 90
             vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a);
91 91
             vec_st(v_yuy2_0, (i << 1), dst);
92 92
             vec_st(v_yuy2_1, (i << 1) + 16, dst);
93 93
         }
94
-        if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
94
+        if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
95 95
             usrc += chromStride;
96 96
             vsrc += chromStride;
97 97
         }
98 98
         ysrc += lumStride;
99
-        dst += dstStride;
99
+        dst  += dstStride;
100 100
     }
101 101
 
102 102
     return srcSliceH;
103 103
 }
104 104
 
105
-static int yv12touyvy_unscaled_altivec(SwsContext *c, const uint8_t* src[],
105
+static int yv12touyvy_unscaled_altivec(SwsContext *c, const uint8_t *src[],
106 106
                                        int srcStride[], int srcSliceY,
107
-                                       int srcSliceH, uint8_t* dstParam[],
107
+                                       int srcSliceH, uint8_t *dstParam[],
108 108
                                        int dstStride_a[])
109 109
 {
110
-    uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY;
111
-    // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]);
112
-    const uint8_t *ysrc = src[0];
113
-    const uint8_t *usrc = src[1];
114
-    const uint8_t *vsrc = src[2];
115
-    const int width = c->srcW;
116
-    const int height = srcSliceH;
117
-    const int lumStride = srcStride[0];
118
-    const int chromStride = srcStride[1];
119
-    const int dstStride = dstStride_a[0];
120
-    const int vertLumPerChroma = 2;
110
+    uint8_t *dst = dstParam[0] + dstStride_a[0] * srcSliceY;
111
+    // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH,
112
+    //            srcStride[0], srcStride[1], dstStride[0]);
113
+    const uint8_t *ysrc              = src[0];
114
+    const uint8_t *usrc              = src[1];
115
+    const uint8_t *vsrc              = src[2];
116
+    const int width                  = c->srcW;
117
+    const int height                 = srcSliceH;
118
+    const int lumStride              = srcStride[0];
119
+    const int chromStride            = srcStride[1];
120
+    const int dstStride              = dstStride_a[0];
121
+    const int vertLumPerChroma       = 2;
121 122
     const vector unsigned char yperm = vec_lvsl(0, ysrc);
122 123
     register unsigned int y;
123 124
 
124 125
     /* This code assumes:
126
+     *
127
+     * 1) dst is 16 bytes-aligned
128
+     * 2) dstStride is a multiple of 16
129
+     * 3) width is a multiple of 16
130
+     * 4) lum & chrom stride are multiples of 8
131
+     */
125 132
 
126
-    1) dst is 16 bytes-aligned
127
-    2) dstStride is a multiple of 16
128
-    3) width is a multiple of 16
129
-    4) lum & chrom stride are multiples of 8
130
-    */
131
-
132
-    for (y=0; y<height; y++) {
133
+    for (y = 0; y < height; y++) {
133 134
         int i;
134
-        for (i = 0; i < width - 31; i+= 32) {
135
-            const unsigned int j = i >> 1;
136
-            vector unsigned char v_yA = vec_ld(i, ysrc);
137
-            vector unsigned char v_yB = vec_ld(i + 16, ysrc);
138
-            vector unsigned char v_yC = vec_ld(i + 32, ysrc);
139
-            vector unsigned char v_y1 = vec_perm(v_yA, v_yB, yperm);
140
-            vector unsigned char v_y2 = vec_perm(v_yB, v_yC, yperm);
141
-            vector unsigned char v_uA = vec_ld(j, usrc);
142
-            vector unsigned char v_uB = vec_ld(j + 16, usrc);
143
-            vector unsigned char v_u = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc));
144
-            vector unsigned char v_vA = vec_ld(j, vsrc);
145
-            vector unsigned char v_vB = vec_ld(j + 16, vsrc);
146
-            vector unsigned char v_v = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc));
147
-            vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
148
-            vector unsigned char v_uv_b = vec_mergel(v_u, v_v);
135
+        for (i = 0; i < width - 31; i += 32) {
136
+            const unsigned int j          = i >> 1;
137
+            vector unsigned char v_yA     = vec_ld(i, ysrc);
138
+            vector unsigned char v_yB     = vec_ld(i + 16, ysrc);
139
+            vector unsigned char v_yC     = vec_ld(i + 32, ysrc);
140
+            vector unsigned char v_y1     = vec_perm(v_yA, v_yB, yperm);
141
+            vector unsigned char v_y2     = vec_perm(v_yB, v_yC, yperm);
142
+            vector unsigned char v_uA     = vec_ld(j, usrc);
143
+            vector unsigned char v_uB     = vec_ld(j + 16, usrc);
144
+            vector unsigned char v_u      = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc));
145
+            vector unsigned char v_vA     = vec_ld(j, vsrc);
146
+            vector unsigned char v_vB     = vec_ld(j + 16, vsrc);
147
+            vector unsigned char v_v      = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc));
148
+            vector unsigned char v_uv_a   = vec_mergeh(v_u, v_v);
149
+            vector unsigned char v_uv_b   = vec_mergel(v_u, v_v);
149 150
             vector unsigned char v_uyvy_0 = vec_mergeh(v_uv_a, v_y1);
150 151
             vector unsigned char v_uyvy_1 = vec_mergel(v_uv_a, v_y1);
151 152
             vector unsigned char v_uyvy_2 = vec_mergeh(v_uv_b, v_y2);
... ...
@@ -156,22 +159,22 @@ static int yv12touyvy_unscaled_altivec(SwsContext *c, const uint8_t* src[],
156 156
             vec_st(v_uyvy_3, (i << 1) + 48, dst);
157 157
         }
158 158
         if (i < width) {
159
-            const unsigned int j = i >> 1;
160
-            vector unsigned char v_y1 = vec_ld(i, ysrc);
161
-            vector unsigned char v_u = vec_ld(j, usrc);
162
-            vector unsigned char v_v = vec_ld(j, vsrc);
163
-            vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
159
+            const unsigned int j          = i >> 1;
160
+            vector unsigned char v_y1     = vec_ld(i, ysrc);
161
+            vector unsigned char v_u      = vec_ld(j, usrc);
162
+            vector unsigned char v_v      = vec_ld(j, vsrc);
163
+            vector unsigned char v_uv_a   = vec_mergeh(v_u, v_v);
164 164
             vector unsigned char v_uyvy_0 = vec_mergeh(v_uv_a, v_y1);
165 165
             vector unsigned char v_uyvy_1 = vec_mergel(v_uv_a, v_y1);
166 166
             vec_st(v_uyvy_0, (i << 1), dst);
167 167
             vec_st(v_uyvy_1, (i << 1) + 16, dst);
168 168
         }
169
-        if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
169
+        if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
170 170
             usrc += chromStride;
171 171
             vsrc += chromStride;
172 172
         }
173 173
         ysrc += lumStride;
174
-        dst += dstStride;
174
+        dst  += dstStride;
175 175
     }
176 176
     return srcSliceH;
177 177
 }
... ...
@@ -184,8 +187,8 @@ void ff_swscale_get_unscaled_altivec(SwsContext *c)
184 184
 
185 185
         // unscaled YV12 -> packed YUV, we want speed
186 186
         if (dstFormat == PIX_FMT_YUYV422)
187
-            c->swScale= yv12toyuy2_unscaled_altivec;
187
+            c->swScale = yv12toyuy2_unscaled_altivec;
188 188
         else if (dstFormat == PIX_FMT_UYVY422)
189
-            c->swScale= yv12touyvy_unscaled_altivec;
189
+            c->swScale = yv12touyvy_unscaled_altivec;
190 190
     }
191 191
 }
... ...
@@ -283,6 +283,11 @@ do_video_encoding prores.mov "-vcodec prores"
283 283
 do_video_decoding "" "-pix_fmt yuv420p"
284 284
 fi
285 285
 
286
+if [ -n "$do_prores_kostya" ] ; then
287
+do_video_encoding prores_kostya.mov "-vcodec prores_kostya -profile hq"
288
+do_video_decoding "" "-pix_fmt yuv420p"
289
+fi
290
+
286 291
 if [ -n "$do_svq1" ] ; then
287 292
 do_video_encoding svq1.mov "-an -vcodec svq1 -qscale 3 -pix_fmt yuv410p"
288 293
 do_video_decoding "" "-pix_fmt yuv420p"
289 294
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+40e7637e04991dbe9a23fe109f95bfc8 *./tests/data/vsynth1/prores_kostya.mov
1
+3858901 ./tests/data/vsynth1/prores_kostya.mov
2
+0a4153637d0cc0a88a8bcbf04cfaf8c6 *./tests/data/prores_kostya.vsynth1.out.yuv
3
+stddev:    3.17 PSNR: 38.09 MAXDIFF:   39 bytes:  7603200/  7603200
0 4
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+ed8b8a94da049518af8f95c5da736e57 *./tests/data/vsynth2/prores_kostya.mov
1
+3884586 ./tests/data/vsynth2/prores_kostya.mov
2
+ca2f6c1162635dedfa468c90f1fdc0ef *./tests/data/prores_kostya.vsynth2.out.yuv
3
+stddev:    0.92 PSNR: 48.77 MAXDIFF:   10 bytes:  7603200/  7603200