Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
adtsenc: Check frame size.
txd: Fix order of operations.
APIchanges: fill in some blanks
timer: fix misspelling of "decicycles"
Eliminate pointless 0/NULL initializers in AVCodec and similar declarations.
indeo3: cosmetics
md5proto: Fix order of operations.
dca: Replace oversized unused get_bits() with skip_bits_long().

Conflicts:
doc/APIchanges
libavformat/mmsh.c

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

Michael Niedermayer authored on 2011/11/29 08:20:29
Showing 26 changed files
... ...
@@ -22,14 +22,14 @@ API changes, most recent first:
22 22
 2011-10-20 - b35e9e1 - lavu 51.22.0
23 23
   Add av_strtok() to avstring.h.
24 24
 
25
-2011-xx-xx - xxxxxxx - lavu 51.18.0
25
+2011-11-23 - bbb46f3 - lavu 51.18.0
26 26
   Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and
27 27
   av_samples_alloc(), to samplefmt.h.
28 28
 
29
-2011-xx-xx - xxxxxxx - lavu 51.17.0
29
+2011-11-23 - 8889cc4 - lavu 51.17.0
30 30
   Add planar sample formats and av_sample_fmt_is_planar() to samplefmt.h.
31 31
 
32
-2011-xx-xx - xxxxxxx - lavc 53.21.0
32
+2011-11-19 - f3a29b7 - lavc 53.21.0
33 33
   Move some AVCodecContext fields to a new private struct, AVCodecInternal,
34 34
   which is accessed from a new field, AVCodecContext.internal.
35 35
   - fields moved:
... ...
@@ -37,6 +37,9 @@ API changes, most recent first:
37 37
       AVCodecContext.internal_buffer_count --> AVCodecInternal.buffer_count
38 38
       AVCodecContext.is_copy               --> AVCodecInternal.is_copy
39 39
 
40
+2011-11-16 - 6270671 - lavu 51.16.0
41
+  Add av_timegm()
42
+
40 43
 2011-11-13 - lavf 53.15.0
41 44
   New interrupt callback API, allowing per-AVFormatContext/AVIOContext
42 45
   interrupt callbacks.
... ...
@@ -47,9 +50,6 @@ API changes, most recent first:
47 47
           This will allow passing AVOptions to protocols after lavf
48 48
           54.0.
49 49
 
50
-2011-11-xx - xxxxxxx - lavu 51.16.0
51
-  Add av_timegm()
52
-
53 50
 2011-11-06 - ba04ecf - lavu 51.14.0
54 51
   Add av_strcasecmp() and av_strncasecmp() to avstring.h.
55 52
 
... ...
@@ -519,7 +519,7 @@ static int dca_parse_frame_header(DCAContext * s)
519 519
     init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
520 520
 
521 521
     /* Sync code */
522
-    get_bits(&s->gb, 32);
522
+    skip_bits_long(&s->gb, 32);
523 523
 
524 524
     /* Frame header */
525 525
     s->frame_type        = get_bits(&s->gb, 1);
... ...
@@ -1257,7 +1257,7 @@ static int dca_subframe_footer(DCAContext * s, int base_channel)
1257 1257
     /* presumably optional information only appears in the core? */
