Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
ffserver: remove unused variable.
Remove unused and outdated TODO file.
gitignore: Drop individual .d ignore; it is already covered by a wildcard.
lavf: deprecate AVStream.quality.
bink: pass Bink version to audio decoder through extradata instead of codec_tag.
libpostproc: Remove disabled code.
flashsv: improve some comments and fix some wrong ones
flashsv: Eliminate redundant variable indirection.
flashsv: set reference frame type to full frame
flashsv: replace bitstream description by a link to the specification
flashsv: convert a debug av_log into av_dlog
flashsv: simplify condition
flashsv: return more meaningful error values
flashsv: cosmetics: break some overly long lines
flashsv: cosmetics: drop some unnecessary parentheses
swscale: amend documentation to mention use of native depth for scaling.
eval: add missing comma to tests.
eval: fix memleak.
H.264: make loopfilter bS const where applicable

Conflicts:
libavcodec/binkaudio.c
libavformat/bink.c

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

Michael Niedermayer authored on 2011/07/07 06:57:11
Showing 17 changed files
... ...
@@ -44,5 +44,4 @@ tools/pktdumper
44 44
 tools/probetest
45 45
 tools/qt-faststart
46 46
 tools/trasher
47
-tools/trasher*.d
48 47
 version.h
49 48
deleted file mode 100644
... ...
@@ -1,82 +0,0 @@
1
-ffmpeg TODO list:
2
-
3
-Fabrice's TODO list: (unordered)
4
-Short term:
5
-
6
-- use AVFMTCTX_DISCARD_PKT in ffplay so that DV has a chance to work
7
-- add RTSP regression test (both client and server)
8
-- make ffserver allocate AVFormatContext
9
-- clean up (incompatible change, for 0.5.0):
10
-    * AVStream -> AVComponent
11
-    * AVFormatContext -> AVInputStream/AVOutputStream
12
-    * suppress rate_emu from AVCodecContext
13
-- add new float/integer audio filterting and conversion : suppress
14
-  CODEC_ID_PCM_xxc and use CODEC_ID_RAWAUDIO.
15
-- fix telecine and frame rate conversion
16
-
17
-Long term (ask me if you want to help):
18
-
19
-- commit new imgconvert API and new PIX_FMT_xxx alpha formats
20
-- commit new LGPL'ed float and integer-only AC3 decoder
21
-- add WMA integer-only decoder
22
-- add new MPEG4-AAC audio decoder (both integer-only and float version)
23
-
24
-Michael's TODO list: (unordered) (if anyone wanna help with sth, just ask)
25
-- optimize H264 CABAC
26
-- more optimizations
27
-- simper rate control
28
-
29
-Philip'a TODO list: (alphabetically ordered) (please help)
30
-- Add a multi-ffm filetype so that feeds can be recorded into multiple files rather
31
-  than one big file.
32
-- Authenticated users support -- where the authentication is in the URL
33
-- Change ASF files so that the embedded timestamp in the frames is right rather
34
-  than being an offset from the start of the stream
35
-- Make ffm files more resilient to changes in the codec structures so that you
36
-  can play old ffm files.
37
-
38
-Baptiste's TODO list:
39
-- mov edit list support (AVEditList)
40
-- YUV 10 bit per component support "2vuy"
41
-- mxf muxer
42
-- mpeg2 non linear quantizer
43
-
44
-unassigned TODO: (unordered)
45
-- use AVFrame for audio codecs too
46
-- rework aviobuf.c buffering strategy and fix url_fskip
47
-- generate optimal huffman tables for mjpeg encoding
48
-- fix ffserver regression tests
49
-- support xvids motion estimation
50
-- support x264s motion estimation
51
-- support x264s rate control
52
-- SNOW: non translational motion compensation
53
-- SNOW: more optimal quantization
54
-- SNOW: 4x4 block support
55
-- SNOW: 1/8 pel motion compensation support
56
-- SNOW: iterative motion estimation based on subsampled images
57
-- SNOW: try B frames and MCTF and see how their PSNR/bitrate/complexity behaves
58
-- SNOW: try to use the wavelet transformed MC-ed reference frame as context for the entropy coder
59
-- SNOW: think about/analyize how to make snow use multiple cpus/threads
60
-- SNOW: finish spec
61
-- FLAC: lossy encoding (viterbi and naive scalar quantization)
62
-- libavfilter
63
-- JPEG2000 decoder & encoder
64
-- MPEG4 GMC encoding support
65
-- macroblock based pixel format (better cache locality, somewhat complex, one paper claimed it faster for high res)
66
-- regression tests for codecs which do not have an encoder (I+P-frame bitstream in the 'master' branch)
67
-- add support for using mplayers video filters to ffmpeg
68
-- H264 encoder
69
-- per MB ratecontrol (so VCD and such do work better)
70
-- write a script which iteratively changes all functions between always_inline and noinline and benchmarks the result to find the best set of inlined functions
71
-- convert all the non SIMD asm into small asm vs. C testcases and submit them to the gcc devels so they can improve gcc
72
-- generic audio mixing API
73
-- extract PES packetizer from PS muxer and use it for new TS muxer
74
-- implement automatic AVBistreamFilter activation
75
-- make cabac encoder use bytestream (see http://trac.videolan.org/x264/changeset/?format=diff&new=651)
76
-- merge imdct and windowing, the current code does considerable amounts of redundant work
... ...
@@ -1155,7 +1155,7 @@ static void do_video_out(AVFormatContext *s,
1155 1155
                          AVOutputStream *ost,
1156 1156
                          AVInputStream *ist,
1157 1157
                          AVFrame *in_picture,
1158
-                         int *frame_size)
1158
+                         int *frame_size, float quality)
1159 1159
 {
1160 1160
     int nb_frames, i, ret, av_unused resample_changed;
1161 1161
     AVFrame *final_picture, *formatted_picture;
... ...
@@ -1286,7 +1286,7 @@ static void do_video_out(AVFormatContext *s,
1286 1286
 
1287 1287
             /* handles sameq here. This is not correct because it may
1288 1288
                not be a global option */
1289
-            big_picture.quality = same_quality ? ist->st->quality : ost->st->quality;
1289
+            big_picture.quality = quality;
1290 1290
             if(!me_threshold)
1291 1291
                 big_picture.pict_type = 0;
1292 1292
 //            big_picture.pts = AV_NOPTS_VALUE;
... ...
@@ -1530,6 +1530,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
1530 1530
 #if CONFIG_AVFILTER
1531 1531
     int frame_available;
1532 1532
 #endif
1533
+    float quality;
1533 1534
 
1534 1535
     AVPacket avpkt;
1535 1536
     int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt);
... ...
@@ -1610,7 +1611,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
1610 1610
 
1611 1611
                     ret = avcodec_decode_video2(ist->st->codec,
1612 1612
                                                 &picture, &got_output, &avpkt);
1613
-                    ist->st->quality= picture.quality;
1613
+                    quality = same_quality ? picture.quality : 0;
1614 1614
                     if (ret < 0)
1615 1615
                         goto fail_decode;
1616 1616
                     if (!got_output) {
... ...
@@ -1736,7 +1737,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
1736 1736
                             if (ost->picref->video && !ost->frame_aspect_ratio)
1737 1737
                                 ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
1738 1738
 #endif
1739
-                            do_video_out(os, ost, ist, &picture, &frame_size);
1739
+                            do_video_out(os, ost, ist, &picture, &frame_size,
1740
+                                         same_quality ? quality : ost->st->codec->global_quality);
1740 1741
                             if (vstats_filename && frame_size)
1741 1742
                                 do_video_stats(os, ost, frame_size);
1742 1743
                             break;
... ...
@@ -3602,8 +3604,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
3602 3602
             video_enc->gop_size = 0;
3603 3603
         if (video_qscale || same_quality) {
3604 3604
             video_enc->flags |= CODEC_FLAG_QSCALE;
3605
-            video_enc->global_quality=
3606
-                st->quality = FF_QP2LAMBDA * video_qscale;
3605
+            video_enc->global_quality = FF_QP2LAMBDA * video_qscale;
3607 3606
         }
3608 3607
 
3609 3608
         if(intra_matrix)
... ...
@@ -3721,7 +3722,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx)
3721 3721
 
3722 3722
         if (audio_qscale > QSCALE_NONE) {
3723 3723
             audio_enc->flags |= CODEC_FLAG_QSCALE;
3724
-            audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
3724
+            audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;
3725 3725
         }
3726 3726
         if (audio_channels)
3727 3727
             audio_enc->channels = audio_channels;
... ...
@@ -2128,13 +2128,12 @@ static int open_input_stream(HTTPContext *c, const char *info)
2128 2128
     char buf[128];
2129 2129
     char input_filename[1024];
2130 2130
     AVFormatContext *s = NULL;
2131
-    int buf_size, i, ret;
2131
+    int i, ret;
2132 2132
     int64_t stream_pos;
2133 2133
 
2134 2134
     /* find file name */
2135 2135
     if (c->stream->feed) {
2136 2136
         strcpy(input_filename, c->stream->feed->feed_filename);
2137
-        buf_size = FFM_PACKET_SIZE;
2138 2137
         /* compute position (absolute time) */
2139 2138
         if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
2140 2139
             if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0)
... ...
@@ -2146,7 +2145,6 @@ static int open_input_stream(HTTPContext *c, const char *info)
2146 2146
             stream_pos = av_gettime() - c->stream->prebuffer * (int64_t)1000;
2147 2147
     } else {
2148 2148
         strcpy(input_filename, c->stream->feed_filename);
2149
-        buf_size = 0;
2150 2149
         /* compute position (relative time) */
2151 2150
         if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
2152 2151
             if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0)
