History

Merge remote-tracking branch 'qatar/master'

* qatar/master: build: fix standalone compilation of OMA muxer build: fix standalone compilation of Microsoft XMV demuxer build: fix standalone compilation of Core Audio Format demuxer kvmc: fix invalid reads 4xm: Add a check in decode_i_frame to prevent buffer overreads adpcm: fix IMA SMJPEG decoding options: set minimum for "threads" to zero bsd: use number of logical CPUs as automatic thread count windows: use number of CPUs as automatic thread count linux: use number of CPUs as automatic thread count pthreads: reset active_thread_type when slice thread_init returrns early v410dec: include correct headers Drop ALT_ prefix from BITSTREAM_READER_LE name. lavfi: always build vsrc_buffer. ra144enc: zero the reflection coeffs if the filter is unstable sws: readd PAL8 to isPacked() mov: Don't stick the QuickTime field ordering atom in extradata. truespeech: fix invalid reads in truespeech_apply_twopoint_filter() Conflicts: configure libavcodec/4xm.c libavcodec/avcodec.h libavfilter/Makefile libavfilter/allfilters.c libavformat/Makefile libswscale/swscale_internal.h

Michael Niedermayer committed 14 years ago

Commit d1c28e32 parents 9f50daf 4e8d62148 files · +291 −84Browse files

Unified · Split

48 files
  1. avconv.c +1 −0
  2. configure +7 −2
  3. ffmpeg.c +1 −0
  4. libavcodec/4xm.c +7 −4
  5. libavcodec/adpcm.c +9 −5
  6. libavcodec/apedec.c +1 −1
  7. libavcodec/avcodec.h +15 −0
  8. libavcodec/bink.c +1 −1
  9. libavcodec/binkaudio.c +1 −1
  10. libavcodec/eatgq.c +1 −1
  11. libavcodec/eatgv.c +1 −1
  12. libavcodec/escape124.c +1 −1
  13. libavcodec/escape130.c +1 −1
  14. libavcodec/g723_1.c +1 −1
  15. libavcodec/get_bits.h +4 −4
  16. libavcodec/indeo2.c +3 −3
  17. libavcodec/indeo2data.h +1 −1
  18. libavcodec/indeo5.c +1 −1
  19. libavcodec/interplayvideo.c +1 −1
  20. libavcodec/ivi_common.c +1 −1
  21. libavcodec/kmvc.c +66 −16
  22. libavcodec/mjpegdec.c +3 −6
  23. libavcodec/msgsmdec.c +1 −1
  24. libavcodec/nellymoser.c +1 −1
  25. libavcodec/nellymoserdec.c +1 −1
  26. libavcodec/options.c +2 −1
  27. libavcodec/pthread.c +62 −1
  28. libavcodec/qdm2.c +1 −1
  29. libavcodec/ra144enc.c +4 −1
  30. libavcodec/ra288.c +1 −1
  31. libavcodec/sipr.c +1 −1
  32. libavcodec/smacker.c +1 −1
  33. libavcodec/tiertexseqv.c +1 −1
  34. libavcodec/truespeech.c +1 −0
  35. libavcodec/tta.c +1 −1
  36. libavcodec/v410dec.c +1 −1
  37. libavcodec/vble.c +1 −1
  38. libavcodec/vorbis.c +1 −1
  39. libavcodec/vorbisdec.c +1 −1
  40. libavcodec/wavpack.c +1 −1
  41. libavcodec/xan.c +1 −1
  42. libavcodec/xxan.c +1 −1
  43. libavfilter/Makefile +1 −1
  44. libavfilter/allfilters.c +6 −1
  45. libavformat/Makefile +4 −3
  46. libavformat/mov.c +43 −5
  47. libavformat/movenc.c +20 −1
  48. libswscale/swscale_internal.h +4 −2