1258 1258
     if (!base_channel) {
1259 1259
         if (s->timestamp)
1260
-            get_bits(&s->gb, 32);
1260
+            skip_bits_long(&s->gb, 32);
1261 1261
 
1262 1262
         if (s->aux_data)
1263 1263
             aux_data_count = get_bits(&s->gb, 6);
... ...
@@ -443,7 +443,6 @@ AVHWAccel ff_h264_dxva2_hwaccel = {
443 443
     .type           = AVMEDIA_TYPE_VIDEO,
444 444
     .id             = CODEC_ID_H264,
445 445
     .pix_fmt        = PIX_FMT_DXVA2_VLD,
446
-    .capabilities   = 0,
447 446
     .start_frame    = start_frame,
448 447
     .decode_slice   = decode_slice,
449 448
     .end_frame      = end_frame,
... ...
@@ -265,7 +265,6 @@ AVHWAccel ff_mpeg2_dxva2_hwaccel = {
265 265
     .type           = AVMEDIA_TYPE_VIDEO,
266 266
     .id             = CODEC_ID_MPEG2VIDEO,
267 267
     .pix_fmt        = PIX_FMT_DXVA2_VLD,
268
-    .capabilities   = 0,
269 268
     .start_frame    = start_frame,
270 269
     .decode_slice   = decode_slice,
271 270
     .end_frame      = end_frame,
... ...
@@ -269,7 +269,6 @@ AVHWAccel ff_wmv3_dxva2_hwaccel = {
269 269
     .type           = AVMEDIA_TYPE_VIDEO,
270 270
     .id             = CODEC_ID_WMV3,
271 271
     .pix_fmt        = PIX_FMT_DXVA2_VLD,
272
-    .capabilities   = 0,
273 272
     .start_frame    = start_frame,
274 273
     .decode_slice   = decode_slice,
275 274
     .end_frame      = end_frame,
... ...
@@ -282,7 +281,6 @@ AVHWAccel ff_vc1_dxva2_hwaccel = {
282 282
     .type           = AVMEDIA_TYPE_VIDEO,
283 283
     .id             = CODEC_ID_VC1,
284 284
     .pix_fmt        = PIX_FMT_DXVA2_VLD,
285
-    .capabilities   = 0,
286 285
     .start_frame    = start_frame,
287 286
     .decode_slice   = decode_slice,
288 287
     .end_frame      = end_frame,
... ...
@@ -759,7 +759,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
759 759
                     av_log(avctx, AV_LOG_ERROR, "SkipCell procedure not implemented yet!\n");
760 760
 
761 761
                 CHECK_CELL
762
-                if(!curr_cell.mv_ptr)
762
+                if (!curr_cell.mv_ptr)
763 763
                     return AVERROR_INVALIDDATA;
764 764
                 copy_cell(ctx, plane, &curr_cell);
765 765
                 return 0;
... ...
@@ -108,6 +108,5 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
108 108
 
109 109
 AVBitStreamFilter ff_mjpeg2jpeg_bsf = {
110 110
     .name           = "mjpeg2jpeg",
111
-    .priv_data_size = 0,
112 111
     .filter         = mjpeg2jpeg_filter,
113 112
 };
... ...
@@ -144,7 +144,6 @@ AVCodec ff_s302m_decoder = {
144 144
     .name           = "s302m",
145 145
     .type           = AVMEDIA_TYPE_AUDIO,
146 146
     .id             = CODEC_ID_S302M,
147
-    .priv_data_size = 0,
148 147
     .decode         = s302m_decode_frame,
149 148
     .long_name      = NULL_IF_CONFIG_SMALL("SMPTE 302M"),
150 149
 };
... ...
@@ -116,7 +116,8 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
116 116
     } else if (depth == 16) {
117 117
         switch (d3d_format) {
118 118
         case 0:
119
-            if (!flags&1) goto unsupported;
119
+            if (!(flags & 1))
120
+                goto unsupported;
120 121
         case FF_S3TC_DXT1:
121 122
             if (buf_end - cur < (w/4) * (h/4) * 8)
122 123
                 return AVERROR_INVALIDDATA;
... ...
@@ -342,9 +342,7 @@ AVHWAccel ff_h264_vaapi_hwaccel = {
342 342
     .type           = AVMEDIA_TYPE_VIDEO,
343 343
     .id             = CODEC_ID_H264,
344 344
     .pix_fmt        = PIX_FMT_VAAPI_VLD,
345
-    .capabilities   = 0,
346 345
     .start_frame    = start_frame,
347 346
     .end_frame      = end_frame,
348 347
     .decode_slice   = decode_slice,
349
-    .priv_data_size = 0,
350 348
 };
... ...
@@ -143,9 +143,7 @@ AVHWAccel ff_mpeg2_vaapi_hwaccel = {
143 143
     .type           = AVMEDIA_TYPE_VIDEO,
144 144
     .id             = CODEC_ID_MPEG2VIDEO,
145 145
     .pix_fmt        = PIX_FMT_VAAPI_VLD,
146
-    .capabilities   = 0,
147 146
     .start_frame    = vaapi_mpeg2_start_frame,
148 147
     .end_frame      = vaapi_mpeg2_end_frame,
149 148
     .decode_slice   = vaapi_mpeg2_decode_slice,
150
-    .priv_data_size = 0,
151 149
 };
... ...
@@ -155,11 +155,9 @@ AVHWAccel ff_mpeg4_vaapi_hwaccel = {
155 155
     .type           = AVMEDIA_TYPE_VIDEO,
156 156
     .id             = CODEC_ID_MPEG4,
157 157
     .pix_fmt        = PIX_FMT_VAAPI_VLD,
158
-    .capabilities   = 0,
159 158
     .start_frame    = vaapi_mpeg4_start_frame,
160 159
     .end_frame      = vaapi_mpeg4_end_frame,
161 160
     .decode_slice   = vaapi_mpeg4_decode_slice,
162
-    .priv_data_size = 0,
163 161
 };
164 162
 #endif
165 163
 
... ...
@@ -169,10 +167,8 @@ AVHWAccel ff_h263_vaapi_hwaccel = {
169 169
     .type           = AVMEDIA_TYPE_VIDEO,
170 170
     .id             = CODEC_ID_H263,
171 171
     .pix_fmt        = PIX_FMT_VAAPI_VLD,
172
-    .capabilities   = 0,
173 172
     .start_frame    = vaapi_mpeg4_start_frame,
174 173
     .end_frame      = vaapi_mpeg4_end_frame,
175 174
     .decode_slice   = vaapi_mpeg4_decode_slice,
176
-    .priv_data_size = 0,
177 175
 };
178 176
 #endif
... ...
@@ -346,11 +346,9 @@ AVHWAccel ff_wmv3_vaapi_hwaccel = {
346 346
     .type           = AVMEDIA_TYPE_VIDEO,
347 347
     .id             = CODEC_ID_WMV3,
348 348
     .pix_fmt        = PIX_FMT_VAAPI_VLD,
349
-    .capabilities   = 0,
350 349
     .start_frame    = vaapi_vc1_start_frame,
351 350
     .end_frame      = vaapi_vc1_end_frame,
352 351
     .decode_slice   = vaapi_vc1_decode_slice,
353
-    .priv_data_size = 0,
354 352
 };
355 353
 #endif
356 354
 
... ...
@@ -359,9 +357,7 @@ AVHWAccel ff_vc1_vaapi_hwaccel = {
359 359
     .type           = AVMEDIA_TYPE_VIDEO,
360 360
     .id             = CODEC_ID_VC1,
361 361
     .pix_fmt        = PIX_FMT_VAAPI_VLD,
362
-    .capabilities   = 0,
363 362
     .start_frame    = vaapi_vc1_start_frame,
364 363
     .end_frame      = vaapi_vc1_end_frame,
365 364
     .decode_slice   = vaapi_vc1_decode_slice,
366
-    .priv_data_size = 0,
367 365
 };
... ...
@@ -86,7 +86,6 @@ AVHWAccel ff_h264_vda_hwaccel = {
86 86
     .type           = AVMEDIA_TYPE_VIDEO,
87 87
     .id             = CODEC_ID_H264,
88 88
     .pix_fmt        = PIX_FMT_VDA_VLD,
89
-    .capabilities   = 0,
90 89
     .start_frame    = start_frame,
91 90
     .decode_slice   = decode_slice,
92 91
     .end_frame      = end_frame,
... ...
@@ -166,7 +166,6 @@ static int a64_write_trailer(struct AVFormatContext *s)
166 166
 AVOutputFormat ff_a64_muxer = {
167 167
     .name = "a64",
168 168
     .long_name = NULL_IF_CONFIG_SMALL("a64 - video for Commodore 64"),
169
-    .mime_type = NULL,
170 169
     .extensions = "a64, A64",
171 170
     .priv_data_size = sizeof (A64Context),
172 171
     .video_codec = CODEC_ID_A64_MULTI,
... ...
@@ -27,6 +27,8 @@
27 27
 #include "avformat.h"
28 28
 #include "adts.h"
29 29
 
30
+#define ADTS_MAX_FRAME_BYTES ((1 << 13) - 1)
31
+
30 32
 int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf, int size)
31 33
 {
32 34
     GetBitContext gb;
... ...
@@ -93,6 +95,13 @@ int ff_adts_write_frame_header(ADTSContext *ctx,
93 93
 {
94 94
     PutBitContext pb;
95 95
 
96
+    unsigned full_frame_size = (unsigned)ADTS_HEADER_SIZE + size + pce_size;
97
+    if (full_frame_size > ADTS_MAX_FRAME_BYTES) {
98
+        av_log(NULL, AV_LOG_ERROR, "ADTS frame size too large: %u (max %d)\n",
99
+               full_frame_size, ADTS_MAX_FRAME_BYTES);
100
+        return AVERROR_INVALIDDATA;
101
+    }
102
+
96 103
     init_put_bits(&pb, buf, ADTS_HEADER_SIZE);
97 104
 
98 105
     /* adts_fixed_header */
... ...
@@ -110,7 +119,7 @@ int ff_adts_write_frame_header(ADTSContext *ctx,
110 110
     /* adts_variable_header */
111 111
     put_bits(&pb, 1, 0);        /* copyright_identification_bit */
112 112
     put_bits(&pb, 1, 0);        /* copyright_identification_start */
113
-    put_bits(&pb, 13, ADTS_HEADER_SIZE + size + pce_size); /* aac_frame_length */
113
+    put_bits(&pb, 13, full_frame_size); /* aac_frame_length */
114 114
     put_bits(&pb, 11, 0x7ff);   /* adts_buffer_fullness */
115 115
     put_bits(&pb, 2, 0);        /* number_of_raw_data_blocks_in_frame */
116 116
 
... ...
@@ -128,7 +137,10 @@ static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
128 128
     if (!pkt->size)
129 129
         return 0;
130 130
     if (adts->write_adts) {
131
-        ff_adts_write_frame_header(adts, buf, pkt->size, adts->pce_size);
131
+        int err = ff_adts_write_frame_header(adts, buf, pkt->size,
132
+                                             adts->pce_size);
133
+        if (err < 0)
134
+            return err;
132 135
         avio_write(pb, buf, ADTS_HEADER_SIZE);
133 136
         if (adts->pce_size) {
134 137
             avio_write(pb, adts->pce_data, adts->pce_size);
... ...
@@ -176,7 +176,6 @@ static int amr_read_packet(AVFormatContext *s,
176 176
 AVInputFormat ff_amr_demuxer = {
177 177
     .name           = "amr",
178 178
     .long_name      = NULL_IF_CONFIG_SMALL("3GPP AMR file format"),
179
-    .priv_data_size = 0, /*priv_data_size*/
180 179
     .read_probe     = amr_probe,
181 180
     .read_header    = amr_read_header,
182 181
     .read_packet    = amr_read_packet,
... ...
@@ -36,7 +36,7 @@ static int md5_open(URLContext *h, const char *filename, int flags)
36 36
         return -1;
37 37
     }
38 38
 
39
-    if (!flags & AVIO_FLAG_WRITE)
39
+    if (!(flags & AVIO_FLAG_WRITE))
40 40
         return AVERROR(EINVAL);
41 41
 
42 42
     av_md5_init(h->priv_data);
... ...
@@ -406,7 +406,6 @@ URLProtocol ff_mmsh_protocol = {
406 406
     .name      = "mmsh",
407 407
     .url_open  = mmsh_open,
408 408
     .url_read  = mmsh_read,
409
-    .url_write = NULL,
410 409
     .url_seek  = mmsh_seek,
411 410
     .url_close = mmsh_close,
412 411
     .url_read_seek  = mmsh_read_seek,
... ...
@@ -620,7 +620,6 @@ AVInputFormat ff_mpegps_demuxer = {
620 620
     .read_probe     = mpegps_probe,
621 621
     .read_header    = mpegps_read_header,
622 622
     .read_packet    = mpegps_read_packet,
623
-    .read_seek      = NULL, //mpegps_read_seek,
624 623
     .read_timestamp = mpegps_read_dts,
625 624
     .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT,
626 625
 };
... ...
@@ -1006,7 +1006,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
1006 1006
             return -1;
1007 1007
         if ((AV_RB16(pkt->data) & 0xfff0) != 0xfff0) {
1008 1008
             ADTSContext *adts = ts_st->adts;
1009
-            int new_size;
1009
+            int new_size, err;
1010 1010
             if (!adts) {
1011 1011
                 av_log(s, AV_LOG_ERROR, "aac bitstream not in adts format "
1012 1012
                        "and extradata missing\n");
... ...
@@ -1018,7 +1018,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
1018 1018
             data = av_malloc(new_size);
1019 1019
             if (!data)
1020 1020
                 return AVERROR(ENOMEM);
1021
-            ff_adts_write_frame_header(adts, data, pkt->size, adts->pce_size);
1021
+            err = ff_adts_write_frame_header(adts, data, pkt->size,
1022
+                                             adts->pce_size);
1023
+            if (err < 0) {
1024
+                av_free(data);
1025
+                return err;
1026
+            }
1022 1027
             if (adts->pce_size) {
1023 1028
                 memcpy(data+ADTS_HEADER_SIZE, adts->pce_data, adts->pce_size);
1024 1029
                 adts->pce_size = 0;
... ...
@@ -92,11 +92,8 @@ AVInputFormat ff_rso_demuxer = {
92 92
     .name           =   "rso",
93 93
     .long_name      =   NULL_IF_CONFIG_SMALL("Lego Mindstorms RSO format"),
94 94
     .extensions     =   "rso",
95
-    .priv_data_size =   0,
96
-    .read_probe     =   NULL, /* no magic value in this format */
97 95
     .read_header    =   rso_read_header,
98 96
     .read_packet    =   rso_read_packet,
99
-    .read_close     =   NULL,
100 97
     .read_seek      =   pcm_read_seek,
101 98
     .codec_tag      =   (const AVCodecTag* const []){ff_codec_rso_tags, 0},
102 99
 };
... ...
@@ -104,7 +104,6 @@ AVOutputFormat ff_rso_muxer = {
104 104
     .name           =   "rso",
105 105
     .long_name      =   NULL_IF_CONFIG_SMALL("Lego Mindstorms RSO format"),
106 106
     .extensions     =   "rso",
107
-    .priv_data_size =   0,
108 107
     .audio_codec    =   CODEC_ID_PCM_U8,
109 108
     .video_codec    =   CODEC_ID_NONE,
110 109
     .write_header   =   rso_write_header,
... ...
@@ -234,9 +234,6 @@ RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler = {
234 234
     .codec_type         = AVMEDIA_TYPE_VIDEO,
235 235
     .codec_id           = CODEC_ID_MPEG4,
236 236
     .parse_sdp_a_line   = parse_sdp_line,
237
-    .alloc              = NULL,
238
-    .free               = NULL,
239
-    .parse_packet       = NULL
240 237
 };
241 238
 
242 239
 RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler = {
... ...
@@ -246,7 +246,6 @@ URLProtocol ff_tls_protocol = {
246 246
     .url_open       = tls_open,
247 247
     .url_read       = tls_read,
248 248
     .url_write      = tls_write,
249
-    .url_seek       = NULL,
250 249
     .url_close      = tls_close,
251 250
     .priv_data_size = sizeof(TLSContext),
252 251
 };
... ...
@@ -61,7 +61,7 @@ tend= AV_READ_TIME();\
61 61
     }else\
62 62
         tskip_count++;\
63 63
     if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\
64
-        av_log(NULL, AV_LOG_ERROR, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n",\
64
+        av_log(NULL, AV_LOG_ERROR, "%"PRIu64" decicycles in %s, %d runs, %d skips\n",\
65 65
                tsum*10/tcount, id, tcount, tskip_count);\
66 66
     }\
67 67
 }