... ...
@@ -90,8 +90,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
90 90
         return -1;
91 91
     }
92 92
 
93
-    if (avctx->extradata && avctx->extradata_size > 0)
94
-        s->version_b = avctx->extradata[0];
93
+    s->version_b = avctx->extradata && avctx->extradata[3] == 'b';
95 94
 
96 95
     if (avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) {
97 96
         // audio is already interleaved for the RDFT format variant
... ...
@@ -25,26 +25,10 @@
25 25
  * Flash Screen Video decoder
26 26
  * @author Alex Beregszaszi
27 27
  * @author Benjamin Larsson
28
- */
29
-
30
-/* Bitstream description
31
- * The picture is divided into blocks that are zlib compressed.
32
- *
33
- * The decoder is fed complete frames, the frameheader contains:
34
- * 4bits of block width
35
- * 12bits of frame width
36
- * 4bits of block height
37
- * 12bits of frame height
38 28
  *
39
- * Directly after the header are the compressed blocks. The blocks
40
- * have their compressed size represented with 16bits in the beginnig.
41
- * If the size = 0 then the block is unchanged from the previous frame.
42
- * All blocks are decompressed until the buffer is consumed.
43
- *
44
- * Encoding ideas, a basic encoder would just use a fixed block size.
45
- * Block sizes can be multipels of 16, from 16 to 256. The blocks don't
46
- * have to be quadratic. A brute force search with a set of diffrent
47
- * block sizes should give a better result then to just use a fixed size.
29
+ * A description of the bitstream format for Flash Screen Video version 1/2
30
+ * is part of the SWF File Format Specification (version 10), which can be
31
+ * downloaded from http://www.adobe.com/devnet/swf.html.
48 32
  */
49 33
 
50 34
 #include <stdio.h>
... ...
@@ -71,7 +55,7 @@ static void copy_region(uint8_t *sptr, uint8_t *dptr,
71 71
     int i;
72 72
 
73 73
     for (i = dx + h; i > dx; i--) {
74
-        memcpy(dptr + (i * stride) + dy * 3, sptr, w * 3);
74
+        memcpy(dptr + i * stride + dy * 3, sptr, w * 3);
75 75
         sptr += w * 3;
76 76
     }
77 77
 }
... ...
@@ -86,7 +70,7 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx)
86 86
     s->zstream.zalloc = Z_NULL;