avconv.c+1−0
@@ -2139,6 +2139,7 @@ static int transcode_init(OutputFile *output_files, · 2138 unmodified lines
21392139 codec->bit_rate = icodec->bit_rate;
21402140 codec->rc_max_rate = icodec->rc_max_rate;
21412141 codec->rc_buffer_size = icodec->rc_buffer_size;
2142+ codec->field_order = icodec->field_order;
21422143 codec->extradata = av_mallocz(extra_size);
21432144 if (!codec->extradata) {
21442145 return AVERROR(ENOMEM);
configure+7−2
@@ -1174,6 +1174,7 @@ HAVE_LIST=" · 1173 unmodified lines
11741174 gethrtime
11751175 GetProcessMemoryInfo
11761176 GetProcessTimes
1177+ GetSystemInfo
11771178 getrusage
11781179 gnu_as
11791180 ibm_asm
@@ -1206,6 +1207,7 @@ HAVE_LIST=" · 26 unmodified lines
12061207 posix_memalign
12071208 round
12081209 roundf
1210+ sched_getaffinity
12091211 sdl
12101212 sdl_video_size
12111213 setmode
@@ -1224,6 +1226,7 @@ HAVE_LIST=" · 12 unmodified lines
12241226 symver
12251227 symver_asm_label
12261228 symver_gnu_asm
1229+ sysctl
12271230 sys_mman_h
12281231 sys_resource_h
12291232 sys_select_h
@@ -1654,14 +1657,13 @@ postproc_deps="gpl" · 424 unmodified lines
16541657
16551658 # programs
16561659 avconv_deps="avcodec avformat swscale"
1657−avconv_select="buffer_filter"
16581660 ffplay_deps="avcodec avformat swscale sdl"
16591661 ffplay_select="buffersink_filter rdft"
16601662 ffprobe_deps="avcodec avformat"
16611663 ffserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer"
16621664 ffserver_extralibs='$ldl'
16631665 ffmpeg_deps="avcodec avformat swscale swresample"
1664−ffmpeg_select="buffer_filter buffersink_filter"
1666+ffmpeg_select="buffersink_filter"
16651667
16661668 doc_deps="texi2html"
16671669
@@ -3000,12 +3002,15 @@ check_func ${malloc_prefix}posix_memalign && enable posix_memalign · 1332 unmodified lines
30003002 check_func setrlimit
30013003 check_func strerror_r
30023004 check_func strptime
3005+check_func sched_getaffinity
3006+check_func sysctl
30033007 check_func_headers conio.h kbhit
30043008 check_func_headers windows.h PeekNamedPipe
30053009 check_func_headers io.h setmode
30063010 check_func_headers lzo/lzo1x.h lzo1x_999_compress
30073011 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
30083012 check_func_headers windows.h GetProcessTimes
3013+check_func_headers windows.h GetSystemInfo
30093014 check_func_headers windows.h MapViewOfFile
30103015 check_func_headers windows.h VirtualAlloc
30113016
ffmpeg.c+1−0
@@ -2213,6 +2213,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 2212 unmodified lines
22132213 codec->bit_rate = icodec->bit_rate;
22142214 codec->rc_max_rate = icodec->rc_max_rate;
22152215 codec->rc_buffer_size = icodec->rc_buffer_size;
2216+ codec->field_order = icodec->field_order;
22162217 codec->extradata = av_mallocz(extra_size);
22172218 if (!codec->extradata) {
22182219 return AVERROR(ENOMEM);
libavcodec/4xm.c+7−4
@@ -688,10 +688,13 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){ · 687 unmodified lines
688688 unsigned int prestream_size;
689689 const uint8_t *prestream;
690690
691− if (bitstream_size > (1<<26) || length < bitstream_size + 12)
692− return -1;
693− prestream_size = 4*AV_RL32(buf + bitstream_size + 4);
694− prestream = buf + bitstream_size + 12;
691+ if (bitstream_size > (1<<26) || length < bitstream_size + 12) {
692+ av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n");
693+ return AVERROR_INVALIDDATA;
694+ }
695+
696+ prestream_size = 4 * AV_RL32(buf + bitstream_size + 4);
697+ prestream = buf + bitstream_size + 12;
695698
696699 if (prestream_size > (1<<26) ||
697700 prestream_size != length - (bitstream_size + 12)){
libavcodec/adpcm.c+9−5
@@ -1007,11 +1007,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1006 unmodified lines
10071007 break;
10081008 case CODEC_ID_ADPCM_IMA_AMV:
10091009 case CODEC_ID_ADPCM_IMA_SMJPEG:
1010− c->status[0].predictor = (int16_t)bytestream_get_le16(&src);
1011− c->status[0].step_index = bytestream_get_le16(&src);
1012−
1013− if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
1014− src+=4;
1010+ if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
1011+ c->status[0].predictor = sign_extend(bytestream_get_le16(&src), 16);
1012+ c->status[0].step_index = bytestream_get_le16(&src);
1013+ src += 4;
1014+ } else {
1015+ c->status[0].predictor = sign_extend(bytestream_get_be16(&src), 16);
1016+ c->status[0].step_index = bytestream_get_byte(&src);
1017+ src += 1;
1018+ }
10151019
10161020 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
10171021 char hi, lo;
libavcodec/apedec.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121 */
2222
23−#define ALT_BITSTREAM_READER_LE
23+#define BITSTREAM_READER_LE
2424 #include "avcodec.h"
2525 #include "dsputil.h"
2626 #include "get_bits.h"
libavcodec/avcodec.h+15−0
@@ -1335,6 +1335,15 @@ typedef struct AVFrame { · 1334 unmodified lines
13351335
13361336 struct AVCodecInternal;
13371337
1338+enum AVFieldOrder {
1339+ AV_FIELD_UNKNOWN,
1340+ AV_FIELD_PROGRESSIVE,
1341+ AV_FIELD_TT, //< Top coded_first, top displayed first
1342+ AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1343+ AV_FIELD_TB, //< Top coded first, bottom displayed first
1344+ AV_FIELD_BT, //< Bottom coded first, top displayed first
1345+};
1346+
13381347 /**
13391348 * main external API structure.
13401349 * New fields can be added to the end with minor version bumps.
@@ -3191,6 +3200,12 @@ typedef struct AVCodecContext { · 1850 unmodified lines
31913200 */
31923201 struct AVCodecInternal *internal;
31933202
3203+ /** Field order
3204+ * - encoding: set by libavcodec
3205+ * - decoding: Set by libavcodec
3206+ */
3207+ enum AVFieldOrder field_order;
3208+
31943209 /**
31953210 * Current statistics for PTS correction.
31963211 * - decoding: maintained and used by libavcodec, not intended to be used by user apps
libavcodec/bink.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 #include "binkdsp.h"
2828 #include "mathops.h"
2929
30−#define ALT_BITSTREAM_READER_LE
30+#define BITSTREAM_READER_LE
3131 #include "get_bits.h"
3232
3333 #define BINK_FLAG_ALPHA 0x00100000
libavcodec/binkaudio.c+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 */
3030
3131 #include "avcodec.h"
32−#define ALT_BITSTREAM_READER_LE
32+#define BITSTREAM_READER_LE
3333 #include "get_bits.h"
3434 #include "dsputil.h"
3535 #include "dct.h"
libavcodec/eatgq.c+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 */
3030
3131 #include "avcodec.h"
32−#define ALT_BITSTREAM_READER_LE
32+#define BITSTREAM_READER_LE
3333 #include "get_bits.h"
3434 #include "bytestream.h"
3535 #include "dsputil.h"
libavcodec/eatgv.c+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 */
3030
3131 #include "avcodec.h"
32−#define ALT_BITSTREAM_READER_LE
32+#define BITSTREAM_READER_LE
3333 #include "get_bits.h"
3434 #include "libavutil/lzo.h"
3535 #include "libavutil/imgutils.h"
libavcodec/escape124.c+1−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121
2222 #include "avcodec.h"
2323
24−#define ALT_BITSTREAM_READER_LE
24+#define BITSTREAM_READER_LE
2525 #include "get_bits.h"
2626
2727 typedef union MacroBlock {
libavcodec/escape130.c+1−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121
2222 #include "avcodec.h"
2323
24−#define ALT_BITSTREAM_READER_LE
24+#define BITSTREAM_READER_LE
2525 #include "get_bits.h"
2626
2727 typedef struct Escape130Context {
libavcodec/g723_1.c+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626 */
2727
2828 #include "avcodec.h"
29−#define ALT_BITSTREAM_READER_LE
29+#define BITSTREAM_READER_LE
3030 #include "get_bits.h"
3131 #include "acelp_vectors.h"
3232 #include "celp_filters.h"
libavcodec/get_bits.h+4−4
@@ -124,7 +124,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc · 123 unmodified lines
124124
125125 #define CLOSE_READER(name, gb) (gb)->index = name##_index
126126
127−#ifdef ALT_BITSTREAM_READER_LE
127+#ifdef BITSTREAM_READER_LE
128128
129129 # ifdef LONG_BITSTREAM_READER
130130 # define UPDATE_CACHE(name, gb) name##_cache = \
@@ -164,7 +164,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc · 33 unmodified lines
164164
165165 #define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
166166
167−#ifdef ALT_BITSTREAM_READER_LE
167+#ifdef BITSTREAM_READER_LE
168168 # define SHOW_UBITS(name, gb, num) zero_extend(name##_cache, num)
169169 # define SHOW_SBITS(name, gb, num) sign_extend(name##_cache, num)
170170 #else
@@ -254,7 +254,7 @@ static inline unsigned int get_bits1(GetBitContext *s) · 83 unmodified lines
254254 {
255255 unsigned int index = s->index;
256256 uint8_t result = s->buffer[index>>3];
257−#ifdef ALT_BITSTREAM_READER_LE
257+#ifdef BITSTREAM_READER_LE
258258 result >>= index & 7;
259259 result &= 1;
260260 #else
@@ -288,7 +288,7 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n) · 27 unmodified lines
288288 if (n <= MIN_CACHE_BITS)
289289 return get_bits(s, n);
290290 else {
291−#ifdef ALT_BITSTREAM_READER_LE
291+#ifdef BITSTREAM_READER_LE
292292 int ret = get_bits(s, 16);
293293 return ret | (get_bits(s, n-16) << 16);
294294 #else
libavcodec/indeo2.c+3−3
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323 * @file
2424 * Intel Indeo 2 decoder.
2525 */
26−#define ALT_BITSTREAM_READER_LE
26+#define BITSTREAM_READER_LE
2727 #include "avcodec.h"
2828 #include "get_bits.h"
2929 #include "indeo2data.h"
@@ -163,7 +163,7 @@ static int ir2_decode_frame(AVCodecContext *avctx, · 133 unmodified lines
163163 s->decode_delta = buf[18];
164164
165165 /* decide whether frame uses deltas or not */
166−#ifndef ALT_BITSTREAM_READER_LE
166+#ifndef BITSTREAM_READER_LE
167167 for (i = 0; i < buf_size; i++)
168168 buf[i] = av_reverse[buf[i]];
169169 #endif
@@ -205,7 +205,7 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){ · 35 unmodified lines
205205
206206 ir2_vlc.table = vlc_tables;
207207 ir2_vlc.table_allocated = 1 << CODE_VLC_BITS;
208−#ifdef ALT_BITSTREAM_READER_LE
208+#ifdef BITSTREAM_READER_LE
209209 init_vlc(&ir2_vlc, CODE_VLC_BITS, IR2_CODES,
210210 &ir2_codes[0][1], 4, 2,
211211 &ir2_codes[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE);
libavcodec/indeo2data.h+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626
2727 #define IR2_CODES 143
2828 static const uint16_t ir2_codes[IR2_CODES][2] = {
29−#ifdef ALT_BITSTREAM_READER_LE
29+#ifdef BITSTREAM_READER_LE
3030 {0x0000, 3}, {0x0004, 3}, {0x0006, 3}, {0x0001, 5},
3131 {0x0009, 5}, {0x0019, 5}, {0x000D, 5}, {0x001D, 5},
3232 {0x0023, 6}, {0x0013, 6}, {0x0033, 6}, {0x000B, 6},
libavcodec/indeo5.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 * Known FOURCCs: 'IV50'
2828 */
2929
30−#define ALT_BITSTREAM_READER_LE
30+#define BITSTREAM_READER_LE
3131 #include "avcodec.h"
3232 #include "get_bits.h"
3333 #include "dsputil.h"
libavcodec/interplayvideo.c+1−1
@@ -41,7 +41,7 @@ · 40 unmodified lines
4141 #include "avcodec.h"
4242 #include "bytestream.h"
4343 #include "dsputil.h"
44−#define ALT_BITSTREAM_READER_LE
44+#define BITSTREAM_READER_LE
4545 #include "get_bits.h"
4646
4747 #define PALETTE_COUNT 256
libavcodec/ivi_common.c+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626 * Indeo5 decoders.
2727 */
2828
29−#define ALT_BITSTREAM_READER_LE
29+#define BITSTREAM_READER_LE
3030 #include "avcodec.h"
3131 #include "get_bits.h"
3232 #include "ivi_common.h"
libavcodec/kmvc.c+66−16
@@ -57,17 +57,21 @@ typedef struct BitBuf { · 56 unmodified lines
5757
5858 #define kmvc_init_getbits(bb, src) bb.bits = 7; bb.bitbuf = *src++;
5959
60−#define kmvc_getbit(bb, src, res) {\
60+#define kmvc_getbit(bb, src, src_end, res) {\
6161 res = 0; \
6262 if (bb.bitbuf & (1 << bb.bits)) res = 1; \
6363 bb.bits--; \
6464 if(bb.bits == -1) { \
65+ if (src >= src_end) { \
66+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); \
67+ return AVERROR_INVALIDDATA; \
68+ } \
6569 bb.bitbuf = *src++; \
6670 bb.bits = 7; \
6771 } \
6872 }
6973
70−static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h)
74+static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src_size, int w, int h)
7175 {
7276 BitBuf bb;
7377 int res, val;
@@ -75,13 +79,18 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 1 unmodified line
7579 int bx, by;
7680 int l0x, l1x, l0y, l1y;
7781 int mx, my;
82+ const uint8_t *src_end = src + src_size;
7883
7984 kmvc_init_getbits(bb, src);
8085
8186 for (by = 0; by < h; by += 8)
8287 for (bx = 0; bx < w; bx += 8) {
83− kmvc_getbit(bb, src, res);
88+ kmvc_getbit(bb, src, src_end, res);
8489 if (!res) { // fill whole 8x8 block
90+ if (src >= src_end) {
91+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
92+ return AVERROR_INVALIDDATA;
93+ }
8594 val = *src++;
8695 for (i = 0; i < 64; i++)
8796 BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
@@ -89,14 +98,22 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 1 unmodified line
8998 for (i = 0; i < 4; i++) {
9099 l0x = bx + (i & 1) * 4;
91100 l0y = by + (i & 2) * 2;
92− kmvc_getbit(bb, src, res);
101+ kmvc_getbit(bb, src, src_end, res);
93102 if (!res) {
94− kmvc_getbit(bb, src, res);
103+ kmvc_getbit(bb, src, src_end, res);
95104 if (!res) { // fill whole 4x4 block
105+ if (src >= src_end) {
106+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
107+ return AVERROR_INVALIDDATA;
108+ }
96109 val = *src++;
97110 for (j = 0; j < 16; j++)
98111 BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
99112 } else { // copy block from already decoded place
113+ if (src >= src_end) {
114+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
115+ return AVERROR_INVALIDDATA;
116+ }
100117 val = *src++;
101118 mx = val & 0xF;
102119 my = val >> 4;
@@ -108,16 +125,24 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 5 unmodified lines
108125 for (j = 0; j < 4; j++) {
109126 l1x = l0x + (j & 1) * 2;
110127 l1y = l0y + (j & 2);
111− kmvc_getbit(bb, src, res);
128+ kmvc_getbit(bb, src, src_end, res);
112129 if (!res) {
113− kmvc_getbit(bb, src, res);
130+ kmvc_getbit(bb, src, src_end, res);
114131 if (!res) { // fill whole 2x2 block
132+ if (src >= src_end) {
133+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
134+ return AVERROR_INVALIDDATA;
135+ }
115136 val = *src++;
116137 BLK(ctx->cur, l1x, l1y) = val;
117138 BLK(ctx->cur, l1x + 1, l1y) = val;
118139 BLK(ctx->cur, l1x, l1y + 1) = val;
119140 BLK(ctx->cur, l1x + 1, l1y + 1) = val;
120141 } else { // copy block from already decoded place
142+ if (src >= src_end) {
143+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
144+ return AVERROR_INVALIDDATA;
145+ }
121146 val = *src++;
122147 mx = val & 0xF;
123148 my = val >> 4;
@@ -140,9 +165,11 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 16 unmodified lines
140165 }
141166 }
142167 }
168+
169+ return 0;
143170 }
144171
145−static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h)
172+static int kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int src_size, int w, int h)
146173 {
147174 BitBuf bb;
148175 int res, val;
@@ -150,15 +177,20 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 1 unmodified line
150177 int bx, by;
151178 int l0x, l1x, l0y, l1y;
152179 int mx, my;
180+ const uint8_t *src_end = src + src_size;
153181
154182 kmvc_init_getbits(bb, src);
155183
156184 for (by = 0; by < h; by += 8)
157185 for (bx = 0; bx < w; bx += 8) {
158− kmvc_getbit(bb, src, res);
186+ kmvc_getbit(bb, src, src_end, res);
159187 if (!res) {
160− kmvc_getbit(bb, src, res);
188+ kmvc_getbit(bb, src, src_end, res);
161189 if (!res) { // fill whole 8x8 block
190+ if (src >= src_end) {
191+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
192+ return AVERROR_INVALIDDATA;
193+ }
162194 val = *src++;
163195 for (i = 0; i < 64; i++)
164196 BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
@@ -171,14 +203,22 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 6 unmodified lines
171203 for (i = 0; i < 4; i++) {
172204 l0x = bx + (i & 1) * 4;
173205 l0y = by + (i & 2) * 2;
174− kmvc_getbit(bb, src, res);
206+ kmvc_getbit(bb, src, src_end, res);
175207 if (!res) {
176− kmvc_getbit(bb, src, res);
208+ kmvc_getbit(bb, src, src_end, res);
177209 if (!res) { // fill whole 4x4 block
210+ if (src >= src_end) {
211+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
212+ return AVERROR_INVALIDDATA;
213+ }
178214 val = *src++;
179215 for (j = 0; j < 16; j++)
180216 BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
181217 } else { // copy block
218+ if (src >= src_end) {
219+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
220+ return AVERROR_INVALIDDATA;
221+ }
182222 val = *src++;
183223 mx = (val & 0xF) - 8;
184224 my = (val >> 4) - 8;
@@ -190,16 +230,24 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 5 unmodified lines
190230 for (j = 0; j < 4; j++) {
191231 l1x = l0x + (j & 1) * 2;
192232 l1y = l0y + (j & 2);
193− kmvc_getbit(bb, src, res);
233+ kmvc_getbit(bb, src, src_end, res);
194234 if (!res) {
195− kmvc_getbit(bb, src, res);
235+ kmvc_getbit(bb, src, src_end, res);
196236 if (!res) { // fill whole 2x2 block
237+ if (src >= src_end) {
238+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
239+ return AVERROR_INVALIDDATA;
240+ }
197241 val = *src++;
198242 BLK(ctx->cur, l1x, l1y) = val;
199243 BLK(ctx->cur, l1x + 1, l1y) = val;
200244 BLK(ctx->cur, l1x, l1y + 1) = val;
201245 BLK(ctx->cur, l1x + 1, l1y + 1) = val;
202246 } else { // copy block
247+ if (src >= src_end) {
248+ av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
249+ return AVERROR_INVALIDDATA;
250+ }
203251 val = *src++;
204252 mx = (val & 0xF) - 8;
205253 my = (val >> 4) - 8;
@@ -222,6 +270,8 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 16 unmodified lines
222270 }
223271 }
224272 }
273+
274+ return 0;
225275 }
226276
227277 static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt)
@@ -299,10 +349,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa · 71 unmodified lines
299349 memcpy(ctx->cur, ctx->prev, 320 * 200);
300350 break;
301351 case 3:
302− kmvc_decode_intra_8x8(ctx, buf, avctx->width, avctx->height);
352+ kmvc_decode_intra_8x8(ctx, buf, buf_size, avctx->width, avctx->height);
303353 break;
304354 case 4:
305− kmvc_decode_inter_8x8(ctx, buf, avctx->width, avctx->height);
355+ kmvc_decode_inter_8x8(ctx, buf, buf_size, avctx->width, avctx->height);
306356 break;
307357 default:
308358 av_log(avctx, AV_LOG_ERROR, "Unknown compression method %i\n", header & KMVC_METHOD);
libavcodec/mjpegdec.c+3−6
@@ -112,12 +112,9 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) · 111 unmodified lines
112112 build_basic_mjpeg_vlc(s);
113113 }
114114 }
115− if (avctx->extradata_size > 9 &&
116− AV_RL32(avctx->extradata + 4) == MKTAG('f','i','e','l')) {
117− if (avctx->extradata[9] == 6) { /* quicktime icefloe 019 */
118− s->interlace_polarity = 1; /* bottom field first */
119− av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n");
120− }
115+ if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */
116+ s->interlace_polarity = 1; /* bottom field first */
117+ av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n");
121118 }
122119 if (avctx->codec->id == CODEC_ID_AMV)
123120 s->flipped = 1;
libavcodec/msgsmdec.c+1−1
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22−#define ALT_BITSTREAM_READER_LE
22+#define BITSTREAM_READER_LE
2323 #include "avcodec.h"
2424 #include "msgsmdec.h"
2525 #include "gsmdec_template.c"
libavcodec/nellymoser.c+1−1
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535 #include "avcodec.h"
3636 #include "dsputil.h"
3737
38−#define ALT_BITSTREAM_READER_LE
38+#define BITSTREAM_READER_LE
3939 #include "get_bits.h"
4040
4141 const float ff_nelly_dequantization_table[127] = {
libavcodec/nellymoserdec.c+1−1
@@ -41,7 +41,7 @@ · 40 unmodified lines
4141 #include "fmtconvert.h"
4242 #include "sinewin.h"
4343
44−#define ALT_BITSTREAM_READER_LE
44+#define BITSTREAM_READER_LE
4545 #include "get_bits.h"
4646
4747
libavcodec/options.c+2−1
@@ -371,7 +371,8 @@ static const AVOption options[]={ · 370 unmodified lines
371371 {"float", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"},
372372 #endif
373373 {"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
374−{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E|D},
374+{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, 0, INT_MAX, V|E|D, "threads"},
375+{"auto", "detect a good number of threads", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"},
375376 {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
376377 {"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
377378 {"dc", "intra_dc_precision", OFFSET(intra_dc_precision), AV_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E},
libavcodec/pthread.c+62−1
@@ -30,6 +30,17 @@ · 29 unmodified lines
3030 */
3131
3232 #include "config.h"
33+
34+#if HAVE_SCHED_GETAFFINITY
35+#define _GNU_SOURCE
36+#include <sched.h>
37+#elif HAVE_GETSYSTEMINFO
38+#include <windows.h>
39+#elif HAVE_SYSCTL
40+#include <sys/sysctl.h>
41+#include <sys/types.h>
42+#endif
43+
3344 #include "avcodec.h"
3445 #include "internal.h"
3546 #include "thread.h"
@@ -135,6 +146,40 @@ typedef struct FrameThreadContext { · 99 unmodified lines
135146 int die; ///< Set when threads should exit.
136147 } FrameThreadContext;
137148
149+
150+/* H264 slice threading seems to be buggy with more than 16 threads,
151+ * limit the number of threads to 16 for automatic detection */
152+#define MAX_AUTO_THREADS 16
153+
154+static int get_logical_cpus(AVCodecContext *avctx)
155+{
156+ int ret, nb_cpus = 1;
157+#if HAVE_SCHED_GETAFFINITY
158+ cpu_set_t cpuset;
159+
160+ CPU_ZERO(&cpuset);
161+
162+ ret = sched_getaffinity(0, sizeof(cpuset), &cpuset);
163+ if (!ret) {
164+ nb_cpus = CPU_COUNT(&cpuset);
165+ }
166+#elif HAVE_GETSYSTEMINFO
167+ SYSTEM_INFO sysinfo;
168+ GetSystemInfo(&sysinfo);
169+ nb_cpus = sysinfo.dwNumberOfProcessors;
170+#elif HAVE_SYSCTL
171+ int mib[2] = { CTL_HW, HW_NCPU };
172+ size_t len = sizeof(nb_cpus);
173+
174+ ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0);
175+ if (ret == -1)
176+ nb_cpus = 0;
177+#endif
178+ av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
179+ return FFMIN(nb_cpus, MAX_AUTO_THREADS);
180+}
181+
182+
138183 static void* attribute_align_arg worker(void *v)
139184 {
140185 AVCodecContext *avctx = v;
@@ -239,8 +284,17 @@ static int thread_init(AVCodecContext *avctx) · 98 unmodified lines
239284 ThreadContext *c;
240285 int thread_count = avctx->thread_count;
241286
242− if (thread_count <= 1)
287+ if (!thread_count) {
288+ int nb_cpus = get_logical_cpus(avctx);
289+ // use number of cores + 1 as thread count if there is motre than one
290+ if (nb_cpus > 1)
291+ thread_count = avctx->thread_count = nb_cpus + 1;
292+ }
293+
294+ if (thread_count <= 1) {
295+ avctx->active_thread_type = 0;
243296 return 0;
297+ }
244298
245299 c = av_mallocz(sizeof(ThreadContext));
246300 if (!c)
@@ -704,6 +758,13 @@ static int frame_thread_init(AVCodecContext *avctx) · 457 unmodified lines
704758 FrameThreadContext *fctx;
705759 int i, err = 0;
706760
761+ if (!thread_count) {
762+ int nb_cpus = get_logical_cpus(avctx);
763+ // use number of cores + 1 as thread count if there is motre than one
764+ if (nb_cpus > 1)
765+ thread_count = avctx->thread_count = nb_cpus + 1;
766+ }
767+
707768 if (thread_count <= 1) {
708769 avctx->active_thread_type = 0;
709770 return 0;
libavcodec/qdm2.c+1−1
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535 #include <stddef.h>
3636 #include <stdio.h>
3737
38−#define ALT_BITSTREAM_READER_LE
38+#define BITSTREAM_READER_LE
3939 #include "avcodec.h"
4040 #include "get_bits.h"
4141 #include "dsputil.h"
libavcodec/ra144enc.c+4−1
@@ -477,7 +477,10 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 476 unmodified lines
477477 * The filter is unstable: use the coefficients of the previous frame.
478478 */
479479 ff_int_to_int16(block_coefs[NBLOCKS - 1], ractx->lpc_coef[1]);
480− ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx);
480+ if (ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx)) {
481+ /* the filter is still unstable. set reflection coeffs to zero. */
482+ memset(lpc_refl, 0, sizeof(lpc_refl));
483+ }
481484 }
482485 init_put_bits(&pb, frame, buf_size);
483486 for (i = 0; i < LPC_ORDER; i++) {
libavcodec/ra288.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 */
2121
2222 #include "avcodec.h"
23−#define ALT_BITSTREAM_READER_LE
23+#define BITSTREAM_READER_LE
2424 #include "get_bits.h"
2525 #include "ra288.h"
2626 #include "lpc.h"
libavcodec/sipr.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727
2828 #include "libavutil/mathematics.h"
2929 #include "avcodec.h"
30−#define ALT_BITSTREAM_READER_LE
30+#define BITSTREAM_READER_LE
3131 #include "get_bits.h"
3232 #include "dsputil.h"
3333
libavcodec/smacker.c+1−1
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535 #include "libavutil/audioconvert.h"
3636 #include "mathops.h"
3737
38−#define ALT_BITSTREAM_READER_LE
38+#define BITSTREAM_READER_LE
3939 #include "get_bits.h"
4040 #include "bytestream.h"
4141
libavcodec/tiertexseqv.c+1−1
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 */
2626
2727 #include "avcodec.h"
28−#define ALT_BITSTREAM_READER_LE
28+#define BITSTREAM_READER_LE
2929 #include "get_bits.h"
3030
3131
libavcodec/truespeech.c+1−0
@@ -179,6 +179,7 @@ static void truespeech_apply_twopoint_filter(TSContext *dec, int quart) · 178 unmodified lines
179179 for(i = 0; i < 146; i++)
180180 tmp[i] = dec->filtbuf[i];
181181 off = (t / 25) + dec->offset1[quart >> 1] + 18;
182+ off = av_clip(off, 0, 145);
182183 ptr0 = tmp + 145 - off;
183184 ptr1 = tmp + 146;
184185 filter = (const int16_t*)ts_order2_coeffs + (t % 25) * 2;
libavcodec/tta.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 * @author Alex Beregszaszi
2828 */
2929
30−#define ALT_BITSTREAM_READER_LE
30+#define BITSTREAM_READER_LE
3131 //#define DEBUG
3232 #include <limits.h>
3333 #include "avcodec.h"
libavcodec/v410dec.c+1−1
@@ -20,8 +20,8 @@ · 19 unmodified lines
2020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121 */
2222
23+#include "libavutil/intreadwrite.h"
2324 #include "avcodec.h"
24−#include "get_bits.h"
2525
2626 static av_cold int v410_decode_init(AVCodecContext *avctx)
2727 {
libavcodec/vble.c+1−1
@@ -24,7 +24,7 @@ · 23 unmodified lines
2424 * VBLE Decoder
2525 */
2626
27−#define ALT_BITSTREAM_READER_LE
27+#define BITSTREAM_READER_LE
2828
2929 #include "avcodec.h"
3030 #include "dsputil.h"
libavcodec/vorbis.c+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626 * @author Denes Balatoni ( dbalatoni programozo hu )
2727 */
2828
29−#define ALT_BITSTREAM_READER_LE
29+#define BITSTREAM_READER_LE
3030 #include "avcodec.h"
3131 #include "get_bits.h"
3232
libavcodec/vorbisdec.c+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include <inttypes.h>
3030 #include <math.h>
3131
32−#define ALT_BITSTREAM_READER_LE
32+#define BITSTREAM_READER_LE
3333 #include "avcodec.h"
3434 #include "get_bits.h"
3535 #include "dsputil.h"
libavcodec/wavpack.c+1−1
@@ -18,7 +18,7 @@ · 17 unmodified lines
1818 * License along with FFmpeg; if not, write to the Free Software
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
21−#define ALT_BITSTREAM_READER_LE
21+#define BITSTREAM_READER_LE
2222 #include "avcodec.h"
2323 #include "get_bits.h"
2424 #include "unary.h"
libavcodec/xan.c+1−1
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535 #include "libavutil/intreadwrite.h"
3636 #include "avcodec.h"
3737 #include "bytestream.h"
38−#define ALT_BITSTREAM_READER_LE
38+#define BITSTREAM_READER_LE
3939 #include "get_bits.h"
4040 // for av_memcpy_backptr
4141 #include "libavutil/lzo.h"
libavcodec/xxan.c+1−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323 #include "avcodec.h"
2424 #include "libavutil/intreadwrite.h"
2525 #include "bytestream.h"
26−#define ALT_BITSTREAM_READER_LE
26+#define BITSTREAM_READER_LE
2727 #include "get_bits.h"
2828 // for av_memcpy_backptr
2929 #include "libavutil/lzo.h"
libavfilter/Makefile+1−1
@@ -20,6 +20,7 @@ OBJS = allfilters.o \ · 19 unmodified lines
2020 formats.o \
2121 graphparser.o \
2222 transform.o \
23+ vsrc_buffer.o
2324
2425 OBJS-$(CONFIG_AVCODEC) += avcodec.o
2526
@@ -83,7 +84,6 @@ OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o · 57 unmodified lines
8384 OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o
8485 OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o
8586
86−OBJS-$(CONFIG_BUFFER_FILTER) += vsrc_buffer.o
8787 OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o
8888 OBJS-$(CONFIG_COLOR_FILTER) += vsrc_color.o
8989 OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o
libavfilter/allfilters.c+6−1
@@ -94,7 +94,6 @@ void avfilter_register_all(void) · 93 unmodified lines
9494 REGISTER_FILTER (VFLIP, vflip, vf);
9595 REGISTER_FILTER (YADIF, yadif, vf);
9696
97− REGISTER_FILTER (BUFFER, buffer, vsrc);
9897 REGISTER_FILTER (CELLAUTO, cellauto, vsrc);
9998 REGISTER_FILTER (COLOR, color, vsrc);
10099 REGISTER_FILTER (FREI0R, frei0r_src, vsrc);
@@ -108,4 +107,10 @@ void avfilter_register_all(void) · 7 unmodified lines
108107
109108 REGISTER_FILTER (BUFFERSINK, buffersink, vsink);
110109 REGISTER_FILTER (NULLSINK, nullsink, vsink);
110+
111+ /* vsrc_buffer is a part of public API => registered unconditionally */
112+ {
113+ extern avfilter_vsrc_buffer;
114+ avfilter_register(&avfilter_vsrc_buffer);
115+ }
111116 }
libavformat/Makefile+4−3
@@ -56,7 +56,8 @@ OBJS-$(CONFIG_BIT_DEMUXER) += bit.o · 55 unmodified lines
5656 OBJS-$(CONFIG_BIT_MUXER) += bit.o
5757 OBJS-$(CONFIG_BMV_DEMUXER) += bmv.o
5858 OBJS-$(CONFIG_C93_DEMUXER) += c93.o vocdec.o voc.o
59−OBJS-$(CONFIG_CAF_DEMUXER) += cafdec.o caf.o mov.o riff.o isom.o
59+OBJS-$(CONFIG_CAF_DEMUXER) += cafdec.o caf.o mov.o mov_chan.o \
60+ riff.o isom.o
6061 OBJS-$(CONFIG_CAF_MUXER) += cafenc.o caf.o riff.o isom.o
6162 OBJS-$(CONFIG_CAVSVIDEO_DEMUXER) += cavsvideodec.o rawdec.o
6263 OBJS-$(CONFIG_CAVSVIDEO_MUXER) += rawenc.o
@@ -195,7 +196,7 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ · 132 unmodified lines
195196 OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \
196197 vorbiscomment.o
197198 OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o
198−OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o
199+OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o
199200 OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += pcmdec.o pcm.o rawdec.o
200201 OBJS-$(CONFIG_PCM_ALAW_MUXER) += pcmenc.o rawenc.o
201202 OBJS-$(CONFIG_PCM_F32BE_DEMUXER) += pcmdec.o pcm.o rawdec.o
@@ -331,7 +332,7 @@ OBJS-$(CONFIG_WTV_MUXER) += wtvenc.o wtv.o asf.o asfenc.o riff.o · 129 unmodified lines
331332 OBJS-$(CONFIG_WV_DEMUXER) += wv.o apetag.o
332333 OBJS-$(CONFIG_XA_DEMUXER) += xa.o
333334 OBJS-$(CONFIG_XBIN_DEMUXER) += bintext.o sauce.o
334−OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o
335+OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o riff.o
335336 OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o riff.o
336337 OBJS-$(CONFIG_YOP_DEMUXER) += yop.o
337338 OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg.o
libavformat/mov.c+43−5
@@ -857,6 +857,40 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 856 unmodified lines
857857 return 0;
858858 }
859859
860+static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
861+{
862+ AVStream *st;
863+ unsigned mov_field_order;
864+ enum AVFieldOrder decoded_field_order = AV_FIELD_UNKNOWN;
865+
866+ if (c->fc->nb_streams < 1) // will happen with jp2 files
867+ return 0;
868+ st = c->fc->streams[c->fc->nb_streams-1];
869+ if (atom.size < 2)
870+ return AVERROR_INVALIDDATA;
871+ mov_field_order = avio_rb16(pb);
872+ if ((mov_field_order & 0xFF00) == 0x0100)
873+ decoded_field_order = AV_FIELD_PROGRESSIVE;
874+ else if ((mov_field_order & 0xFF00) == 0x0200) {
875+ switch (mov_field_order & 0xFF) {
876+ case 0x01: decoded_field_order = AV_FIELD_TT;
877+ break;
878+ case 0x06: decoded_field_order = AV_FIELD_BB;
879+ break;
880+ case 0x09: decoded_field_order = AV_FIELD_TB;
881+ break;
882+ case 0x0E: decoded_field_order = AV_FIELD_BT;
883+ break;
884+ }
885+ }
886+ if (decoded_field_order == AV_FIELD_UNKNOWN && mov_field_order) {
887+ av_log(NULL, AV_LOG_ERROR, "Unknown MOV field order 0x%04x\n", mov_field_order);
888+ }
889+ st->codec->field_order = decoded_field_order;
890+
891+ return 0;
892+}
893+
860894 /* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */
861895 static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom,
862896 enum CodecID codec_id)
@@ -898,11 +932,6 @@ static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 35 unmodified lines
898932 return mov_read_extradata(c, pb, atom, CODEC_ID_AVS);
899933 }
900934
901−static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
902−{
903− return mov_read_extradata(c, pb, atom, CODEC_ID_MJPEG);
904−}
905−
906935 static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
907936 {
908937 return mov_read_extradata(c, pb, atom, CODEC_ID_JPEG2000);
@@ -950,6 +979,15 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 41 unmodified lines
950979 if ((uint64_t)atom.size > (1<<30))
951980 return -1;
952981
982+ if (atom.size >= 10) {
983+ // Broken files created by legacy versions of Libav and FFmpeg will
984+ // wrap a whole fiel atom inside of a glbl atom.
985+ unsigned size = avio_rb32(pb);
986+ unsigned type = avio_rl32(pb);
987+ avio_seek(pb, -8, SEEK_CUR);
988+ if (type == MKTAG('f','i','e','l') && size == atom.size)
989+ return mov_read_default(c, pb, atom);
990+ }
953991 av_free(st->codec->extradata);
954992 st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
955993 if (!st->codec->extradata)
libavformat/movenc.c+20−1
@@ -799,6 +799,23 @@ static int mov_write_uuid_tag_ipod(AVIOContext *pb) · 798 unmodified lines
799799 return 28;
800800 }
801801
802+static const uint16_t fiel_data[] = {
803+ 0x0000, 0x0100, 0x0201, 0x0206, 0x0209, 0x020e
804+};
805+
806+static int mov_write_fiel_tag(AVIOContext *pb, MOVTrack *track)
807+{
808+ unsigned mov_field_order = 0;
809+ if (track->enc->field_order < FF_ARRAY_ELEMS(fiel_data))
810+ mov_field_order = fiel_data[track->enc->field_order];
811+ else
812+ return 0;
813+ avio_wb32(pb, 10);
814+ ffio_wfourcc(pb, "fiel");
815+ avio_wb16(pb, mov_field_order);
816+ return 10;
817+}
818+
802819 static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
803820 {
804821 int64_t pos = avio_tell(pb);
@@ -885,7 +902,9 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) · 80 unmodified lines
885902 mov_write_avcc_tag(pb, track);
886903 if(track->mode == MODE_IPOD)
887904 mov_write_uuid_tag_ipod(pb);
888− } else if(track->vosLen > 0)
905+ } else if (track->enc->field_order != AV_FIELD_UNKNOWN)
906+ mov_write_fiel_tag(pb, track);
907+ else if(track->vosLen > 0)
889908 mov_write_glbl_tag(pb, track);
890909
891910 if (track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num &&
libswscale/swscale_internal.h+4−2
@@ -655,9 +655,11 @@ const char *sws_format_name(enum PixelFormat format); · 654 unmodified lines
655655 || isBGRinInt(x) \
656656 )
657657 #else
658−#define isPacked(x) \
658+#define isPacked(x) (\
659659 (av_pix_fmt_descriptors[x].nb_components >= 2 && \
660− !(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
660+ !(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR)) || \
661+ (x) == PIX_FMT_PAL8\
662+ )
661663
662664 #endif
663665 #define isPlanar(x) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t