Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
Revert "v210enc: use FFALIGN()"
doxygen: Do not include license boilerplates in Doxygen comment blocks.
avplay: reset decoder flush state when seeking
ape: skip packets with invalid size
ape: calculate final packet size instead of guessing
ape: stop reading after the last frame has been read
ape: return AVERROR_EOF instead of AVERROR(EIO) when demuxing is finished
ape: return error if seeking to the current packet fails in ape_read_packet()
avcodec: Clarify AVFrame member documentation.
v210dec: check for coded_frame allocation failure
v210enc: use stride as it is already calculated
v210enc: use FFALIGN()
v210enc: return proper AVERROR codes instead of -1
v210enc: do not set coded_frame->key_frame
v210enc: check for coded_frame allocation failure
drawtext: add 'fix_bounds' option on coords fixing
drawtext: fix text_{w, h} expression vars
drawtext: add missing braces around an if() block.

Conflicts:
libavcodec/arm/vp8.h
libavcodec/arm/vp8dsp_init_arm.c
libavcodec/v210dec.c
libavfilter/vf_drawtext.c
libavformat/ape.c

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

Michael Niedermayer authored on 2012/02/07 09:40:29
Showing 21 changed files
... ...
@@ -1256,6 +1256,9 @@ libfreetype flags.
1256 1256
 @item tabsize
1257 1257
 The size in number of spaces to use for rendering the tab.
1258 1258
 Default value is 4.
1259
+
1260
+@item fix_bounds
1261
+If true, check and fix text coords to avoid clipping.
1259 1262
 @end table
1260 1263
 
1261 1264
 The parameters for @var{x} and @var{y} are expressions containing the
... ...
@@ -2145,8 +2145,10 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
2145 2145
         if ((new_packet = packet_queue_get(&is->audioq, pkt, 1)) < 0)
2146 2146
             return -1;
2147 2147
 
2148
-        if (pkt->data == flush_pkt.data)
2148
+        if (pkt->data == flush_pkt.data) {
2149 2149
             avcodec_flush_buffers(dec);
2150
+            flush_complete = 0;
2151
+        }
2150 2152
 
2151 2153
         *pkt_temp = *pkt;
2152 2154
 
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * ALAC audio encoder
3 3
  * Copyright (c) 2008  Jaikrishnan Menon <realityman@gmx.net>
4 4
  *
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * This file is part of FFmpeg.
3 3
  *
4 4
  * FFmpeg is free software; you can redistribute it and/or
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * Copyright (C) 2010 Mans Rullgard
3 3
  *
4 4
  * This file is part of FFmpeg.
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * This file is part of FFmpeg.
3 3
  *
4 4
  * FFmpeg is free software; you can redistribute it and/or
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * VP8 NEON optimisations
3 3
  *
4 4
  * Copyright (c) 2010 Rob Clark <rob@ti.com>