87 87
     s->zstream.zfree  = Z_NULL;
88 88
     s->zstream.opaque = Z_NULL;
89
-    zret = inflateInit(&(s->zstream));
89
+    zret = inflateInit(&s->zstream);
90 90
     if (zret != Z_OK) {
91 91
         av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
92 92
         return 1;
... ...
@@ -102,7 +86,6 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx)
102 102
 static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
103 103
                                 int *data_size, AVPacket *avpkt)
104 104
 {
105
-    const uint8_t *buf = avpkt->data;
106 105
     int buf_size       = avpkt->size;
107 106
     FlashSVContext *s  = avctx->priv_data;
108 107
     int h_blocks, v_blocks, h_part, v_part, i, j;
... ...
@@ -114,7 +97,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
114 114
     if (buf_size < 4)
115 115
         return -1;
116 116
 
117
-    init_get_bits(&gb, buf, buf_size * 8);
117
+    init_get_bits(&gb, avpkt->data, buf_size * 8);
118 118
 
119 119
     /* start to parse the bitstream */
120 120
     s->block_width  = 16 * (get_bits(&gb,  4) + 1);
... ...
@@ -122,7 +105,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
122 122
     s->block_height = 16 * (get_bits(&gb,  4) + 1);
123 123
     s->image_height =       get_bits(&gb, 12);
124 124
 
125
-    /* calculate amount of blocks and the size of the border blocks */
125
+    /* calculate number of blocks and size of border (partial) blocks */
126 126
     h_blocks = s->image_width  / s->block_width;
127 127
     h_part   = s->image_width  % s->block_width;
128 128
     v_blocks = s->image_height / s->block_height;
... ...
@@ -139,26 +122,29 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
139 139
     }
