* 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
Unified · Split
| @@ -2139,6 +2139,7 @@ static int transcode_init(OutputFile *output_files, · 2138 unmodified lines | ||
| 2139 | 2139 | codec->bit_rate = icodec->bit_rate; |
| 2140 | 2140 | codec->rc_max_rate = icodec->rc_max_rate; |
| 2141 | 2141 | codec->rc_buffer_size = icodec->rc_buffer_size; |
| 2142 | + codec->field_order = icodec->field_order; | |
| 2142 | 2143 | codec->extradata = av_mallocz(extra_size); |
| 2143 | 2144 | if (!codec->extradata) { |
| 2144 | 2145 | return AVERROR(ENOMEM); |
| @@ -1174,6 +1174,7 @@ HAVE_LIST=" · 1173 unmodified lines | ||
| 1174 | 1174 | gethrtime |
| 1175 | 1175 | GetProcessMemoryInfo |
| 1176 | 1176 | GetProcessTimes |
| 1177 | + GetSystemInfo | |
| 1177 | 1178 | getrusage |
| 1178 | 1179 | gnu_as |
| 1179 | 1180 | ibm_asm |
| @@ -1206,6 +1207,7 @@ HAVE_LIST=" · 26 unmodified lines | ||
| 1206 | 1207 | posix_memalign |
| 1207 | 1208 | round |
| 1208 | 1209 | roundf |
| 1210 | + sched_getaffinity | |
| 1209 | 1211 | sdl |
| 1210 | 1212 | sdl_video_size |
| 1211 | 1213 | setmode |
| @@ -1224,6 +1226,7 @@ HAVE_LIST=" · 12 unmodified lines | ||
| 1224 | 1226 | symver |
| 1225 | 1227 | symver_asm_label |
| 1226 | 1228 | symver_gnu_asm |
| 1229 | + sysctl | |
| 1227 | 1230 | sys_mman_h |
| 1228 | 1231 | sys_resource_h |
| 1229 | 1232 | sys_select_h |
| @@ -1654,14 +1657,13 @@ postproc_deps="gpl" · 424 unmodified lines | ||
| 1654 | 1657 | |
| 1655 | 1658 | # programs |
| 1656 | 1659 | avconv_deps="avcodec avformat swscale" |
| 1657 | −avconv_select="buffer_filter" | |
| 1658 | 1660 | ffplay_deps="avcodec avformat swscale sdl" |
| 1659 | 1661 | ffplay_select="buffersink_filter rdft" |
| 1660 | 1662 | ffprobe_deps="avcodec avformat" |
| 1661 | 1663 | ffserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer" |
| 1662 | 1664 | ffserver_extralibs='$ldl' |
| 1663 | 1665 | ffmpeg_deps="avcodec avformat swscale swresample" |
| 1664 | −ffmpeg_select="buffer_filter buffersink_filter" | |
| 1666 | +ffmpeg_select="buffersink_filter" | |
| 1665 | 1667 | |
| 1666 | 1668 | doc_deps="texi2html" |
| 1667 | 1669 | |
| @@ -3000,12 +3002,15 @@ check_func ${malloc_prefix}posix_memalign && enable posix_memalign · 1332 unmodified lines | ||
| 3000 | 3002 | check_func setrlimit |
| 3001 | 3003 | check_func strerror_r |
| 3002 | 3004 | check_func strptime |
| 3005 | +check_func sched_getaffinity | |
| 3006 | +check_func sysctl | |
| 3003 | 3007 | check_func_headers conio.h kbhit |
| 3004 | 3008 | check_func_headers windows.h PeekNamedPipe |
| 3005 | 3009 | check_func_headers io.h setmode |
| 3006 | 3010 | check_func_headers lzo/lzo1x.h lzo1x_999_compress |
| 3007 | 3011 | check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi |
| 3008 | 3012 | check_func_headers windows.h GetProcessTimes |
| 3013 | +check_func_headers windows.h GetSystemInfo | |
| 3009 | 3014 | check_func_headers windows.h MapViewOfFile |
| 3010 | 3015 | check_func_headers windows.h VirtualAlloc |
| 3011 | 3016 | |
| @@ -2213,6 +2213,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 2212 unmodified lines | ||
| 2213 | 2213 | codec->bit_rate = icodec->bit_rate; |
| 2214 | 2214 | codec->rc_max_rate = icodec->rc_max_rate; |
| 2215 | 2215 | codec->rc_buffer_size = icodec->rc_buffer_size; |
| 2216 | + codec->field_order = icodec->field_order; | |
| 2216 | 2217 | codec->extradata = av_mallocz(extra_size); |
| 2217 | 2218 | if (!codec->extradata) { |
| 2218 | 2219 | return AVERROR(ENOMEM); |
| @@ -688,10 +688,13 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){ · 687 unmodified lines | ||
| 688 | 688 | unsigned int prestream_size; |
| 689 | 689 | const uint8_t *prestream; |
| 690 | 690 | |
| 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; | |
| 695 | 698 | |
| 696 | 699 | if (prestream_size > (1<<26) || |
| 697 | 700 | prestream_size != length - (bitstream_size + 12)){ |
| @@ -1007,11 +1007,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1006 unmodified lines | ||
| 1007 | 1007 | break; |
| 1008 | 1008 | case CODEC_ID_ADPCM_IMA_AMV: |
| 1009 | 1009 | 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 | + } | |
| 1015 | 1019 | |
| 1016 | 1020 | for (n = nb_samples >> (1 - st); n > 0; n--, src++) { |
| 1017 | 1021 | char hi, lo; |
| @@ -20,7 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | −#define ALT_BITSTREAM_READER_LE | |
| 23 | +#define BITSTREAM_READER_LE | |
| 24 | 24 | #include "avcodec.h" |
| 25 | 25 | #include "dsputil.h" |
| 26 | 26 | #include "get_bits.h" |
| @@ -1335,6 +1335,15 @@ typedef struct AVFrame { · 1334 unmodified lines | ||
| 1335 | 1335 | |
| 1336 | 1336 | struct AVCodecInternal; |
| 1337 | 1337 | |
| 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 | + | |
| 1338 | 1347 | /** |
| 1339 | 1348 | * main external API structure. |
| 1340 | 1349 | * New fields can be added to the end with minor version bumps. |
| @@ -3191,6 +3200,12 @@ typedef struct AVCodecContext { · 1850 unmodified lines | ||
| 3191 | 3200 | */ |
| 3192 | 3201 | struct AVCodecInternal *internal; |
| 3193 | 3202 | |
| 3203 | + /** Field order | |
| 3204 | + * - encoding: set by libavcodec | |
| 3205 | + * - decoding: Set by libavcodec | |
| 3206 | + */ | |
| 3207 | + enum AVFieldOrder field_order; | |
| 3208 | + | |
| 3194 | 3209 | /** |
| 3195 | 3210 | * Current statistics for PTS correction. |
| 3196 | 3211 | * - decoding: maintained and used by libavcodec, not intended to be used by user apps |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "binkdsp.h" |
| 28 | 28 | #include "mathops.h" |
| 29 | 29 | |
| 30 | −#define ALT_BITSTREAM_READER_LE | |
| 30 | +#define BITSTREAM_READER_LE | |
| 31 | 31 | #include "get_bits.h" |
| 32 | 32 | |
| 33 | 33 | #define BINK_FLAG_ALPHA 0x00100000 |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | #include "avcodec.h" |
| 32 | −#define ALT_BITSTREAM_READER_LE | |
| 32 | +#define BITSTREAM_READER_LE | |
| 33 | 33 | #include "get_bits.h" |
| 34 | 34 | #include "dsputil.h" |
| 35 | 35 | #include "dct.h" |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | #include "avcodec.h" |
| 32 | −#define ALT_BITSTREAM_READER_LE | |
| 32 | +#define BITSTREAM_READER_LE | |
| 33 | 33 | #include "get_bits.h" |
| 34 | 34 | #include "bytestream.h" |
| 35 | 35 | #include "dsputil.h" |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | #include "avcodec.h" |
| 32 | −#define ALT_BITSTREAM_READER_LE | |
| 32 | +#define BITSTREAM_READER_LE | |
| 33 | 33 | #include "get_bits.h" |
| 34 | 34 | #include "libavutil/lzo.h" |
| 35 | 35 | #include "libavutil/imgutils.h" |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | #include "avcodec.h" |
| 23 | 23 | |
| 24 | −#define ALT_BITSTREAM_READER_LE | |
| 24 | +#define BITSTREAM_READER_LE | |
| 25 | 25 | #include "get_bits.h" |
| 26 | 26 | |
| 27 | 27 | typedef union MacroBlock { |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | #include "avcodec.h" |
| 23 | 23 | |
| 24 | −#define ALT_BITSTREAM_READER_LE | |
| 24 | +#define BITSTREAM_READER_LE | |
| 25 | 25 | #include "get_bits.h" |
| 26 | 26 | |
| 27 | 27 | typedef struct Escape130Context { |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | #include "avcodec.h" |
| 29 | −#define ALT_BITSTREAM_READER_LE | |
| 29 | +#define BITSTREAM_READER_LE | |
| 30 | 30 | #include "get_bits.h" |
| 31 | 31 | #include "acelp_vectors.h" |
| 32 | 32 | #include "celp_filters.h" |
| @@ -124,7 +124,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc · 123 unmodified lines | ||
| 124 | 124 | |
| 125 | 125 | #define CLOSE_READER(name, gb) (gb)->index = name##_index |
| 126 | 126 | |
| 127 | −#ifdef ALT_BITSTREAM_READER_LE | |
| 127 | +#ifdef BITSTREAM_READER_LE | |
| 128 | 128 | |
| 129 | 129 | # ifdef LONG_BITSTREAM_READER |
| 130 | 130 | # 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 | ||
| 164 | 164 | |
| 165 | 165 | #define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) |
| 166 | 166 | |
| 167 | −#ifdef ALT_BITSTREAM_READER_LE | |
| 167 | +#ifdef BITSTREAM_READER_LE | |
| 168 | 168 | # define SHOW_UBITS(name, gb, num) zero_extend(name##_cache, num) |
| 169 | 169 | # define SHOW_SBITS(name, gb, num) sign_extend(name##_cache, num) |
| 170 | 170 | #else |
| @@ -254,7 +254,7 @@ static inline unsigned int get_bits1(GetBitContext *s) · 83 unmodified lines | ||
| 254 | 254 | { |
| 255 | 255 | unsigned int index = s->index; |
| 256 | 256 | uint8_t result = s->buffer[index>>3]; |
| 257 | −#ifdef ALT_BITSTREAM_READER_LE | |
| 257 | +#ifdef BITSTREAM_READER_LE | |
| 258 | 258 | result >>= index & 7; |
| 259 | 259 | result &= 1; |
| 260 | 260 | #else |
| @@ -288,7 +288,7 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n) · 27 unmodified lines | ||
| 288 | 288 | if (n <= MIN_CACHE_BITS) |
| 289 | 289 | return get_bits(s, n); |
| 290 | 290 | else { |
| 291 | −#ifdef ALT_BITSTREAM_READER_LE | |
| 291 | +#ifdef BITSTREAM_READER_LE | |
| 292 | 292 | int ret = get_bits(s, 16); |
| 293 | 293 | return ret | (get_bits(s, n-16) << 16); |
| 294 | 294 | #else |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | * @file |
| 24 | 24 | * Intel Indeo 2 decoder. |
| 25 | 25 | */ |
| 26 | −#define ALT_BITSTREAM_READER_LE | |
| 26 | +#define BITSTREAM_READER_LE | |
| 27 | 27 | #include "avcodec.h" |
| 28 | 28 | #include "get_bits.h" |
| 29 | 29 | #include "indeo2data.h" |
| @@ -163,7 +163,7 @@ static int ir2_decode_frame(AVCodecContext *avctx, · 133 unmodified lines | ||
| 163 | 163 | s->decode_delta = buf[18]; |
| 164 | 164 | |
| 165 | 165 | /* decide whether frame uses deltas or not */ |
| 166 | −#ifndef ALT_BITSTREAM_READER_LE | |
| 166 | +#ifndef BITSTREAM_READER_LE | |
| 167 | 167 | for (i = 0; i < buf_size; i++) |
| 168 | 168 | buf[i] = av_reverse[buf[i]]; |
| 169 | 169 | #endif |
| @@ -205,7 +205,7 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){ · 35 unmodified lines | ||
| 205 | 205 | |
| 206 | 206 | ir2_vlc.table = vlc_tables; |
| 207 | 207 | ir2_vlc.table_allocated = 1 << CODE_VLC_BITS; |
| 208 | −#ifdef ALT_BITSTREAM_READER_LE | |
| 208 | +#ifdef BITSTREAM_READER_LE | |
| 209 | 209 | init_vlc(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, |
| 210 | 210 | &ir2_codes[0][1], 4, 2, |
| 211 | 211 | &ir2_codes[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE); |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | |
| 27 | 27 | #define IR2_CODES 143 |
| 28 | 28 | static const uint16_t ir2_codes[IR2_CODES][2] = { |
| 29 | −#ifdef ALT_BITSTREAM_READER_LE | |
| 29 | +#ifdef BITSTREAM_READER_LE | |
| 30 | 30 | {0x0000, 3}, {0x0004, 3}, {0x0006, 3}, {0x0001, 5}, |
| 31 | 31 | {0x0009, 5}, {0x0019, 5}, {0x000D, 5}, {0x001D, 5}, |
| 32 | 32 | {0x0023, 6}, {0x0013, 6}, {0x0033, 6}, {0x000B, 6}, |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | * Known FOURCCs: 'IV50' |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | −#define ALT_BITSTREAM_READER_LE | |
| 30 | +#define BITSTREAM_READER_LE | |
| 31 | 31 | #include "avcodec.h" |
| 32 | 32 | #include "get_bits.h" |
| 33 | 33 | #include "dsputil.h" |
| @@ -41,7 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #include "avcodec.h" |
| 42 | 42 | #include "bytestream.h" |
| 43 | 43 | #include "dsputil.h" |
| 44 | −#define ALT_BITSTREAM_READER_LE | |
| 44 | +#define BITSTREAM_READER_LE | |
| 45 | 45 | #include "get_bits.h" |
| 46 | 46 | |
| 47 | 47 | #define PALETTE_COUNT 256 |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | * Indeo5 decoders. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | −#define ALT_BITSTREAM_READER_LE | |
| 29 | +#define BITSTREAM_READER_LE | |
| 30 | 30 | #include "avcodec.h" |
| 31 | 31 | #include "get_bits.h" |
| 32 | 32 | #include "ivi_common.h" |
| @@ -57,17 +57,21 @@ typedef struct BitBuf { · 56 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | #define kmvc_init_getbits(bb, src) bb.bits = 7; bb.bitbuf = *src++; |
| 59 | 59 | |
| 60 | −#define kmvc_getbit(bb, src, res) {\ | |
| 60 | +#define kmvc_getbit(bb, src, src_end, res) {\ | |
| 61 | 61 | res = 0; \ |
| 62 | 62 | if (bb.bitbuf & (1 << bb.bits)) res = 1; \ |
| 63 | 63 | bb.bits--; \ |
| 64 | 64 | 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 | + } \ | |
| 65 | 69 | bb.bitbuf = *src++; \ |
| 66 | 70 | bb.bits = 7; \ |
| 67 | 71 | } \ |
| 68 | 72 | } |
| 69 | 73 | |
| 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) | |
| 71 | 75 | { |
| 72 | 76 | BitBuf bb; |
| 73 | 77 | int res, val; |
| @@ -75,13 +79,18 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 1 unmodified line | ||
| 75 | 79 | int bx, by; |
| 76 | 80 | int l0x, l1x, l0y, l1y; |
| 77 | 81 | int mx, my; |
| 82 | + const uint8_t *src_end = src + src_size; | |
| 78 | 83 | |
| 79 | 84 | kmvc_init_getbits(bb, src); |
| 80 | 85 | |
| 81 | 86 | for (by = 0; by < h; by += 8) |
| 82 | 87 | for (bx = 0; bx < w; bx += 8) { |
| 83 | − kmvc_getbit(bb, src, res); | |
| 88 | + kmvc_getbit(bb, src, src_end, res); | |
| 84 | 89 | 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 | + } | |
| 85 | 94 | val = *src++; |
| 86 | 95 | for (i = 0; i < 64; i++) |
| 87 | 96 | 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 | ||
| 89 | 98 | for (i = 0; i < 4; i++) { |
| 90 | 99 | l0x = bx + (i & 1) * 4; |
| 91 | 100 | l0y = by + (i & 2) * 2; |
| 92 | − kmvc_getbit(bb, src, res); | |
| 101 | + kmvc_getbit(bb, src, src_end, res); | |
| 93 | 102 | if (!res) { |
| 94 | − kmvc_getbit(bb, src, res); | |
| 103 | + kmvc_getbit(bb, src, src_end, res); | |
| 95 | 104 | 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 | + } | |
| 96 | 109 | val = *src++; |
| 97 | 110 | for (j = 0; j < 16; j++) |
| 98 | 111 | BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val; |
| 99 | 112 | } 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 | + } | |
| 100 | 117 | val = *src++; |
| 101 | 118 | mx = val & 0xF; |
| 102 | 119 | my = val >> 4; |
| @@ -108,16 +125,24 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 5 unmodified lines | ||
| 108 | 125 | for (j = 0; j < 4; j++) { |
| 109 | 126 | l1x = l0x + (j & 1) * 2; |
| 110 | 127 | l1y = l0y + (j & 2); |
| 111 | − kmvc_getbit(bb, src, res); | |
| 128 | + kmvc_getbit(bb, src, src_end, res); | |
| 112 | 129 | if (!res) { |
| 113 | − kmvc_getbit(bb, src, res); | |
| 130 | + kmvc_getbit(bb, src, src_end, res); | |
| 114 | 131 | 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 | + } | |
| 115 | 136 | val = *src++; |
| 116 | 137 | BLK(ctx->cur, l1x, l1y) = val; |
| 117 | 138 | BLK(ctx->cur, l1x + 1, l1y) = val; |
| 118 | 139 | BLK(ctx->cur, l1x, l1y + 1) = val; |
| 119 | 140 | BLK(ctx->cur, l1x + 1, l1y + 1) = val; |
| 120 | 141 | } 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 | + } | |
| 121 | 146 | val = *src++; |
| 122 | 147 | mx = val & 0xF; |
| 123 | 148 | my = val >> 4; |
| @@ -140,9 +165,11 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 16 unmodified lines | ||
| 140 | 165 | } |
| 141 | 166 | } |
| 142 | 167 | } |
| 168 | + | |
| 169 | + return 0; | |
| 143 | 170 | } |
| 144 | 171 | |
| 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) | |
| 146 | 173 | { |
| 147 | 174 | BitBuf bb; |
| 148 | 175 | int res, val; |
| @@ -150,15 +177,20 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, · 1 unmodified line | ||
| 150 | 177 | int bx, by; |
| 151 | 178 | int l0x, l1x, l0y, l1y; |
| 152 | 179 | int mx, my; |
| 180 | + const uint8_t *src_end = src + src_size; | |
| 153 | 181 | |
| 154 | 182 | kmvc_init_getbits(bb, src); |
| 155 | 183 | |
| 156 | 184 | for (by = 0; by < h; by += 8) |
| 157 | 185 | for (bx = 0; bx < w; bx += 8) { |
| 158 | − kmvc_getbit(bb, src, res); | |
| 186 | + kmvc_getbit(bb, src, src_end, res); | |
| 159 | 187 | if (!res) { |
| 160 | − kmvc_getbit(bb, src, res); | |
| 188 | + kmvc_getbit(bb, src, src_end, res); | |
| 161 | 189 | 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 | + } | |
| 162 | 194 | val = *src++; |
| 163 | 195 | for (i = 0; i < 64; i++) |
| 164 | 196 | 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 | ||
| 171 | 203 | for (i = 0; i < 4; i++) { |
| 172 | 204 | l0x = bx + (i & 1) * 4; |
| 173 | 205 | l0y = by + (i & 2) * 2; |
| 174 | − kmvc_getbit(bb, src, res); | |
| 206 | + kmvc_getbit(bb, src, src_end, res); | |
| 175 | 207 | if (!res) { |
| 176 | − kmvc_getbit(bb, src, res); | |
| 208 | + kmvc_getbit(bb, src, src_end, res); | |
| 177 | 209 | 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 | + } | |
| 178 | 214 | val = *src++; |
| 179 | 215 | for (j = 0; j < 16; j++) |
| 180 | 216 | BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val; |
| 181 | 217 | } else { // copy block |
| 218 | + if (src >= src_end) { | |
| 219 | + av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); | |
| 220 | + return AVERROR_INVALIDDATA; | |
| 221 | + } | |
| 182 | 222 | val = *src++; |
| 183 | 223 | mx = (val & 0xF) - 8; |
| 184 | 224 | 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 | ||
| 190 | 230 | for (j = 0; j < 4; j++) { |
| 191 | 231 | l1x = l0x + (j & 1) * 2; |
| 192 | 232 | l1y = l0y + (j & 2); |
| 193 | − kmvc_getbit(bb, src, res); | |
| 233 | + kmvc_getbit(bb, src, src_end, res); | |
| 194 | 234 | if (!res) { |
| 195 | − kmvc_getbit(bb, src, res); | |
| 235 | + kmvc_getbit(bb, src, src_end, res); | |
| 196 | 236 | 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 | + } | |
| 197 | 241 | val = *src++; |
| 198 | 242 | BLK(ctx->cur, l1x, l1y) = val; |
| 199 | 243 | BLK(ctx->cur, l1x + 1, l1y) = val; |
| 200 | 244 | BLK(ctx->cur, l1x, l1y + 1) = val; |
| 201 | 245 | BLK(ctx->cur, l1x + 1, l1y + 1) = val; |
| 202 | 246 | } else { // copy block |
| 247 | + if (src >= src_end) { | |
| 248 | + av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); | |
| 249 | + return AVERROR_INVALIDDATA; | |
| 250 | + } | |
| 203 | 251 | val = *src++; |
| 204 | 252 | mx = (val & 0xF) - 8; |
| 205 | 253 | 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 | ||
| 222 | 270 | } |
| 223 | 271 | } |
| 224 | 272 | } |
| 273 | + | |
| 274 | + return 0; | |
| 225 | 275 | } |
| 226 | 276 | |
| 227 | 277 | 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 | ||
| 299 | 349 | memcpy(ctx->cur, ctx->prev, 320 * 200); |
| 300 | 350 | break; |
| 301 | 351 | 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); | |
| 303 | 353 | break; |
| 304 | 354 | 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); | |
| 306 | 356 | break; |
| 307 | 357 | default: |
| 308 | 358 | av_log(avctx, AV_LOG_ERROR, "Unknown compression method %i\n", header & KMVC_METHOD); |
| @@ -112,12 +112,9 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) · 111 unmodified lines | ||
| 112 | 112 | build_basic_mjpeg_vlc(s); |
| 113 | 113 | } |
| 114 | 114 | } |
| 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"); | |
| 121 | 118 | } |
| 122 | 119 | if (avctx->codec->id == CODEC_ID_AMV) |
| 123 | 120 | s->flipped = 1; |
| @@ -19,7 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | −#define ALT_BITSTREAM_READER_LE | |
| 22 | +#define BITSTREAM_READER_LE | |
| 23 | 23 | #include "avcodec.h" |
| 24 | 24 | #include "msgsmdec.h" |
| 25 | 25 | #include "gsmdec_template.c" |
| @@ -35,7 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #include "avcodec.h" |
| 36 | 36 | #include "dsputil.h" |
| 37 | 37 | |
| 38 | −#define ALT_BITSTREAM_READER_LE | |
| 38 | +#define BITSTREAM_READER_LE | |
| 39 | 39 | #include "get_bits.h" |
| 40 | 40 | |
| 41 | 41 | const float ff_nelly_dequantization_table[127] = { |
| @@ -41,7 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #include "fmtconvert.h" |
| 42 | 42 | #include "sinewin.h" |
| 43 | 43 | |
| 44 | −#define ALT_BITSTREAM_READER_LE | |
| 44 | +#define BITSTREAM_READER_LE | |
| 45 | 45 | #include "get_bits.h" |
| 46 | 46 | |
| 47 | 47 | |
| @@ -371,7 +371,8 @@ static const AVOption options[]={ · 370 unmodified lines | ||
| 371 | 371 | {"float", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"}, |
| 372 | 372 | #endif |
| 373 | 373 | {"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"}, | |
| 375 | 376 | {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, |
| 376 | 377 | {"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, |
| 377 | 378 | {"dc", "intra_dc_precision", OFFSET(intra_dc_precision), AV_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, |
| @@ -30,6 +30,17 @@ · 29 unmodified lines | ||
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | 32 | #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 | + | |
| 33 | 44 | #include "avcodec.h" |
| 34 | 45 | #include "internal.h" |
| 35 | 46 | #include "thread.h" |
| @@ -135,6 +146,40 @@ typedef struct FrameThreadContext { · 99 unmodified lines | ||
| 135 | 146 | int die; ///< Set when threads should exit. |
| 136 | 147 | } FrameThreadContext; |
| 137 | 148 | |
| 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 | + | |
| 138 | 183 | static void* attribute_align_arg worker(void *v) |
| 139 | 184 | { |
| 140 | 185 | AVCodecContext *avctx = v; |
| @@ -239,8 +284,17 @@ static int thread_init(AVCodecContext *avctx) · 98 unmodified lines | ||
| 239 | 284 | ThreadContext *c; |
| 240 | 285 | int thread_count = avctx->thread_count; |
| 241 | 286 | |
| 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; | |
| 243 | 296 | return 0; |
| 297 | + } | |
| 244 | 298 | |
| 245 | 299 | c = av_mallocz(sizeof(ThreadContext)); |
| 246 | 300 | if (!c) |
| @@ -704,6 +758,13 @@ static int frame_thread_init(AVCodecContext *avctx) · 457 unmodified lines | ||
| 704 | 758 | FrameThreadContext *fctx; |
| 705 | 759 | int i, err = 0; |
| 706 | 760 | |
| 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 | + | |
| 707 | 768 | if (thread_count <= 1) { |
| 708 | 769 | avctx->active_thread_type = 0; |
| 709 | 770 | return 0; |
| @@ -35,7 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #include <stddef.h> |
| 36 | 36 | #include <stdio.h> |
| 37 | 37 | |
| 38 | −#define ALT_BITSTREAM_READER_LE | |
| 38 | +#define BITSTREAM_READER_LE | |
| 39 | 39 | #include "avcodec.h" |
| 40 | 40 | #include "get_bits.h" |
| 41 | 41 | #include "dsputil.h" |
| @@ -477,7 +477,10 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 476 unmodified lines | ||
| 477 | 477 | * The filter is unstable: use the coefficients of the previous frame. |
| 478 | 478 | */ |
| 479 | 479 | 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 | + } | |
| 481 | 484 | } |
| 482 | 485 | init_put_bits(&pb, frame, buf_size); |
| 483 | 486 | for (i = 0; i < LPC_ORDER; i++) { |
| @@ -20,7 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | #include "avcodec.h" |
| 23 | −#define ALT_BITSTREAM_READER_LE | |
| 23 | +#define BITSTREAM_READER_LE | |
| 24 | 24 | #include "get_bits.h" |
| 25 | 25 | #include "ra288.h" |
| 26 | 26 | #include "lpc.h" |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | |
| 28 | 28 | #include "libavutil/mathematics.h" |
| 29 | 29 | #include "avcodec.h" |
| 30 | −#define ALT_BITSTREAM_READER_LE | |
| 30 | +#define BITSTREAM_READER_LE | |
| 31 | 31 | #include "get_bits.h" |
| 32 | 32 | #include "dsputil.h" |
| 33 | 33 | |
| @@ -35,7 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #include "libavutil/audioconvert.h" |
| 36 | 36 | #include "mathops.h" |
| 37 | 37 | |
| 38 | −#define ALT_BITSTREAM_READER_LE | |
| 38 | +#define BITSTREAM_READER_LE | |
| 39 | 39 | #include "get_bits.h" |
| 40 | 40 | #include "bytestream.h" |
| 41 | 41 | |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #include "avcodec.h" |
| 28 | −#define ALT_BITSTREAM_READER_LE | |
| 28 | +#define BITSTREAM_READER_LE | |
| 29 | 29 | #include "get_bits.h" |
| 30 | 30 | |
| 31 | 31 | |
| @@ -179,6 +179,7 @@ static void truespeech_apply_twopoint_filter(TSContext *dec, int quart) · 178 unmodified lines | ||
| 179 | 179 | for(i = 0; i < 146; i++) |
| 180 | 180 | tmp[i] = dec->filtbuf[i]; |
| 181 | 181 | off = (t / 25) + dec->offset1[quart >> 1] + 18; |
| 182 | + off = av_clip(off, 0, 145); | |
| 182 | 183 | ptr0 = tmp + 145 - off; |
| 183 | 184 | ptr1 = tmp + 146; |
| 184 | 185 | filter = (const int16_t*)ts_order2_coeffs + (t % 25) * 2; |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | * @author Alex Beregszaszi |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | −#define ALT_BITSTREAM_READER_LE | |
| 30 | +#define BITSTREAM_READER_LE | |
| 31 | 31 | //#define DEBUG |
| 32 | 32 | #include <limits.h> |
| 33 | 33 | #include "avcodec.h" |
| @@ -20,8 +20,8 @@ · 19 unmodified lines | ||
| 20 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | +#include "libavutil/intreadwrite.h" | |
| 23 | 24 | #include "avcodec.h" |
| 24 | −#include "get_bits.h" | |
| 25 | 25 | |
| 26 | 26 | static av_cold int v410_decode_init(AVCodecContext *avctx) |
| 27 | 27 | { |
| @@ -24,7 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | * VBLE Decoder |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | −#define ALT_BITSTREAM_READER_LE | |
| 27 | +#define BITSTREAM_READER_LE | |
| 28 | 28 | |
| 29 | 29 | #include "avcodec.h" |
| 30 | 30 | #include "dsputil.h" |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | * @author Denes Balatoni ( dbalatoni programozo hu ) |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | −#define ALT_BITSTREAM_READER_LE | |
| 29 | +#define BITSTREAM_READER_LE | |
| 30 | 30 | #include "avcodec.h" |
| 31 | 31 | #include "get_bits.h" |
| 32 | 32 | |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include <inttypes.h> |
| 30 | 30 | #include <math.h> |
| 31 | 31 | |
| 32 | −#define ALT_BITSTREAM_READER_LE | |
| 32 | +#define BITSTREAM_READER_LE | |
| 33 | 33 | #include "avcodec.h" |
| 34 | 34 | #include "get_bits.h" |
| 35 | 35 | #include "dsputil.h" |
| @@ -18,7 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | * License along with FFmpeg; if not, write to the Free Software |
| 19 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 | */ |
| 21 | −#define ALT_BITSTREAM_READER_LE | |
| 21 | +#define BITSTREAM_READER_LE | |
| 22 | 22 | #include "avcodec.h" |
| 23 | 23 | #include "get_bits.h" |
| 24 | 24 | #include "unary.h" |
| @@ -35,7 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #include "libavutil/intreadwrite.h" |
| 36 | 36 | #include "avcodec.h" |
| 37 | 37 | #include "bytestream.h" |
| 38 | −#define ALT_BITSTREAM_READER_LE | |
| 38 | +#define BITSTREAM_READER_LE | |
| 39 | 39 | #include "get_bits.h" |
| 40 | 40 | // for av_memcpy_backptr |
| 41 | 41 | #include "libavutil/lzo.h" |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "avcodec.h" |
| 24 | 24 | #include "libavutil/intreadwrite.h" |
| 25 | 25 | #include "bytestream.h" |
| 26 | −#define ALT_BITSTREAM_READER_LE | |
| 26 | +#define BITSTREAM_READER_LE | |
| 27 | 27 | #include "get_bits.h" |
| 28 | 28 | // for av_memcpy_backptr |
| 29 | 29 | #include "libavutil/lzo.h" |
| @@ -20,6 +20,7 @@ OBJS = allfilters.o \ · 19 unmodified lines | ||
| 20 | 20 | formats.o \ |
| 21 | 21 | graphparser.o \ |
| 22 | 22 | transform.o \ |
| 23 | + vsrc_buffer.o | |
| 23 | 24 | |
| 24 | 25 | OBJS-$(CONFIG_AVCODEC) += avcodec.o |
| 25 | 26 | |
| @@ -83,7 +84,6 @@ OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o · 57 unmodified lines | ||
| 83 | 84 | OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o |
| 84 | 85 | OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o |
| 85 | 86 | |
| 86 | −OBJS-$(CONFIG_BUFFER_FILTER) += vsrc_buffer.o | |
| 87 | 87 | OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o |
| 88 | 88 | OBJS-$(CONFIG_COLOR_FILTER) += vsrc_color.o |
| 89 | 89 | OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o |
| @@ -94,7 +94,6 @@ void avfilter_register_all(void) · 93 unmodified lines | ||
| 94 | 94 | REGISTER_FILTER (VFLIP, vflip, vf); |
| 95 | 95 | REGISTER_FILTER (YADIF, yadif, vf); |
| 96 | 96 | |
| 97 | − REGISTER_FILTER (BUFFER, buffer, vsrc); | |
| 98 | 97 | REGISTER_FILTER (CELLAUTO, cellauto, vsrc); |
| 99 | 98 | REGISTER_FILTER (COLOR, color, vsrc); |
| 100 | 99 | REGISTER_FILTER (FREI0R, frei0r_src, vsrc); |
| @@ -108,4 +107,10 @@ void avfilter_register_all(void) · 7 unmodified lines | ||
| 108 | 107 | |
| 109 | 108 | REGISTER_FILTER (BUFFERSINK, buffersink, vsink); |
| 110 | 109 | 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 | + } | |
| 111 | 116 | } |
| @@ -56,7 +56,8 @@ OBJS-$(CONFIG_BIT_DEMUXER) += bit.o · 55 unmodified lines | ||
| 56 | 56 | OBJS-$(CONFIG_BIT_MUXER) += bit.o |
| 57 | 57 | OBJS-$(CONFIG_BMV_DEMUXER) += bmv.o |
| 58 | 58 | 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 | |
| 60 | 61 | OBJS-$(CONFIG_CAF_MUXER) += cafenc.o caf.o riff.o isom.o |
| 61 | 62 | OBJS-$(CONFIG_CAVSVIDEO_DEMUXER) += cavsvideodec.o rawdec.o |
| 62 | 63 | OBJS-$(CONFIG_CAVSVIDEO_MUXER) += rawenc.o |
| @@ -195,7 +196,7 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ · 132 unmodified lines | ||
| 195 | 196 | OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \ |
| 196 | 197 | vorbiscomment.o |
| 197 | 198 | 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 | |
| 199 | 200 | OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += pcmdec.o pcm.o rawdec.o |
| 200 | 201 | OBJS-$(CONFIG_PCM_ALAW_MUXER) += pcmenc.o rawenc.o |
| 201 | 202 | 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 | ||
| 331 | 332 | OBJS-$(CONFIG_WV_DEMUXER) += wv.o apetag.o |
| 332 | 333 | OBJS-$(CONFIG_XA_DEMUXER) += xa.o |
| 333 | 334 | OBJS-$(CONFIG_XBIN_DEMUXER) += bintext.o sauce.o |
| 334 | −OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o | |
| 335 | +OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o riff.o | |
| 335 | 336 | OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o riff.o |
| 336 | 337 | OBJS-$(CONFIG_YOP_DEMUXER) += yop.o |
| 337 | 338 | OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg.o |
| @@ -857,6 +857,40 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 856 unmodified lines | ||
| 857 | 857 | return 0; |
| 858 | 858 | } |
| 859 | 859 | |
| 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 | + | |
| 860 | 894 | /* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */ |
| 861 | 895 | static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, |
| 862 | 896 | enum CodecID codec_id) |
| @@ -898,11 +932,6 @@ static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 35 unmodified lines | ||
| 898 | 932 | return mov_read_extradata(c, pb, atom, CODEC_ID_AVS); |
| 899 | 933 | } |
| 900 | 934 | |
| 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 | − | |
| 906 | 935 | static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
| 907 | 936 | { |
| 908 | 937 | 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 | ||
| 950 | 979 | if ((uint64_t)atom.size > (1<<30)) |
| 951 | 980 | return -1; |
| 952 | 981 | |
| 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 | + } | |
| 953 | 991 | av_free(st->codec->extradata); |
| 954 | 992 | st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE); |
| 955 | 993 | if (!st->codec->extradata) |
| @@ -799,6 +799,23 @@ static int mov_write_uuid_tag_ipod(AVIOContext *pb) · 798 unmodified lines | ||
| 799 | 799 | return 28; |
| 800 | 800 | } |
| 801 | 801 | |
| 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 | + | |
| 802 | 819 | static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track) |
| 803 | 820 | { |
| 804 | 821 | int64_t pos = avio_tell(pb); |
| @@ -885,7 +902,9 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) · 80 unmodified lines | ||
| 885 | 902 | mov_write_avcc_tag(pb, track); |
| 886 | 903 | if(track->mode == MODE_IPOD) |
| 887 | 904 | 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) | |
| 889 | 908 | mov_write_glbl_tag(pb, track); |
| 890 | 909 | |
| 891 | 910 | if (track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num && |
| @@ -655,9 +655,11 @@ const char *sws_format_name(enum PixelFormat format); · 654 unmodified lines | ||
| 655 | 655 | || isBGRinInt(x) \ |
| 656 | 656 | ) |
| 657 | 657 | #else |
| 658 | −#define isPacked(x) \ | |
| 658 | +#define isPacked(x) (\ | |
| 659 | 659 | (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 | + ) | |
| 661 | 663 | |
| 662 | 664 | #endif |
| 663 | 665 | #define isPlanar(x) \ |