... ...
@@ -884,7 +884,7 @@ typedef struct AVFrame {
884 884
      * For audio, only linesize[0] may be set. For planar audio, each channel
885 885
      * plane must be the same size.
886 886
      *
887
-     * - encoding: Set by user (video only)
887
+     * - encoding: Set by user
888 888
      * - decoding: set by AVCodecContext.get_buffer()
889 889
      */
890 890
     int linesize[AV_NUM_DATA_POINTERS];
... ...
@@ -1134,7 +1134,7 @@ typedef struct AVFrame {
1134 1134
 
1135 1135
     /**
1136 1136
      * number of audio samples (per channel) described by this frame
1137
-     * - encoding: unused
1137
+     * - encoding: Set by user
1138 1138
      * - decoding: Set by libavcodec
1139 1139
      */
1140 1140
     int nb_samples;
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * FLAC audio encoder
3 3
  * Copyright (c) 2006  Justin Ruggles <justin.ruggles@gmail.com>
4 4
  *
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * This file is part of Libav.
3 3
  *
4 4
  * Libav is free software; you can redistribute it and/or
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * LPC utility code
3 3
  * Copyright (c) 2006  Justin Ruggles <justin.ruggles@gmail.com>
4 4
  *
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * LPC utility code
3 3
  * Copyright (c) 2006  Justin Ruggles <justin.ruggles@gmail.com>
4 4
  *
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * VP8 compatible video decoder
3 3
  *
4 4
  * Copyright (C) 2010 David Conrad
... ...
@@ -28,7 +28,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
28 28
 {
29 29
     if (avctx->width & 1) {
30 30
         av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n");
31
-        return -1;
31
+        return AVERROR(EINVAL);
32 32
     }
33 33
 
34 34
     if (avctx->pix_fmt != PIX_FMT_YUV422P10) {
... ...
@@ -62,9 +62,9 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
62 62
     uint8_t *p = buf;
63 63
     uint8_t *pdst = buf;
64 64
 
65
-    if (buf_size < aligned_width * avctx->height * 8 / 3) {
65
+    if (buf_size < avctx->height * stride) {
66 66
         av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
67
-        return -1;
67
+        return AVERROR(ENOMEM);
68 68
     }
69 69
 
70 70
 #define CLIP(v) av_clip(v, 4, 1019)
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * VP8 compatible video decoder
3 3
  *
4 4
  * Copyright (C) 2010 David Conrad
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * VP8 compatible video decoder
3 3
  *
4 4
  * Copyright (C) 2010 David Conrad
... ...
@@ -139,6 +139,7 @@ typedef struct {
139 139
     short int draw_box;             ///< draw box around text - true or false
140 140
     int use_kerning;                ///< font kerning is used - true/false
141 141
     int tabsize;                    ///< tab size
142
+    int fix_bounds;                 ///< do we let it go out of frame bounds - t/f
142 143
 
143 144
     FT_Library library;             ///< freetype font library handle
144 145
     FT_Face face;                   ///< freetype font face handle
... ...
@@ -184,6 +185,8 @@ static const AVOption drawtext_options[]= {
184 184
 {"timecode", "set initial timecode", OFFSET(tc_opt_string),      AV_OPT_TYPE_STRING, {.str=NULL},  CHAR_MIN, CHAR_MAX },
185 185
 {"r",        "set rate (timecode only)", OFFSET(tc_rate),        AV_OPT_TYPE_RATIONAL, {.dbl=0},          0,  INT_MAX },
186 186
 {"rate",     "set rate (timecode only)", OFFSET(tc_rate),        AV_OPT_TYPE_RATIONAL, {.dbl=0},          0,  INT_MAX },
187
+{"fix_bounds", "if true, check and fix text coords to avoid clipping",
188
+                                     OFFSET(fix_bounds),         AV_OPT_TYPE_INT,    {.dbl=1},     0,        1        },
187 189
 
188 190
 /* FT_LOAD_* flags */
189 191
 {"ft_load_flags", "set font loading flags for libfreetype",   OFFSET(ft_load_flags),  AV_OPT_TYPE_FLAGS,  {.dbl=FT_LOAD_DEFAULT|FT_LOAD_RENDER}, 0, INT_MAX, 0, "ft_load_flags" },
... ...
@@ -754,8 +757,9 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
754 754
         /* get glyph */
755 755
         dummy.code = code;
756 756
         glyph = av_tree_find(dtext->glyphs, &dummy, glyph_cmp, NULL);
757
-        if (!glyph)
757
+        if (!glyph) {
758 758
             load_glyph(ctx, &glyph, code);
759
+        }
759 760
 
760 761
         y_min = FFMIN(glyph->bbox.yMin, y_min);
761 762
         y_max = FFMAX(glyph->bbox.yMax, y_max);
... ...
@@ -159,8 +159,8 @@ static int ape_read_header(AVFormatContext * s)
159 159
     AVStream *st;
160 160
     uint32_t tag;
161 161
     int i;
162
-    int total_blocks;
163
-    int64_t pts;
162
+    int total_blocks, final_size = 0;
163
+    int64_t pts, file_size;
164 164
 
165 165
     /* Skip any leading junk such as id3v2 tags */
166 166
     ape->junklength = avio_tell(pb);
... ...
@@ -289,8 +289,17 @@ static int ape_read_header(AVFormatContext * s)
289 289
         ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;
290 290
         ape->frames[i].skip     = (ape->frames[i].pos - ape->frames[0].pos) & 3;
291 291
     }
292
-    ape->frames[ape->totalframes - 1].size    = ape->finalframeblocks * 4;
293 292
     ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;
293
+    /* calculate final packet size from total file size, if available */
294
+    file_size = avio_size(pb);
295
+    if (file_size > 0) {
296
+        final_size = file_size - ape->frames[ape->totalframes - 1].pos -
297
+                     ape->wavtaillength;
298
+        final_size -= final_size & 3;
299
+    }
300
+    if (file_size <= 0 || final_size <= 0)
301
+        final_size = ape->finalframeblocks * 8;
302
+    ape->frames[ape->totalframes - 1].size = final_size;
294 303
 
295 304
     for (i = 0; i < ape->totalframes; i++) {
296 305
         if(ape->frames[i].skip){
... ...
@@ -357,11 +366,12 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
357 357
     uint32_t extra_size = 8;
358 358
 
359 359
     if (url_feof(s->pb))
360
-        return AVERROR(EIO);
361
-    if (ape->currentframe > ape->totalframes)
362
-        return AVERROR(EIO);
360
+        return AVERROR_EOF;
361
+    if (ape->currentframe >= ape->totalframes)
362
+        return AVERROR_EOF;
363 363
 
364
-    avio_seek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
364
+    if (avio_seek(s->pb, ape->frames[ape->currentframe].pos, SEEK_SET) < 0)
365
+        return AVERROR(EIO);
365 366
 
366 367
     /* Calculate how many blocks there are in this frame */
367 368
     if (ape->currentframe == (ape->totalframes - 1))
... ...
@@ -369,6 +379,14 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
369 369
     else
370 370
         nblocks = ape->blocksperframe;
371 371
 
372
+    if (ape->frames[ape->currentframe].size <= 0 ||
373
+        ape->frames[ape->currentframe].size > INT_MAX - extra_size) {
374
+        av_log(s, AV_LOG_ERROR, "invalid packet size: %d\n",
375
+               ape->frames[ape->currentframe].size);
376
+        ape->currentframe++;
377
+        return AVERROR(EIO);
378
+    }
379
+
372 380
     if (av_new_packet(pkt,  ape->frames[ape->currentframe].size + extra_size) < 0)
373 381
         return AVERROR(ENOMEM);
374 382
 
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * RTP Depacketization of MP4A-LATM, RFC 3016
3 3
  * Copyright (c) 2010 Martin Storsjo
4 4
  *
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * Common code for the RTP depacketization of MPEG-4 formats.
3 3
  * Copyright (c) 2010 Fabrice Bellard
4 4
  *                    Romain Degez
... ...
@@ -1,4 +1,4 @@
1
-/**
1
+/*
2 2
  * RTP Depacketization of QCELP/PureVoice, RFC 2658
3 3
  * Copyright (c) 2010 Martin Storsjo
4 4
  *