140 140
     s->block_size = s->block_width * s->block_height;
141 141
 
142
-    /* init the image size once */
143
-    if ((avctx->width == 0) && (avctx->height == 0)) {
142
+    /* initialize the image size once */
143
+    if (avctx->width == 0 && avctx->height == 0) {
144 144
         avctx->width  = s->image_width;
145 145
         avctx->height = s->image_height;
146 146
     }
147 147
 
148 148
     /* check for changes of image width and image height */
149
-    if ((avctx->width != s->image_width) || (avctx->height != s->image_height)) {
150
-        av_log(avctx, AV_LOG_ERROR, "Frame width or height differs from first frames!\n");
151
-        av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d  vs  ch = %d, cv = %d\n", avctx->height,
152
-        avctx->width, s->image_height, s->image_width);
153
-        return -1;
149
+    if (avctx->width != s->image_width || avctx->height != s->image_height) {
150
+        av_log(avctx, AV_LOG_ERROR,
151
+               "Frame width or height differs from first frames!\n");
152
+        av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d  vs  ch = %d, cv = %d\n",
153
+               avctx->height, avctx->width, s->image_height, s->image_width);
154
+        return AVERROR_INVALIDDATA;
154 155
     }
155 156
 
156
-    av_log(avctx, AV_LOG_DEBUG, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n",
157
-           s->image_width, s->image_height, s->block_width, s->block_height,
158
-           h_blocks, v_blocks, h_part, v_part);
157
+    av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n",
158
+            s->image_width, s->image_height, s->block_width, s->block_height,
159
+            h_blocks, v_blocks, h_part, v_part);
159 160
 
