Compare commits
328 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c13b19a5bc | |||
| 394f4ee61e | |||
| 497d661262 | |||
| 8044ab94e4 | |||
| 257188acea | |||
| 80a77c0c5b | |||
| 854fa0d1ab | |||
| 5d790cdb9e | |||
| bb015b519e | |||
| acf7c5b8ee | |||
| a5a2f8ac5a | |||
| 437a0ae1a1 | |||
| da19bfb287 | |||
| a94fe0e151 | |||
| 688ab26604 | |||
| a2c6cb260f | |||
| aed8f48545 | |||
| 6596f5c3aa | |||
| a457115f0f | |||
| b5d7b80a7e | |||
| 90241187ce | |||
| e719bfc403 | |||
| 7d42ede8fe | |||
| 2ec8e46550 | |||
| b5ae0e349a | |||
| 0a83007cee | |||
| 330791c2ae | |||
| 5404bf29c3 | |||
| 2c10833d5e | |||
| cdfd61b78b | |||
| f3ae90621e | |||
| c4dabc38a3 | |||
| d60f680fa7 | |||
| 452e343295 | |||
| 5a2d1913a9 | |||
| e24d1cbc4e | |||
| c98d164a6a | |||
| 0ab76ddf31 | |||
| 042c25f54b | |||
| dcc68de942 | |||
| ebe2292eaf | |||
| d86df7dd49 | |||
| a79e58cdc6 | |||
| 4709baecc9 | |||
| c79cf0129e | |||
| 9d5f4f0253 | |||
| cf6b2a0ad2 | |||
| 3aebdffb01 | |||
| a1804df66a | |||
| e17dc0a254 | |||
| 4a6622550a | |||
| 50493f1f7d | |||
| 3e60501f31 | |||
| 7585a6254b | |||
| 184c79729d | |||
| a465ed5707 | |||
| 976f2e0a54 | |||
| 28f2d3c5a5 | |||
| 277103e07f | |||
| e4fdfdf65d | |||
| 187cfd3c13 | |||
| 9153b33a74 | |||
| a907fc0b21 | |||
| d77ad6ec2d | |||
| e122fb594a | |||
| 359383c983 | |||
| e7f5dacd55 | |||
| 6a968073da | |||
| c1ac5896ef | |||
| 9c7321e2b8 | |||
| da97174dcb | |||
| 6a679279f7 | |||
| dd8464bc99 | |||
| 363cf196c9 | |||
| 90b69d1d02 | |||
| 71a3ad42b8 | |||
| ec29aec618 | |||
| 6cf254ea68 | |||
| f24246a889 | |||
| 2facb10f70 | |||
| 3b977a6ded | |||
| 2088340173 | |||
| 952738d0af | |||
| d499685d80 | |||
| 0be41c6586 | |||
| 18b233428a | |||
| c437ab3c4e | |||
| b827189c6f | |||
| fe30351d52 | |||
| 7c520e5cd6 | |||
| d076ee5216 | |||
| 8d32735629 | |||
| 0558832796 | |||
| ced5c8e6b3 | |||
| 1e83191d5c | |||
| 69db5f2779 | |||
| 97a5b4ba53 | |||
| f2275400fe | |||
| 1ab94468dd | |||
| ef076d3bd6 | |||
| 2b40afae70 | |||
| bca2ebbeee | |||
| 53dcd772aa | |||
| 2f894deeda | |||
| e771425e98 | |||
| 9552b37e26 | |||
| d75b149757 | |||
| 516ea2dccd | |||
| 6f4404b24b | |||
| 7fa7270029 | |||
| 110680c5a2 | |||
| 65c3593792 | |||
| b7b798a1af | |||
| 5463a2b056 | |||
| 079758e49a | |||
| 42dcfe32a8 | |||
| a0a90b1a11 | |||
| fa60904ebd | |||
| 330c180324 | |||
| 71b8c8430c | |||
| 27ac9585c9 | |||
| 35ba079fbf | |||
| a7cce9ebf3 | |||
| 51ae8e26af | |||
| c4033cd4eb | |||
| b473fdcde3 | |||
| 1dce4a031f | |||
| d0ecfe3249 | |||
| db52f056c3 | |||
| 9938e450c8 | |||
| 07558d0b9f | |||
| 7f33a24e82 | |||
| 0f71a5df4b | |||
| 3ee26080d6 | |||
| e0d8a17402 | |||
| 2cbc8dfedd | |||
| ecf21ab0ec | |||
| afab4c422b | |||
| 16f0f97eec | |||
| f1a8885ae9 | |||
| aedf1a2996 | |||
| bf0cb89a8d | |||
| ec772cca60 | |||
| 7b00340f97 | |||
| 6f9e6ac6aa | |||
| 43b1762ab8 | |||
| f157f18b34 | |||
| 68b14c044a | |||
| ae51d93983 | |||
| ca8c3ec11b | |||
| 4e47ae4e71 | |||
| 5cab56dc9e | |||
| 98f44b24b5 | |||
| ad4963a944 | |||
| 5640ea43d7 | |||
| 15efd9a7c0 | |||
| 0d82c3a0ca | |||
| b7a750f67f | |||
| 0120e480bf | |||
| fd2fc130b2 | |||
| 3da4fdd5ac | |||
| 2c1d84499b | |||
| 2fb0a52e70 | |||
| de0e442e9d | |||
| 43aa7eb38e | |||
| 9786c24bb7 | |||
| 4279e0e8d0 | |||
| a6003760bd | |||
| cf676c159b | |||
| 36017d49e2 | |||
| 8cade1352b | |||
| 5522c564d4 | |||
| b0db7a523d | |||
| e03b875c0b | |||
| 30c8a5e4f6 | |||
| 716ee73c99 | |||
| 979f77b0dc | |||
| 2f4e066d66 | |||
| 6a56d16dc1 | |||
| 23144c5f06 | |||
| e964207e6c | |||
| 2c0bfce4cb | |||
| b68e5b1195 | |||
| cb5d0ea0be | |||
| ef6c90e102 | |||
| d04194db45 | |||
| 976a7b72a3 | |||
| a89acaa0b0 | |||
| 41216ebb9e | |||
| 86a423d2b8 | |||
| a26bfc444d | |||
| 93e3ec451c | |||
| 76c48a78d1 | |||
| 6c0c799bd5 | |||
| d1c7a7776f | |||
| 5339a9f000 | |||
| bd953f9404 | |||
| 9e96051d5d | |||
| 85c02da307 | |||
| 8b24e17d09 | |||
| 3736b13753 | |||
| 48d57650f1 | |||
| 9925f7df0a | |||
| 1123870879 | |||
| 371659d1ad | |||
| 29fa517d40 | |||
| c00e491aeb | |||
| fbc52044f3 | |||
| 49c1defee5 | |||
| 871baf3127 | |||
| 591d5281f5 | |||
| e972338e35 | |||
| 90294e31a1 | |||
| d92c908e23 | |||
| cb4a101fbe | |||
| 993977032a | |||
| 5e8243e843 | |||
| 159993acc7 | |||
| d3986f4f1b | |||
| 5a40e4c64d | |||
| 416ad3ecf2 | |||
| b29c31c21e | |||
| 380e373267 | |||
| ac1e61d559 | |||
| 7fdb915fc7 | |||
| 456a939210 | |||
| 1438181a29 | |||
| 35c39d2ee2 | |||
| c211ba9b59 | |||
| 213b8aa0a9 | |||
| ea1c9424d1 | |||
| f23b1cc7d9 | |||
| 889bdc47f6 | |||
| e80071892b | |||
| efe59ad90b | |||
| 2c31141585 | |||
| 61d56054a9 | |||
| ff8837e9c6 | |||
| cd254e8540 | |||
| 036136fa89 | |||
| b19eafa2b9 | |||
| 486c457675 | |||
| 68a1df13c4 | |||
| 75dabbff8b | |||
| e3ba6ff935 | |||
| b81d804f2a | |||
| 61032c577d | |||
| 3b169044ca | |||
| 843b330c3c | |||
| f241d5aa1f | |||
| e01d623e01 | |||
| 0a23055b8a | |||
| 33b88170d7 | |||
| 7d8a4bb8d2 | |||
| 2b71a78841 | |||
| f0db793bee | |||
| 712945d21e | |||
| 2ef84218b2 | |||
| 75f811babc | |||
| d5c104c1ae | |||
| 48f27c854f | |||
| 802deb2d13 | |||
| 290783b848 | |||
| 7f80928c0e | |||
| b9e90b36cd | |||
| 7981b5c20e | |||
| 9291012d52 | |||
| 594b843608 | |||
| b6fc0127ce | |||
| b997a6a86d | |||
| 6f6cd7dbe5 | |||
| b5736759ee | |||
| d4a24e43ed | |||
| 58e212c1fb | |||
| 4ddbe89d40 | |||
| d83dff2e09 | |||
| 5e708b4de3 | |||
| 8528feb13c | |||
| 2e57d4ba24 | |||
| 7c72398787 | |||
| 048e284201 | |||
| e31518e86e | |||
| 1c896e865c | |||
| 39d76907c9 | |||
| 1825d6d096 | |||
| a5115752ca | |||
| cb297f6ae7 | |||
| 3667874833 | |||
| ae9652605a | |||
| d2f4846591 | |||
| 62c8bf00bb | |||
| a1b82c6b1c | |||
| 2ed8a550da | |||
| 86d0bf0e96 | |||
| ef67d8107e | |||
| be8b796f55 | |||
| 8119336df4 | |||
| 8297853917 | |||
| b8ba48c725 | |||
| 1682c9fb59 | |||
| 5971631d84 | |||
| c08127c5e6 | |||
| 558c1f35fa | |||
| 8096691a68 | |||
| abb41f19cc | |||
| 36fc320747 | |||
| 4a11d773f9 | |||
| c1ebdef01b | |||
| cda26ab21e | |||
| d2eddcfc83 | |||
| 3cc05e0d9d | |||
| b98a824c3e | |||
| e930b112d1 | |||
| 067713f159 | |||
| 5312fb8287 | |||
| a9ebc17b2d | |||
| 2da49df19e | |||
| c25bbb6fdb | |||
| 12dc01bb1f | |||
| cd9b0bb07a | |||
| 53c76b6803 | |||
| 7999ff8966 | |||
| a0b8f85f29 | |||
| c02b9e6e63 | |||
| efe710f8a0 | |||
| aedde1a48d | |||
| c5da487a38 | |||
| f21dce6044 |
@@ -4,6 +4,170 @@ releases are sorted from youngest to oldest.
|
||||
version next:
|
||||
|
||||
|
||||
version 0.10.11
|
||||
|
||||
- pthread: Avoid spurious wakeups
|
||||
- pthread: Fix deadlock during thread initialization
|
||||
- mpegvideo: Initialize chroma_*_shift and codec_tag even if the size is 0
|
||||
- vc1dec: Don't decode slices when the latest slice header failed to decode
|
||||
- vc1dec: Make sure last_picture is initialized in vc1_decode_skip_blocks
|
||||
- r3d: Add more input value validation
|
||||
- fraps: Make the input buffer size checks more strict
|
||||
- svq3: Avoid a division by zero
|
||||
- rmdec: Validate the fps value
|
||||
- twinvqdec: Check the ibps parameter separately
|
||||
- asfdec: Check the return value of asf_read_stream_properties
|
||||
- mxfdec: set audio timebase to 1/samplerate
|
||||
- pcx: Check the packet size before assuming it fits a palette
|
||||
- rpza: Fix a buffer size check
|
||||
- xxan: Disallow odd width
|
||||
- xan: Only read within the data that actually was initialized
|
||||
- xan: Use bytestream2 to limit reading to within the buffer
|
||||
- pcx: Consume the whole packet if giving up due to missing palette
|
||||
- pngdec: Stop trying to decode once inflate returns Z_STREAM_END
|
||||
- mov: Make sure the read sample count is nonnegative
|
||||
- bfi: Add some very basic sanity checks for input packet sizes
|
||||
- bfi: Avoid divisions by zero
|
||||
- electronicarts: Add more sanity checking for the number of channels
|
||||
- riffdec: Add sanity checks for the sample rate
|
||||
- mvi: Add sanity checking for the audio frame size
|
||||
- xwma: Avoid division by zero
|
||||
- avidec: Make sure a packet is large enough before reading its data
|
||||
- vqf: Make sure the bitrate is in the valid range
|
||||
- vqf: Make sure sample_rate is set to a valid value
|
||||
- vc1dec: Undo mpegvideo initialization if unable to allocate tables
|
||||
- vc1dec: Fix leaks in ff_vc1_decode_init_alloc_tables on errors
|
||||
- wnv1: Make sure the input packet is large enough
|
||||
- dca: Validate the lfe parameter
|
||||
- rl2: Avoid a division by zero
|
||||
- wtv: Add more sanity checks for a length read from the file
|
||||
- segafilm: Validate the number of audio channels
|
||||
- qpeg: Add checks for running out of rows in qpeg_decode_inter
|
||||
- mpegaudiodec: Validate that the number of channels fits at the given offset
|
||||
- asv1: Verify the amount of extradata
|
||||
- idroqdec: Make sure a video stream has been allocated before returning packets
|
||||
- rv10: Validate the dimensions set from the container
|
||||
- xmv: Add more sanity checks for parameters read from the bitstream
|
||||
- ffv1: Make sure at least one slice context is initialized
|
||||
- truemotion2: Use av_freep properly in an error path
|
||||
- eacmv: Make sure a reference frame exists before referencing it
|
||||
- mpeg4videodec: Check the width/height in mpeg4_decode_sprite_trajectory
|
||||
- ivi_common: Make sure color planes have been initialized
|
||||
- oggparseogm: Convert to use bytestream2
|
||||
- rv34: Check the return value from ff_rv34_decode_init
|
||||
- matroskadec: Verify realaudio codec parameters
|
||||
- mace: Make sure that the channel count is set to a valid value
|
||||
- svq3: Check for any negative return value from ff_h264_check_intra_pred_mode
|
||||
- vp3: Check the framerate for validity
|
||||
- cavsdec: Make sure a sequence header has been decoded before decoding pictures
|
||||
- sierravmd: Do sanity checking of frame sizes
|
||||
- omadec: Properly check lengths before incrementing the position
|
||||
- mpc8: Make sure the first stream exists before parsing the seek table
|
||||
- mpc8: Check the seek table size parsed from the bitstream
|
||||
- zmbvdec: Check the buffer size for uncompressed data
|
||||
- ape: Don't allow the seektable to be omitted
|
||||
- shorten: Break out of loop looking for fmt chunk if none is found
|
||||
- shorten: Use a checked bytestream reader for the wave header
|
||||
- smacker: Make sure we don't fill in huffman codes out of range
|
||||
- smacker: Avoid integer overflow when allocating packets
|
||||
- smacker: Don't return packets in unallocated streams
|
||||
- dsicin: Add some basic sanity checks for fields read from the file
|
||||
- roqvideodec: check dimensions validity
|
||||
- qdm2: check array index before use, fix out of array accesses
|
||||
- alsdec: check block length
|
||||
|
||||
|
||||
version 0.10.10
|
||||
|
||||
- x86: fft: Remove 3DNow! optimizations, they break FATE
|
||||
- x86: ac3dsp: Drop mmx variant of ac3_max_msb_abs_int16
|
||||
- aac: Check init_get_bits return value
|
||||
- aac: return meaningful errors
|
||||
- dsicinav: K&R formatting cosmetics
|
||||
- mov: Seek back if overreading an individual atom
|
||||
- vcr1: add sanity checks
|
||||
- pictordec: pass correct context to avpriv_request_sample
|
||||
- dsicinav: Clip the source size to the expected maximum
|
||||
- alsdec: Clean up error paths
|
||||
- ogg: Fix potential infinite discard loop
|
||||
- nuv: check rtjpeg_decode_frame_yuv420 return value
|
||||
- nuv: Reset the frame on resize
|
||||
- nuv: Use av_fast_realloc
|
||||
- nuv: return meaningful error codes.
|
||||
- nuv: Pad the lzo outbuf
|
||||
- nuv: Do not ignore lzo decompression failures
|
||||
- oma: correctly mark and decrypt partial packets
|
||||
- oma: check geob tag boundary
|
||||
- oma: refactor seek function
|
||||
- 8bps: Bound-check the input buffer
|
||||
- rtmp: Do not misuse memcmp
|
||||
- rtmp: rename data_size to size
|
||||
- lavc: set the default rc_initial_buffer_occupancy
|
||||
- 4xm: Reject not a multiple of 16 dimension
|
||||
- 4xm: do not overread the prestream buffer
|
||||
- 4xm: validate the buffer size before parsing it
|
||||
- indeo: Do not reference mismatched tiles
|
||||
- indeo: Sanitize ff_ivi_init_planes fail paths
|
||||
- indeo: Bound-check before applying motion compensation
|
||||
- indeo: Bound-check before applying transform
|
||||
- indeo: reject negative array indexes
|
||||
- indeo: Cosmetic formatting
|
||||
- indeo: Refactor ff_ivi_init_tiles and ivi_decode_blocks
|
||||
- indeo: Refactor ff_ivi_dec_huff_desc
|
||||
- lavf: fix the comparison in an overflow check
|
||||
- dv: Add a guard to not overread the ppcm array
|
||||
- mpegvideo: Avoid 32-bit wrapping of linesize multiplications
|
||||
- mjpegb: Detect changing number of planes in interlaced video
|
||||
- matroskadec: Check that .lang was allocated and set before reading it
|
||||
- ape demuxer: check for EOF in potentially long loops
|
||||
- lavf: avoid integer overflow when estimating bitrate
|
||||
- pictordec: break out of both decoding loops when y drops below 0
|
||||
- ac3: Return proper error codes
|
||||
- ac3: Clean up the error paths
|
||||
- ac3: Do not clash with normal AVERROR
|
||||
- dxa: Make sure the reference frame exists
|
||||
- h261: check the mtype index
|
||||
- segafilm: Error out on impossible packet size
|
||||
- ogg: Always alloc the private context in vorbis_header
|
||||
- vc1: check mb_height validity.
|
||||
- vc1: check the source buffer in vc1_mc functions
|
||||
- bink: Bound check the quantization matrix.
|
||||
- xl: Make sure the width is valid
|
||||
- alsdec: Fix the clipping range
|
||||
- dsicinav: Bound-check the source buffer when needed
|
||||
- mov: Do not allow updating the time scale after it has been set
|
||||
- ac3dec: Don't consume more data than the actual input packet size
|
||||
- indeo: Reject impossible FRAMETYPE_NULL
|
||||
- indeo5: return proper error codes
|
||||
- indeo4: Validate scantable dimension
|
||||
- indeo4: Check the quantization matrix index
|
||||
- indeo4: Do not access missing reference MV
|
||||
- adpcm: Unbreak ima-dk4
|
||||
- ac3dec: validate channel output mode against channel count
|
||||
- dca: Respect the current limits in the downmixing capabilities
|
||||
- dca: Error out on missing DSYNC
|
||||
- pcm: always use codec->id instead of codec_id
|
||||
- mlpdec: Do not set invalid context in read_restart_header
|
||||
- pcx: Do not overread source buffer in pcx_rle_decode
|
||||
- wmavoice: conceal clearly corrupted blocks
|
||||
- iff: Do not read over the source buffer
|
||||
- qdm2: Conceal broken samples
|
||||
- qdm2: refactor joined stereo support
|
||||
- adpcm: Write the correct number of samples for ima-dk4
|
||||
- imc: Catch a division by zero
|
||||
- atrac3: Error on impossible encoding/channel combinations
|
||||
- atrac3: set the getbits context the right buffer_end
|
||||
- atrac3: fix error handling
|
||||
- qdm2: check and reset dithering index per channel
|
||||
- westwood_vqa: do not free extradata on error in read_header
|
||||
- vqavideo: check the version
|
||||
- rmdec: Use the AVIOContext given as parameter in rm_read_metadata()
|
||||
- avio: Handle AVERROR_EOF in the same way as the return value 0
|
||||
- wtv: Mark attachment with a negative stream id
|
||||
- avidec: Let the inner dv demuxer take care of discarding
|
||||
- swfdec: do better validation of tag length
|
||||
|
||||
|
||||
version 0.10.8
|
||||
- kmvc: Clip pixel position to valid range
|
||||
- kmvc: use fixed sized arrays in the context
|
||||
|
||||
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 0.10.9
|
||||
PROJECT_NUMBER = 0.10.15
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify an logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
+5
-3
@@ -56,7 +56,7 @@
|
||||
struct SwsContext *sws_opts;
|
||||
AVDictionary *format_opts, *codec_opts;
|
||||
|
||||
const int this_year = 2013;
|
||||
const int this_year = 2014;
|
||||
|
||||
static FILE *report_file;
|
||||
|
||||
@@ -423,7 +423,10 @@ int opt_default(const char *opt, const char *arg)
|
||||
const AVOption *oc, *of, *os;
|
||||
char opt_stripped[128];
|
||||
const char *p;
|
||||
const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(), *sc;
|
||||
const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
|
||||
#if CONFIG_SWSCALE
|
||||
const AVClass *sc = sws_get_class();
|
||||
#endif
|
||||
|
||||
if (!(p = strchr(opt, ':')))
|
||||
p = opt + strlen(opt);
|
||||
@@ -438,7 +441,6 @@ int opt_default(const char *opt, const char *arg)
|
||||
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)))
|
||||
av_dict_set(&format_opts, opt, arg, FLAGS(of));
|
||||
#if CONFIG_SWSCALE
|
||||
sc = sws_get_class();
|
||||
if ((os = av_opt_find(&sc, opt, NULL, 0,
|
||||
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
|
||||
// XXX we only support sws_flags, not arbitrary sws options
|
||||
|
||||
@@ -54,6 +54,8 @@ if test "$E1" != 0 || test "$E2" = 0; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
|
||||
|
||||
show_help(){
|
||||
cat <<EOF
|
||||
Usage: configure [options]
|
||||
@@ -688,6 +690,13 @@ check_ld(){
|
||||
check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs
|
||||
}
|
||||
|
||||
print_include(){
|
||||
hdr=$1
|
||||
test "${hdr%.h}" = "${hdr}" &&
|
||||
echo "#include $hdr" ||
|
||||
echo "#include <$hdr>"
|
||||
}
|
||||
|
||||
check_cppflags(){
|
||||
log check_cppflags "$@"
|
||||
set -- $($filter_cppflags "$@")
|
||||
@@ -765,7 +774,7 @@ check_func_headers(){
|
||||
shift 2
|
||||
{
|
||||
for hdr in $headers; do
|
||||
echo "#include <$hdr>"
|
||||
print_include $hdr
|
||||
done
|
||||
for func in $funcs; do
|
||||
echo "long check_$func(void) { return (long) $func; }"
|
||||
@@ -3134,7 +3143,7 @@ enabled libdirac && require_pkg_config dirac \
|
||||
"libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h" \
|
||||
"dirac_decoder_init dirac_encoder_init"
|
||||
enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
|
||||
enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
|
||||
enabled libfreetype && require_pkg_config freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
|
||||
enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
|
||||
enabled libmodplug && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
|
||||
enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
|
||||
@@ -3367,6 +3376,8 @@ elif enabled clang; then
|
||||
check_cflags -mllvm -stack-alignment=16
|
||||
check_cflags -Qunused-arguments
|
||||
check_cflags -Werror=return-type
|
||||
check_cflags -Werror=implicit-function-declaration
|
||||
check_cflags -Werror=missing-prototypes
|
||||
elif enabled armcc; then
|
||||
# 2523: use of inline assembler is deprecated
|
||||
add_cflags -W${armcc_opt},--diag_suppress=2523
|
||||
|
||||
+4
-3
@@ -51,14 +51,15 @@ The toolchain provided with Xcode is sufficient to build the basic
|
||||
unacelerated code.
|
||||
|
||||
Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
|
||||
@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
|
||||
assembler functions. Just download the Perl script and put it somewhere
|
||||
@url{https://github.com/FFmpeg/gas-preprocessor} or
|
||||
@url{https://github.com/yuvi/gas-preprocessor} to build the optimized
|
||||
assembler functions. Put the Perl script somewhere
|
||||
in your PATH, FFmpeg's configure will pick it up automatically.
|
||||
|
||||
Mac OS X on amd64 and x86 requires @command{yasm} to build most of the
|
||||
optimized assembler functions. @uref{http://www.finkproject.org/, Fink},
|
||||
@uref{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix},
|
||||
@uref{http://mxcl.github.com/homebrew/, Homebrew}
|
||||
@uref{https://mxcl.github.com/homebrew/, Homebrew}
|
||||
or @uref{http://www.macports.org, MacPorts} can easily provide it.
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@ data transferred over RDT).
|
||||
|
||||
The muxer can be used to send a stream using RTSP ANNOUNCE to a server
|
||||
supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's
|
||||
@uref{http://github.com/revmischa/rtsp-server, RTSP server}).
|
||||
@uref{https://github.com/revmischa/rtsp-server, RTSP server}).
|
||||
|
||||
The required syntax for a RTSP url is:
|
||||
@example
|
||||
|
||||
@@ -4057,8 +4057,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
|
||||
if (p) p++;
|
||||
}
|
||||
video_enc->rc_override_count = i;
|
||||
if (!video_enc->rc_initial_buffer_occupancy)
|
||||
video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size * 3 / 4;
|
||||
video_enc->intra_dc_precision = intra_dc_precision - 8;
|
||||
|
||||
if (do_psnr)
|
||||
@@ -4698,7 +4696,8 @@ static int opt_target(OptionsContext *o, const char *opt, const char *arg)
|
||||
for (j = 0; j < nb_input_files; j++) {
|
||||
for (i = 0; i < input_files[j].nb_streams; i++) {
|
||||
AVCodecContext *c = input_files[j].ctx->streams[i]->codec;
|
||||
if (c->codec_type != AVMEDIA_TYPE_VIDEO)
|
||||
if (c->codec_type != AVMEDIA_TYPE_VIDEO ||
|
||||
!c->time_base.num)
|
||||
continue;
|
||||
fr = c->time_base.den * 1000 / c->time_base.num;
|
||||
if (fr == 25000) {
|
||||
|
||||
@@ -1611,7 +1611,7 @@ static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic)
|
||||
|
||||
if (pic->data[0] == NULL) {
|
||||
pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
|
||||
return codec->get_buffer(codec, pic);
|
||||
return input_get_buffer(codec, pic);
|
||||
}
|
||||
|
||||
if ((codec->width != ref->video->w) || (codec->height != ref->video->h) ||
|
||||
|
||||
+27
-9
@@ -403,6 +403,8 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length){
|
||||
unsigned int bitstream_size, bytestream_size, wordstream_size, extra, bytestream_offset, wordstream_offset;
|
||||
|
||||
if(f->version>1){
|
||||
if (length < 20)
|
||||
return AVERROR_INVALIDDATA;
|
||||
extra=20;
|
||||
if (length < extra)
|
||||
return -1;
|
||||
@@ -560,7 +562,10 @@ static int decode_i_mb(FourXContext *f){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const buf, int buf_size){
|
||||
static const uint8_t *read_huffman_tables(FourXContext *f,
|
||||
const uint8_t * const buf,
|
||||
int buf_size)
|
||||
{
|
||||
int frequency[512];
|
||||
uint8_t flag[512];
|
||||
int up[512];
|
||||
@@ -581,6 +586,9 @@ static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const
|
||||
|
||||
if (start <= end && ptr_end - ptr < end - start + 1 + 1)
|
||||
return NULL;
|
||||
if (end < start || buf_size < 0)
|
||||
return NULL;
|
||||
|
||||
for(i=start; i<=end; i++){
|
||||
frequency[i]= *ptr++;
|
||||
}
|
||||
@@ -767,25 +775,35 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
AVFrame *p, temp;
|
||||
int i, frame_4cc, frame_size;
|
||||
|
||||
if (buf_size < 12)
|
||||
if (buf_size < 20)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (avctx->width % 16 || avctx->height % 16) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Dimensions non-multiple of 16 are invalid.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
frame_4cc= AV_RL32(buf);
|
||||
if(buf_size != AV_RL32(buf+4)+8 || buf_size < 20){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, AV_RL32(buf+4));
|
||||
}
|
||||
|
||||
if (buf_size < AV_RL32(buf + 4) + 8) {
|
||||
av_log(f->avctx, AV_LOG_ERROR,
|
||||
"size mismatch %d %d\n", buf_size, AV_RL32(buf + 4));
|
||||
}
|
||||
|
||||
frame_4cc = AV_RL32(buf);
|
||||
|
||||
if(frame_4cc == AV_RL32("cfrm")){
|
||||
int free_index=-1;
|
||||
const int data_size= buf_size - 20;
|
||||
const int id= AV_RL32(buf+12);
|
||||
const int whole_size= AV_RL32(buf+16);
|
||||
int id, whole_size;
|
||||
const int data_size = buf_size - 20;
|
||||
CFrameBuffer *cfrm;
|
||||
|
||||
id = AV_RL32(buf + 12);
|
||||
whole_size = AV_RL32(buf + 16);
|
||||
|
||||
if (data_size < 0 || whole_size < 0){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "sizes invalid\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for(i=0; i<CFRAME_BUFFER_COUNT; i++){
|
||||
if(f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
|
||||
av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n", f->cfrm[i].id);
|
||||
|
||||
+7
-3
@@ -69,7 +69,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
unsigned char *pixptr, *pixptr_end;
|
||||
unsigned int height = avctx->height; // Real image height
|
||||
unsigned int dlen, p, row;
|
||||
const unsigned char *lp, *dp;
|
||||
const unsigned char *lp, *dp, *ep;
|
||||
unsigned char count;
|
||||
unsigned int planes = c->planes;
|
||||
unsigned char *planemap = c->planemap;
|
||||
@@ -84,6 +84,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
return -1;
|
||||
}
|
||||
|
||||
ep = encoded + buf_size;
|
||||
|
||||
/* Set data pointer after line lengths */
|
||||
dp = encoded + planes * (height << 1);
|
||||
|
||||
@@ -95,16 +97,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
for(row = 0; row < height; row++) {
|
||||
pixptr = c->pic.data[0] + row * c->pic.linesize[0] + planemap[p];
|
||||
pixptr_end = pixptr + c->pic.linesize[0];
|
||||
if (ep - lp < row * 2 + 2)
|
||||
return AVERROR_INVALIDDATA;
|
||||
dlen = av_be2ne16(*(const unsigned short *)(lp+row*2));
|
||||
/* Decode a row of this plane */
|
||||
while(dlen > 0) {
|
||||
if(dp + 1 >= buf+buf_size) return -1;
|
||||
if(ep - dp <= 1) return -1;
|
||||
if ((count = *dp++) <= 127) {
|
||||
count++;
|
||||
dlen -= count + 1;
|
||||
if (pixptr + count * planes > pixptr_end)
|
||||
break;
|
||||
if(dp + count > buf+buf_size) return -1;
|
||||
if(ep - dp < count) return -1;
|
||||
while(count--) {
|
||||
*pixptr = *dp++;
|
||||
pixptr += planes;
|
||||
|
||||
+2
-1
@@ -38,6 +38,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
|
||||
/** decoder context */
|
||||
typedef struct EightSvxContext {
|
||||
@@ -151,7 +152,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
esc->frame.nb_samples = (FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx) +avctx->channels-1) / avctx->channels;
|
||||
if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &esc->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+40
-32
@@ -362,7 +362,7 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
|
||||
comment_len = get_bits(gb, 8) * 8;
|
||||
if (get_bits_left(gb) < comment_len) {
|
||||
av_log(avctx, AV_LOG_ERROR, overread_err);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
skip_bits_long(gb, comment_len);
|
||||
return 0;
|
||||
@@ -383,7 +383,7 @@ static av_cold int set_default_channel_config(AVCodecContext *avctx,
|
||||
if (channel_config < 1 || channel_config > 7) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
|
||||
channel_config);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* default channel configurations:
|
||||
@@ -501,20 +501,21 @@ static int decode_audio_specific_config(AACContext *ac,
|
||||
int sync_extension)
|
||||
{
|
||||
GetBitContext gb;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
av_dlog(avctx, "extradata size %d\n", avctx->extradata_size);
|
||||
for (i = 0; i < avctx->extradata_size; i++)
|
||||
av_dlog(avctx, "%02x ", avctx->extradata[i]);
|
||||
av_dlog(avctx, "\n");
|
||||
|
||||
init_get_bits(&gb, data, bit_size);
|
||||
if ((ret = init_get_bits(&gb, data, bit_size)) < 0)
|
||||
return ret;
|
||||
|
||||
if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, sync_extension)) < 0)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (m4ac->sampling_index > 12) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
skip_bits_long(&gb, i);
|
||||
@@ -523,13 +524,14 @@ static int decode_audio_specific_config(AACContext *ac,
|
||||
case AOT_AAC_MAIN:
|
||||
case AOT_AAC_LC:
|
||||
case AOT_AAC_LTP:
|
||||
if (decode_ga_specific_config(ac, avctx, &gb, m4ac, m4ac->chan_config))
|
||||
return -1;
|
||||
if ((ret = decode_ga_specific_config(ac, avctx, &gb,
|
||||
m4ac, m4ac->chan_config)) < 0)
|
||||
return ret;
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
|
||||
m4ac->sbr == 1? "SBR+" : "", m4ac->object_type);
|
||||
return -1;
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
av_dlog(avctx, "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
|
||||
@@ -600,16 +602,17 @@ static void reset_predictor_group(PredictorState *ps, int group_num)
|
||||
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
AACContext *ac = avctx->priv_data;
|
||||
int ret;
|
||||
float output_scale_factor;
|
||||
|
||||
ac->avctx = avctx;
|
||||
ac->m4ac.sample_rate = avctx->sample_rate;
|
||||
|
||||
if (avctx->extradata_size > 0) {
|
||||
if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
|
||||
if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
|
||||
avctx->extradata,
|
||||
avctx->extradata_size*8, 1) < 0)
|
||||
return -1;
|
||||
avctx->extradata_size*8, 1)) < 0)
|
||||
return ret;
|
||||
} else {
|
||||
int sr, i;
|
||||
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
|
||||
@@ -702,7 +705,7 @@ static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
|
||||
|
||||
if (get_bits_left(gb) < 8 * count) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
skip_bits_long(gb, 8 * count);
|
||||
return 0;
|
||||
@@ -716,7 +719,7 @@ static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
|
||||
ics->predictor_reset_group = get_bits(gb, 5);
|
||||
if (ics->predictor_reset_group == 0 || ics->predictor_reset_group > 30) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->m4ac.sampling_index]); sfb++) {
|
||||
@@ -826,20 +829,20 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120],
|
||||
int sect_band_type = get_bits(gb, 4);
|
||||
if (sect_band_type == 12) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
do {
|
||||
sect_len_incr = get_bits(gb, bits);
|
||||
sect_end += sect_len_incr;
|
||||
if (get_bits_left(gb) < 0) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (sect_end > ics->max_sfb) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR,
|
||||
"Number of bands (%d) exceeds limit (%d).\n",
|
||||
sect_end, ics->max_sfb);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
} while (sect_len_incr == (1 << bits) - 1);
|
||||
for (; k < sect_end; k++) {
|
||||
@@ -911,7 +914,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
|
||||
if (offset[0] > 255U) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR,
|
||||
"%s (%d) out of range.\n", sf_str[0], offset[0]);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO];
|
||||
}
|
||||
@@ -969,7 +972,7 @@ static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
|
||||
tns->order[w][filt], tns_max_order);
|
||||
tns->order[w][filt] = 0;
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (tns->order[w][filt]) {
|
||||
tns->direction[w][filt] = get_bits1(gb);
|
||||
@@ -1252,7 +1255,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
|
||||
|
||||
if (b > 8) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
SKIP_BITS(re, gb, b + 1);
|
||||
@@ -1395,6 +1398,7 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce,
|
||||
IndividualChannelStream *ics = &sce->ics;
|
||||
float *out = sce->coeffs;
|
||||
int global_gain, pulse_present = 0;
|
||||
int ret;
|
||||
|
||||
/* This assignment is to silence a GCC warning about the variable being used
|
||||
* uninitialized when in fact it always is.
|
||||
@@ -1408,25 +1412,27 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0)
|
||||
return -1;
|
||||
if (decode_scalefactors(ac, sce->sf, gb, global_gain, ics, sce->band_type, sce->band_type_run_end) < 0)
|
||||
return -1;
|
||||
if ((ret = decode_band_types(ac, sce->band_type,
|
||||
sce->band_type_run_end, gb, ics)) < 0)
|
||||
return ret;
|
||||
if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics,
|
||||
sce->band_type, sce->band_type_run_end)) < 0)
|
||||
return ret;
|
||||
|
||||
pulse_present = 0;
|
||||
if (!scale_flag) {
|
||||
if ((pulse_present = get_bits1(gb))) {
|
||||
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (get_bits1(gb)) {
|
||||
av_log_missing_feature(ac->avctx, "SSR", 1);
|
||||
return -1;
|
||||
@@ -1434,7 +1440,7 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce,
|
||||
}
|
||||
|
||||
if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, &pulse, ics, sce->band_type) < 0)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (ac->m4ac.object_type == AOT_AAC_MAIN && !common_window)
|
||||
apply_prediction(ac, sce);
|
||||
@@ -1532,7 +1538,7 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
|
||||
ms_present = get_bits(gb, 2);
|
||||
if (ms_present == 3) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
} else if (ms_present)
|
||||
decode_mid_side_stereo(cpe, gb, ms_present);
|
||||
}
|
||||
@@ -2270,7 +2276,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
|
||||
if (samples) {
|
||||
/* get output buffer */
|
||||
ac->frame.nb_samples = samples;
|
||||
if ((err = avctx->get_buffer(avctx, &ac->frame)) < 0) {
|
||||
if ((err = ff_get_buffer(avctx, &ac->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return err;
|
||||
}
|
||||
@@ -2323,7 +2329,8 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
init_get_bits(&gb, buf, buf_size * 8);
|
||||
if ((err = init_get_bits(&gb, buf, buf_size * 8)) < 0)
|
||||
return err;
|
||||
|
||||
if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb)) < 0)
|
||||
return err;
|
||||
@@ -2568,7 +2575,8 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out,
|
||||
int muxlength, err;
|
||||
GetBitContext gb;
|
||||
|
||||
init_get_bits(&gb, avpkt->data, avpkt->size * 8);
|
||||
if ((err = init_get_bits(&gb, avpkt->data, avpkt->size * 8)) < 0)
|
||||
return err;
|
||||
|
||||
// check for LOAS sync word
|
||||
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
|
||||
|
||||
+1
-1
@@ -1415,7 +1415,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = s->num_blocks * 256;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "put_bits.h"
|
||||
#include "bytestream.h"
|
||||
@@ -556,7 +557,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
c->frame.nb_samples = nb_samples;
|
||||
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
|
||||
offset = AV_RB16(buf + 2) + 4;
|
||||
|
||||
/* if copyright string is within the provided data, validate it */
|
||||
if (bufsize >= offset && memcmp(buf + offset - 6, "(c)CRI", 6))
|
||||
if (bufsize >= offset && offset >= 6 && memcmp(buf + offset - 6, "(c)CRI", 6))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* check for encoding=3 block_size=18, sample_size=4 */
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "adx.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
@@ -140,7 +141,7 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
c->frame.nb_samples = num_blocks * BLOCK_SAMPLES;
|
||||
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+8
-1
@@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "bytestream.h"
|
||||
#include "unary.h"
|
||||
@@ -417,7 +418,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
alac->frame.nb_samples = outputsamples;
|
||||
if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &alac->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -615,6 +616,12 @@ static int alac_set_info(ALACContext *alac)
|
||||
|
||||
/* buffer size / 2 ? */
|
||||
alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
|
||||
if (!alac->setinfo_max_samples_per_frame ||
|
||||
alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t)) {
|
||||
av_log(alac->avctx, AV_LOG_ERROR, "max samples per frame invalid: %u\n",
|
||||
alac->setinfo_max_samples_per_frame);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
ptr++; /* compatible version */
|
||||
alac->setinfo_sample_size = *ptr++;
|
||||
alac->setinfo_rice_historymult = *ptr++;
|
||||
|
||||
+84
-63
@@ -30,6 +30,7 @@
|
||||
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "unary.h"
|
||||
#include "mpeg4audio.h"
|
||||
@@ -283,7 +284,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
GetBitContext gb;
|
||||
uint64_t ht_size;
|
||||
int i, config_offset;
|
||||
MPEG4AudioConfig m4ac;
|
||||
MPEG4AudioConfig m4ac = {0};
|
||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||
AVCodecContext *avctx = ctx->avctx;
|
||||
uint32_t als_id, header_size, trailer_size;
|
||||
@@ -294,12 +295,12 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
avctx->extradata_size * 8, 1);
|
||||
|
||||
if (config_offset < 0)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
skip_bits_long(&gb, config_offset);
|
||||
|
||||
if (get_bits_left(&gb) < (30 << 3))
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
// read the fixed items
|
||||
als_id = get_bits_long(&gb, 32);
|
||||
@@ -334,7 +335,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
|
||||
// check for ALSSpecificConfig struct
|
||||
if (als_id != MKBETAG('A','L','S','\0'))
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
ctx->cur_frame_length = sconf->frame_length;
|
||||
|
||||
@@ -349,7 +350,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
int chan_pos_bits = av_ceil_log2(avctx->channels);
|
||||
int bits_needed = avctx->channels * chan_pos_bits + 7;
|
||||
if (get_bits_left(&gb) < bits_needed)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (!(sconf->chan_pos = av_malloc(avctx->channels * sizeof(*sconf->chan_pos))))
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -367,7 +368,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
// read fixed header and trailer sizes,
|
||||
// if size = 0xFFFFFFFF then there is no data field!
|
||||
if (get_bits_left(&gb) < 64)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
header_size = get_bits_long(&gb, 32);
|
||||
trailer_size = get_bits_long(&gb, 32);
|
||||
@@ -381,10 +382,10 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
|
||||
// skip the header and trailer data
|
||||
if (get_bits_left(&gb) < ht_size)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (ht_size > INT32_MAX)
|
||||
return -1;
|
||||
return AVERROR_PATCHWELCOME;
|
||||
|
||||
skip_bits_long(&gb, ht_size);
|
||||
|
||||
@@ -392,7 +393,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
// initialize CRC calculation
|
||||
if (sconf->crc_enabled) {
|
||||
if (get_bits_left(&gb) < 32)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {
|
||||
ctx->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
|
||||
@@ -632,7 +633,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
if (bd->block_length & (sub_blocks - 1)) {
|
||||
av_log(avctx, AV_LOG_WARNING,
|
||||
"Block length is not evenly divisible by the number of subblocks.\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
sb_length = bd->block_length >> log2_sub_blocks;
|
||||
@@ -963,18 +964,18 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
*/
|
||||
static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
{
|
||||
int ret = 0;
|
||||
GetBitContext *gb = &ctx->gb;
|
||||
|
||||
*bd->shift_lsbs = 0;
|
||||
// read block type flag and read the samples accordingly
|
||||
if (get_bits1(gb)) {
|
||||
if (read_var_block_data(ctx, bd))
|
||||
return -1;
|
||||
ret = read_var_block_data(ctx, bd);
|
||||
} else {
|
||||
read_const_block_data(ctx, bd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -983,12 +984,16 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
{
|
||||
unsigned int smp;
|
||||
int ret = 0;
|
||||
|
||||
// read block type flag and read the samples accordingly
|
||||
if (*bd->const_block)
|
||||
decode_const_block_data(ctx, bd);
|
||||
else if (decode_var_block_data(ctx, bd))
|
||||
return -1;
|
||||
else
|
||||
ret = decode_var_block_data(ctx, bd); // always return 0
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
// TODO: read RLSLMS extension data
|
||||
|
||||
@@ -1006,14 +1011,10 @@ static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = read_block(ctx, bd);
|
||||
|
||||
if (ret)
|
||||
if ((ret = read_block(ctx, bd)) < 0)
|
||||
return ret;
|
||||
|
||||
ret = decode_block(ctx, bd);
|
||||
|
||||
return ret;
|
||||
return decode_block(ctx, bd);
|
||||
}
|
||||
|
||||
|
||||
@@ -1039,6 +1040,7 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
|
||||
unsigned int c, const unsigned int *div_blocks,
|
||||
unsigned int *js_blocks)
|
||||
{
|
||||
int ret;
|
||||
unsigned int b;
|
||||
ALSBlockData bd;
|
||||
|
||||
@@ -1061,10 +1063,10 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
|
||||
for (b = 0; b < ctx->num_blocks; b++) {
|
||||
bd.block_length = div_blocks[b];
|
||||
|
||||
if (read_decode_block(ctx, &bd)) {
|
||||
if ((ret = read_decode_block(ctx, &bd)) < 0) {
|
||||
// damaged block, write zero for the rest of the frame
|
||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd.raw_samples);
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
bd.raw_samples += div_blocks[b];
|
||||
bd.ra_block = 0;
|
||||
@@ -1083,6 +1085,7 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
|
||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||
unsigned int offset = 0;
|
||||
unsigned int b;
|
||||
int ret;
|
||||
ALSBlockData bd[2];
|
||||
|
||||
memset(bd, 0, 2 * sizeof(ALSBlockData));
|
||||
@@ -1126,12 +1129,10 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
|
||||
bd[0].raw_other = bd[1].raw_samples;
|
||||
bd[1].raw_other = bd[0].raw_samples;
|
||||
|
||||
if(read_decode_block(ctx, &bd[0]) || read_decode_block(ctx, &bd[1])) {
|
||||
// damaged block, write zero for the rest of the frame
|
||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd[0].raw_samples);
|
||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd[1].raw_samples);
|
||||
return -1;
|
||||
}
|
||||
if ((ret = read_decode_block(ctx, &bd[0])) < 0 ||
|
||||
(ret = read_decode_block(ctx, &bd[1])) < 0)
|
||||
goto fail;
|
||||
|
||||
|
||||
// reconstruct joint-stereo blocks
|
||||
if (bd[0].js_blocks) {
|
||||
@@ -1157,6 +1158,11 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
|
||||
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
// damaged block, write zero for the rest of the frame
|
||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd[0].raw_samples);
|
||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd[1].raw_samples);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int als_weighting(GetBitContext *gb, int k, int off)
|
||||
@@ -1180,7 +1186,7 @@ static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
|
||||
|
||||
if (current->master_channel >= channels) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid master channel!\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (current->master_channel != c) {
|
||||
@@ -1205,7 +1211,7 @@ static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
|
||||
|
||||
if (entries == channels) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Damaged channel data!\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
align_get_bits(gb);
|
||||
@@ -1237,7 +1243,7 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
||||
|
||||
if (dep == channels) {
|
||||
av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation!\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
bd->const_block = ctx->const_block + c;
|
||||
@@ -1310,6 +1316,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
||||
unsigned int js_blocks[2];
|
||||
|
||||
uint32_t bs_info = 0;
|
||||
int ret;
|
||||
|
||||
// skip the size of the ra unit if present in the frame
|
||||
if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)
|
||||
@@ -1340,13 +1347,15 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
||||
independent_bs = 1;
|
||||
|
||||
if (independent_bs) {
|
||||
if (decode_blocks_ind(ctx, ra_frame, c, div_blocks, js_blocks))
|
||||
return -1;
|
||||
|
||||
ret = decode_blocks_ind(ctx, ra_frame, c,
|
||||
div_blocks, js_blocks);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
independent_bs--;
|
||||
} else {
|
||||
if (decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks))
|
||||
return -1;
|
||||
ret = decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -1365,7 +1374,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
||||
for (c = 0; c < avctx->channels; c++)
|
||||
if (ctx->chan_data[c] < ctx->chan_data_buffer) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data!\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
memset(&bd, 0, sizeof(ALSBlockData));
|
||||
@@ -1378,6 +1387,11 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
||||
|
||||
for (b = 0; b < ctx->num_blocks; b++) {
|
||||
bd.block_length = div_blocks[b];
|
||||
if (bd.block_length <= 0) {
|
||||
av_log(ctx->avctx, AV_LOG_WARNING,
|
||||
"Invalid block length %d in channel data!\n", bd.block_length);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (c = 0; c < avctx->channels; c++) {
|
||||
bd.const_block = ctx->const_block + c;
|
||||
@@ -1397,11 +1411,12 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (c = 0; c < avctx->channels; c++)
|
||||
if (revert_channel_correlation(ctx, &bd, ctx->chan_data,
|
||||
reverted_channels, offset, c))
|
||||
return -1;
|
||||
|
||||
for (c = 0; c < avctx->channels; c++) {
|
||||
ret = revert_channel_correlation(ctx, &bd, ctx->chan_data,
|
||||
reverted_channels, offset, c);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
for (c = 0; c < avctx->channels; c++) {
|
||||
bd.const_block = ctx->const_block + c;
|
||||
bd.shift_lsbs = ctx->shift_lsbs + c;
|
||||
@@ -1470,7 +1485,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
|
||||
|
||||
/* get output buffer */
|
||||
ctx->frame.nb_samples = ctx->cur_frame_length;
|
||||
if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -1598,29 +1613,30 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
unsigned int c;
|
||||
unsigned int channel_size;
|
||||
int num_buffers;
|
||||
int num_buffers, ret;
|
||||
ALSDecContext *ctx = avctx->priv_data;
|
||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||
ctx->avctx = avctx;
|
||||
|
||||
if (!avctx->extradata) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Missing required ALS extradata.\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (read_specific_config(ctx)) {
|
||||
if ((ret = read_specific_config(ctx)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Reading ALSSpecificConfig failed.\n");
|
||||
decode_end(avctx);
|
||||
return -1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (check_specific_config(ctx)) {
|
||||
decode_end(avctx);
|
||||
return -1;
|
||||
if ((ret = check_specific_config(ctx)) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (sconf->bgmc)
|
||||
ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status);
|
||||
if (sconf->bgmc) {
|
||||
ret = ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (sconf->floating) {
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||
@@ -1656,7 +1672,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
!ctx->quant_cof_buffer || !ctx->lpc_cof_buffer ||
|
||||
!ctx->lpc_cof_reversed_buffer) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// assign quantized parcor coefficient buffers
|
||||
@@ -1681,8 +1698,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
!ctx->use_ltp || !ctx->ltp_lag ||
|
||||
!ctx->ltp_gain || !ctx->ltp_gain_buffer) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||
decode_end(avctx);
|
||||
return AVERROR(ENOMEM);
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (c = 0; c < num_buffers; c++)
|
||||
@@ -1699,8 +1716,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
|
||||
if (!ctx->chan_data_buffer || !ctx->chan_data || !ctx->reverted_channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||
decode_end(avctx);
|
||||
return AVERROR(ENOMEM);
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (c = 0; c < num_buffers; c++)
|
||||
@@ -1721,8 +1738,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
// allocate previous raw sample buffer
|
||||
if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||
decode_end(avctx);
|
||||
return AVERROR(ENOMEM);
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// assign raw samples buffers
|
||||
@@ -1739,8 +1756,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
av_get_bytes_per_sample(avctx->sample_fmt));
|
||||
if (!ctx->crc_buffer) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||
decode_end(avctx);
|
||||
return AVERROR(ENOMEM);
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1750,6 +1767,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
avctx->coded_frame = &ctx->frame;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
decode_end(avctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "celp_math.h"
|
||||
@@ -944,7 +945,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
p->avframe.nb_samples = AMR_BLOCK_SIZE;
|
||||
if ((ret = avctx->get_buffer(avctx, &p->avframe)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &p->avframe)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "libavutil/lfg.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "lsp.h"
|
||||
#include "celp_math.h"
|
||||
@@ -1087,7 +1088,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k;
|
||||
if ((ret = avctx->get_buffer(avctx, &ctx->avframe)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &ctx->avframe)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "libavutil/lfg.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "cga_data.h"
|
||||
|
||||
#define ATTR_BOLD 0x01 /**< Bold/Bright-foreground (mode 1) */
|
||||
@@ -222,7 +223,7 @@ static int execute_code(AVCodecContext * avctx, int c)
|
||||
if (s->frame.data[0])
|
||||
avctx->release_buffer(avctx, &s->frame);
|
||||
avcodec_set_dimensions(avctx, width, height);
|
||||
ret = avctx->get_buffer(avctx, &s->frame);
|
||||
ret = ff_get_buffer(avctx, &s->frame);
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
|
||||
+3
-4
@@ -22,6 +22,7 @@
|
||||
|
||||
#define BITSTREAM_READER_LE
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "dsputil.h"
|
||||
#include "get_bits.h"
|
||||
#include "bytestream.h"
|
||||
@@ -822,7 +823,6 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int16_t *samples;
|
||||
int i, ret;
|
||||
int blockstodecode;
|
||||
int bytes_used = 0;
|
||||
|
||||
/* this should never be negative, but bad things will happen if it is, so
|
||||
check it just to make sure. */
|
||||
@@ -877,7 +877,6 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
bytes_used = buf_size;
|
||||
}
|
||||
|
||||
if (!s->data) {
|
||||
@@ -889,7 +888,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = blockstodecode;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -920,7 +919,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
||||
*got_frame_ptr = 1;
|
||||
*(AVFrame *)data = s->frame;
|
||||
|
||||
return bytes_used;
|
||||
return (s->samples == 0) ? buf_size : 0;
|
||||
}
|
||||
|
||||
static void ape_flush(AVCodecContext *avctx)
|
||||
|
||||
@@ -132,6 +132,13 @@ T ldr \rt, [\rn]
|
||||
T add \rn, \rn, \rm
|
||||
.endm
|
||||
|
||||
.macro ldrc_pre cc, rt, rn, rm:vararg
|
||||
A ldr\cc \rt, [\rn, \rm]!
|
||||
T itt \cc
|
||||
T add\cc \rn, \rn, \rm
|
||||
T ldr\cc \rt, [\rn]
|
||||
.endm
|
||||
|
||||
.macro ldrd_reg rt, rt2, rn, rm
|
||||
A ldrd \rt, \rt2, [\rn, \rm]
|
||||
T add \rt, \rn, \rm
|
||||
|
||||
@@ -146,10 +146,11 @@ function ff_put_pixels8_y2_armv6, export=1
|
||||
eor r7, r5, r7
|
||||
uadd8 r10, r10, r6
|
||||
and r7, r7, r12
|
||||
ldr_pre r6, r1, r2
|
||||
ldrc_pre ne, r6, r1, r2
|
||||
uadd8 r11, r11, r7
|
||||
strd_post r8, r9, r0, r2
|
||||
ldr r7, [r1, #4]
|
||||
it ne
|
||||
ldrne r7, [r1, #4]
|
||||
strd_post r10, r11, r0, r2
|
||||
bne 1b
|
||||
|
||||
@@ -198,9 +199,10 @@ function ff_put_pixels8_y2_no_rnd_armv6, export=1
|
||||
uhadd8 r9, r5, r7
|
||||
ldr r5, [r1, #4]
|
||||
uhadd8 r12, r4, r6
|
||||
ldr_pre r6, r1, r2
|
||||
ldrc_pre ne, r6, r1, r2
|
||||
uhadd8 r14, r5, r7
|
||||
ldr r7, [r1, #4]
|
||||
it ne
|
||||
ldrne r7, [r1, #4]
|
||||
stm r0, {r8,r9}
|
||||
add r0, r0, r2
|
||||
stm r0, {r12,r14}
|
||||
|
||||
@@ -89,7 +89,7 @@ static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const i
|
||||
c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
|
||||
c->h264_idct_add16 = ff_h264_idct_add16_neon;
|
||||
c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
|
||||
if (chroma_format_idc == 1)
|
||||
if (chroma_format_idc <= 1)
|
||||
c->h264_idct_add8 = ff_h264_idct_add8_neon;
|
||||
c->h264_idct8_add = ff_h264_idct8_add_neon;
|
||||
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
|
||||
|
||||
@@ -66,10 +66,10 @@ function ff_scalarproduct_int16_neon, export=1
|
||||
|
||||
3: vpadd.s32 d16, d0, d1
|
||||
vpadd.s32 d17, d2, d3
|
||||
vpadd.s32 d10, d4, d5
|
||||
vpadd.s32 d11, d6, d7
|
||||
vpadd.s32 d18, d4, d5
|
||||
vpadd.s32 d19, d6, d7
|
||||
vpadd.s32 d0, d16, d17
|
||||
vpadd.s32 d1, d10, d11
|
||||
vpadd.s32 d1, d18, d19
|
||||
vpadd.s32 d2, d0, d1
|
||||
vpaddl.s32 d3, d2
|
||||
vmov.32 r0, d3[0]
|
||||
@@ -106,10 +106,10 @@ function ff_scalarproduct_and_madd_int16_neon, export=1
|
||||
|
||||
vpadd.s32 d16, d0, d1
|
||||
vpadd.s32 d17, d2, d3
|
||||
vpadd.s32 d10, d4, d5
|
||||
vpadd.s32 d11, d6, d7
|
||||
vpadd.s32 d18, d4, d5
|
||||
vpadd.s32 d19, d6, d7
|
||||
vpadd.s32 d0, d16, d17
|
||||
vpadd.s32 d1, d10, d11
|
||||
vpadd.s32 d1, d18, d19
|
||||
vpadd.s32 d2, d0, d1
|
||||
vpaddl.s32 d3, d2
|
||||
vmov.32 r0, d3[0]
|
||||
|
||||
@@ -535,6 +535,11 @@ static av_cold int decode_init(AVCodecContext *avctx){
|
||||
int i;
|
||||
const int scale= avctx->codec_id == CODEC_ID_ASV1 ? 1 : 2;
|
||||
|
||||
if (avctx->extradata_size < 1) {
|
||||
av_log(avctx, AV_LOG_ERROR, "No extradata provided\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
common_init(avctx);
|
||||
init_vlcs(a);
|
||||
ff_init_scantable(a->dsp.idct_permutation, &a->scantable, scantab);
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
@@ -291,7 +292,7 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
q->frame.nb_samples = AT1_SU_SAMPLES;
|
||||
if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-1
@@ -37,6 +37,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "bytestream.h"
|
||||
@@ -852,7 +853,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
q->frame.nb_samples = SAMPLES_PER_FRAME;
|
||||
if ((result = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
||||
if ((result = ff_get_buffer(avctx, &q->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#define BITSTREAM_READER_LE
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
@@ -340,7 +341,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = s->block_size / avctx->channels;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "bytestream.h"
|
||||
#include "libavutil/avassert.h"
|
||||
|
||||
@@ -274,7 +275,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
c->pic.reference = 1;
|
||||
if (avctx->get_buffer(avctx, &c->pic) < 0) {
|
||||
if (ff_get_buffer(avctx, &c->pic) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -339,7 +340,7 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
c->frame.nb_samples = total_blocks * 32;
|
||||
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -198,6 +198,16 @@ static av_always_inline int bytestream2_tell_p(PutByteContext *p)
|
||||
return (int)(p->buffer - p->buffer_start);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_size(GetByteContext *g)
|
||||
{
|
||||
return (int)(g->buffer_end - g->buffer_start);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_size_p(PutByteContext *p)
|
||||
{
|
||||
return (int)(p->buffer_end - p->buffer_start);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_seek(GetByteContext *g,
|
||||
int offset,
|
||||
int whence)
|
||||
@@ -323,6 +333,32 @@ static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p)
|
||||
return p->eof;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_copy_bufferu(PutByteContext *p,
|
||||
GetByteContext *g,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy(p->buffer, g->buffer, size);
|
||||
p->buffer += size;
|
||||
g->buffer += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p,
|
||||
GetByteContext *g,
|
||||
unsigned int size)
|
||||
{
|
||||
int size2;
|
||||
|
||||
if (p->eof)
|
||||
return 0;
|
||||
size = FFMIN(g->buffer_end - g->buffer, size);
|
||||
size2 = FFMIN(p->buffer_end - p->buffer, size);
|
||||
if (size2 != size)
|
||||
p->eof = 1;
|
||||
|
||||
return bytestream2_copy_bufferu(p, g, size2);
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b,
|
||||
uint8_t *dst,
|
||||
unsigned int size)
|
||||
|
||||
@@ -166,8 +166,8 @@ static inline int decode_residual_inter(AVSContext *h) {
|
||||
|
||||
/* get coded block pattern */
|
||||
int cbp= get_ue_golomb(&h->s.gb);
|
||||
if(cbp > 63U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal inter cbp\n");
|
||||
if(cbp > 63 || cbp < 0){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal inter cbp %d\n", cbp);
|
||||
return -1;
|
||||
}
|
||||
h->cbp = cbp_tab[cbp][1];
|
||||
@@ -226,7 +226,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code) {
|
||||
/* get coded block pattern */
|
||||
if(h->pic_type == AV_PICTURE_TYPE_I)
|
||||
cbp_code = get_ue_golomb(gb);
|
||||
if(cbp_code > 63U){
|
||||
if(cbp_code > 63 || cbp_code < 0 ){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal intra cbp\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -468,6 +468,11 @@ static int decode_pic(AVSContext *h) {
|
||||
int skip_count = -1;
|
||||
enum cavs_mb mb_type;
|
||||
|
||||
if (!h->top_qp) {
|
||||
av_log(h, AV_LOG_ERROR, "No sequence header decoded yet\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (!s->context_initialized) {
|
||||
s->avctx->idct_algo = FF_IDCT_CAVS;
|
||||
if (MPV_common_init(s) < 0)
|
||||
|
||||
+10
-8
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "bytestream.h"
|
||||
|
||||
/**
|
||||
@@ -268,7 +269,7 @@ static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
|
||||
static int cdg_decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size, AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
GetByteContext gb;
|
||||
int buf_size = avpkt->size;
|
||||
int ret;
|
||||
uint8_t command, inst;
|
||||
@@ -285,17 +286,19 @@ static int cdg_decode_frame(AVCodecContext *avctx,
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
bytestream2_init(&gb, avpkt->data, avpkt->size);
|
||||
|
||||
ret = avctx->reget_buffer(avctx, &cc->frame);
|
||||
if (ret) {
|
||||
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
command = bytestream_get_byte(&buf);
|
||||
inst = bytestream_get_byte(&buf);
|
||||
command = bytestream2_get_byte(&gb);
|
||||
inst = bytestream2_get_byte(&gb);
|
||||
inst &= CDG_MASK;
|
||||
buf += 2; /// skipping 2 unneeded bytes
|
||||
bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
|
||||
bytestream2_skip(&gb, 2);
|
||||
bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));
|
||||
|
||||
if ((command & CDG_MASK) == CDG_COMMAND) {
|
||||
switch (inst) {
|
||||
@@ -337,7 +340,7 @@ static int cdg_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
cdg_init_frame(&new_frame);
|
||||
ret = avctx->get_buffer(avctx, &new_frame);
|
||||
ret = ff_get_buffer(avctx, &new_frame);
|
||||
if (ret) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
@@ -354,11 +357,10 @@ static int cdg_decode_frame(AVCodecContext *avctx,
|
||||
*data_size = sizeof(AVFrame);
|
||||
} else {
|
||||
*data_size = 0;
|
||||
buf_size = 0;
|
||||
}
|
||||
|
||||
*(AVFrame *) data = cc->frame;
|
||||
return buf_size;
|
||||
return avpkt->size;
|
||||
}
|
||||
|
||||
static av_cold int cdg_decode_end(AVCodecContext *avctx)
|
||||
|
||||
+2
-1
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "libavutil/lfg.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "bytestream.h"
|
||||
@@ -991,7 +992,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data,
|
||||
/* get output buffer */
|
||||
if (q->discarded_packets >= 2) {
|
||||
q->frame.nb_samples = q->samples_per_channel;
|
||||
if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+7
-1
@@ -32,6 +32,7 @@
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/audioconvert.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
#include "get_bits.h"
|
||||
@@ -577,6 +578,11 @@ static int dca_parse_frame_header(DCAContext *s)
|
||||
s->lfe = get_bits(&s->gb, 2);
|
||||
s->predictor_history = get_bits(&s->gb, 1);
|
||||
|
||||
if (s->lfe > 2) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid LFE value: %d\n", s->lfe);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* TODO: check CRC */
|
||||
if (s->crc_present)
|
||||
s->header_crc = get_bits(&s->gb, 16);
|
||||
@@ -1890,7 +1896,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = 256 * (s->sample_blocks / 8);
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "bytestream.h"
|
||||
|
||||
#include "libavutil/imgutils.h"
|
||||
@@ -325,7 +326,7 @@ static int dfa_decode_frame(AVCodecContext *avctx,
|
||||
if (s->pic.data[0])
|
||||
avctx->release_buffer(avctx, &s->pic);
|
||||
|
||||
if ((ret = avctx->get_buffer(avctx, &s->pic))) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->pic))) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1332,8 +1332,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
|
||||
motion_y >>= s->chroma_y_shift;
|
||||
}
|
||||
|
||||
mx = motion_x & ~(-1 << s->mv_precision);
|
||||
my = motion_y & ~(-1 << s->mv_precision);
|
||||
mx = motion_x & ~(-1U << s->mv_precision);
|
||||
my = motion_y & ~(-1U << s->mv_precision);
|
||||
motion_x >>= s->mv_precision;
|
||||
motion_y >>= s->mv_precision;
|
||||
/* normalize subpel coordinates to epel */
|
||||
|
||||
@@ -220,7 +220,7 @@ static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
|
||||
|
||||
static int dnxhd_init_rc(DNXHDEncContext *ctx)
|
||||
{
|
||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);
|
||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*(ctx->m.avctx->qmax + 1)*sizeof(RCEntry), fail);
|
||||
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
|
||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
|
||||
|
||||
|
||||
+2
-1
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "bytestream.h"
|
||||
|
||||
typedef struct DPCMContext {
|
||||
@@ -216,7 +217,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = (out + s->channels - 1) / s->channels;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+66
-50
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "bytestream.h"
|
||||
#include "mathops.h"
|
||||
|
||||
@@ -108,27 +109,31 @@ static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cin_apply_delta_data(const unsigned char *src, unsigned char *dst, int size)
|
||||
static void cin_apply_delta_data(const unsigned char *src, unsigned char *dst,
|
||||
int size)
|
||||
{
|
||||
while (size--)
|
||||
*dst++ += *src++;
|
||||
}
|
||||
|
||||
static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
||||
static int cin_decode_huffman(const unsigned char *src, int src_size,
|
||||
unsigned char *dst, int dst_size)
|
||||
{
|
||||
int b, huff_code = 0;
|
||||
unsigned char huff_code_table[15];
|
||||
unsigned char *dst_cur = dst;
|
||||
unsigned char *dst_end = dst + dst_size;
|
||||
unsigned char *dst_cur = dst;
|
||||
unsigned char *dst_end = dst + dst_size;
|
||||
const unsigned char *src_end = src + src_size;
|
||||
|
||||
memcpy(huff_code_table, src, 15); src += 15; src_size -= 15;
|
||||
memcpy(huff_code_table, src, 15);
|
||||
src += 15;
|
||||
src_size -= 15;
|
||||
|
||||
while (src < src_end) {
|
||||
huff_code = *src++;
|
||||
if ((huff_code >> 4) == 15) {
|
||||
b = huff_code << 4;
|
||||
huff_code = *src++;
|
||||
b = huff_code << 4;
|
||||
huff_code = *src++;
|
||||
*dst_cur++ = b | (huff_code >> 4);
|
||||
} else
|
||||
*dst_cur++ = huff_code_table[huff_code >> 4];
|
||||
@@ -147,11 +152,12 @@ static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned c
|
||||
return dst_cur - dst;
|
||||
}
|
||||
|
||||
static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
||||
static int cin_decode_lzss(const unsigned char *src, int src_size,
|
||||
unsigned char *dst, int dst_size)
|
||||
{
|
||||
uint16_t cmd;
|
||||
int i, sz, offset, code;
|
||||
unsigned char *dst_end = dst + dst_size, *dst_start = dst;
|
||||
unsigned char *dst_end = dst + dst_size, *dst_start = dst;
|
||||
const unsigned char *src_end = src + src_size;
|
||||
|
||||
while (src < src_end && dst < dst_end) {
|
||||
@@ -160,13 +166,15 @@ static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char
|
||||
if (code & (1 << i)) {
|
||||
*dst++ = *src++;
|
||||
} else {
|
||||
cmd = AV_RL16(src); src += 2;
|
||||
cmd = AV_RL16(src);
|
||||
src += 2;
|
||||
offset = cmd >> 4;
|
||||
if ((int) (dst - dst_start) < offset + 1)
|
||||
if ((int)(dst - dst_start) < offset + 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
sz = (cmd & 0xF) + 2;
|
||||
/* don't use memcpy/memmove here as the decoding routine (ab)uses */
|
||||
/* buffer overlappings to repeat bytes in the destination */
|
||||
/* don't use memcpy/memmove here as the decoding routine
|
||||
* (ab)uses buffer overlappings to repeat bytes in the
|
||||
* destination */
|
||||
sz = FFMIN(sz, dst_end - dst);
|
||||
while (sz--) {
|
||||
*dst = *(dst - offset - 1);
|
||||
@@ -179,10 +187,11 @@ static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
||||
static void cin_decode_rle(const unsigned char *src, int src_size,
|
||||
unsigned char *dst, int dst_size)
|
||||
{
|
||||
int len, code;
|
||||
unsigned char *dst_end = dst + dst_size;
|
||||
unsigned char *dst_end = dst + dst_size;
|
||||
const unsigned char *src_end = src + src_size;
|
||||
|
||||
while (src < src_end && dst < dst_end) {
|
||||
@@ -205,15 +214,16 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size,
|
||||
AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
CinVideoContext *cin = avctx->priv_data;
|
||||
int i, y, palette_type, palette_colors_count, bitmap_frame_type, bitmap_frame_size, res = 0;
|
||||
int i, y, palette_type, palette_colors_count,
|
||||
bitmap_frame_type, bitmap_frame_size, res = 0;
|
||||
|
||||
palette_type = buf[0];
|
||||
palette_type = buf[0];
|
||||
palette_colors_count = AV_RL16(buf+1);
|
||||
bitmap_frame_type = buf[3];
|
||||
buf += 4;
|
||||
bitmap_frame_type = buf[3];
|
||||
buf += 4;
|
||||
|
||||
bitmap_frame_size = buf_size - 4;
|
||||
|
||||
@@ -224,46 +234,50 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
||||
if (palette_colors_count > 256)
|
||||
return AVERROR_INVALIDDATA;
|
||||
for (i = 0; i < palette_colors_count; ++i) {
|
||||
cin->palette[i] = 0xFF << 24 | bytestream_get_le24(&buf);
|
||||
cin->palette[i] = 0xFF << 24 | bytestream_get_le24(&buf);
|
||||
bitmap_frame_size -= 3;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < palette_colors_count; ++i) {
|
||||
cin->palette[buf[0]] = 0xFF << 24 | AV_RL24(buf+1);
|
||||
buf += 4;
|
||||
bitmap_frame_size -= 4;
|
||||
cin->palette[buf[0]] = 0xFF << 24 | AV_RL24(buf + 1);
|
||||
buf += 4;
|
||||
bitmap_frame_size -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* note: the decoding routines below assumes that surface.width = surface.pitch */
|
||||
bitmap_frame_size = FFMIN(cin->bitmap_size, bitmap_frame_size);
|
||||
|
||||
/* note: the decoding routines below assumes that
|
||||
* surface.width = surface.pitch */
|
||||
switch (bitmap_frame_type) {
|
||||
case 9:
|
||||
cin_decode_rle(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
case 34:
|
||||
cin_decode_rle(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
case 35:
|
||||
cin_decode_huffman(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
|
||||
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
case 36:
|
||||
bitmap_frame_size = cin_decode_huffman(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_INT_BMP],
|
||||
cin->bitmap_size);
|
||||
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
case 37:
|
||||
cin_decode_huffman(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
case 38:
|
||||
res = cin_decode_lzss(buf, bitmap_frame_size,
|
||||
@@ -279,24 +293,26 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
||||
if (res < 0)
|
||||
return res;
|
||||
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
}
|
||||
|
||||
cin->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
||||
if (avctx->reget_buffer(avctx, &cin->frame)) {
|
||||
av_log(cin->avctx, AV_LOG_ERROR, "delphinecinvideo: reget_buffer() failed to allocate a frame\n");
|
||||
return -1;
|
||||
if ((res = avctx->reget_buffer(avctx, &cin->frame)) < 0) {
|
||||
av_log(cin->avctx, AV_LOG_ERROR,
|
||||
"delphinecinvideo: reget_buffer() failed to allocate a frame\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
memcpy(cin->frame.data[1], cin->palette, sizeof(cin->palette));
|
||||
cin->frame.palette_has_changed = 1;
|
||||
for (y = 0; y < cin->avctx->height; ++y)
|
||||
memcpy(cin->frame.data[0] + (cin->avctx->height - 1 - y) * cin->frame.linesize[0],
|
||||
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
|
||||
cin->avctx->width);
|
||||
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
|
||||
cin->avctx->width);
|
||||
|
||||
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_table[CIN_PRE_BMP]);
|
||||
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP],
|
||||
cin->bitmap_table[CIN_PRE_BMP]);
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
*(AVFrame *)data = cin->frame;
|
||||
@@ -340,15 +356,15 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx)
|
||||
static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int *got_frame_ptr, AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
CinAudioContext *cin = avctx->priv_data;
|
||||
const uint8_t *buf = avpkt->data;
|
||||
CinAudioContext *cin = avctx->priv_data;
|
||||
const uint8_t *buf_end = buf + avpkt->size;
|
||||
int16_t *samples;
|
||||
int delta, ret;
|
||||
|
||||
/* get output buffer */
|
||||
cin->frame.nb_samples = avpkt->size - cin->initial_decode_frame;
|
||||
if ((ret = avctx->get_buffer(avctx, &cin->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &cin->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -357,13 +373,13 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
|
||||
delta = cin->delta;
|
||||
if (cin->initial_decode_frame) {
|
||||
cin->initial_decode_frame = 0;
|
||||
delta = sign_extend(AV_RL16(buf), 16);
|
||||
buf += 2;
|
||||
*samples++ = delta;
|
||||
delta = sign_extend(AV_RL16(buf), 16);
|
||||
buf += 2;
|
||||
*samples++ = delta;
|
||||
}
|
||||
while (buf < buf_end) {
|
||||
delta += cinaudio_delta16_table[*buf++];
|
||||
delta = av_clip_int16(delta);
|
||||
delta += cinaudio_delta16_table[*buf++];
|
||||
delta = av_clip_int16(delta);
|
||||
*samples++ = delta;
|
||||
}
|
||||
cin->delta = delta;
|
||||
|
||||
@@ -1912,7 +1912,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
|
||||
|
||||
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
|
||||
long i;
|
||||
for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
|
||||
for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
|
||||
long a = *(long*)(src+i);
|
||||
long b = *(long*)(dst+i);
|
||||
*(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
|
||||
@@ -1937,7 +1937,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
|
||||
}
|
||||
}else
|
||||
#endif
|
||||
for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
|
||||
for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
|
||||
long a = *(long*)(src1+i);
|
||||
long b = *(long*)(src2+i);
|
||||
*(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx)
|
||||
@@ -51,7 +52,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
}
|
||||
|
||||
pic->reference = 0;
|
||||
if ((ret = avctx->get_buffer(avctx, pic)) < 0)
|
||||
if ((ret = ff_get_buffer(avctx, pic)) < 0)
|
||||
return ret;
|
||||
|
||||
pic->pict_type = AV_PICTURE_TYPE_I;
|
||||
|
||||
+2
-2
@@ -112,8 +112,8 @@ static void cmv_decode_inter(CmvContext * s, const uint8_t *buf, const uint8_t *
|
||||
int yoffset = ((buf[i] >> 4)) - 7;
|
||||
if (s->last_frame.data[0])
|
||||
cmv_motcomp(s->frame.data[0], s->frame.linesize[0],
|
||||
s->last_frame.data[0], s->last_frame.linesize[0],
|
||||
x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
|
||||
s->last_frame.data[0], s->last_frame.linesize[0],
|
||||
x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
+23
-19
@@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bytestream.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "aandcttab.h"
|
||||
@@ -246,32 +247,34 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
const uint8_t *buf_end = buf+buf_size;
|
||||
MadContext *t = avctx->priv_data;
|
||||
GetByteContext gb;
|
||||
MpegEncContext *s = &t->s;
|
||||
int chunk_type;
|
||||
int inter;
|
||||
|
||||
if (buf_size < 17) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
|
||||
*data_size = 0;
|
||||
return -1;
|
||||
}
|
||||
bytestream2_init(&gb, buf, buf_size);
|
||||
|
||||
chunk_type = AV_RL32(&buf[0]);
|
||||
chunk_type = bytestream2_get_le32(&gb);
|
||||
inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);
|
||||
buf += 8;
|
||||
bytestream2_skip(&gb, 10);
|
||||
|
||||
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
|
||||
AV_RL16(&buf[6]), 1000, 1<<30);
|
||||
bytestream2_get_le16(&gb), 1000, 1<<30);
|
||||
|
||||
s->width = AV_RL16(&buf[8]);
|
||||
s->height = AV_RL16(&buf[10]);
|
||||
calc_intra_matrix(t, buf[13]);
|
||||
buf += 16;
|
||||
s->width = bytestream2_get_le16(&gb);
|
||||
s->height = bytestream2_get_le16(&gb);
|
||||
bytestream2_skip(&gb, 1);
|
||||
calc_intra_matrix(t, bytestream2_get_byte(&gb));
|
||||
bytestream2_skip(&gb, 2);
|
||||
|
||||
if (bytestream2_get_bytes_left(&gb) < 2) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Input data too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (avctx->width != s->width || avctx->height != s->height) {
|
||||
if((s->width * s->height)/2048*7 > buf_end-buf)
|
||||
if((s->width * s->height)/2048*7 > bytestream2_get_bytes_left(&gb))
|
||||
return -1;
|
||||
if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
|
||||
return -1;
|
||||
@@ -290,13 +293,14 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
}
|
||||
|
||||
av_fast_malloc(&t->bitstream_buf, &t->bitstream_buf_size, (buf_end-buf) + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
av_fast_malloc(&t->bitstream_buf, &t->bitstream_buf_size,
|
||||
bytestream2_get_bytes_left(&gb) + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!t->bitstream_buf)
|
||||
return AVERROR(ENOMEM);
|
||||
bswap16_buf(t->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
|
||||
memset((uint8_t*)t->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
init_get_bits(&s->gb, t->bitstream_buf, 8*(buf_end-buf));
|
||||
|
||||
bswap16_buf(t->bitstream_buf, (const uint16_t *)(buf + bytestream2_tell(&gb)),
|
||||
bytestream2_get_bytes_left(&gb) / 2);
|
||||
memset((uint8_t*)t->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
init_get_bits(&s->gb, t->bitstream_buf, 8*(bytestream2_get_bytes_left(&gb)));
|
||||
for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
|
||||
for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)
|
||||
if(decode_mb(t, inter) < 0)
|
||||
|
||||
@@ -921,6 +921,12 @@ void ff_er_frame_end(MpegEncContext *s)
|
||||
return;
|
||||
};
|
||||
|
||||
if (s->picture_structure == PICT_FRAME &&
|
||||
s->current_picture.f.linesize[0] != s->current_picture_ptr->f.linesize[0]) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->current_picture.f.motion_val[0] == NULL) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
|
||||
|
||||
|
||||
+44
-12
@@ -722,6 +722,10 @@ static av_cold int init_slice_contexts(FFV1Context *f){
|
||||
int i;
|
||||
|
||||
f->slice_count= f->num_h_slices * f->num_v_slices;
|
||||
if (f->slice_count <= 0) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "Invalid number of slices\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
for(i=0; i<f->slice_count; i++){
|
||||
FFV1Context *fs= av_mallocz(sizeof(*fs));
|
||||
@@ -1547,20 +1551,48 @@ static int read_header(FFV1Context *f){
|
||||
memset(state, 128, sizeof(state));
|
||||
|
||||
if(f->version < 2){
|
||||
f->version= get_symbol(c, state, 0);
|
||||
f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
|
||||
if(f->ac>1){
|
||||
for(i=1; i<256; i++){
|
||||
f->state_transition[i]= get_symbol(c, state, 1) + c->one_state[i];
|
||||
int chroma_h_shift, chroma_v_shift, colorspace, bits_per_raw_sample;
|
||||
int transparency;
|
||||
unsigned v = get_symbol(c, state, 0);
|
||||
if (v > 1) {
|
||||
av_log(f->avctx, AV_LOG_ERROR,
|
||||
"invalid version %d in version 1 header\n", v);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
f->version = v;
|
||||
|
||||
f->ac = f->avctx->coder_type = get_symbol(c, state, 0);
|
||||
|
||||
if (f->ac > 1) {
|
||||
for (i = 1; i < 256; i++)
|
||||
f->state_transition[i] =
|
||||
get_symbol(c, state, 1) + c->one_state[i];
|
||||
}
|
||||
|
||||
colorspace = get_symbol(c, state, 0); //YUV cs type
|
||||
bits_per_raw_sample = f->version > 0 ? get_symbol(c, state, 0) : f->avctx->bits_per_raw_sample;
|
||||
get_rac(c, state); //no chroma = false
|
||||
chroma_h_shift = get_symbol(c, state, 0);
|
||||
chroma_v_shift = get_symbol(c, state, 0);
|
||||
transparency = get_rac(c, state);
|
||||
|
||||
if (f->plane_count) {
|
||||
if (colorspace != f->colorspace ||
|
||||
bits_per_raw_sample != f->avctx->bits_per_raw_sample ||
|
||||
chroma_h_shift != f->chroma_h_shift ||
|
||||
chroma_v_shift != f->chroma_v_shift ||
|
||||
transparency != f->transparency) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "Invalid change of global parameters\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
f->colorspace= get_symbol(c, state, 0); //YUV cs type
|
||||
if(f->version>0)
|
||||
f->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
|
||||
get_rac(c, state); //no chroma = false
|
||||
f->chroma_h_shift= get_symbol(c, state, 0);
|
||||
f->chroma_v_shift= get_symbol(c, state, 0);
|
||||
f->transparency= get_rac(c, state);
|
||||
|
||||
f->colorspace = colorspace;
|
||||
f->avctx->bits_per_raw_sample = bits_per_raw_sample;
|
||||
f->chroma_h_shift = chroma_h_shift;
|
||||
f->chroma_v_shift = chroma_v_shift;
|
||||
f->transparency = transparency;
|
||||
|
||||
f->plane_count= 2 + f->transparency;
|
||||
}
|
||||
|
||||
|
||||
@@ -599,7 +599,7 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = s->blocksize;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -389,7 +389,9 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
||||
s->diff_start = get_bits(&gb, 8);
|
||||
s->diff_height = get_bits(&gb, 8);
|
||||
if (s->diff_start + s->diff_height > cur_blk_height) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Block parameters invalid\n");
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Block parameters invalid: %d + %d > %d\n",
|
||||
s->diff_start, s->diff_height, cur_blk_height);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
av_log(avctx, AV_LOG_DEBUG,
|
||||
|
||||
+7
-1
@@ -142,6 +142,11 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
const int planes = 3;
|
||||
enum PixelFormat pix_fmt;
|
||||
|
||||
if (buf_size < 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Packet is too short\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
header = AV_RL32(buf);
|
||||
version = header & 0xff;
|
||||
header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */
|
||||
@@ -180,7 +185,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
avctx->pix_fmt = pix_fmt;
|
||||
|
||||
switch(version) {
|
||||
switch (version) {
|
||||
case 0:
|
||||
default:
|
||||
/* Fraps v0 is a reordered YUV420 */
|
||||
@@ -219,6 +224,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
|
||||
case 1:
|
||||
/* Fraps v1 is an upside-down BGR24 */
|
||||
|
||||
if (avctx->reget_buffer(avctx, f)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||
return -1;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "g722.h"
|
||||
#include "libavutil/opt.h"
|
||||
@@ -96,7 +97,7 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
c->frame.nb_samples = avpkt->size * 2;
|
||||
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+1
-1
@@ -448,7 +448,7 @@ static int g726_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
c->frame.nb_samples = out_samples;
|
||||
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
|
||||
int buffer_size;
|
||||
int ret = 0;
|
||||
|
||||
if (bit_size > INT_MAX - 7 || bit_size < 0) {
|
||||
if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
|
||||
buffer_size = bit_size = 0;
|
||||
buffer = NULL;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "msgsmdec.h"
|
||||
|
||||
@@ -72,7 +73,7 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = avctx->frame_size;
|
||||
if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
+122
-47
@@ -106,10 +106,10 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h){
|
||||
|
||||
int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma){
|
||||
MpegEncContext * const s = &h->s;
|
||||
static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1};
|
||||
static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8};
|
||||
static const int8_t top[4] = { LEFT_DC_PRED8x8, 1, -1, -1 };
|
||||
static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
|
||||
|
||||
if(mode > 6U) {
|
||||
if(mode > 3U) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "out of range intra chroma pred mode at %d %d\n", s->mb_x, s->mb_y);
|
||||
return -1;
|
||||
}
|
||||
@@ -1300,6 +1300,8 @@ int ff_h264_frame_start(H264Context *h){
|
||||
int i;
|
||||
const int pixel_shift = h->pixel_shift;
|
||||
|
||||
h->next_output_pic = NULL;
|
||||
|
||||
if(MPV_frame_start(s, s->avctx) < 0)
|
||||
return -1;
|
||||
ff_er_frame_start(s);
|
||||
@@ -1349,8 +1351,6 @@ int ff_h264_frame_start(H264Context *h){
|
||||
s->current_picture_ptr->field_poc[0]=
|
||||
s->current_picture_ptr->field_poc[1]= INT_MAX;
|
||||
|
||||
h->next_output_pic = NULL;
|
||||
|
||||
assert(s->current_picture_ptr->long_ref==0);
|
||||
|
||||
return 0;
|
||||
@@ -2607,6 +2607,52 @@ int ff_h264_get_profile(SPS *sps)
|
||||
return profile;
|
||||
}
|
||||
|
||||
static int h264_set_parameter_from_sps(H264Context *h)
|
||||
{
|
||||
MpegEncContext *s = &h->s;
|
||||
|
||||
if (s->flags & CODEC_FLAG_LOW_DELAY ||
|
||||
(h->sps.bitstream_restriction_flag &&
|
||||
!h->sps.num_reorder_frames)) {
|
||||
if (s->avctx->has_b_frames > 1 || h->delayed_pic[0])
|
||||
av_log(h->s.avctx, AV_LOG_WARNING, "Delayed frames seen. "
|
||||
"Reenabling low delay requires a codec flush.\n");
|
||||
else
|
||||
s->low_delay = 1;
|
||||
}
|
||||
|
||||
if (s->avctx->has_b_frames < 2)
|
||||
s->avctx->has_b_frames = !s->low_delay;
|
||||
|
||||
if (s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
|
||||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
|
||||
if (s->avctx->codec &&
|
||||
s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU &&
|
||||
(h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"VDPAU decoding does not support video colorspace.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
|
||||
s->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
|
||||
h->cur_chroma_format_idc = h->sps.chroma_format_idc;
|
||||
h->pixel_shift = h->sps.bit_depth_luma > 8;
|
||||
|
||||
ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
|
||||
h->sps.chroma_format_idc);
|
||||
ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma,
|
||||
h->sps.chroma_format_idc);
|
||||
s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
|
||||
dsputil_init(&s->dsp, s->avctx);
|
||||
} else {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
|
||||
h->sps.bit_depth_luma);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a slice header.
|
||||
* This will also call MPV_common_init() and frame_start() as needed.
|
||||
@@ -2624,7 +2670,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
int num_ref_idx_active_override_flag;
|
||||
unsigned int slice_type, tmp, i, j;
|
||||
int default_ref_list_done = 0;
|
||||
int last_pic_structure, last_pic_dropable;
|
||||
int last_pic_structure, last_pic_dropable, ret;
|
||||
|
||||
/* FIXME: 2tap qpel isn't implemented for high bit depth. */
|
||||
if((s->avctx->flags2 & CODEC_FLAG2_FAST) && !h->nal_ref_idc && !h->pixel_shift){
|
||||
@@ -2672,7 +2718,14 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
h->slice_type= slice_type;
|
||||
h->slice_type_nos= slice_type & 3;
|
||||
|
||||
s->pict_type= h->slice_type; // to make a few old functions happy, it's wrong though
|
||||
if (h->nal_unit_type == NAL_IDR_SLICE &&
|
||||
h->slice_type_nos != AV_PICTURE_TYPE_I) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
// to make a few old functions happy, it's wrong though
|
||||
s->pict_type = h->slice_type;
|
||||
|
||||
pps_id= get_ue_golomb(&s->gb);
|
||||
if(pps_id>=MAX_PPS_COUNT){
|
||||
@@ -2689,7 +2742,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
|
||||
return -1;
|
||||
}
|
||||
h->sps = *h0->sps_buffers[h->pps.sps_id];
|
||||
|
||||
if (h->pps.sps_id != h->current_sps_id ||
|
||||
h0->sps_buffers[h->pps.sps_id]->new) {
|
||||
h0->sps_buffers[h->pps.sps_id]->new = 0;
|
||||
|
||||
h->current_sps_id = h->pps.sps_id;
|
||||
h->sps = *h0->sps_buffers[h->pps.sps_id];
|
||||
|
||||
if ((ret = h264_set_parameter_from_sps(h)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
s->avctx->profile = ff_h264_get_profile(&h->sps);
|
||||
s->avctx->level = h->sps.level_idc;
|
||||
@@ -2989,8 +3052,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
|
||||
Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
|
||||
av_log(h->s.avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num);
|
||||
if (ff_h264_frame_start(h) < 0)
|
||||
if (ff_h264_frame_start(h) < 0) {
|
||||
h0->s.first_field = 0;
|
||||
return -1;
|
||||
}
|
||||
h->prev_frame_num++;
|
||||
h->prev_frame_num %= 1<<h->sps.log2_max_frame_num;
|
||||
s->current_picture_ptr->frame_num= h->prev_frame_num;
|
||||
@@ -3224,8 +3289,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
}
|
||||
|
||||
h->deblocking_filter = 1;
|
||||
h->slice_alpha_c0_offset = 52;
|
||||
h->slice_beta_offset = 52;
|
||||
h->slice_alpha_c0_offset = 0;
|
||||
h->slice_beta_offset = 0;
|
||||
if( h->pps.deblocking_filter_parameters_present ) {
|
||||
tmp= get_ue_golomb_31(&s->gb);
|
||||
if(tmp > 2){
|
||||
@@ -3236,12 +3301,16 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
if(h->deblocking_filter < 2)
|
||||
h->deblocking_filter^= 1; // 1<->0
|
||||
|
||||
if( h->deblocking_filter ) {
|
||||
h->slice_alpha_c0_offset += get_se_golomb(&s->gb) << 1;
|
||||
h->slice_beta_offset += get_se_golomb(&s->gb) << 1;
|
||||
if( h->slice_alpha_c0_offset > 104U
|
||||
|| h->slice_beta_offset > 104U){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "deblocking filter parameters %d %d out of range\n", h->slice_alpha_c0_offset, h->slice_beta_offset);
|
||||
if (h->deblocking_filter) {
|
||||
h->slice_alpha_c0_offset = get_se_golomb(&s->gb) * 2;
|
||||
h->slice_beta_offset = get_se_golomb(&s->gb) * 2;
|
||||
if (h->slice_alpha_c0_offset > 12 ||
|
||||
h->slice_alpha_c0_offset < -12 ||
|
||||
h->slice_beta_offset > 12 ||
|
||||
h->slice_beta_offset < -12) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"deblocking filter parameters %d %d out of range\n",
|
||||
h->slice_alpha_c0_offset, h->slice_beta_offset);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -3270,14 +3339,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
}
|
||||
}
|
||||
}
|
||||
h->qp_thresh = 15 + 52 - FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset)
|
||||
- FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1])
|
||||
+ 6 * (h->sps.bit_depth_luma - 8);
|
||||
|
||||
#if 0 //FMO
|
||||
if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5)
|
||||
slice_group_change_cycle= get_bits(&s->gb, ?);
|
||||
#endif
|
||||
h->qp_thresh = 15 -
|
||||
FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
|
||||
FFMAX3(0,
|
||||
h->pps.chroma_qp_index_offset[0],
|
||||
h->pps.chroma_qp_index_offset[1]) +
|
||||
6 * (h->sps.bit_depth_luma - 8);
|
||||
|
||||
h0->last_slice_type = slice_type;
|
||||
h->slice_num = ++h0->current_slice;
|
||||
@@ -3338,7 +3405,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],
|
||||
h->ref_count[0], h->ref_count[1],
|
||||
s->qscale,
|
||||
h->deblocking_filter, h->slice_alpha_c0_offset/2-26, h->slice_beta_offset/2-26,
|
||||
h->deblocking_filter,
|
||||
h->slice_alpha_c0_offset, h->slice_beta_offset,
|
||||
h->use_weight,
|
||||
h->use_weight==1 && h->use_weight_chroma ? "c" : "",
|
||||
h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : ""
|
||||
@@ -3821,6 +3889,12 @@ static int execute_decode_slices(H264Context *h, int context_count){
|
||||
H264Context *hx;
|
||||
int i;
|
||||
|
||||
if (s->mb_y >= s->mb_height) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Input contains more MB rows than the frame height.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->avctx->hwaccel || s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
|
||||
return 0;
|
||||
if(context_count == 1) {
|
||||
@@ -4033,12 +4107,24 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
}
|
||||
break;
|
||||
case NAL_DPA:
|
||||
if (s->flags2 & CODEC_FLAG2_CHUNKS) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR,
|
||||
"Decoding in chunks is not supported for "
|
||||
"partitioned slices.\n");
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
init_get_bits(&hx->s.gb, ptr, bit_length);
|
||||
hx->intra_gb_ptr=
|
||||
hx->inter_gb_ptr= NULL;
|
||||
|
||||
if ((err = decode_slice_header(hx, h)) < 0)
|
||||
if ((err = decode_slice_header(hx, h)) < 0) {
|
||||
/* make sure data_partitioning is cleared if it was set
|
||||
* before, so we don't try decoding a slice without a valid
|
||||
* slice header later */
|
||||
s->data_partitioning = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
hx->s.data_partitioning = 1;
|
||||
|
||||
@@ -4073,24 +4159,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
ff_h264_decode_seq_parameter_set(h);
|
||||
}
|
||||
|
||||
if (s->flags & CODEC_FLAG_LOW_DELAY ||
|
||||
(h->sps.bitstream_restriction_flag &&
|
||||
!h->sps.num_reorder_frames)) {
|
||||
if (s->avctx->has_b_frames > 1 || h->delayed_pic[0])
|
||||
av_log(avctx, AV_LOG_WARNING, "Delayed frames seen "
|
||||
"reenabling low delay requires a codec "
|
||||
"flush.\n");
|
||||
else
|
||||
s->low_delay = 1;
|
||||
}
|
||||
|
||||
if(avctx->has_b_frames < 2)
|
||||
avctx->has_b_frames= !s->low_delay;
|
||||
|
||||
if (h->sps.bit_depth_luma != h->sps.bit_depth_chroma) {
|
||||
av_log_missing_feature(s->avctx,
|
||||
"Different bit depth between chroma and luma", 1);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
if (h264_set_parameter_from_sps(h) < 0) {
|
||||
buf_index = -1;
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
case NAL_PPS:
|
||||
@@ -4115,9 +4186,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
context_count = 0;
|
||||
}
|
||||
|
||||
if (err < 0)
|
||||
if (err < 0) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
|
||||
else if(err == 1) {
|
||||
h->ref_count[0] = h->ref_count[1] = h->list_count = 0;
|
||||
} else if (err == 1) {
|
||||
/* Slice could not be decoded in parallel mode, copy down
|
||||
* NAL unit stuff to context 0 and restart. Note that
|
||||
* rbsp_buffer is not transferred, but since we no longer
|
||||
@@ -4168,6 +4240,9 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
|
||||
s->flags= avctx->flags;
|
||||
s->flags2= avctx->flags2;
|
||||
/* reset data partitioning here, to ensure GetBitContexts from previous
|
||||
* packets do not get used. */
|
||||
s->data_partitioning = 0;
|
||||
|
||||
/* end of stream, output what is still in the buffers */
|
||||
if (buf_size == 0) {
|
||||
|
||||
@@ -206,6 +206,7 @@ typedef struct SPS{
|
||||
int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
|
||||
int residual_color_transform_flag; ///< residual_colour_transform_flag
|
||||
int constraint_set_flags; ///< constraint_set[0-3]_flag
|
||||
int new; ///< flag to keep track if the decoder context needs re-init due to changed SPS
|
||||
}SPS;
|
||||
|
||||
/**
|
||||
@@ -332,6 +333,7 @@ typedef struct H264Context{
|
||||
int emu_edge_width;
|
||||
int emu_edge_height;
|
||||
|
||||
unsigned current_sps_id; ///< id of the current SPS
|
||||
SPS sps; ///< current sps
|
||||
|
||||
/**
|
||||
|
||||
@@ -770,6 +770,10 @@ decode_intra_mb:
|
||||
|
||||
// We assume these blocks are very rare so we do not optimize it.
|
||||
align_get_bits(&s->gb);
|
||||
if (get_bits_left(&s->gb) < mb_size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
// The pixels are stored in the same order as levels in h->mb array.
|
||||
for(x=0; x < mb_size; x++){
|
||||
|
||||
@@ -254,8 +254,8 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
|
||||
int top_type= h->top_type;
|
||||
|
||||
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
|
||||
int a = h->slice_alpha_c0_offset - qp_bd_offset;
|
||||
int b = h->slice_beta_offset - qp_bd_offset;
|
||||
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
|
||||
int b = 52 + h->slice_beta_offset - qp_bd_offset;
|
||||
|
||||
int mb_type = s->current_picture.f.mb_type[mb_xy];
|
||||
int qp = s->current_picture.f.qscale_table[mb_xy];
|
||||
@@ -715,8 +715,8 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint
|
||||
av_unused int dir;
|
||||
int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
|
||||
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
|
||||
int a = h->slice_alpha_c0_offset - qp_bd_offset;
|
||||
int b = h->slice_beta_offset - qp_bd_offset;
|
||||
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
|
||||
int b = 52 + h->slice_beta_offset - qp_bd_offset;
|
||||
|
||||
if (FRAME_MBAFF
|
||||
// and current and left pair do not have the same interlaced type
|
||||
|
||||
@@ -156,7 +156,7 @@ pps:
|
||||
goto fail;
|
||||
|
||||
/* prepend only to the first type 5 NAL unit of an IDR picture */
|
||||
if (ctx->first_idr && unit_type == 5) {
|
||||
if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) {
|
||||
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
|
||||
avctx->extradata, avctx->extradata_size,
|
||||
buf, nal_size)) < 0)
|
||||
|
||||
+13
-3
@@ -250,7 +250,9 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
|
||||
}
|
||||
|
||||
if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames);
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "Clipping illegal num_reorder_frames %d\n",
|
||||
sps->num_reorder_frames);
|
||||
sps->num_reorder_frames = 16;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -368,6 +370,11 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
|
||||
sps->bit_depth_luma, sps->bit_depth_chroma);
|
||||
goto fail;
|
||||
}
|
||||
if (sps->bit_depth_chroma != sps->bit_depth_luma) {
|
||||
av_log_missing_feature(s->avctx,
|
||||
"Different bit depth between chroma and luma", 1);
|
||||
goto fail;
|
||||
}
|
||||
sps->transform_bypass = get_bits1(&s->gb);
|
||||
decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
|
||||
}else{
|
||||
@@ -487,10 +494,13 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
|
||||
sps->bit_depth_luma
|
||||
);
|
||||
}
|
||||
sps->new = 1;
|
||||
|
||||
av_free(h->sps_buffers[sps_id]);
|
||||
h->sps_buffers[sps_id]= sps;
|
||||
h->sps = *sps;
|
||||
h->sps_buffers[sps_id] = sps;
|
||||
h->sps = *sps;
|
||||
h->current_sps_id = sps_id;
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
av_free(sps);
|
||||
|
||||
+20
-12
@@ -63,20 +63,22 @@ static int split_field_copy(Picture *dest, Picture *src,
|
||||
return match;
|
||||
}
|
||||
|
||||
static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel){
|
||||
static int build_def_list(Picture *def, int def_len,
|
||||
Picture **in, int len, int is_long, int sel)
|
||||
{
|
||||
int i[2]={0};
|
||||
int index=0;
|
||||
|
||||
while(i[0]<len || i[1]<len){
|
||||
while ((i[0] < len || i[1] < len) && index < def_len) {
|
||||
while (i[0] < len && !(in[ i[0] ] && (in[ i[0] ]->f.reference & sel)))
|
||||
i[0]++;
|
||||
while (i[1] < len && !(in[ i[1] ] && (in[ i[1] ]->f.reference & (sel^3))))
|
||||
i[1]++;
|
||||
if(i[0] < len){
|
||||
if (i[0] < len && index < def_len) {
|
||||
in[ i[0] ]->pic_id= is_long ? i[0] : in[ i[0] ]->frame_num;
|
||||
split_field_copy(&def[index++], in[ i[0]++ ], sel , 1);
|
||||
}
|
||||
if(i[1] < len){
|
||||
if (i[1] < len && index < def_len) {
|
||||
in[ i[1] ]->pic_id= is_long ? i[1] : in[ i[1] ]->frame_num;
|
||||
split_field_copy(&def[index++], in[ i[1]++ ], sel^3, 0);
|
||||
}
|
||||
@@ -124,9 +126,12 @@ int ff_h264_fill_default_ref_list(H264Context *h){
|
||||
len= add_sorted(sorted , h->short_ref, h->short_ref_count, cur_poc, 1^list);
|
||||
len+=add_sorted(sorted+len, h->short_ref, h->short_ref_count, cur_poc, 0^list);
|
||||
assert(len<=32);
|
||||
len= build_def_list(h->default_ref_list[list] , sorted , len, 0, s->picture_structure);
|
||||
len+=build_def_list(h->default_ref_list[list]+len, h->long_ref, 16 , 1, s->picture_structure);
|
||||
assert(len<=32);
|
||||
|
||||
len = build_def_list(h->default_ref_list[list], FF_ARRAY_ELEMS(h->default_ref_list[0]),
|
||||
sorted, len, 0, s->picture_structure);
|
||||
len += build_def_list(h->default_ref_list[list] + len,
|
||||
FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
|
||||
h->long_ref, 16, 1, s->picture_structure);
|
||||
|
||||
if(len < h->ref_count[list])
|
||||
memset(&h->default_ref_list[list][len], 0, sizeof(Picture)*(h->ref_count[list] - len));
|
||||
@@ -139,9 +144,12 @@ int ff_h264_fill_default_ref_list(H264Context *h){
|
||||
FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]);
|
||||
}
|
||||
}else{
|
||||
len = build_def_list(h->default_ref_list[0] , h->short_ref, h->short_ref_count, 0, s->picture_structure);
|
||||
len+= build_def_list(h->default_ref_list[0]+len, h-> long_ref, 16 , 1, s->picture_structure);
|
||||
assert(len <= 32);
|
||||
len = build_def_list(h->default_ref_list[0], FF_ARRAY_ELEMS(h->default_ref_list[0]),
|
||||
h->short_ref, h->short_ref_count, 0, s->picture_structure);
|
||||
len += build_def_list(h->default_ref_list[0] + len,
|
||||
FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
|
||||
h-> long_ref, 16, 1, s->picture_structure);
|
||||
|
||||
if(len < h->ref_count[0])
|
||||
memset(&h->default_ref_list[0][len], 0, sizeof(Picture)*(h->ref_count[0] - len));
|
||||
}
|
||||
@@ -516,7 +524,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
||||
if(!pic){
|
||||
if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg]
|
||||
|| h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
|
||||
av_log(h->s.avctx, h->short_ref_count ? AV_LOG_ERROR : AV_LOG_DEBUG, "mmco: unref short failure\n");
|
||||
err = AVERROR_INVALIDDATA;
|
||||
}
|
||||
continue;
|
||||
@@ -653,7 +661,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
||||
print_short_term(h);
|
||||
print_long_term(h);
|
||||
|
||||
if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
||||
if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=2 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
||||
s->current_picture_ptr->sync |= 1;
|
||||
if(!h->s.avctx->has_b_frames)
|
||||
h->sync = 2;
|
||||
|
||||
@@ -184,6 +184,12 @@ int ff_h264_decode_sei(H264Context *h){
|
||||
if(s->avctx->debug&FF_DEBUG_STARTCODE)
|
||||
av_log(h->s.avctx, AV_LOG_DEBUG, "SEI %d len:%d\n", type, size);
|
||||
|
||||
if (size > get_bits_left(&s->gb) / 8) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "SEI type %d truncated at %d\n",
|
||||
type, get_bits_left(&s->gb));
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
switch(type){
|
||||
case SEI_TYPE_PIC_TIMING: // Picture timing SEI
|
||||
if(decode_picture_timing(h) < 0)
|
||||
|
||||
@@ -53,13 +53,13 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_fo
|
||||
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
|
||||
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
|
||||
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
|
||||
if (chroma_format_idc == 1)\
|
||||
if (chroma_format_idc <= 1)\
|
||||
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
|
||||
else\
|
||||
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
|
||||
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
|
||||
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
|
||||
if (chroma_format_idc == 1)\
|
||||
if (chroma_format_idc <= 1)\
|
||||
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
|
||||
else\
|
||||
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
|
||||
@@ -80,20 +80,20 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_fo
|
||||
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
|
||||
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
|
||||
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
|
||||
if (chroma_format_idc == 1)\
|
||||
if (chroma_format_idc <= 1)\
|
||||
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
|
||||
else\
|
||||
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
|
||||
if (chroma_format_idc == 1)\
|
||||
if (chroma_format_idc <= 1)\
|
||||
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
|
||||
else\
|
||||
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
|
||||
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
|
||||
if (chroma_format_idc == 1)\
|
||||
if (chroma_format_idc <= 1)\
|
||||
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
|
||||
else\
|
||||
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
|
||||
if (chroma_format_idc == 1)\
|
||||
if (chroma_format_idc <= 1)\
|
||||
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
|
||||
else\
|
||||
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
|
||||
|
||||
@@ -434,7 +434,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, co
|
||||
h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\
|
||||
h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\
|
||||
\
|
||||
if (chroma_format_idc == 1) {\
|
||||
if (chroma_format_idc <= 1) {\
|
||||
h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\
|
||||
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\
|
||||
} else {\
|
||||
@@ -442,7 +442,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, co
|
||||
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\
|
||||
}\
|
||||
if (codec_id != CODEC_ID_VP8) {\
|
||||
if (chroma_format_idc == 1) {\
|
||||
if (chroma_format_idc <= 1) {\
|
||||
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\
|
||||
} else {\
|
||||
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane , depth);\
|
||||
@@ -450,7 +450,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, co
|
||||
} else\
|
||||
h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
|
||||
if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\
|
||||
if (chroma_format_idc == 1) {\
|
||||
if (chroma_format_idc <= 1) {\
|
||||
h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
|
||||
h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
|
||||
h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\
|
||||
@@ -476,7 +476,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, co
|
||||
h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\
|
||||
}\
|
||||
}\
|
||||
if (chroma_format_idc == 1) {\
|
||||
if (chroma_format_idc <= 1) {\
|
||||
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\
|
||||
} else {\
|
||||
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\
|
||||
@@ -510,7 +510,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, co
|
||||
h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\
|
||||
h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\
|
||||
h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\
|
||||
if (chroma_format_idc == 1) {\
|
||||
if (chroma_format_idc <= 1) {\
|
||||
h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\
|
||||
h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\
|
||||
} else {\
|
||||
|
||||
+62
-37
@@ -302,10 +302,12 @@ static void generate_len_table(uint8_t *dst, const uint64_t *stats){
|
||||
}
|
||||
#endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */
|
||||
|
||||
static void generate_joint_tables(HYuvContext *s){
|
||||
static int generate_joint_tables(HYuvContext *s){
|
||||
uint16_t symbols[1<<VLC_BITS];
|
||||
uint16_t bits[1<<VLC_BITS];
|
||||
uint8_t len[1<<VLC_BITS];
|
||||
int ret;
|
||||
|
||||
if(s->bitstream_bpp < 24){
|
||||
int p, i, y, u;
|
||||
for(p=0; p<3; p++){
|
||||
@@ -327,7 +329,9 @@ static void generate_joint_tables(HYuvContext *s){
|
||||
}
|
||||
}
|
||||
ff_free_vlc(&s->vlc[3+p]);
|
||||
ff_init_vlc_sparse(&s->vlc[3+p], VLC_BITS, i, len, 1, 1, bits, 2, 2, symbols, 2, 2, 0);
|
||||
if ((ret = ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1,
|
||||
bits, 2, 2, symbols, 2, 2, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
}else{
|
||||
uint8_t (*map)[4] = (uint8_t(*)[4])s->pix_bgr_map;
|
||||
@@ -369,29 +373,33 @@ static void generate_joint_tables(HYuvContext *s){
|
||||
}
|
||||
}
|
||||
ff_free_vlc(&s->vlc[3]);
|
||||
init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0);
|
||||
if ((ret = init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1,
|
||||
bits, 2, 2, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
|
||||
GetBitContext gb;
|
||||
int i;
|
||||
int ret;
|
||||
int i, ret;
|
||||
|
||||
init_get_bits(&gb, src, length*8);
|
||||
if ((ret = init_get_bits(&gb, src, length * 8)) < 0)
|
||||
return ret;
|
||||
|
||||
for(i=0; i<3; i++){
|
||||
if(read_len_table(s->len[i], &gb)<0)
|
||||
return -1;
|
||||
if(generate_bits_table(s->bits[i], s->len[i])<0){
|
||||
return -1;
|
||||
}
|
||||
if ((ret = read_len_table(s->len[i], &gb)) < 0)
|
||||
return ret;
|
||||
if ((ret = generate_bits_table(s->bits[i], s->len[i])) < 0)
|
||||
return ret;
|
||||
ff_free_vlc(&s->vlc[i]);
|
||||
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0)) < 0)
|
||||
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
|
||||
s->bits[i], 4, 4, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
generate_joint_tables(s);
|
||||
if ((ret = generate_joint_tables(s)) < 0)
|
||||
return ret;
|
||||
|
||||
return (get_bits_count(&gb)+7)/8;
|
||||
}
|
||||
@@ -399,15 +407,18 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
|
||||
static int read_old_huffman_tables(HYuvContext *s){
|
||||
#if 1
|
||||
GetBitContext gb;
|
||||
int i;
|
||||
int ret;
|
||||
int i, ret;
|
||||
|
||||
init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size*8);
|
||||
if(read_len_table(s->len[0], &gb)<0)
|
||||
return -1;
|
||||
init_get_bits(&gb, classic_shift_chroma, classic_shift_chroma_table_size*8);
|
||||
if(read_len_table(s->len[1], &gb)<0)
|
||||
return -1;
|
||||
if ((ret = init_get_bits(&gb, classic_shift_luma,
|
||||
classic_shift_luma_table_size * 8)) < 0)
|
||||
return ret;
|
||||
if ((ret = read_len_table(s->len[0], &gb)) < 0)
|
||||
return ret;
|
||||
if ((ret = init_get_bits(&gb, classic_shift_chroma,
|
||||
classic_shift_chroma_table_size * 8)) < 0)
|
||||
return ret;
|
||||
if ((ret = read_len_table(s->len[1], &gb)) < 0)
|
||||
return ret;
|
||||
|
||||
for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i];
|
||||
for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i];
|
||||
@@ -421,11 +432,13 @@ static int read_old_huffman_tables(HYuvContext *s){
|
||||
|
||||
for(i=0; i<3; i++){
|
||||
ff_free_vlc(&s->vlc[i]);
|
||||
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0)) < 0)
|
||||
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
|
||||
s->bits[i], 4, 4, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
generate_joint_tables(s);
|
||||
if ((ret = generate_joint_tables(s)) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
@@ -465,6 +478,7 @@ static av_cold int common_init(AVCodecContext *avctx){
|
||||
static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
HYuvContext *s = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
common_init(avctx);
|
||||
memset(s->vlc, 0, 3*sizeof(VLC));
|
||||
@@ -500,8 +514,9 @@ s->bgr32=1;
|
||||
s->interlaced= (interlace==1) ? 1 : (interlace==2) ? 0 : s->interlaced;
|
||||
s->context= ((uint8_t*)avctx->extradata)[2] & 0x40 ? 1 : 0;
|
||||
|
||||
if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size-4) < 0)
|
||||
return -1;
|
||||
if ((ret = read_huffman_tables(s, ((uint8_t*)avctx->extradata) + 4,
|
||||
avctx->extradata_size - 4)) < 0)
|
||||
return ret;
|
||||
}else{
|
||||
switch(avctx->bits_per_coded_sample&7){
|
||||
case 1:
|
||||
@@ -528,8 +543,8 @@ s->bgr32=1;
|
||||
s->bitstream_bpp= avctx->bits_per_coded_sample & ~7;
|
||||
s->context= 0;
|
||||
|
||||
if(read_old_huffman_tables(s) < 0)
|
||||
return -1;
|
||||
if ((ret = read_old_huffman_tables(s)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch(s->bitstream_bpp){
|
||||
@@ -555,6 +570,13 @@ s->bgr32=1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->predictor == MEDIAN && avctx->pix_fmt == PIX_FMT_YUV422P &&
|
||||
avctx->width % 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "width must be multiple of 4 "
|
||||
"for this combination of colorspace and predictor type.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
alloc_temp(s);
|
||||
|
||||
// av_log(NULL, AV_LOG_DEBUG, "pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_coded_sample, s->interlaced);
|
||||
@@ -565,7 +587,7 @@ s->bgr32=1;
|
||||
static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
|
||||
{
|
||||
HYuvContext *s = avctx->priv_data;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
avctx->coded_frame= &s->picture;
|
||||
alloc_temp(s);
|
||||
@@ -574,11 +596,12 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
|
||||
s->vlc[i].table = NULL;
|
||||
|
||||
if(s->version==2){
|
||||
if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size) < 0)
|
||||
return -1;
|
||||
if ((ret = read_huffman_tables(s, ((uint8_t*)avctx->extradata) + 4,
|
||||
avctx->extradata_size)) < 0)
|
||||
return ret;
|
||||
}else{
|
||||
if(read_old_huffman_tables(s) < 0)
|
||||
return -1;
|
||||
if ((ret = read_old_huffman_tables(s)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1001,7 +1024,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
const int height= s->height;
|
||||
int fake_ystride, fake_ustride, fake_vstride;
|
||||
AVFrame * const p= &s->picture;
|
||||
int table_size= 0;
|
||||
int table_size = 0, ret;
|
||||
|
||||
AVFrame *picture = data;
|
||||
|
||||
@@ -1016,21 +1039,23 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
ff_thread_release_buffer(avctx, p);
|
||||
|
||||
p->reference= 0;
|
||||
if(ff_thread_get_buffer(avctx, p) < 0){
|
||||
if ((ret = ff_thread_get_buffer(avctx, p)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(s->context){
|
||||
table_size = read_huffman_tables(s, s->bitstream_buffer, buf_size);
|
||||
if(table_size < 0)
|
||||
return -1;
|
||||
return table_size;
|
||||
}
|
||||
|
||||
if((unsigned)(buf_size-table_size) >= INT_MAX/8)
|
||||
return -1;
|
||||
|
||||
init_get_bits(&s->gb, s->bitstream_buffer+table_size, (buf_size-table_size)*8);
|
||||
if ((ret = init_get_bits(&s->gb, s->bitstream_buffer + table_size,
|
||||
(buf_size - table_size) * 8)) < 0)
|
||||
return ret;
|
||||
|
||||
fake_ystride= s->interlaced ? p->linesize[0]*2 : p->linesize[0];
|
||||
fake_ustride= s->interlaced ? p->linesize[1]*2 : p->linesize[1];
|
||||
|
||||
+3
-2
@@ -28,6 +28,7 @@
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "bytestream.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
// TODO: masking bits
|
||||
@@ -479,7 +480,7 @@ static int decode_frame_ilbm(AVCodecContext *avctx,
|
||||
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||
return res;
|
||||
}
|
||||
} else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
} else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return res;
|
||||
} else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt == PIX_FMT_PAL8) {
|
||||
@@ -579,7 +580,7 @@ static int decode_frame_byterun1(AVCodecContext *avctx,
|
||||
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||
return res;
|
||||
}
|
||||
} else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
} else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return res;
|
||||
} else if (avctx->pix_fmt == PIX_FMT_PAL8) {
|
||||
|
||||
+2
-1
@@ -36,6 +36,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
@@ -680,7 +681,7 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
q->frame.nb_samples = COEFFS;
|
||||
if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "dsputil.h"
|
||||
#include "bytestream.h"
|
||||
#include "get_bits.h"
|
||||
@@ -1097,7 +1098,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
avctx->release_buffer(avctx, &ctx->frame);
|
||||
|
||||
ctx->frame.reference = 0;
|
||||
if ((res = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
if ((res = ff_get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
||||
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
|
||||
if (ff_ivi_init_planes(ctx->planes, &pic_conf)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
|
||||
ctx->pic_conf.luma_bands = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
@@ -348,6 +349,13 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
||||
band->inv_transform = transforms[transform_id].inv_trans;
|
||||
band->dc_transform = transforms[transform_id].dc_trans;
|
||||
band->is_2d_trans = transforms[transform_id].is_2d_trans;
|
||||
if (transform_id < 10)
|
||||
band->transform_size = 8;
|
||||
else
|
||||
band->transform_size = 4;
|
||||
|
||||
if (band->blk_size != band->transform_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
scan_indx = get_bits(&ctx->gb, 4);
|
||||
if (scan_indx == 15) {
|
||||
|
||||
+25
-17
@@ -113,7 +113,7 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
/* check if picture layout was changed and reallocate buffers */
|
||||
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
|
||||
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf) || ctx->gop_invalid) {
|
||||
result = ff_ivi_init_planes(ctx->planes, &pic_conf);
|
||||
if (result < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
|
||||
@@ -148,39 +148,47 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
||||
/* select transform function and scan pattern according to plane and band number */
|
||||
switch ((p << 2) + i) {
|
||||
case 0:
|
||||
band->inv_transform = ff_ivi_inverse_slant_8x8;
|
||||
band->dc_transform = ff_ivi_dc_slant_2d;
|
||||
band->scan = ff_zigzag_direct;
|
||||
band->inv_transform = ff_ivi_inverse_slant_8x8;
|
||||
band->dc_transform = ff_ivi_dc_slant_2d;
|
||||
band->scan = ff_zigzag_direct;
|
||||
band->transform_size = 8;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
band->inv_transform = ff_ivi_row_slant8;
|
||||
band->dc_transform = ff_ivi_dc_row_slant;
|
||||
band->scan = ff_ivi_vertical_scan_8x8;
|
||||
band->inv_transform = ff_ivi_row_slant8;
|
||||
band->dc_transform = ff_ivi_dc_row_slant;
|
||||
band->scan = ff_ivi_vertical_scan_8x8;
|
||||
band->transform_size = 8;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
band->inv_transform = ff_ivi_col_slant8;
|
||||
band->dc_transform = ff_ivi_dc_col_slant;
|
||||
band->scan = ff_ivi_horizontal_scan_8x8;
|
||||
band->inv_transform = ff_ivi_col_slant8;
|
||||
band->dc_transform = ff_ivi_dc_col_slant;
|
||||
band->scan = ff_ivi_horizontal_scan_8x8;
|
||||
band->transform_size = 8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
band->inv_transform = ff_ivi_put_pixels_8x8;
|
||||
band->dc_transform = ff_ivi_put_dc_pixel_8x8;
|
||||
band->scan = ff_ivi_horizontal_scan_8x8;
|
||||
band->inv_transform = ff_ivi_put_pixels_8x8;
|
||||
band->dc_transform = ff_ivi_put_dc_pixel_8x8;
|
||||
band->scan = ff_ivi_horizontal_scan_8x8;
|
||||
band->transform_size = 8;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
band->inv_transform = ff_ivi_inverse_slant_4x4;
|
||||
band->dc_transform = ff_ivi_dc_slant_2d;
|
||||
band->scan = ff_ivi_direct_scan_4x4;
|
||||
band->inv_transform = ff_ivi_inverse_slant_4x4;
|
||||
band->dc_transform = ff_ivi_dc_slant_2d;
|
||||
band->scan = ff_ivi_direct_scan_4x4;
|
||||
band->transform_size = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 ||
|
||||
band->inv_transform == ff_ivi_inverse_slant_4x4;
|
||||
|
||||
if (band->transform_size != band->blk_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* select dequant matrix according to plane and band number */
|
||||
if (!p) {
|
||||
quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
|
||||
@@ -311,9 +319,9 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
||||
ctx->frame_num = get_bits(&ctx->gb, 8);
|
||||
|
||||
if (ctx->frame_type == FRAMETYPE_INTRA) {
|
||||
ctx->gop_invalid = 1;
|
||||
if ((ret = decode_gop_header(ctx, avctx)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
|
||||
ctx->gop_invalid = 1;
|
||||
return ret;
|
||||
}
|
||||
ctx->gop_invalid = 0;
|
||||
|
||||
@@ -136,4 +136,7 @@ int avpriv_unlock_avformat(void);
|
||||
*/
|
||||
int ff_alloc_packet(AVPacket *avpkt, int size);
|
||||
|
||||
|
||||
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame);
|
||||
|
||||
#endif /* AVCODEC_INTERNAL_H */
|
||||
|
||||
@@ -755,6 +755,8 @@ int ff_h263_decode_mb(MpegEncContext *s,
|
||||
}
|
||||
|
||||
if(IS_DIRECT(mb_type)){
|
||||
if (!s->pp_time)
|
||||
return AVERROR_INVALIDDATA;
|
||||
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
|
||||
mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0);
|
||||
}else{
|
||||
|
||||
+270
-176
@@ -28,6 +28,7 @@
|
||||
|
||||
#define BITSTREAM_READER_LE
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "ivi_common.h"
|
||||
#include "libavutil/common.h"
|
||||
@@ -42,6 +43,26 @@ VLC ff_ivi_blk_vlc_tabs[8];
|
||||
typedef void (*ivi_mc_func) (int16_t *buf, const int16_t *ref_buf,
|
||||
uint32_t pitch, int mc_type);
|
||||
|
||||
static int ivi_mc(IVIBandDesc *band, ivi_mc_func mc,
|
||||
int offs, int mv_x, int mv_y, int mc_type)
|
||||
{
|
||||
int ref_offs = offs + mv_y * band->pitch + mv_x;
|
||||
int buf_size = band->pitch * band->aheight;
|
||||
int min_size = band->pitch * (band->blk_size - 1) + band->blk_size;
|
||||
int ref_size = (mc_type > 1) * band->pitch + (mc_type & 1);
|
||||
|
||||
if (offs < 0 || ref_offs < 0 || !band->ref_buf)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (buf_size - min_size < offs)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (buf_size - min_size - ref_size < ref_offs)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
mc(band->buf + offs, band->ref_buf + ref_offs, band->pitch, mc_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse "nbits" bits of the value "val" and return the result
|
||||
* in the least significant bits.
|
||||
@@ -51,9 +72,10 @@ static uint16_t inv_bits(uint16_t val, int nbits)
|
||||
uint16_t res;
|
||||
|
||||
if (nbits <= 8) {
|
||||
res = av_reverse[val] >> (8-nbits);
|
||||
res = av_reverse[val] >> (8 - nbits);
|
||||
} else
|
||||
res = ((av_reverse[val & 0xFF] << 8) + (av_reverse[val >> 8])) >> (16-nbits);
|
||||
res = ((av_reverse[val & 0xFF] << 8) +
|
||||
(av_reverse[val >> 8])) >> (16 - nbits);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -103,10 +125,12 @@ void ff_ivi_init_static_vlc(void)
|
||||
for (i = 0; i < 8; i++) {
|
||||
ff_ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192;
|
||||
ff_ivi_mb_vlc_tabs[i].table_allocated = 8192;
|
||||
ff_ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i], &ff_ivi_mb_vlc_tabs[i], 1);
|
||||
ff_ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i],
|
||||
&ff_ivi_mb_vlc_tabs[i], 1);
|
||||
ff_ivi_blk_vlc_tabs[i].table = table_data + (i * 2 + 1) * 8192;
|
||||
ff_ivi_blk_vlc_tabs[i].table_allocated = 8192;
|
||||
ff_ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &ff_ivi_blk_vlc_tabs[i], 1);
|
||||
ff_ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i],
|
||||
&ff_ivi_blk_vlc_tabs[i], 1);
|
||||
}
|
||||
initialized_vlcs = 1;
|
||||
}
|
||||
@@ -114,47 +138,48 @@ void ff_ivi_init_static_vlc(void)
|
||||
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
|
||||
IVIHuffTab *huff_tab, AVCodecContext *avctx)
|
||||
{
|
||||
int i, result;
|
||||
int i, result;
|
||||
IVIHuffDesc new_huff;
|
||||
|
||||
if (!desc_coded) {
|
||||
/* select default table */
|
||||
huff_tab->tab = (which_tab) ? &ff_ivi_blk_vlc_tabs[7]
|
||||
: &ff_ivi_mb_vlc_tabs [7];
|
||||
} else {
|
||||
huff_tab->tab_sel = get_bits(gb, 3);
|
||||
if (huff_tab->tab_sel == 7) {
|
||||
/* custom huffman table (explicitly encoded) */
|
||||
new_huff.num_rows = get_bits(gb, 4);
|
||||
if (!new_huff.num_rows) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Empty custom Huffman table!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
: &ff_ivi_mb_vlc_tabs [7];
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < new_huff.num_rows; i++)
|
||||
new_huff.xbits[i] = get_bits(gb, 4);
|
||||
|
||||
/* Have we got the same custom table? Rebuild if not. */
|
||||
if (ff_ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc)) {
|
||||
ff_ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff);
|
||||
|
||||
if (huff_tab->cust_tab.table)
|
||||
ff_free_vlc(&huff_tab->cust_tab);
|
||||
result = ff_ivi_create_huff_from_desc(&huff_tab->cust_desc,
|
||||
&huff_tab->cust_tab, 0);
|
||||
if (result) {
|
||||
huff_tab->cust_desc.num_rows = 0; // reset faulty description
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Error while initializing custom vlc table!\n");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
huff_tab->tab = &huff_tab->cust_tab;
|
||||
} else {
|
||||
/* select one of predefined tables */
|
||||
huff_tab->tab = (which_tab) ? &ff_ivi_blk_vlc_tabs[huff_tab->tab_sel]
|
||||
: &ff_ivi_mb_vlc_tabs [huff_tab->tab_sel];
|
||||
huff_tab->tab_sel = get_bits(gb, 3);
|
||||
if (huff_tab->tab_sel == 7) {
|
||||
/* custom huffman table (explicitly encoded) */
|
||||
new_huff.num_rows = get_bits(gb, 4);
|
||||
if (!new_huff.num_rows) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Empty custom Huffman table!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (i = 0; i < new_huff.num_rows; i++)
|
||||
new_huff.xbits[i] = get_bits(gb, 4);
|
||||
|
||||
/* Have we got the same custom table? Rebuild if not. */
|
||||
if (ff_ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc)) {
|
||||
ff_ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff);
|
||||
|
||||
if (huff_tab->cust_tab.table)
|
||||
ff_free_vlc(&huff_tab->cust_tab);
|
||||
result = ff_ivi_create_huff_from_desc(&huff_tab->cust_desc,
|
||||
&huff_tab->cust_tab, 0);
|
||||
if (result) {
|
||||
huff_tab->cust_desc.num_rows = 0; // reset faulty description
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Error while initializing custom vlc table!\n");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
huff_tab->tab = &huff_tab->cust_tab;
|
||||
} else {
|
||||
/* select one of predefined tables */
|
||||
huff_tab->tab = (which_tab) ? &ff_ivi_blk_vlc_tabs[huff_tab->tab_sel]
|
||||
: &ff_ivi_mb_vlc_tabs [huff_tab->tab_sel];
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -174,12 +199,17 @@ void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src)
|
||||
|
||||
int av_cold ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
|
||||
{
|
||||
int p, b;
|
||||
uint32_t b_width, b_height, align_fac, width_aligned, height_aligned, buf_size;
|
||||
int p, b;
|
||||
uint32_t b_width, b_height, align_fac, width_aligned,
|
||||
height_aligned, buf_size;
|
||||
IVIBandDesc *band;
|
||||
|
||||
ff_ivi_free_buffers(planes);
|
||||
|
||||
if (cfg->pic_width < 1 || cfg->pic_height < 1 ||
|
||||
cfg->luma_bands < 1 || cfg->chroma_bands < 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* fill in the descriptor of the luminance plane */
|
||||
planes[0].width = cfg->pic_width;
|
||||
planes[0].height = cfg->pic_height;
|
||||
@@ -198,8 +228,10 @@ int av_cold ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
|
||||
/* select band dimensions: if there is only one band then it
|
||||
* has the full size, if there are several bands each of them
|
||||
* has only half size */
|
||||
b_width = planes[p].num_bands == 1 ? planes[p].width : (planes[p].width + 1) >> 1;
|
||||
b_height = planes[p].num_bands == 1 ? planes[p].height : (planes[p].height + 1) >> 1;
|
||||
b_width = planes[p].num_bands == 1 ? planes[p].width
|
||||
: (planes[p].width + 1) >> 1;
|
||||
b_height = planes[p].num_bands == 1 ? planes[p].height
|
||||
: (planes[p].height + 1) >> 1;
|
||||
|
||||
/* luma band buffers will be aligned on 16x16 (max macroblock size) */
|
||||
/* chroma band buffers will be aligned on 8x8 (max macroblock size) */
|
||||
@@ -227,8 +259,8 @@ int av_cold ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
|
||||
if (!band->bufs[2])
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0; /* reset custom vlc */
|
||||
/* reset custom vlc */
|
||||
planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,14 +284,51 @@ void av_cold ff_ivi_free_buffers(IVIPlaneDesc *planes)
|
||||
av_freep(&planes[p].bands[b].tiles);
|
||||
}
|
||||
av_freep(&planes[p].bands);
|
||||
planes[p].num_bands = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int ivi_init_tiles(IVIBandDesc *band, IVITile *ref_tile,
|
||||
int p, int b, int t_height, int t_width)
|
||||
{
|
||||
int x, y;
|
||||
IVITile *tile = band->tiles;
|
||||
|
||||
for (y = 0; y < band->height; y += t_height) {
|
||||
for (x = 0; x < band->width; x += t_width) {
|
||||
tile->xpos = x;
|
||||
tile->ypos = y;
|
||||
tile->mb_size = band->mb_size;
|
||||
tile->width = FFMIN(band->width - x, t_width);
|
||||
tile->height = FFMIN(band->height - y, t_height);
|
||||
tile->is_empty = tile->data_size = 0;
|
||||
/* calculate number of macroblocks */
|
||||
tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
|
||||
band->mb_size);
|
||||
|
||||
av_freep(&tile->mbs);
|
||||
tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
|
||||
if (!tile->mbs)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
tile->ref_mbs = 0;
|
||||
if (p || b) {
|
||||
if (tile->num_MBs != ref_tile->num_MBs)
|
||||
return AVERROR_INVALIDDATA;
|
||||
tile->ref_mbs = ref_tile->mbs;
|
||||
ref_tile++;
|
||||
}
|
||||
tile++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_cold ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height)
|
||||
{
|
||||
int p, b, x, y, x_tiles, y_tiles, t_width, t_height;
|
||||
int p, b, x_tiles, y_tiles, t_width, t_height, ret;
|
||||
IVIBandDesc *band;
|
||||
IVITile *tile, *ref_tile;
|
||||
|
||||
for (p = 0; p < 3; p++) {
|
||||
t_width = !p ? tile_width : (tile_width + 3) >> 2;
|
||||
@@ -283,41 +352,14 @@ int av_cold ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_hei
|
||||
if (!band->tiles)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
tile = band->tiles;
|
||||
|
||||
/* use the first luma band as reference for motion vectors
|
||||
* and quant */
|
||||
ref_tile = planes[0].bands[0].tiles;
|
||||
|
||||
for (y = 0; y < band->height; y += t_height) {
|
||||
for (x = 0; x < band->width; x += t_width) {
|
||||
tile->xpos = x;
|
||||
tile->ypos = y;
|
||||
tile->mb_size = band->mb_size;
|
||||
tile->width = FFMIN(band->width - x, t_width);
|
||||
tile->height = FFMIN(band->height - y, t_height);
|
||||
tile->is_empty = tile->data_size = 0;
|
||||
/* calculate number of macroblocks */
|
||||
tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
|
||||
band->mb_size);
|
||||
|
||||
av_freep(&tile->mbs);
|
||||
tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
|
||||
if (!tile->mbs)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
tile->ref_mbs = 0;
|
||||
if (p || b) {
|
||||
tile->ref_mbs = ref_tile->mbs;
|
||||
ref_tile++;
|
||||
}
|
||||
|
||||
tile++;
|
||||
}
|
||||
}
|
||||
|
||||
}// for b
|
||||
}// for p
|
||||
ret = ivi_init_tiles(band, planes[0].bands[0].tiles,
|
||||
p, b, t_height, t_width);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -339,25 +381,125 @@ int ff_ivi_dec_tile_data_size(GetBitContext *gb)
|
||||
return len;
|
||||
}
|
||||
|
||||
static int ivi_dc_transform(IVIBandDesc *band, int *prev_dc, int buf_offs,
|
||||
int blk_size)
|
||||
{
|
||||
int buf_size = band->pitch * band->aheight - buf_offs;
|
||||
int min_size = (blk_size - 1) * band->pitch + blk_size;
|
||||
|
||||
if (!band->dc_transform)
|
||||
return 0;
|
||||
|
||||
|
||||
if (min_size > buf_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
band->dc_transform(prev_dc, band->buf + buf_offs,
|
||||
band->pitch, blk_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band,
|
||||
ivi_mc_func mc, int mv_x, int mv_y,
|
||||
int *prev_dc, int is_intra, int mc_type,
|
||||
uint32_t quant, int offs)
|
||||
{
|
||||
const uint16_t *base_tab = is_intra ? band->intra_base : band->inter_base;
|
||||
RVMapDesc *rvmap = band->rv_map;
|
||||
uint8_t col_flags[8];
|
||||
int32_t trvec[64];
|
||||
uint32_t sym = 0, lo, hi, q;
|
||||
int pos, run, val;
|
||||
int blk_size = band->blk_size;
|
||||
int num_coeffs = blk_size * blk_size;
|
||||
int col_mask = blk_size - 1;
|
||||
int scan_pos = -1;
|
||||
int min_size = band->pitch * (band->transform_size - 1) +
|
||||
band->transform_size;
|
||||
int buf_size = band->pitch * band->aheight - offs;
|
||||
|
||||
if (min_size > buf_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (!band->scan)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* zero transform vector */
|
||||
memset(trvec, 0, num_coeffs * sizeof(trvec[0]));
|
||||
/* zero column flags */
|
||||
memset(col_flags, 0, sizeof(col_flags));
|
||||
while (scan_pos <= num_coeffs) {
|
||||
sym = get_vlc2(gb, band->blk_vlc.tab->table,
|
||||
IVI_VLC_BITS, 1);
|
||||
if (sym == rvmap->eob_sym)
|
||||
break; /* End of block */
|
||||
|
||||
/* Escape - run/val explicitly coded using 3 vlc codes */
|
||||
if (sym == rvmap->esc_sym) {
|
||||
run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
|
||||
lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
||||
hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
||||
/* merge them and convert into signed val */
|
||||
val = IVI_TOSIGNED((hi << 6) | lo);
|
||||
} else {
|
||||
if (sym >= 256U)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
run = rvmap->runtab[sym];
|
||||
val = rvmap->valtab[sym];
|
||||
}
|
||||
|
||||
/* de-zigzag and dequantize */
|
||||
scan_pos += run;
|
||||
if (scan_pos >= num_coeffs || scan_pos < 0)
|
||||
break;
|
||||
pos = band->scan[scan_pos];
|
||||
|
||||
q = (base_tab[pos] * quant) >> 9;
|
||||
if (q > 1)
|
||||
val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
|
||||
trvec[pos] = val;
|
||||
/* track columns containing non-zero coeffs */
|
||||
col_flags[pos & col_mask] |= !!val;
|
||||
}
|
||||
|
||||
if (scan_pos < 0 || scan_pos >= num_coeffs && sym != rvmap->eob_sym)
|
||||
return AVERROR_INVALIDDATA; /* corrupt block data */
|
||||
|
||||
/* undoing DC coeff prediction for intra-blocks */
|
||||
if (is_intra && band->is_2d_trans) {
|
||||
*prev_dc += trvec[0];
|
||||
trvec[0] = *prev_dc;
|
||||
col_flags[0] |= !!*prev_dc;
|
||||
}
|
||||
|
||||
/* apply inverse transform */
|
||||
band->inv_transform(trvec, band->buf + offs,
|
||||
band->pitch, col_flags);
|
||||
|
||||
/* apply motion compensation */
|
||||
if (!is_intra)
|
||||
return ivi_mc(band, mc, offs, mv_x, mv_y, mc_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
|
||||
{
|
||||
int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val,
|
||||
pos, is_intra, mc_type, mv_x, mv_y, col_mask;
|
||||
uint8_t col_flags[8];
|
||||
int32_t prev_dc, trvec[64];
|
||||
uint32_t cbp, sym, lo, hi, quant, buf_offs, q;
|
||||
IVIMbInfo *mb;
|
||||
RVMapDesc *rvmap = band->rv_map;
|
||||
int mbn, blk, num_blocks, blk_size, ret, is_intra, mc_type = 0;
|
||||
int mv_x = 0, mv_y = 0;
|
||||
int32_t prev_dc;
|
||||
uint32_t cbp, quant, buf_offs;
|
||||
IVIMbInfo *mb;
|
||||
ivi_mc_func mc_with_delta_func, mc_no_delta_func;
|
||||
const uint16_t *base_tab;
|
||||
const uint8_t *scale_tab;
|
||||
|
||||
prev_dc = 0; /* init intra prediction for the DC coefficient */
|
||||
const uint8_t *scale_tab;
|
||||
|
||||
/* init intra prediction for the DC coefficient */
|
||||
prev_dc = 0;
|
||||
blk_size = band->blk_size;
|
||||
col_mask = blk_size - 1; /* column mask for tracking non-zero coeffs */
|
||||
num_blocks = (band->mb_size != blk_size) ? 4 : 1; /* number of blocks per mb */
|
||||
num_coeffs = blk_size * blk_size;
|
||||
/* number of blocks per mb */
|
||||
num_blocks = (band->mb_size != blk_size) ? 4 : 1;
|
||||
if (blk_size == 8) {
|
||||
mc_with_delta_func = ff_ivi_mc_8x8_delta;
|
||||
mc_no_delta_func = ff_ivi_mc_8x8_no_delta;
|
||||
@@ -373,7 +515,6 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
|
||||
|
||||
quant = av_clip(band->glob_quant + mb->q_delta, 0, 23);
|
||||
|
||||
base_tab = is_intra ? band->intra_base : band->inter_base;
|
||||
scale_tab = is_intra ? band->intra_scale : band->inter_scale;
|
||||
if (scale_tab)
|
||||
quant = scale_tab[quant];
|
||||
@@ -396,10 +537,10 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
|
||||
cx = mb->mv_x & band->is_halfpel;
|
||||
cy = mb->mv_y & band->is_halfpel;
|
||||
|
||||
if ( mb->xpos + dmv_x < 0
|
||||
|| mb->xpos + dmv_x + band->mb_size + cx > band->pitch
|
||||
|| mb->ypos + dmv_y < 0
|
||||
|| mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
|
||||
if (mb->xpos + dmv_x < 0 ||
|
||||
mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
|
||||
mb->ypos + dmv_y < 0 ||
|
||||
mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
@@ -415,81 +556,25 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
|
||||
}
|
||||
|
||||
if (cbp & 1) { /* block coded ? */
|
||||
if (!band->scan) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Scan pattern is not set.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
scan_pos = -1;
|
||||
memset(trvec, 0, num_coeffs*sizeof(trvec[0])); /* zero transform vector */
|
||||
memset(col_flags, 0, sizeof(col_flags)); /* zero column flags */
|
||||
|
||||
while (scan_pos <= num_coeffs) {
|
||||
sym = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
||||
if (sym == rvmap->eob_sym)
|
||||
break; /* End of block */
|
||||
|
||||
if (sym == rvmap->esc_sym) { /* Escape - run/val explicitly coded using 3 vlc codes */
|
||||
run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
|
||||
lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
||||
hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
||||
val = IVI_TOSIGNED((hi << 6) | lo); /* merge them and convert into signed val */
|
||||
} else {
|
||||
if (sym >= 256U) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
run = rvmap->runtab[sym];
|
||||
val = rvmap->valtab[sym];
|
||||
}
|
||||
|
||||
/* de-zigzag and dequantize */
|
||||
scan_pos += run;
|
||||
if (scan_pos >= num_coeffs)
|
||||
break;
|
||||
pos = band->scan[scan_pos];
|
||||
|
||||
if (!val)
|
||||
av_dlog(NULL, "Val = 0 encountered!\n");
|
||||
|
||||
q = (base_tab[pos] * quant) >> 9;
|
||||
if (q > 1)
|
||||
val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
|
||||
trvec[pos] = val;
|
||||
col_flags[pos & col_mask] |= !!val; /* track columns containing non-zero coeffs */
|
||||
}// while
|
||||
|
||||
if (scan_pos >= num_coeffs && sym != rvmap->eob_sym)
|
||||
return AVERROR_INVALIDDATA; /* corrupt block data */
|
||||
|
||||
/* undoing DC coeff prediction for intra-blocks */
|
||||
if (is_intra && band->is_2d_trans) {
|
||||
prev_dc += trvec[0];
|
||||
trvec[0] = prev_dc;
|
||||
col_flags[0] |= !!prev_dc;
|
||||
}
|
||||
|
||||
/* apply inverse transform */
|
||||
band->inv_transform(trvec, band->buf + buf_offs,
|
||||
band->pitch, col_flags);
|
||||
|
||||
/* apply motion compensation */
|
||||
if (!is_intra)
|
||||
mc_with_delta_func(band->buf + buf_offs,
|
||||
band->ref_buf + buf_offs + mv_y * band->pitch + mv_x,
|
||||
band->pitch, mc_type);
|
||||
ret = ivi_decode_coded_blocks(gb, band, mc_with_delta_func,
|
||||
mv_x, mv_y, &prev_dc, is_intra,
|
||||
mc_type, quant, buf_offs);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
/* block not coded */
|
||||
/* for intra blocks apply the dc slant transform */
|
||||
/* for inter - perform the motion compensation without delta */
|
||||
if (is_intra) {
|
||||
if (band->dc_transform)
|
||||
band->dc_transform(&prev_dc, band->buf + buf_offs,
|
||||
band->pitch, blk_size);
|
||||
} else
|
||||
mc_no_delta_func(band->buf + buf_offs,
|
||||
band->ref_buf + buf_offs + mv_y * band->pitch + mv_x,
|
||||
band->pitch, mc_type);
|
||||
ret = ivi_dc_transform(band, &prev_dc, buf_offs, blk_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
ret = ivi_mc(band, mc_no_delta_func, buf_offs,
|
||||
mv_x, mv_y, mc_type);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
cbp >>= 1;
|
||||
@@ -514,7 +599,7 @@ static int ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
|
||||
IVITile *tile, int32_t mv_scale)
|
||||
{
|
||||
int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
|
||||
int offs, mb_offset, row_offset;
|
||||
int offs, mb_offset, row_offset, ret;
|
||||
IVIMbInfo *mb, *ref_mb;
|
||||
const int16_t *src;
|
||||
int16_t *dst;
|
||||
@@ -592,9 +677,10 @@ static int ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
|
||||
for (blk = 0; blk < num_blocks; blk++) {
|
||||
/* adjust block position in the buffer according with its number */
|
||||
offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
|
||||
mc_no_delta_func(band->buf + offs,
|
||||
band->ref_buf + offs + mv_y * band->pitch + mv_x,
|
||||
band->pitch, mc_type);
|
||||
ret = ivi_mc(band, mc_no_delta_func, offs,
|
||||
mv_x, mv_y, mc_type);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -757,7 +843,8 @@ static int decode_band(IVI45DecContext *ctx, int plane_num,
|
||||
}
|
||||
}
|
||||
|
||||
/* restore the selected rvmap table by applying its corrections in reverse order */
|
||||
/* restore the selected rvmap table by applying its corrections in
|
||||
* reverse order */
|
||||
for (i = band->num_corr-1; i >= 0; i--) {
|
||||
idx1 = band->corr[i*2];
|
||||
idx2 = band->corr[i*2+1];
|
||||
@@ -770,7 +857,8 @@ static int decode_band(IVI45DecContext *ctx, int plane_num,
|
||||
uint16_t chksum = ivi_calc_band_checksum(band);
|
||||
if (chksum != band->checksum) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n",
|
||||
"Band checksum mismatch! Plane %d, band %d, "
|
||||
"received: %x, calculated: %x\n",
|
||||
band->plane, band->band_num, band->checksum, chksum);
|
||||
}
|
||||
}
|
||||
@@ -807,6 +895,11 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (!ctx->planes[0].bands) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Color planes not initialized yet\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
ctx->switch_buffers(ctx);
|
||||
|
||||
//{ START_TIMER;
|
||||
@@ -837,7 +930,8 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
/* If the bidirectional mode is enabled, next I and the following P frame will */
|
||||
/* be sent together. Unfortunately the approach below seems to be the only way */
|
||||
/* to handle the B-frames mode. That's exactly the same Intel decoders do. */
|
||||
if (avctx->codec_id == CODEC_ID_INDEO4 && ctx->frame_type == 0/*FRAMETYPE_INTRA*/) {
|
||||
if (avctx->codec_id == CODEC_ID_INDEO4 &&
|
||||
ctx->frame_type == 0/*FRAMETYPE_INTRA*/) {
|
||||
while (get_bits(&ctx->gb, 8)); // skip version string
|
||||
skip_bits_long(&ctx->gb, 64); // skip padding, TODO: implement correct 8-bytes alignment
|
||||
if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)
|
||||
@@ -849,7 +943,7 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
|
||||
ctx->frame.reference = 0;
|
||||
avcodec_set_dimensions(avctx, ctx->planes[0].width, ctx->planes[0].height);
|
||||
if ((result = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
if ((result = ff_get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ typedef struct {
|
||||
int num_tiles; ///< number of tiles in this band
|
||||
IVITile *tiles; ///< array of tile descriptors
|
||||
InvTransformPtr *inv_transform;
|
||||
int transform_size;
|
||||
DCTransformPtr *dc_transform;
|
||||
int is_2d_trans; ///< 1 indicates that the two-dimensional inverse transform is used
|
||||
int32_t checksum; ///< for debug purposes
|
||||
|
||||
@@ -143,6 +143,8 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RI
|
||||
ret = ret >> 1;
|
||||
}
|
||||
|
||||
if(FFABS(ret) > 0xFFFF)
|
||||
return -0x10000;
|
||||
/* update state */
|
||||
state->A[Q] += FFABS(ret) - RItype;
|
||||
ret *= state->twonear;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
|
||||
typedef struct {
|
||||
AVCodecContext *avctx;
|
||||
@@ -70,7 +71,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
maxcnt = w * h;
|
||||
|
||||
c->cur.reference = 3;
|
||||
if ((res = avctx->get_buffer(avctx, &c->cur)) < 0)
|
||||
if ((res = ff_get_buffer(avctx, &c->cur)) < 0)
|
||||
return res;
|
||||
out = (uint16_t *) c->cur.data[0];
|
||||
if (c->prev.data[0]) {
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef struct LagarithContext {
|
||||
int zeros; /**< number of consecutive zero bytes encountered */
|
||||
int zeros_rem; /**< number of zero bytes remaining to output */
|
||||
uint8_t *rgb_planes;
|
||||
int rgb_planes_allocated;
|
||||
int rgb_stride;
|
||||
} LagarithContext;
|
||||
|
||||
@@ -507,13 +508,12 @@ static int lag_decode_frame(AVCodecContext *avctx,
|
||||
offs[2] = 13;
|
||||
offs[3] = AV_RL32(buf + 9);
|
||||
|
||||
l->rgb_stride = FFALIGN(avctx->width, 16);
|
||||
av_fast_malloc(&l->rgb_planes, &l->rgb_planes_allocated,
|
||||
l->rgb_stride * avctx->height * 4 + 1);
|
||||
if (!l->rgb_planes) {
|
||||
l->rgb_stride = FFALIGN(avctx->width, 16);
|
||||
l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * 4);
|
||||
if (!l->rgb_planes) {
|
||||
av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
for (i = 0; i < 4; i++)
|
||||
srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;
|
||||
|
||||
@@ -107,6 +107,9 @@ static inline uint8_t lag_get_rac(lag_rac *l)
|
||||
l->range -= range_scaled * l->prob[255];
|
||||
}
|
||||
|
||||
if (!l->range)
|
||||
l->range = 0x80;
|
||||
|
||||
l->low -= range_scaled * l->prob[val];
|
||||
|
||||
return val;
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@
|
||||
#include <gsm/gsm.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "gsm.h"
|
||||
|
||||
static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
|
||||
@@ -188,7 +189,7 @@ static int libgsm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = avctx->frame_size;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
@@ -143,7 +144,7 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = 160;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -295,7 +296,7 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = 320;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <speex/speex_stereo.h>
|
||||
#include <speex/speex_callbacks.h>
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
|
||||
typedef struct {
|
||||
AVFrame frame;
|
||||
@@ -108,7 +109,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = s->frame_size;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+4
-3
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
|
||||
/*
|
||||
* Adapted to libavcodec by Francois Revol <revol@free.fr>
|
||||
@@ -231,8 +232,8 @@ static av_cold int mace_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
MACEContext *ctx = avctx->priv_data;
|
||||
|
||||
if (avctx->channels > 2)
|
||||
return -1;
|
||||
if (avctx->channels > 2 || avctx->channels < 1)
|
||||
return AVERROR(EINVAL);
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
|
||||
avcodec_get_frame_defaults(&ctx->frame);
|
||||
@@ -253,7 +254,7 @@ static int mace_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
ctx->frame.nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
|
||||
if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1111,7 +1111,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (!Al) {
|
||||
s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss);
|
||||
s->coefs_finished[c] |= (2LL << se) - (1LL << ss);
|
||||
last_scan = !~s->coefs_finished[c];
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "dsputil.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "get_bits.h"
|
||||
@@ -982,7 +983,7 @@ static int output_data(MLPDecodeContext *m, unsigned int substr,
|
||||
|
||||
/* get output buffer */
|
||||
m->frame.nb_samples = s->blockpos;
|
||||
if ((ret = avctx->get_buffer(avctx, &m->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &m->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -152,6 +152,8 @@ static int mm_decode_inter(MmContext * s, int half_horiz, int half_vert)
|
||||
int replace_array = bytestream2_get_byte(&s->gb);
|
||||
for(j=0; j<8; j++) {
|
||||
int replace = (replace_array >> (7-j)) & 1;
|
||||
if (x + half_horiz >= s->avctx->width)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (replace) {
|
||||
int color = bytestream2_get_byte(&data_ptr);
|
||||
s->frame.data[0][y*s->frame.linesize[0] + x] = color;
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "libavutil/lfg.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "mpegaudiodsp.h"
|
||||
@@ -217,7 +218,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE;
|
||||
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "libavutil/lfg.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "mpegaudiodsp.h"
|
||||
@@ -253,7 +254,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
c->frame.nb_samples = MPC_FRAME_SIZE;
|
||||
if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||
if ((res = ff_get_buffer(avctx, &c->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
+29
-19
@@ -83,6 +83,15 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
|
||||
return sign_extend(val, 5 + shift);
|
||||
}
|
||||
|
||||
#define check_scantable_index(ctx, x) \
|
||||
do { \
|
||||
if ((x) > 63) { \
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", \
|
||||
ctx->mb_x, ctx->mb_y); \
|
||||
return AVERROR_INVALIDDATA; \
|
||||
} \
|
||||
} while (0) \
|
||||
|
||||
static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
|
||||
{
|
||||
int level, dc, diff, i, j, run;
|
||||
@@ -114,6 +123,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
||||
break;
|
||||
} else if (level != 0) {
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||
level = (level - 1) | 1;
|
||||
@@ -130,6 +140,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
||||
level = SHOW_UBITS(re, &s->gb, 8) ; LAST_SKIP_BITS(re, &s->gb, 8);
|
||||
}
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
if (level < 0) {
|
||||
level = -level;
|
||||
@@ -141,10 +152,6 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
||||
level = (level - 1) | 1;
|
||||
}
|
||||
}
|
||||
if (i > 63) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
|
||||
return -1;
|
||||
}
|
||||
|
||||
block[j] = level;
|
||||
}
|
||||
@@ -264,6 +271,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
|
||||
|
||||
if (level != 0) {
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
level = ((level * 2 + 1) * qscale) >> 1;
|
||||
level = (level - 1) | 1;
|
||||
@@ -280,6 +288,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
|
||||
level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
|
||||
}
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
if (level < 0) {
|
||||
level = -level;
|
||||
@@ -345,6 +354,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
||||
|
||||
if (level != 0) {
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||
@@ -356,6 +366,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
if (level < 0) {
|
||||
level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||
@@ -364,10 +375,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
||||
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||
}
|
||||
}
|
||||
if (i > 63) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mismatch ^= level;
|
||||
block[j] = level;
|
||||
@@ -414,6 +421,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
||||
|
||||
if (level != 0) {
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
level = ((level * 2 + 1) * qscale) >> 1;
|
||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||
@@ -425,6 +433,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
if (level < 0) {
|
||||
level = ((-level * 2 + 1) * qscale) >> 1;
|
||||
@@ -491,6 +500,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
||||
break;
|
||||
} else if (level != 0) {
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||
@@ -501,6 +511,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
||||
UPDATE_CACHE(re, &s->gb);
|
||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
if (level < 0) {
|
||||
level = (-level * qscale * quant_matrix[j]) >> 4;
|
||||
@@ -509,10 +520,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||
}
|
||||
}
|
||||
if (i > 63) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mismatch ^= level;
|
||||
block[j] = level;
|
||||
@@ -527,10 +534,10 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
||||
|
||||
static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
|
||||
{
|
||||
int level, dc, diff, j, run;
|
||||
int level, dc, diff, i, j, run;
|
||||
int component;
|
||||
RLTable *rl;
|
||||
uint8_t * scantable = s->intra_scantable.permutated;
|
||||
uint8_t * const scantable = s->intra_scantable.permutated;
|
||||
const uint16_t *quant_matrix;
|
||||
const int qscale = s->qscale;
|
||||
|
||||
@@ -549,6 +556,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
||||
dc += diff;
|
||||
s->last_dc[component] = dc;
|
||||
block[0] = dc << (3 - s->intra_dc_precision);
|
||||
i = 0;
|
||||
if (s->intra_vlc_format)
|
||||
rl = &ff_rl_mpeg2;
|
||||
else
|
||||
@@ -564,8 +572,9 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
||||
if (level == 127) {
|
||||
break;
|
||||
} else if (level != 0) {
|
||||
scantable += run;
|
||||
j = *scantable;
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||
LAST_SKIP_BITS(re, &s->gb, 1);
|
||||
@@ -574,8 +583,9 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
||||
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
|
||||
UPDATE_CACHE(re, &s->gb);
|
||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||
scantable += run;
|
||||
j = *scantable;
|
||||
i += run;
|
||||
check_scantable_index(s, i);
|
||||
j = scantable[i];
|
||||
if (level < 0) {
|
||||
level = (-level * qscale * quant_matrix[j]) >> 4;
|
||||
level = -level;
|
||||
@@ -589,7 +599,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
||||
CLOSE_READER(re, &s->gb);
|
||||
}
|
||||
|
||||
s->block_last_index[n] = scantable - s->intra_scantable.permutated;
|
||||
s->block_last_index[n] = i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ static inline int mpeg4_is_resync(MpegEncContext *s){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
|
||||
static int mpeg4_decode_sprite_trajectory(MpegEncContext *s, GetBitContext *gb)
|
||||
{
|
||||
int i;
|
||||
int a= 2<<s->sprite_warping_accuracy;
|
||||
@@ -176,8 +176,8 @@ static int mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
|
||||
int h= s->height;
|
||||
int min_ab;
|
||||
|
||||
if(w<=0 || h<=0)
|
||||
return -1;
|
||||
if (w <= 0 || h <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for(i=0; i<s->num_sprite_warping_points; i++){
|
||||
int length;
|
||||
@@ -415,8 +415,8 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s)
|
||||
skip_bits(&s->gb, 3); /* intra dc vlc threshold */
|
||||
//FIXME don't just ignore everything
|
||||
if(s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
|
||||
if(mpeg4_decode_sprite_trajectory(s, &s->gb) < 0)
|
||||
return -1;
|
||||
if (mpeg4_decode_sprite_trajectory(s, &s->gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
av_log(s->avctx, AV_LOG_ERROR, "untested\n");
|
||||
}
|
||||
|
||||
@@ -2056,8 +2056,8 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
|
||||
}
|
||||
|
||||
if(s->pict_type == AV_PICTURE_TYPE_S && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
|
||||
if(mpeg4_decode_sprite_trajectory(s, gb) < 0)
|
||||
return -1;
|
||||
if (mpeg4_decode_sprite_trajectory(s, gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
|
||||
if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "libavutil/audioconvert.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "mathops.h"
|
||||
#include "mpegaudiodsp.h"
|
||||
@@ -1602,7 +1603,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples,
|
||||
/* get output buffer */
|
||||
if (!samples) {
|
||||
s->frame.nb_samples = s->avctx->frame_size;
|
||||
if ((ret = s->avctx->get_buffer(s->avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(s->avctx, &s->frame)) < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -1908,7 +1909,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame->nb_samples = MPA_FRAME_SIZE;
|
||||
if ((ret = avctx->get_buffer(avctx, s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -1941,7 +1942,8 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
|
||||
|
||||
avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);
|
||||
|
||||
if (ch + m->nb_channels > avctx->channels) {
|
||||
if (ch + m->nb_channels > avctx->channels ||
|
||||
s->coff[fr] + m->nb_channels > avctx->channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec "
|
||||
"channel count\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
+12
-2
@@ -1237,8 +1237,13 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
||||
i = ff_find_unused_picture(s, 0);
|
||||
if (i < 0)
|
||||
return i;
|
||||
s->last_picture_ptr= &s->picture[i];
|
||||
|
||||
s->last_picture_ptr = &s->picture[i];
|
||||
|
||||
s->last_picture_ptr->f.reference = 3;
|
||||
s->last_picture_ptr->f.key_frame = 0;
|
||||
s->last_picture_ptr->f.pict_type = AV_PICTURE_TYPE_P;
|
||||
|
||||
if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0)
|
||||
return -1;
|
||||
|
||||
@@ -1259,8 +1264,13 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
||||
i = ff_find_unused_picture(s, 0);
|
||||
if (i < 0)
|
||||
return i;
|
||||
s->next_picture_ptr= &s->picture[i];
|
||||
|
||||
s->next_picture_ptr = &s->picture[i];
|
||||
|
||||
s->next_picture_ptr->f.reference = 3;
|
||||
s->next_picture_ptr->f.key_frame = 0;
|
||||
s->next_picture_ptr->f.pict_type = AV_PICTURE_TYPE_P;
|
||||
|
||||
if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0)
|
||||
return -1;
|
||||
ff_thread_report_progress((AVFrame *) s->next_picture_ptr,
|
||||
|
||||
@@ -686,6 +686,9 @@ typedef struct MpegEncContext {
|
||||
int (*dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
|
||||
int (*fast_dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
|
||||
void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block);
|
||||
|
||||
uint8_t *pkt_swapped;
|
||||
int pkt_swapped_allocated;
|
||||
} MpegEncContext;
|
||||
|
||||
#define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
#include "msrledec.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
|
||||
typedef struct MsrleContext {
|
||||
AVCodecContext *avctx;
|
||||
@@ -108,7 +109,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
/* FIXME how to correctly detect RLE ??? */
|
||||
if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
|
||||
int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8;
|
||||
int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
|
||||
uint8_t *ptr = s->frame.data[0];
|
||||
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
|
||||
int i, j;
|
||||
|
||||
@@ -25,8 +25,10 @@
|
||||
* MxPEG decoder
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "mjpeg.h"
|
||||
#include "mjpegdec.h"
|
||||
#include "internal.h"
|
||||
|
||||
typedef struct MXpegDecodeContext {
|
||||
MJpegDecodeContext jpg;
|
||||
@@ -250,7 +252,7 @@ static int mxpeg_decode_frame(AVCodecContext *avctx,
|
||||
/* use stored SOF data to allocate current picture */
|
||||
if (jpg->picture_ptr->data[0])
|
||||
avctx->release_buffer(avctx, jpg->picture_ptr);
|
||||
if (avctx->get_buffer(avctx, jpg->picture_ptr) < 0) {
|
||||
if (ff_get_buffer(avctx, jpg->picture_ptr) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
@@ -269,7 +271,7 @@ static int mxpeg_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
/* allocate dummy reference picture if needed */
|
||||
if (!reference_ptr->data[0] &&
|
||||
avctx->get_buffer(avctx, reference_ptr) < 0) {
|
||||
ff_get_buffer(avctx, reference_ptr) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "libavutil/random_seed.h"
|
||||
#include "libavutil/audioconvert.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
#include "fmtconvert.h"
|
||||
@@ -184,7 +185,7 @@ static int decode_tag(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = NELLY_SAMPLES * blocks;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
+31
-19
@@ -85,7 +85,7 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c,
|
||||
int i;
|
||||
if (size < 2 * 64 * 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "insufficient rtjpeg quant data\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
for (i = 0; i < 64; i++, buf += 4)
|
||||
c->lq[i] = AV_RL32(buf);
|
||||
@@ -108,6 +108,8 @@ static void get_quant_quality(NuvContext *c, int quality) {
|
||||
|
||||
static int codec_reinit(AVCodecContext *avctx, int width, int height, int quality) {
|
||||
NuvContext *c = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
width = FFALIGN(width, 2);
|
||||
height = FFALIGN(height, 2);
|
||||
if (quality >= 0)
|
||||
@@ -115,12 +117,14 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, int qualit
|
||||
if (width != c->width || height != c->height) {
|
||||
// also reserve space for a possible additional header
|
||||
int buf_size = 24 + height * width * 3 / 2 + AV_LZO_OUTPUT_PADDING;
|
||||
if (av_image_check_size(height, width, 0, avctx) < 0 ||
|
||||
buf_size > INT_MAX/8)
|
||||
if (buf_size > INT_MAX/8)
|
||||
return -1;
|
||||
if ((ret = av_image_check_size(height, width, 0, avctx)) < 0)
|
||||
return ret;
|
||||
avctx->width = c->width = width;
|
||||
avctx->height = c->height = height;
|
||||
av_fast_malloc(&c->decomp_buf, &c->decomp_size, buf_size);
|
||||
av_fast_malloc(&c->decomp_buf, &c->decomp_size,
|
||||
buf_size);
|
||||
if (!c->decomp_buf) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -142,13 +146,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
int keyframe;
|
||||
int size_change = 0;
|
||||
int result;
|
||||
int ret;
|
||||
enum {NUV_UNCOMPRESSED = '0', NUV_RTJPEG = '1',
|
||||
NUV_RTJPEG_IN_LZO = '2', NUV_LZO = '3',
|
||||
NUV_BLACK = 'N', NUV_COPY_LAST = 'L'} comptype;
|
||||
|
||||
if (buf_size < 12) {
|
||||
av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
// codec data (rtjpeg quant tables)
|
||||
@@ -166,7 +171,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
|
||||
if (buf[0] != 'V' || buf_size < 12) {
|
||||
av_log(avctx, AV_LOG_ERROR, "not a nuv video frame\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
comptype = buf[1];
|
||||
switch (comptype) {
|
||||
@@ -183,14 +188,17 @@ retry:
|
||||
buf = &buf[12];
|
||||
buf_size -= 12;
|
||||
if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) {
|
||||
int outlen = c->decomp_size - AV_LZO_OUTPUT_PADDING, inlen = buf_size;
|
||||
if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen))
|
||||
int outlen = c->decomp_size - FFMAX(FF_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING);
|
||||
int inlen = buf_size;
|
||||
if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
buf = c->decomp_buf;
|
||||
buf_size = c->decomp_size - AV_LZO_OUTPUT_PADDING - outlen;
|
||||
buf_size = c->decomp_size - FFMAX(FF_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING) - outlen;
|
||||
}
|
||||
if (c->codec_frameheader) {
|
||||
int w, h, q, res;
|
||||
int w, h, q;
|
||||
if (buf_size < RTJPEG_HEADER_SIZE || buf[4] != RTJPEG_HEADER_SIZE ||
|
||||
buf[5] != RTJPEG_FILE_VERSION) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame\n");
|
||||
@@ -199,11 +207,10 @@ retry:
|
||||
w = AV_RL16(&buf[6]);
|
||||
h = AV_RL16(&buf[8]);
|
||||
q = buf[10];
|
||||
if ((result = codec_reinit(avctx, w, h, q)) < 0)
|
||||
return result;
|
||||
|
||||
res = codec_reinit(avctx, w, h, q);
|
||||
if (res < 0)
|
||||
return res;
|
||||
if (res) {
|
||||
if (result) {
|
||||
buf = avpkt->data;
|
||||
buf_size = avpkt->size;
|
||||
size_change = 1;
|
||||
@@ -221,7 +228,7 @@ retry:
|
||||
result = avctx->reget_buffer(avctx, &c->pic);
|
||||
if (result < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
||||
@@ -240,7 +247,9 @@ retry:
|
||||
}
|
||||
case NUV_RTJPEG_IN_LZO:
|
||||
case NUV_RTJPEG: {
|
||||
rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
|
||||
ret = rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
case NUV_BLACK: {
|
||||
@@ -255,7 +264,7 @@ retry:
|
||||
}
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
*picture = c->pic;
|
||||
@@ -265,6 +274,8 @@ retry:
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx) {
|
||||
NuvContext *c = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
avctx->pix_fmt = PIX_FMT_YUV420P;
|
||||
c->pic.data[0] = NULL;
|
||||
c->decomp_buf = NULL;
|
||||
@@ -275,8 +286,9 @@ static av_cold int decode_init(AVCodecContext *avctx) {
|
||||
if (avctx->extradata_size)
|
||||
get_quant(avctx, c, avctx->extradata, avctx->extradata_size);
|
||||
dsputil_init(&c->dsp, avctx);
|
||||
if (codec_reinit(avctx, avctx->width, avctx->height, -1) < 0)
|
||||
return 1;
|
||||
if ((ret = codec_reinit(avctx, avctx->width, avctx->height, -1)) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "libavutil/audioconvert.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "bytestream.h"
|
||||
|
||||
/*
|
||||
@@ -163,7 +164,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = samples;
|
||||
if ((retval = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((retval = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return retval;
|
||||
}
|
||||
|
||||
+2
-1
@@ -48,6 +48,7 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx)
|
||||
|
||||
avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
|
||||
avctx->block_align = avctx->channels * avctx->bits_per_coded_sample/8;
|
||||
avctx->bit_rate = avctx->block_align * avctx->sample_rate * 8;
|
||||
avctx->coded_frame= avcodec_alloc_frame();
|
||||
avctx->coded_frame->key_frame= 1;
|
||||
|
||||
@@ -304,7 +305,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = n * samples_per_block / avctx->channels;
|
||||
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user