160
-    s->frame.reference    = 1;
161
-    s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
161
+    s->frame.reference    = 3;
162
+    s->frame.buffer_hints = FF_BUFFER_HINTS_VALID    |
163
+                            FF_BUFFER_HINTS_PRESERVE |
164
+                            FF_BUFFER_HINTS_REUSABLE;
162 165
     if (avctx->reget_buffer(avctx, &s->frame) < 0) {
163 166
         av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
164 167
         return -1;
... ...
@@ -167,48 +153,50 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
167 167
     /* loop over all block columns */
168 168
     for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) {
169 169
 
170
-        int hp = j * s->block_height; // horiz position in frame
171
-        int hs = (j < v_blocks) ? s->block_height : v_part; // size of block
170
+        int hp = j * s->block_height; // vertical position in frame
171
+        int hs = (j < v_blocks) ? s->block_height : v_part; // block size
172 172
 
173 173
 
174 174
         /* loop over all block rows */
175 175
         for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) {
176
-            int wp = i * s->block_width; // vert position in frame
177
-            int ws = (i < h_blocks) ? s->block_width : h_part; // size of block
176
+            int wp = i * s->block_width; // horizontal position in frame
177
+            int ws = (i < h_blocks) ? s->block_width : h_part; // block size
178 178
 
179 179
             /* get the size of the compressed zlib chunk */
180 180
             int size = get_bits(&gb, 16);
181 181
             if (8 * size > get_bits_left(&gb)) {
182 182
                 avctx->release_buffer(avctx, &s->frame);
183 183
                 s->frame.data[0] = NULL;
184
-                return -1;
184
+                return AVERROR_INVALIDDATA;
185 185
             }
186 186
 
187
-            if (size == 0) {
188
-                /* no change, don't do anything */
189
-            } else {
187
+            /* skip unchanged blocks, which have size 0 */
188
+            if (size) {
190 189
                 /* decompress block */
191
-                int ret = inflateReset(&(s->zstream));
190
+                int ret = inflateReset(&s->zstream);
192 191
                 if (ret != Z_OK) {
193
-                    av_log(avctx, AV_LOG_ERROR, "error in decompression (reset) of block %dx%d\n", i, j);
192
+                    av_log(avctx, AV_LOG_ERROR,
193
+                           "error in decompression (reset) of block %dx%d\n", i, j);
194 194
                     /* return -1; */
195 195
                 }
196
-                s->zstream.next_in   = buf + (get_bits_count(&gb) / 8);
196
+                s->zstream.next_in   = avpkt->data + get_bits_count(&gb) / 8;
197 197
                 s->zstream.avail_in  = size;
198 198
                 s->zstream.next_out  = s->tmpblock;
199 199
                 s->zstream.avail_out = s->block_size * 3;
200
-                ret = inflate(&(s->zstream), Z_FINISH);
200
+                ret = inflate(&s->zstream, Z_FINISH);
201 201
                 if (ret == Z_DATA_ERROR) {
202 202
                     av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n");
203
-                    inflateSync(&(s->zstream));
204
-                    ret = inflate(&(s->zstream), Z_FINISH);
203
+                    inflateSync(&s->zstream);
204
+                    ret = inflate(&s->zstream, Z_FINISH);
205 205
                 }
206 206
 
207
-                if ((ret != Z_OK) && (ret != Z_STREAM_END)) {
208
-                    av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d: %d\n", i, j, ret);
207
+                if (ret != Z_OK && ret != Z_STREAM_END) {
208
+                    av_log(avctx, AV_LOG_ERROR,
209
+                           "error in decompression of block %dx%d: %d\n", i, j, ret);
209 210
                     /* return -1; */
210 211
                 }
211
-                copy_region(s->tmpblock, s->frame.data[0], s->image_height - (hp + hs + 1),
212
+                copy_region(s->tmpblock, s->frame.data[0],
213
+                            s->image_height - (hp + hs + 1),
212 214
                             wp, hs, ws, s->frame.linesize[0]);
213 215
                 skip_bits_long(&gb, 8 * size);   /* skip the consumed bits */
214 216
             }
... ...
@@ -230,7 +218,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
230 230
 static av_cold int flashsv_decode_end(AVCodecContext *avctx)
231 231
 {
232 232
     FlashSVContext *s = avctx->priv_data;
233
-    inflateEnd(&(s->zstream));
233
+    inflateEnd(&s->zstream);
234 234
     /* release the frame if needed */
235 235
     if (s->frame.data[0])
236 236
         avctx->release_buffer(avctx, &s->frame);
... ...
@@ -100,7 +100,7 @@ static const uint8_t tc0_table[52*3][4] = {
100 100
     {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
101 101
 };
102 102
 
103
-static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h) {
103
+static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h) {
104 104
     const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
105 105
     const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
106 106
     const int alpha = alpha_table[index_a];
... ...
@@ -118,7 +118,7 @@ static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t
118 118
         h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);
119 119
     }
120 120
 }
121
-static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
121
+static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
122 122
     const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
123 123
     const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
124 124
     const int alpha = alpha_table[index_a];
... ...
@@ -137,7 +137,7 @@ static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t
137 137
     }
138 138
 }
139 139
 
140
-static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) {
140
+static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) {
141 141
     const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
142 142
     int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
143 143
     int alpha = alpha_table[index_a];
... ...
@@ -155,7 +155,7 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int
155 155
         h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
156 156
     }
157 157
 }
158
-static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) {
158
+static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) {
159 159
     const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
160 160
     int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
161 161
     int alpha = alpha_table[index_a];
... ...
@@ -174,7 +174,7 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, in
174 174
     }
175 175
 }
176 176
 
177
-static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
177
+static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
178 178
     const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
179 179
     const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
180 180
     const int alpha = alpha_table[index_a];
... ...
@@ -193,7 +193,7 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t
193 193
     }
194 194
 }
195 195
 
196
-static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
196
+static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
197 197
     const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
198 198
     const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
199 199
     const int alpha = alpha_table[index_a];
... ...
@@ -247,9 +247,9 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
247 247
         return;
248 248
 
249 249
     if( IS_INTRA(mb_type) ) {
250
-        int16_t bS4[4] = {4,4,4,4};
251
-        int16_t bS3[4] = {3,3,3,3};
252
-        int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;
250
+        static const int16_t bS4[4] = {4,4,4,4};
251
+        static const int16_t bS3[4] = {3,3,3,3};
252
+        const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;
253 253
         if(left_type)
254 254
             filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h);
255 255
         if( IS_8x8DCT(mb_type) ) {
... ...
@@ -528,12 +528,14 @@ typedef struct AVStream {
528 528
     int stream_copy; /**< If set, just copy stream. */
529 529
     enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
530 530
 
531
+#if FF_API_AVSTREAM_QUALITY
531 532
     //FIXME move stuff to a flags field?
532 533
     /**
533 534
      * Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
534 535
      * MN: dunno if that is the right place for it
535 536
      */
536
-    float quality;
537
+    attribute_deprecated float quality;
538
+#endif
537 539
 
538 540
     /**
539 541
      * Decoding: pts of the first frame of the stream, in stream time base.
... ...
@@ -134,15 +134,18 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
134 134
             if (!ast)
135 135
                 return AVERROR(ENOMEM);
136 136
             ast->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
137
+            ast->codec->codec_tag   = 0;
137 138
             ast->codec->sample_rate = avio_rl16(pb);
138 139
             av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
139 140
             flags = avio_rl16(pb);
140 141
             ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
141 142
                                    CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT;
142 143
             ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1;
143
-            ast->codec->extradata  = av_mallocz(1 + FF_INPUT_BUFFER_PADDING_SIZE);
144
-            ast->codec->extradata_size = 1;
145
-            ast->codec->extradata[0] = vst->codec->codec_tag == MKTAG('B','I','K','b');
144
+            ast->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
145
+            if (!ast->codec->extradata)
146
+                return AVERROR(ENOMEM);
147
+            ast->codec->extradata_size = 4;
148
+            AV_WL32(ast->codec->extradata, vst->codec->codec_tag);
146 149
         }
147 150
 
148 151
         for (i = 0; i < bink->num_audio_tracks; i++)
... ...
@@ -301,7 +301,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
301 301
         codec->codec_id = avio_rb32(pb);
302 302
         codec->codec_type = avio_r8(pb); /* codec_type */
303 303
         codec->bit_rate = avio_rb32(pb);
304
-        st->quality = avio_rb32(pb);
305 304
         codec->flags = avio_rb32(pb);
306 305
         codec->flags2 = avio_rb32(pb);
307 306
         codec->debug = avio_rb32(pb);
... ...
@@ -114,7 +114,6 @@ static int ffm_write_header(AVFormatContext *s)
114 114
         avio_wb32(pb, codec->codec_id);
115 115
         avio_w8(pb, codec->codec_type);
116 116
         avio_wb32(pb, codec->bit_rate);
117
-        avio_wb32(pb, st->quality);
118 117
         avio_wb32(pb, codec->flags);
119 118
         avio_wb32(pb, codec->flags2);
120 119
         avio_wb32(pb, codec->debug);
... ...
@@ -77,5 +77,8 @@
77 77
 #ifndef FF_API_FLAG_RTP_HINT
78 78
 #define FF_API_FLAG_RTP_HINT           (LIBAVFORMAT_VERSION_MAJOR < 54)
79 79
 #endif
80
+#ifndef FF_API_AVSTREAM_QUALITY
81
+#define FF_API_AVSTREAM_QUALITY        (LIBAVFORMAT_VERSION_MAJOR < 54)
82
+#endif
80 83
 
81 84
 #endif /* AVFORMAT_VERSION_H */
... ...
@@ -500,6 +500,7 @@ int av_expr_parse(AVExpr **expr, const char *s,
500 500
     if ((ret = parse_expr(&e, &p)) < 0)
501 501
         goto end;
502 502
     if (*p.s) {
503
+        av_expr_free(e);
503 504
         av_log(&p, AV_LOG_ERROR, "Invalid chars '%s' at the end of expression '%s'\n", p.s, s0);
504 505
         ret = AVERROR(EINVAL);
505 506
         goto end;
... ...
@@ -601,7 +602,7 @@ int main(int argc, char **argv)
601 601
         "-PI",
602 602
         "+PI",
603 603
         "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
604
-        "80G/80Gi"
604
+        "80G/80Gi",
605 605
         "1k",
606 606
         "1Gi",
607 607
         "1gi",
... ...
@@ -246,7 +246,6 @@ static inline int isVertDC_C(uint8_t src[], int stride, PPContext *c)
246 246
 static inline int isHorizMinMaxOk_C(uint8_t src[], int stride, int QP)
247 247
 {
248 248
     int i;
249
-#if 1
250 249
     for(i=0; i<2; i++){
251 250
         if((unsigned)(src[0] - src[5] + 2*QP) > 4*QP) return 0;
252 251
         src += stride;
... ...
@@ -257,19 +256,11 @@ static inline int isHorizMinMaxOk_C(uint8_t src[], int stride, int QP)
257 257
         if((unsigned)(src[6] - src[3] + 2*QP) > 4*QP) return 0;
258 258
         src += stride;
259 259
     }
260
-#else
261
-    for(i=0; i<8; i++){
262
-        if((unsigned)(src[0] - src[7] + 2*QP) > 4*QP) return 0;
263
-        src += stride;
264
-    }
265
-#endif
266 260
     return 1;
267 261
 }
268 262
 
269 263
 static inline int isVertMinMaxOk_C(uint8_t src[], int stride, int QP)
270 264
 {
271
-#if 1
272
-#if 1
273 265
     int x;
274 266
     src+= stride*4;
275 267
     for(x=0; x<BLOCK_SIZE; x+=4){
... ...
@@ -278,30 +269,7 @@ static inline int isVertMinMaxOk_C(uint8_t src[], int stride, int QP)
278 278
         if((unsigned)(src[2+x + 4*stride] - src[2+x + 1*stride] + 2*QP) > 4*QP) return 0;
279 279
         if((unsigned)(src[3+x + 6*stride] - src[3+x + 3*stride] + 2*QP) > 4*QP) return 0;
280 280
     }
281
-#else
282
-    int x;
283
-    src+= stride*3;
284
-    for(x=0; x<BLOCK_SIZE; x++){
285
-        if((unsigned)(src[x + stride] - src[x + (stride<<3)] + 2*QP) > 4*QP) return 0;
286
-    }
287
-#endif
288
-    return 1;
289
-#else
290
-    int x;
291
-    src+= stride*4;
292
-    for(x=0; x<BLOCK_SIZE; x++){
293
-        int min=255;
294
-        int max=0;
295
-        int y;
296
-        for(y=0; y<8; y++){
297
-            int v= src[x + y*stride];
298
-            if(v>max) max=v;
299
-            if(v<min) min=v;
300
-        }
301
-        if(max-min > 2*QP) return 0;
302
-    }
303 281
     return 1;
304
-#endif
305 282
 }
306 283
 
307 284
 static inline int horizClassify_C(uint8_t src[], int stride, PPContext *c)
... ...
@@ -435,7 +435,10 @@ typedef struct SwsContext {
435 435
      * @param dstW       width of destination image
436 436
      * @param src        pointer to source data to be scaled. If scaling depth
437 437
      *                   is 8, this is 8bpp in 8bpp (uint8_t) width. If scaling
438
-     *                   depth is 16, this is 16bpp in 16bpp (uint16_t) depth.
438
+     *                   depth is 16, this is native depth in 16bbp (uint16_t)
439
+     *                   width. In other words, for 9-bit YUV input, this is
440
+     *                   9bpp, for 10-bit YUV input, this is 10bpp, and for
441
+     *                   16-bit RGB or YUV, this is 16bpp.
439 442
      * @param filter     filter coefficients to be used per output pixel for
440 443
      *                   scaling. This contains 14bpp filtering coefficients.
441 444
      *                   Guaranteed to contain dstW * filterSize entries.
... ...
@@ -16,8 +16,11 @@ Evaluating '+PI'
16 16
 Evaluating '1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)'
17 17
 '1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)' -> 12.700000
18 18
 
19
-Evaluating '80G/80Gi1k'
20
-'80G/80Gi1k' -> nan
19
+Evaluating '80G/80Gi'
20
+'80G/80Gi' -> 0.931323
21
+
22
+Evaluating '1k'
23
+'1k' -> 1000.000000
21 24
 
22 25
 Evaluating '1Gi'
23 26
 '1Gi' -> 1073741824.000000
... ...
@@ -1,3 +1,3 @@
1
-b6acf782a38d313153b68c4ca204fc90 *./tests/data/lavf/lavf.ffm
1
+f9bee27ea1b6b83a06b5f9efb0a4ac1f *./tests/data/lavf/lavf.ffm
2 2
 376832 ./tests/data/lavf/lavf.ffm
3 3
 ./tests/data/lavf/lavf.ffm CRC=0xf361ed74