Compare commits
98 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1eb646ec9f | |||
| c809cf1c5b | |||
| 5e833d958c | |||
| ffcfab882b | |||
| d8c82ed321 | |||
| 983dc64772 | |||
| 98aedbf9fe | |||
| 18189ebab3 | |||
| 74a88a509c | |||
| ff68bf7a1b | |||
| ef905b1b27 | |||
| ad03cef420 | |||
| be369f6e40 | |||
| 1166d9245a | |||
| c72c1b8716 | |||
| 8696762b9a | |||
| 384f6801a2 | |||
| b7c8d072ea | |||
| 46236b0bae | |||
| d819a2c986 | |||
| 3953c497e2 | |||
| 40f5222e9c | |||
| 3e167497c7 | |||
| 95d8912bfd | |||
| 1cb19f4f08 | |||
| 3489693051 | |||
| abe503329d | |||
| 80e091853d | |||
| d137bb92b2 | |||
| 4f4ff23ccb | |||
| dcfd83fb8e | |||
| 29a97823ba | |||
| e9deb55810 | |||
| dec0316c0f | |||
| 1b15487e90 | |||
| 58070590b1 | |||
| 68650eda95 | |||
| c7cb598bdd | |||
| 6a71e748b3 | |||
| 0628dfd994 | |||
| d661cfad02 | |||
| 755c3222e2 | |||
| bf44ab5181 | |||
| 98d916300a | |||
| 1fc2a1f336 | |||
| 3528822f96 | |||
| 8f06795533 | |||
| 7085f68c14 | |||
| 17b7262b4f | |||
| f9dbe8ab2a | |||
| 7ff8f9a604 | |||
| a5bc5dd49a | |||
| 5464da8905 | |||
| fc0df14de1 | |||
| dd141a50cc | |||
| 568c1b8166 | |||
| 3903a60d4b | |||
| 58a0dc1bdf | |||
| da13957525 | |||
| 27d50fb2d5 | |||
| e4e3b14bba | |||
| b4d265e2dc | |||
| a1879d347e | |||
| 7a12379463 | |||
| 7d03a9156d | |||
| bda906a195 | |||
| 3c99f8b4ad | |||
| f5a73058b0 | |||
| a2a545d8db | |||
| fb22fc0c46 | |||
| 062f63e46c | |||
| 057d6e1cd6 | |||
| cdd594e24b | |||
| 5ebae729b9 | |||
| 177014a494 | |||
| 3dd5c6a4ba | |||
| de943a3460 | |||
| 1728aa3442 | |||
| f569422d66 | |||
| 3dc303a051 | |||
| 42c54f8f4d | |||
| fd989ff9ca | |||
| 6b2163caab | |||
| a61759596d | |||
| 8d98fbef16 | |||
| 4ac8b94a73 | |||
| e83d998634 | |||
| 962ad32891 | |||
| 9e1a818a2d | |||
| f1a4af4dc2 | |||
| 51a624bb80 | |||
| e9502ee26a | |||
| 11f597ed84 | |||
| 2e210e19b1 | |||
| d4c7a1ecb8 | |||
| 2d55d3483b | |||
| e29f68cf9e | |||
| f621ae6a6d |
@@ -1,6 +1,103 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 2.5.8
|
||||
- snow: remove an obsolete av_assert2
|
||||
- huffyuvdec: validate image size
|
||||
- vc1dec: use get_bits_long and limit the read bits to 32
|
||||
- mpegaudiodec: copy AVFloatDSPContext from first context to all contexts
|
||||
- libshine: fix support for shine 3.0
|
||||
- avidec: check for valid bit_rate range
|
||||
- avformat/nut: support WavPack
|
||||
- avcodec/diracdec: Check slices malloc and propagate error code
|
||||
- avcodec/vp8: Check buffer size in vp8_decode_frame_header()
|
||||
- avcodec/vp8: Fix null pointer dereference in ff_vp8_decode_free()
|
||||
- avcodec/diracdec: Check for hpel_base allocation failure
|
||||
- avcodec/rv34: Clear pointers in ff_rv34_decode_init_thread_copy()
|
||||
- avfilter/af_aresample: Check ff_all_* for allocation failures
|
||||
- avcodec/pthread_frame: clear priv_data, avoid stale pointer in error case
|
||||
- swscale/utils: Clear pix buffers
|
||||
- avutil/fifo: Fix the case where func() returns less bytes than requested in av_fifo_generic_write()
|
||||
- avformat/mov: Fix deallocation when MOVStreamContext failed to allocate
|
||||
- ffmpeg: Fix crash with ost->last_frame allocation failure
|
||||
- ffmpeg: Fix cleanup with ost = NULL
|
||||
- avcodec/pthread_frame: check avctx on deallocation
|
||||
- avcodec/sanm: Reset sizes in destroy_buffers()
|
||||
- avcodec/alac: Clear pointers in allocate_buffers()
|
||||
- bytestream2: set the reader to the end when reading more than available
|
||||
- avcodec/utils: use a minimum 32pixel width in avcodec_align_dimensions2() for H.264
|
||||
- avcodec/mpegvideo: Clear pointers in ff_mpv_common_init()
|
||||
- oggparsedirac: check return value of init_get_bits
|
||||
- wmalosslessdec: reset frame->nb_samples on packet loss
|
||||
- wmalosslessdec: avoid reading 0 bits with get_bits
|
||||
- avcodec/rawenc: Use ff_alloc_packet() instead of ff_alloc_packet2()
|
||||
- avcodec/aacsbr: Assert that bs_num_env is positive
|
||||
- avcodec/aacsbr: check that the element type matches before applying SBR
|
||||
- avcodec/h264_slice: Use w/h from the AVFrame instead of mb_w/h
|
||||
- vp9/update_prob: prevent out of bounds table read
|
||||
- avfilter/vf_transpose: Fix rounding error
|
||||
- avcodec/pngdec: Check values before updating context in decode_fctl_chunk()
|
||||
- avcodec/pngdec: Require a IHDR chunk before fctl
|
||||
- avcodec/pngdec: Only allow one IHDR chunk
|
||||
- wmavoice: limit wmavoice_decode_packet return value to packet size
|
||||
- swscale/swscale_unscaled: Fix rounding difference with RGBA output between little and big endian
|
||||
- ffmpeg: Do not use the data/size of a bitstream filter after failure
|
||||
- swscale/x86/rgb2rgb_template: fix signedness of v in shuffle_bytes_2103_{mmx,mmxext}
|
||||
- swscale/x86/rgb2rgb_template: add missing xmm clobbers
|
||||
- vda: unlock the pixel buffer base address.
|
||||
- swscale/rgb2rgb_template: Fix signedness of v in shuffle_bytes_2103_c()
|
||||
- swscale/rgb2rgb_template: Implement shuffle_bytes_0321_c and fix shuffle_bytes_2103_c on BE
|
||||
- swscale/rgb2rgb_template: Disable shuffle_bytes_2103_c on big endian
|
||||
- swr: Remember previously set int_sample_format from user
|
||||
- matroskadec: check audio sample rate
|
||||
- matroskadec: validate audio channels and bitdepth
|
||||
- avcodec/dpxenc: implement write16/32 as functions
|
||||
- postproc: fix unaligned access
|
||||
- ffmpeg: Free last_frame instead of just unref
|
||||
- avio: fix potential crashes when combining ffio_ensure_seekback + crc
|
||||
- h264: er: Copy from the previous reference only if compatible
|
||||
- sonic: set avctx->channels in sonic_decode_init
|
||||
- vp8: change mv_{min,max}.{x,y} type to int
|
||||
- vp9: change type of tile_size from unsigned to int64_t
|
||||
- arm: only enable setend on ARMv6
|
||||
- libopenjpegdec: check existence of image component data
|
||||
- mov: abort on EOF in ff_mov_read_chan
|
||||
- ffmpeg_opt: Check for localtime() failure
|
||||
- avformat: Fix bug in parse_rps for HEVC.
|
||||
- takdec: ensure chan2 is a valid channel index
|
||||
- avcodec/h264_slice: Use AVFrame diemensions for grayscale handling
|
||||
- avdevice/lavfi: do not rescale AV_NOPTS_VALUE in lavfi_read_packet()
|
||||
- libavutil/channel_layout: Correctly return layout when channel specification ends with a trailing 'c'.
|
||||
- avcodec/jpeg2000dec: Check that coords match before applying ICT
|
||||
- avformat/ffmdec: Check ffio_set_buf_size() return value
|
||||
- avcodec/adpcm: Check for overreads
|
||||
- avcodec/alsdec: Check for overread
|
||||
- avcodec/atrac3plusdec: consume only as many bytes as available
|
||||
- libavutil/softfloat: Fix av_normalize1_sf bias.
|
||||
- swresample/swresample: Cleanup on init failure.
|
||||
- Revert "avformat/rtpenc: check av_packet_get_side_data() return, fix null ptr dereference"
|
||||
- avformat/mxfenc: Accept MXF D-10 with 49.999840 Mbit/sec
|
||||
- swresample/dither: check memory allocation
|
||||
- libopenjpegenc: add NULL check for img before accessing it
|
||||
- swresample: Check the return value of resampler->init()
|
||||
- h264: Make sure reinit failures mark the context as not initialized
|
||||
- ffmpeg_opt: Set the video VBV parameters only for the video stream from -target
|
||||
- avcodec/bitstream: Assert that there is enough space left in avpriv_copy_bits()
|
||||
- avcodec/put_bits: Assert that there is enough space left in skip_put_bytes()
|
||||
- avcodec/mpegvideo_enc: Update the buffer size as more slices are merged
|
||||
- avcodec/put_bits: Update size_in_bits in set_put_bits_buffer_size()
|
||||
- avformat/wavdec: Increase dts packet threshold to fix more misdetections
|
||||
- avformat/wavdec: Increase probe_packets limit
|
||||
- avformat/swfdec: Do not error out on pixel format changes
|
||||
- avfilter/x86/vf_hqdn3d: Fix register types
|
||||
- avcodec/mjpegenc_common: Use ff_mpv_reallocate_putbitbuffer()
|
||||
- avcodec/mpegvideo: Factor ff_mpv_reallocate_putbitbuffer() out
|
||||
- avformat/mov: Mark avio context of decompressed atoms as seekable
|
||||
- avcodec/hevc_ps: Only discard overread VPS if a previous is available
|
||||
- avcodec/x86/h264_weight: handle weight1=128
|
||||
- avcodec/exr: fix crash caused by merge
|
||||
|
||||
|
||||
version 2.5.7
|
||||
- avformat/nutdec: Fix recovery when immedeately after seeking a failure happens
|
||||
- nutdec: fix memleaks on error in nut_read_header
|
||||
|
||||
+1
-1
@@ -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 = 2.5.7
|
||||
PROJECT_NUMBER = 2.5.8
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
@@ -466,7 +466,12 @@ static void ffmpeg_cleanup(int ret)
|
||||
}
|
||||
for (i = 0; i < nb_output_streams; i++) {
|
||||
OutputStream *ost = output_streams[i];
|
||||
AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
|
||||
AVBitStreamFilterContext *bsfc;
|
||||
|
||||
if (!ost)
|
||||
continue;
|
||||
|
||||
bsfc = ost->bitstream_filters;
|
||||
while (bsfc) {
|
||||
AVBitStreamFilterContext *next = bsfc->next;
|
||||
av_bitstream_filter_close(bsfc);
|
||||
@@ -650,6 +655,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
|
||||
if (!new_pkt.buf)
|
||||
exit_program(1);
|
||||
} else if (a < 0) {
|
||||
new_pkt = *pkt;
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open bitstream filter %s for stream %d with codec %s",
|
||||
bsfc->filter->name, pkt->stream_index,
|
||||
avctx->codec ? avctx->codec->name : "copy");
|
||||
@@ -1142,7 +1148,10 @@ static void do_video_out(AVFormatContext *s,
|
||||
if (!ost->last_frame)
|
||||
ost->last_frame = av_frame_alloc();
|
||||
av_frame_unref(ost->last_frame);
|
||||
av_frame_ref(ost->last_frame, next_picture);
|
||||
if (next_picture && ost->last_frame)
|
||||
av_frame_ref(ost->last_frame, next_picture);
|
||||
else
|
||||
av_frame_free(&ost->last_frame);
|
||||
}
|
||||
|
||||
static double psnr(double d)
|
||||
|
||||
+12
-9
@@ -2248,9 +2248,9 @@ static int opt_target(void *optctx, const char *opt, const char *arg)
|
||||
opt_default(NULL, "g", norm == PAL ? "15" : "18");
|
||||
|
||||
opt_default(NULL, "b:v", "1150000");
|
||||
opt_default(NULL, "maxrate", "1150000");
|
||||
opt_default(NULL, "minrate", "1150000");
|
||||
opt_default(NULL, "bufsize", "327680"); // 40*1024*8;
|
||||
opt_default(NULL, "maxrate:v", "1150000");
|
||||
opt_default(NULL, "minrate:v", "1150000");
|
||||
opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8;
|
||||
|
||||
opt_default(NULL, "b:a", "224000");
|
||||
parse_option(o, "ar", "44100", options);
|
||||
@@ -2277,9 +2277,9 @@ static int opt_target(void *optctx, const char *opt, const char *arg)
|
||||
opt_default(NULL, "g", norm == PAL ? "15" : "18");
|
||||
|
||||
opt_default(NULL, "b:v", "2040000");
|
||||
opt_default(NULL, "maxrate", "2516000");
|
||||
opt_default(NULL, "minrate", "0"); // 1145000;
|
||||
opt_default(NULL, "bufsize", "1835008"); // 224*1024*8;
|
||||
opt_default(NULL, "maxrate:v", "2516000");
|
||||
opt_default(NULL, "minrate:v", "0"); // 1145000;
|
||||
opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
|
||||
opt_default(NULL, "scan_offset", "1");
|
||||
|
||||
opt_default(NULL, "b:a", "224000");
|
||||
@@ -2299,9 +2299,9 @@ static int opt_target(void *optctx, const char *opt, const char *arg)
|
||||
opt_default(NULL, "g", norm == PAL ? "15" : "18");
|
||||
|
||||
opt_default(NULL, "b:v", "6000000");
|
||||
opt_default(NULL, "maxrate", "9000000");
|
||||
opt_default(NULL, "minrate", "0"); // 1500000;
|
||||
opt_default(NULL, "bufsize", "1835008"); // 224*1024*8;
|
||||
opt_default(NULL, "maxrate:v", "9000000");
|
||||
opt_default(NULL, "minrate:v", "0"); // 1500000;
|
||||
opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
|
||||
|
||||
opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
|
||||
opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
|
||||
@@ -2345,6 +2345,9 @@ static int opt_vstats(void *optctx, const char *opt, const char *arg)
|
||||
time_t today2 = time(NULL);
|
||||
struct tm *today = localtime(&today2);
|
||||
|
||||
if (!today)
|
||||
return AVERROR(errno);
|
||||
|
||||
snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
|
||||
today->tm_sec);
|
||||
return opt_vstats_file(NULL, opt, filename);
|
||||
|
||||
@@ -77,6 +77,8 @@ static int vda_retrieve_data(AVCodecContext *s, AVFrame *frame)
|
||||
frame->width, frame->height);
|
||||
|
||||
ret = av_frame_copy_props(vda->tmp_frame, frame);
|
||||
CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -1018,6 +1018,8 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr,
|
||||
{
|
||||
unsigned int cnt = get_bits_count(gb);
|
||||
|
||||
sbr->id_aac = id_aac;
|
||||
|
||||
if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) {
|
||||
if (read_sbr_single_channel_element(ac, sbr, gb)) {
|
||||
sbr_turnoff(sbr);
|
||||
@@ -1694,6 +1696,12 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
|
||||
int nch = (id_aac == TYPE_CPE) ? 2 : 1;
|
||||
int err;
|
||||
|
||||
if (id_aac != sbr->id_aac) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR,
|
||||
"element type mismatch %d != %d\n", id_aac, sbr->id_aac);
|
||||
sbr_turnoff(sbr);
|
||||
}
|
||||
|
||||
if (!sbr->kx_and_m_pushed) {
|
||||
sbr->kx[0] = sbr->kx[1];
|
||||
sbr->m[0] = sbr->m[1];
|
||||
@@ -1717,6 +1725,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
|
||||
sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1,
|
||||
(const float (*)[40][2]) sbr->X_low, sbr->k[0]);
|
||||
sbr_chirp(sbr, &sbr->data[ch]);
|
||||
av_assert0(sbr->data[ch].bs_num_env > 0);
|
||||
sbr_hf_gen(ac, sbr, sbr->X_high,
|
||||
(const float (*)[40][2]) sbr->X_low,
|
||||
(const float (*)[2]) sbr->alpha0,
|
||||
|
||||
+12
-1
@@ -574,6 +574,8 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
case AV_CODEC_ID_ADPCM_IMA_DK4:
|
||||
if (avctx->block_align > 0)
|
||||
buf_size = FFMIN(buf_size, avctx->block_align);
|
||||
if (buf_size < 4 * ch)
|
||||
return AVERROR_INVALIDDATA;
|
||||
nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_IMA_RAD:
|
||||
@@ -587,13 +589,15 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
|
||||
if (avctx->block_align > 0)
|
||||
buf_size = FFMIN(buf_size, avctx->block_align);
|
||||
if (buf_size < 4 * ch)
|
||||
return AVERROR_INVALIDDATA;
|
||||
nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
|
||||
break;
|
||||
}
|
||||
case AV_CODEC_ID_ADPCM_MS:
|
||||
if (avctx->block_align > 0)
|
||||
buf_size = FFMIN(buf_size, avctx->block_align);
|
||||
nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
|
||||
nb_samples = (buf_size - 6 * ch) * 2 / ch;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_SBPRO_2:
|
||||
case AV_CODEC_ID_ADPCM_SBPRO_3:
|
||||
@@ -606,6 +610,8 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
|
||||
}
|
||||
if (!s->status[0].step_index) {
|
||||
if (buf_size < ch)
|
||||
return AVERROR_INVALIDDATA;
|
||||
nb_samples++;
|
||||
buf_size -= ch;
|
||||
}
|
||||
@@ -1524,6 +1530,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
|
||||
if (avpkt->size < bytestream2_tell(&gb)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Overread of %d < %d\n", avpkt->size, bytestream2_tell(&gb));
|
||||
return avpkt->size;
|
||||
}
|
||||
|
||||
return bytestream2_tell(&gb);
|
||||
}
|
||||
|
||||
|
||||
@@ -533,6 +533,12 @@ static int allocate_buffers(ALACContext *alac)
|
||||
int ch;
|
||||
int buf_size = alac->max_samples_per_frame * sizeof(int32_t);
|
||||
|
||||
for (ch = 0; ch < 2; ch++) {
|
||||
alac->predict_error_buffer[ch] = NULL;
|
||||
alac->output_samples_buffer[ch] = NULL;
|
||||
alac->extra_bits_buffer[ch] = NULL;
|
||||
}
|
||||
|
||||
for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
|
||||
FF_ALLOC_OR_GOTO(alac->avctx, alac->predict_error_buffer[ch],
|
||||
buf_size, buf_alloc_fail);
|
||||
|
||||
@@ -1493,6 +1493,11 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
||||
|
||||
// TODO: read_diff_float_data
|
||||
|
||||
if (get_bits_left(gb) < 0) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Overread %d\n", -get_bits_left(gb));
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
|
||||
return avctx->block_align;
|
||||
return FFMIN(avctx->block_align, avpkt->size);
|
||||
}
|
||||
|
||||
AVCodec ff_atrac3p_decoder = {
|
||||
|
||||
@@ -69,6 +69,8 @@ void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
av_assert0(length <= put_bits_left(pb));
|
||||
|
||||
if (CONFIG_SMALL || words < 16 || put_bits_count(pb) & 7) {
|
||||
for (i = 0; i < words; i++)
|
||||
put_bits(pb, 16, AV_RB16(src + 2 * i));
|
||||
|
||||
@@ -71,8 +71,10 @@ static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \
|
||||
} \
|
||||
static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \
|
||||
{ \
|
||||
if (g->buffer_end - g->buffer < bytes) \
|
||||
if (g->buffer_end - g->buffer < bytes) { \
|
||||
g->buffer = g->buffer_end; \
|
||||
return 0; \
|
||||
} \
|
||||
return bytestream2_get_ ## name ## u(g); \
|
||||
} \
|
||||
static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \
|
||||
|
||||
+21
-7
@@ -772,7 +772,7 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
|
||||
* Dirac Specification ->
|
||||
* 13.5.1 low_delay_transform_data()
|
||||
*/
|
||||
static void decode_lowdelay(DiracContext *s)
|
||||
static int decode_lowdelay(DiracContext *s)
|
||||
{
|
||||
AVCodecContext *avctx = s->avctx;
|
||||
int slice_x, slice_y, bytes, bufsize;
|
||||
@@ -781,6 +781,8 @@ static void decode_lowdelay(DiracContext *s)
|
||||
int slice_num = 0;
|
||||
|
||||
slices = av_mallocz_array(s->lowdelay.num_x, s->lowdelay.num_y * sizeof(struct lowdelay_slice));
|
||||
if (!slices)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
align_get_bits(&s->gb);
|
||||
/*[DIRAC_STD] 13.5.2 Slices. slice(sx,sy) */
|
||||
@@ -811,6 +813,7 @@ static void decode_lowdelay(DiracContext *s)
|
||||
intra_dc_prediction(&s->plane[1].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
|
||||
intra_dc_prediction(&s->plane[2].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
|
||||
av_free(slices);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_planes(DiracContext *s)
|
||||
@@ -1561,7 +1564,7 @@ static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen,
|
||||
}
|
||||
}
|
||||
|
||||
static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
|
||||
static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
|
||||
{
|
||||
/* chroma allocates an edge of 8 when subsampled
|
||||
which for 4:2:2 means an h edge of 16 and v edge of 8
|
||||
@@ -1573,11 +1576,14 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
|
||||
|
||||
/* no need for hpel if we only have fpel vectors */
|
||||
if (!s->mv_precision)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < 4; i++) {
|
||||
if (!ref->hpel_base[plane][i])
|
||||
ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe->linesize[plane] + 32);
|
||||
if (!ref->hpel_base[plane][i]) {
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
/* we need to be 16-byte aligned even for chroma */
|
||||
ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe->linesize[plane] + 16;
|
||||
}
|
||||
@@ -1591,6 +1597,8 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
|
||||
s->mpvencdsp.draw_edges(ref->hpel[plane][3], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
||||
}
|
||||
ref->interpolated[plane] = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1601,6 +1609,7 @@ static int dirac_decode_frame_internal(DiracContext *s)
|
||||
{
|
||||
DWTContext d;
|
||||
int y, i, comp, dsty;
|
||||
int ret;
|
||||
|
||||
if (s->low_delay) {
|
||||
/* [DIRAC_STD] 13.5.1 low_delay_transform_data() */
|
||||
@@ -1608,8 +1617,10 @@ static int dirac_decode_frame_internal(DiracContext *s)
|
||||
Plane *p = &s->plane[comp];
|
||||
memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
|
||||
}
|
||||
if (!s->zero_res)
|
||||
decode_lowdelay(s);
|
||||
if (!s->zero_res) {
|
||||
if ((ret = decode_lowdelay(s)) < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
for (comp = 0; comp < 3; comp++) {
|
||||
@@ -1640,8 +1651,11 @@ static int dirac_decode_frame_internal(DiracContext *s)
|
||||
|
||||
select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen);
|
||||
|
||||
for (i = 0; i < s->num_refs; i++)
|
||||
interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
|
||||
for (i = 0; i < s->num_refs; i++) {
|
||||
int ret = interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
memset(s->mctmp, 0, 4*p->yoffset*p->stride);
|
||||
|
||||
|
||||
+13
-10
@@ -75,17 +75,20 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define write16(p, value) \
|
||||
do { \
|
||||
if (s->big_endian) AV_WB16(p, value); \
|
||||
else AV_WL16(p, value); \
|
||||
} while(0)
|
||||
static av_always_inline void write16_internal(int big_endian, void *p, int value)
|
||||
{
|
||||
if (big_endian) AV_WB16(p, value);
|
||||
else AV_WL16(p, value);
|
||||
}
|
||||
|
||||
#define write32(p, value) \
|
||||
do { \
|
||||
if (s->big_endian) AV_WB32(p, value); \
|
||||
else AV_WL32(p, value); \
|
||||
} while(0)
|
||||
static av_always_inline void write32_internal(int big_endian, void *p, int value)
|
||||
{
|
||||
if (big_endian) AV_WB32(p, value);
|
||||
else AV_WL32(p, value);
|
||||
}
|
||||
|
||||
#define write16(p, value) write16_internal(s->big_endian, p, value)
|
||||
#define write32(p, value) write32_internal(s->big_endian, p, value)
|
||||
|
||||
static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst)
|
||||
{
|
||||
|
||||
+16
-15
@@ -1012,6 +1012,22 @@ static int decode_header(EXRContext *s)
|
||||
int current_channel_offset = 0;
|
||||
int magic_number, version, flags, i;
|
||||
|
||||
s->xmin = ~0;
|
||||
s->xmax = ~0;
|
||||
s->ymin = ~0;
|
||||
s->ymax = ~0;
|
||||
s->xdelta = ~0;
|
||||
s->ydelta = ~0;
|
||||
s->channel_offsets[0] = -1;
|
||||
s->channel_offsets[1] = -1;
|
||||
s->channel_offsets[2] = -1;
|
||||
s->channel_offsets[3] = -1;
|
||||
s->pixel_type = EXR_UNKNOWN;
|
||||
s->compression = EXR_UNKN;
|
||||
s->nb_channels = 0;
|
||||
s->w = 0;
|
||||
s->h = 0;
|
||||
|
||||
if (bytestream2_get_bytes_left(&s->gb) < 10) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -1352,21 +1368,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
float one_gamma = 1.0f / s->gamma;
|
||||
|
||||
s->avctx = avctx;
|
||||
s->xmin = ~0;
|
||||
s->xmax = ~0;
|
||||
s->ymin = ~0;
|
||||
s->ymax = ~0;
|
||||
s->xdelta = ~0;
|
||||
s->ydelta = ~0;
|
||||
s->channel_offsets[0] = -1;
|
||||
s->channel_offsets[1] = -1;
|
||||
s->channel_offsets[2] = -1;
|
||||
s->channel_offsets[3] = -1;
|
||||
s->pixel_type = EXR_UNKNOWN;
|
||||
s->compression = EXR_UNKN;
|
||||
s->nb_channels = 0;
|
||||
s->w = 0;
|
||||
s->h = 0;
|
||||
|
||||
if ( one_gamma > 0.9999f && one_gamma < 1.0001f ) {
|
||||
for ( i = 0; i < 65536; ++i ) {
|
||||
|
||||
+11
-7
@@ -278,11 +278,11 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
|
||||
av_pix_fmt_get_chroma_sub_sample(pic->f.format,
|
||||
&h_chroma_shift, &v_chroma_shift);
|
||||
|
||||
for(i=0; i<FF_CEIL_RSHIFT(h->avctx->height, v_chroma_shift); i++) {
|
||||
for(i=0; i<FF_CEIL_RSHIFT(pic->f.height, v_chroma_shift); i++) {
|
||||
memset(pic->f.data[1] + pic->f.linesize[1]*i,
|
||||
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||
0x80, FF_CEIL_RSHIFT(pic->f.width, h_chroma_shift));
|
||||
memset(pic->f.data[2] + pic->f.linesize[2]*i,
|
||||
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||
0x80, FF_CEIL_RSHIFT(pic->f.width, h_chroma_shift));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1472,6 +1472,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
|
||||
|
||||
if (h->context_initialized &&
|
||||
(must_reinit || needs_reinit)) {
|
||||
h->context_initialized = 0;
|
||||
if (h != h0) {
|
||||
av_log(h->avctx, AV_LOG_ERROR,
|
||||
"changing width %d -> %d / height %d -> %d on "
|
||||
@@ -1686,14 +1687,17 @@ int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
|
||||
* vectors. Given we are concealing a lost frame, this probably
|
||||
* is not noticeable by comparison, but it should be fixed. */
|
||||
if (h->short_ref_count) {
|
||||
if (prev) {
|
||||
if (prev &&
|
||||
h->short_ref[0]->f.width == prev->f.width &&
|
||||
h->short_ref[0]->f.height == prev->f.height &&
|
||||
h->short_ref[0]->f.format == prev->f.format) {
|
||||
av_image_copy(h->short_ref[0]->f.data,
|
||||
h->short_ref[0]->f.linesize,
|
||||
(const uint8_t **)prev->f.data,
|
||||
prev->f.linesize,
|
||||
h->avctx->pix_fmt,
|
||||
h->mb_width * 16,
|
||||
h->mb_height * 16);
|
||||
prev->f.format,
|
||||
prev->f.width,
|
||||
prev->f.height);
|
||||
h->short_ref[0]->poc = prev->poc + 2;
|
||||
}
|
||||
h->short_ref[0]->frame_num = h->prev_frame_num;
|
||||
|
||||
@@ -461,7 +461,8 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
|
||||
if (get_bits_left(gb) < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Overread VPS by %d bits\n", -get_bits_left(gb));
|
||||
goto err;
|
||||
if (s->vps_list[vps_id])
|
||||
goto err;
|
||||
}
|
||||
|
||||
av_buffer_unref(&s->vps_list[vps_id]);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "huffyuv.h"
|
||||
#include "huffyuvdsp.h"
|
||||
#include "thread.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
|
||||
#define classic_shift_luma_table_size 42
|
||||
@@ -291,6 +292,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
HYuvContext *s = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ff_huffyuvdsp_init(&s->hdsp);
|
||||
memset(s->vlc, 0, 4 * sizeof(VLC));
|
||||
|
||||
|
||||
@@ -1148,11 +1148,16 @@ static inline void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
|
||||
int i, csize = 1;
|
||||
void *src[3];
|
||||
|
||||
for (i = 1; i < 3; i++)
|
||||
for (i = 1; i < 3; i++) {
|
||||
if (tile->codsty[0].transform != tile->codsty[i].transform) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Transforms mismatch, MCT not supported\n");
|
||||
return;
|
||||
}
|
||||
if (memcmp(tile->comp[0].coord, tile->comp[i].coord, sizeof(tile->comp[0].coord))) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Coords mismatch, MCT not supported\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (tile->codsty[0].transform == FF_DWT97)
|
||||
|
||||
@@ -356,6 +356,15 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (i = 0; i < image->numcomps; i++) {
|
||||
if (!image->comps[i].data) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Image component %d contains no data.\n", i);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
|
||||
pixel_size = desc->comp[0].step_minus1 + 1;
|
||||
ispacked = libopenjpeg_ispacked(avctx->pix_fmt);
|
||||
|
||||
@@ -164,6 +164,9 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
|
||||
|
||||
img = opj_image_create(numcomps, cmptparm, color_space);
|
||||
|
||||
if (!img)
|
||||
return NULL;
|
||||
|
||||
// x0, y0 is the top left corner of the image
|
||||
// x1, y1 is the width, height of the reference grid
|
||||
img->x0 = 0;
|
||||
|
||||
@@ -71,7 +71,7 @@ static int libshine_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
SHINEContext *s = avctx->priv_data;
|
||||
MPADecodeHeader hdr;
|
||||
unsigned char *data;
|
||||
long written;
|
||||
int written;
|
||||
int ret, len;
|
||||
|
||||
if (frame)
|
||||
|
||||
@@ -337,20 +337,30 @@ void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
|
||||
}
|
||||
}
|
||||
|
||||
void ff_mjpeg_encode_stuffing(MpegEncContext *s)
|
||||
int ff_mjpeg_encode_stuffing(MpegEncContext *s)
|
||||
{
|
||||
int i;
|
||||
PutBitContext *pbc = &s->pb;
|
||||
int mb_y = s->mb_y - !s->mb_x;
|
||||
|
||||
int ret = ff_mpv_reallocate_putbitbuffer(s, put_bits_count(&s->pb) / 8 + 100,
|
||||
put_bits_count(&s->pb) / 4 + 1000);
|
||||
if (ret < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Buffer reallocation failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ff_mjpeg_escape_FF(pbc, s->esc_pos);
|
||||
|
||||
if((s->avctx->active_thread_type & FF_THREAD_SLICE) && mb_y < s->mb_height)
|
||||
put_marker(pbc, RST0 + (mb_y&7));
|
||||
s->esc_pos = put_bits_count(pbc) >> 3;
|
||||
fail:
|
||||
|
||||
for(i=0; i<3; i++)
|
||||
s->last_dc[i] = 128 << s->intra_dc_precision;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
|
||||
|
||||
@@ -34,7 +34,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
|
||||
uint16_t chroma_intra_matrix[64]);
|
||||
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
|
||||
void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
|
||||
void ff_mjpeg_encode_stuffing(MpegEncContext *s);
|
||||
int ff_mjpeg_encode_stuffing(MpegEncContext *s);
|
||||
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[3], int vsample[3]);
|
||||
|
||||
void ff_mjpeg_encode_dc(PutBitContext *pb, int val,
|
||||
|
||||
@@ -1893,6 +1893,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx)
|
||||
s->mp3decctx[i]->adu_mode = 1;
|
||||
s->mp3decctx[i]->avctx = avctx;
|
||||
s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
|
||||
s->mp3decctx[i]->fdsp = s->mp3decctx[0]->fdsp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+78
-4
@@ -1286,6 +1286,82 @@ fail:
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static void clear_context(MpegEncContext *s)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
memset(&s->next_picture, 0, sizeof(s->next_picture));
|
||||
memset(&s->last_picture, 0, sizeof(s->last_picture));
|
||||
memset(&s->current_picture, 0, sizeof(s->current_picture));
|
||||
memset(&s->new_picture, 0, sizeof(s->new_picture));
|
||||
|
||||
memset(s->thread_context, 0, sizeof(s->thread_context));
|
||||
|
||||
s->me.map = NULL;
|
||||
s->me.score_map = NULL;
|
||||
s->dct_error_sum = NULL;
|
||||
s->block = NULL;
|
||||
s->blocks = NULL;
|
||||
memset(s->pblocks, 0, sizeof(s->pblocks));
|
||||
s->ac_val_base = NULL;
|
||||
s->ac_val[0] =
|
||||
s->ac_val[1] =
|
||||
s->ac_val[2] =NULL;
|
||||
s->edge_emu_buffer = NULL;
|
||||
s->me.scratchpad = NULL;
|
||||
s->me.temp =
|
||||
s->rd_scratchpad =
|
||||
s->b_scratchpad =
|
||||
s->obmc_scratchpad = NULL;
|
||||
|
||||
s->parse_context.buffer = NULL;
|
||||
s->parse_context.buffer_size = 0;
|
||||
s->bitstream_buffer = NULL;
|
||||
s->allocated_bitstream_buffer_size = 0;
|
||||
s->picture = NULL;
|
||||
s->mb_type = NULL;
|
||||
s->p_mv_table_base = NULL;
|
||||
s->b_forw_mv_table_base = NULL;
|
||||
s->b_back_mv_table_base = NULL;
|
||||
s->b_bidir_forw_mv_table_base = NULL;
|
||||
s->b_bidir_back_mv_table_base = NULL;
|
||||
s->b_direct_mv_table_base = NULL;
|
||||
s->p_mv_table = NULL;
|
||||
s->b_forw_mv_table = NULL;
|
||||
s->b_back_mv_table = NULL;
|
||||
s->b_bidir_forw_mv_table = NULL;
|
||||
s->b_bidir_back_mv_table = NULL;
|
||||
s->b_direct_mv_table = NULL;
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (k = 0; k < 2; k++) {
|
||||
s->b_field_mv_table_base[i][j][k] = NULL;
|
||||
s->b_field_mv_table[i][j][k] = NULL;
|
||||
}
|
||||
s->b_field_select_table[i][j] = NULL;
|
||||
s->p_field_mv_table_base[i][j] = NULL;
|
||||
s->p_field_mv_table[i][j] = NULL;
|
||||
}
|
||||
s->p_field_select_table[i] = NULL;
|
||||
}
|
||||
|
||||
s->dc_val_base = NULL;
|
||||
s->coded_block_base = NULL;
|
||||
s->mbintra_table = NULL;
|
||||
s->cbp_table = NULL;
|
||||
s->pred_dir_table = NULL;
|
||||
|
||||
s->mbskip_table = NULL;
|
||||
|
||||
s->er.error_status_table = NULL;
|
||||
s->er.er_temp_buffer = NULL;
|
||||
s->mb_index2xy = NULL;
|
||||
s->lambda_table = NULL;
|
||||
|
||||
s->cplx_tab = NULL;
|
||||
s->bits_tab = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* init common structure for both encoder and decoder.
|
||||
* this assumes that some variables like width/height are already set
|
||||
@@ -1297,6 +1373,8 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
|
||||
s->avctx->active_thread_type & FF_THREAD_SLICE) ?
|
||||
s->avctx->thread_count : 1;
|
||||
|
||||
clear_context(s);
|
||||
|
||||
if (s->encoding && s->avctx->slices)
|
||||
nb_slices = s->avctx->slices;
|
||||
|
||||
@@ -1344,10 +1422,6 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
|
||||
if (!s->picture[i].f)
|
||||
goto fail;
|
||||
}
|
||||
memset(&s->next_picture, 0, sizeof(s->next_picture));
|
||||
memset(&s->last_picture, 0, sizeof(s->last_picture));
|
||||
memset(&s->current_picture, 0, sizeof(s->current_picture));
|
||||
memset(&s->new_picture, 0, sizeof(s->new_picture));
|
||||
s->next_picture.f = av_frame_alloc();
|
||||
if (!s->next_picture.f)
|
||||
goto fail;
|
||||
|
||||
@@ -773,6 +773,7 @@ void ff_mpv_encode_init_x86(MpegEncContext *s);
|
||||
int ff_mpv_encode_end(AVCodecContext *avctx);
|
||||
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
||||
const AVFrame *frame, int *got_packet);
|
||||
int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase);
|
||||
|
||||
void ff_clean_intra_table_entries(MpegEncContext *s);
|
||||
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h);
|
||||
|
||||
+34
-23
@@ -2718,6 +2718,35 @@ static void update_mb_info(MpegEncContext *s, int startcode)
|
||||
write_mb_info(s);
|
||||
}
|
||||
|
||||
int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase)
|
||||
{
|
||||
if ( s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold
|
||||
&& s->slice_context_count == 1
|
||||
&& s->pb.buf == s->avctx->internal->byte_buffer) {
|
||||
int lastgob_pos = s->ptr_lastgob - s->pb.buf;
|
||||
int vbv_pos = s->vbv_delay_ptr - s->pb.buf;
|
||||
|
||||
uint8_t *new_buffer = NULL;
|
||||
int new_buffer_size = 0;
|
||||
|
||||
av_fast_padded_malloc(&new_buffer, &new_buffer_size,
|
||||
s->avctx->internal->byte_buffer_size + size_increase);
|
||||
if (!new_buffer)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
memcpy(new_buffer, s->avctx->internal->byte_buffer, s->avctx->internal->byte_buffer_size);
|
||||
av_free(s->avctx->internal->byte_buffer);
|
||||
s->avctx->internal->byte_buffer = new_buffer;
|
||||
s->avctx->internal->byte_buffer_size = new_buffer_size;
|
||||
rebase_put_bits(&s->pb, new_buffer, new_buffer_size);
|
||||
s->ptr_lastgob = s->pb.buf + lastgob_pos;
|
||||
s->vbv_delay_ptr = s->pb.buf + vbv_pos;
|
||||
}
|
||||
if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold)
|
||||
return AVERROR(EINVAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int encode_thread(AVCodecContext *c, void *arg){
|
||||
MpegEncContext *s= *(void**)arg;
|
||||
int mb_x, mb_y, pdif = 0;
|
||||
@@ -2794,30 +2823,10 @@ static int encode_thread(AVCodecContext *c, void *arg){
|
||||
// int d;
|
||||
int dmin= INT_MAX;
|
||||
int dir;
|
||||
int size_increase = s->avctx->internal->byte_buffer_size/4
|
||||
+ s->mb_width*MAX_MB_BYTES;
|
||||
|
||||
if ( s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES
|
||||
&& s->slice_context_count == 1
|
||||
&& s->pb.buf == s->avctx->internal->byte_buffer) {
|
||||
int new_size = s->avctx->internal->byte_buffer_size
|
||||
+ s->avctx->internal->byte_buffer_size/4
|
||||
+ s->mb_width*MAX_MB_BYTES;
|
||||
int lastgob_pos = s->ptr_lastgob - s->pb.buf;
|
||||
int vbv_pos = s->vbv_delay_ptr - s->pb.buf;
|
||||
|
||||
uint8_t *new_buffer = NULL;
|
||||
int new_buffer_size = 0;
|
||||
|
||||
av_fast_padded_malloc(&new_buffer, &new_buffer_size, new_size);
|
||||
if (new_buffer) {
|
||||
memcpy(new_buffer, s->avctx->internal->byte_buffer, s->avctx->internal->byte_buffer_size);
|
||||
av_free(s->avctx->internal->byte_buffer);
|
||||
s->avctx->internal->byte_buffer = new_buffer;
|
||||
s->avctx->internal->byte_buffer_size = new_buffer_size;
|
||||
rebase_put_bits(&s->pb, new_buffer, new_buffer_size);
|
||||
s->ptr_lastgob = s->pb.buf + lastgob_pos;
|
||||
s->vbv_delay_ptr = s->pb.buf + vbv_pos;
|
||||
}
|
||||
}
|
||||
ff_mpv_reallocate_putbitbuffer(s, MAX_MB_BYTES, size_increase);
|
||||
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
|
||||
return -1;
|
||||
@@ -3733,6 +3742,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)
|
||||
}
|
||||
s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
|
||||
for(i=1; i<context_count; i++){
|
||||
if (s->pb.buf_end == s->thread_context[i]->pb.buf)
|
||||
set_put_bits_buffer_size(&s->pb, FFMIN(s->thread_context[i]->pb.buf_end - s->pb.buf, INT_MAX/8-32));
|
||||
merge_context_after_encode(s, s->thread_context[i]);
|
||||
}
|
||||
emms_c();
|
||||
|
||||
+31
-13
@@ -538,6 +538,11 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->state & PNG_IHDR) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Multiple IHDR\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
s->width = s->cur_w = bytestream2_get_be32(&s->gb);
|
||||
s->height = s->cur_h = bytestream2_get_be32(&s->gb);
|
||||
if (av_image_check_size(s->width, s->height, 0, avctx)) {
|
||||
@@ -804,28 +809,34 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
uint32_t length)
|
||||
{
|
||||
uint32_t sequence_number;
|
||||
int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op;
|
||||
|
||||
if (length != 26)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (!(s->state & PNG_IHDR)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "fctl before IHDR\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
sequence_number = bytestream2_get_be32(&s->gb);
|
||||
s->cur_w = bytestream2_get_be32(&s->gb);
|
||||
s->cur_h = bytestream2_get_be32(&s->gb);
|
||||
s->x_offset = bytestream2_get_be32(&s->gb);
|
||||
s->y_offset = bytestream2_get_be32(&s->gb);
|
||||
cur_w = bytestream2_get_be32(&s->gb);
|
||||
cur_h = bytestream2_get_be32(&s->gb);
|
||||
x_offset = bytestream2_get_be32(&s->gb);
|
||||
y_offset = bytestream2_get_be32(&s->gb);
|
||||
bytestream2_skip(&s->gb, 4); /* delay_num (2), delay_den (2) */
|
||||
s->dispose_op = bytestream2_get_byte(&s->gb);
|
||||
s->blend_op = bytestream2_get_byte(&s->gb);
|
||||
dispose_op = bytestream2_get_byte(&s->gb);
|
||||
blend_op = bytestream2_get_byte(&s->gb);
|
||||
bytestream2_skip(&s->gb, 4); /* crc */
|
||||
|
||||
if (sequence_number == 0 &&
|
||||
(s->cur_w != s->width ||
|
||||
s->cur_h != s->height ||
|
||||
s->x_offset != 0 ||
|
||||
s->y_offset != 0) ||
|
||||
s->cur_w <= 0 || s->cur_h <= 0 ||
|
||||
s->x_offset < 0 || s->y_offset < 0 ||
|
||||
s->cur_w > s->width - s->x_offset|| s->cur_h > s->height - s->y_offset)
|
||||
(cur_w != s->width ||
|
||||
cur_h != s->height ||
|
||||
x_offset != 0 ||
|
||||
y_offset != 0) ||
|
||||
cur_w <= 0 || cur_h <= 0 ||
|
||||
x_offset < 0 || y_offset < 0 ||
|
||||
cur_w > s->width - x_offset|| cur_h > s->height - y_offset)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* always (re)start with a clean frame */
|
||||
@@ -839,6 +850,13 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
s->dispose_op = APNG_DISPOSE_OP_NONE;
|
||||
}
|
||||
|
||||
s->cur_w = cur_w;
|
||||
s->cur_h = cur_h;
|
||||
s->x_offset = x_offset;
|
||||
s->y_offset = y_offset;
|
||||
s->dispose_op = dispose_op;
|
||||
s->blend_op = blend_op;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
|
||||
pthread_join(p->thread, NULL);
|
||||
p->thread_init=0;
|
||||
|
||||
if (codec->close)
|
||||
if (codec->close && p->avctx)
|
||||
codec->close(p->avctx);
|
||||
|
||||
avctx->codec = NULL;
|
||||
@@ -591,12 +591,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
|
||||
av_packet_unref(&p->avpkt);
|
||||
av_freep(&p->released_buffers);
|
||||
|
||||
if (i) {
|
||||
if (i && p->avctx) {
|
||||
av_freep(&p->avctx->priv_data);
|
||||
av_freep(&p->avctx->slice_offset);
|
||||
}
|
||||
|
||||
av_freep(&p->avctx->internal);
|
||||
if (p->avctx)
|
||||
av_freep(&p->avctx->internal);
|
||||
av_freep(&p->avctx);
|
||||
}
|
||||
|
||||
@@ -668,6 +669,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
|
||||
|
||||
copy->internal = av_malloc(sizeof(AVCodecInternal));
|
||||
if (!copy->internal) {
|
||||
copy->priv_data = NULL;
|
||||
err = AVERROR(ENOMEM);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -230,6 +230,7 @@ static inline void skip_put_bytes(PutBitContext *s, int n)
|
||||
{
|
||||
av_assert2((put_bits_count(s) & 7) == 0);
|
||||
av_assert2(s->bit_left == 32);
|
||||
av_assert0(n <= s->buf_end - s->buf_ptr);
|
||||
s->buf_ptr += n;
|
||||
}
|
||||
|
||||
@@ -253,6 +254,7 @@ static inline void skip_put_bits(PutBitContext *s, int n)
|
||||
static inline void set_put_bits_buffer_size(PutBitContext *s, int size)
|
||||
{
|
||||
s->buf_end = s->buf + size;
|
||||
s->size_in_bits = 8*size;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_PUT_BITS_H */
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = ff_alloc_packet2(avctx, pkt, ret)) < 0)
|
||||
if ((ret = ff_alloc_packet(pkt, ret)) < 0)
|
||||
return ret;
|
||||
if ((ret = avpicture_layout((const AVPicture *)frame, avctx->pix_fmt, avctx->width,
|
||||
avctx->height, pkt->data, pkt->size)) < 0)
|
||||
|
||||
@@ -1534,7 +1534,14 @@ int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
|
||||
|
||||
if (avctx->internal->is_copy) {
|
||||
r->tmp_b_block_base = NULL;
|
||||
r->cbp_chroma = NULL;
|
||||
r->cbp_luma = NULL;
|
||||
r->deblock_coefs = NULL;
|
||||
r->intra_types_hist = NULL;
|
||||
r->mb_type = NULL;
|
||||
|
||||
ff_mpv_idct_init(&r->s);
|
||||
|
||||
if ((err = ff_mpv_common_init(&r->s)) < 0)
|
||||
return err;
|
||||
if ((err = rv34_decoder_alloc(r)) < 0) {
|
||||
|
||||
@@ -457,6 +457,7 @@ static void destroy_buffers(SANMVideoContext *ctx)
|
||||
ctx->frm0_size =
|
||||
ctx->frm1_size =
|
||||
ctx->frm2_size = 0;
|
||||
init_sizes(ctx, 0, 0);
|
||||
}
|
||||
|
||||
static av_cold int init_buffers(SANMVideoContext *ctx)
|
||||
|
||||
@@ -137,6 +137,7 @@ typedef struct AACSBRContext {
|
||||
struct SpectralBandReplication {
|
||||
int sample_rate;
|
||||
int start;
|
||||
int id_aac;
|
||||
int reset;
|
||||
SpectrumParameters spectrum_params;
|
||||
int bs_amp_res_header;
|
||||
|
||||
+2
-2
@@ -298,6 +298,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
|
||||
BlockNode *lb= lt+b_stride;
|
||||
BlockNode *rb= lb+1;
|
||||
uint8_t *block[4];
|
||||
// When src_stride is large enough, it is possible to interleave the blocks.
|
||||
// Otherwise the blocks are written sequentially in the tmp buffer.
|
||||
int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;
|
||||
uint8_t *tmp = s->scratchbuf;
|
||||
uint8_t *ptmp;
|
||||
@@ -341,8 +343,6 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
|
||||
|
||||
if(b_w<=0 || b_h<=0) return;
|
||||
|
||||
av_assert2(src_stride > 2*MB_SIZE + 5);
|
||||
|
||||
if(!sliced && offset_dst)
|
||||
dst += src_x + src_y*dst_stride;
|
||||
dst8+= src_x + src_y*src_stride;
|
||||
|
||||
@@ -900,6 +900,7 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
|
||||
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avctx->channels = s->channels;
|
||||
|
||||
s->lossless = get_bits1(&gb);
|
||||
if (!s->lossless)
|
||||
|
||||
@@ -799,6 +799,12 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (s->mcdparams[i].present) {
|
||||
s->mcdparams[i].index = get_bits(gb, 2);
|
||||
s->mcdparams[i].chan2 = get_bits(gb, 4);
|
||||
if (s->mcdparams[i].chan2 >= avctx->channels) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"invalid channel 2 (%d) for %d channel(s)\n",
|
||||
s->mcdparams[i].chan2, avctx->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (s->mcdparams[i].index == 1) {
|
||||
if ((nbit == s->mcdparams[i].chan2) ||
|
||||
(ch_mask & 1 << s->mcdparams[i].chan2))
|
||||
|
||||
+3
-1
@@ -424,10 +424,12 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
|
||||
*width = FFALIGN(*width, w_align);
|
||||
*height = FFALIGN(*height, h_align);
|
||||
if (s->codec_id == AV_CODEC_ID_H264 || s->lowres)
|
||||
if (s->codec_id == AV_CODEC_ID_H264 || s->lowres) {
|
||||
// some of the optimized chroma MC reads one line too much
|
||||
// which is also done in mpeg decoders with lowres > 0
|
||||
*height += 2;
|
||||
*width = FFMAX(*width, 32);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
linesize_align[i] = STRIDE_ALIGN;
|
||||
|
||||
+1
-1
@@ -465,7 +465,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
|
||||
count = avctx->extradata_size*8 - get_bits_count(&gb);
|
||||
if (count > 0) {
|
||||
av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n",
|
||||
count, get_bits(&gb, count));
|
||||
count, get_bits_long(&gb, FFMIN(count, 32)));
|
||||
} else if (count < 0) {
|
||||
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
|
||||
}
|
||||
|
||||
+12
-2
@@ -639,6 +639,11 @@ static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
|
||||
int width = s->avctx->width;
|
||||
int height = s->avctx->height;
|
||||
|
||||
if (buf_size < 3) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Insufficent data (%d) for header\n", buf_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
s->keyframe = !(buf[0] & 1);
|
||||
s->profile = (buf[0]>>1) & 7;
|
||||
s->invisible = !(buf[0] & 0x10);
|
||||
@@ -757,8 +762,10 @@ static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
|
||||
static av_always_inline
|
||||
void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src)
|
||||
{
|
||||
dst->x = av_clip(src->x, s->mv_min.x, s->mv_max.x);
|
||||
dst->y = av_clip(src->y, s->mv_min.y, s->mv_max.y);
|
||||
dst->x = av_clip(src->x, av_clip(s->mv_min.x, INT16_MIN, INT16_MAX),
|
||||
av_clip(s->mv_max.x, INT16_MIN, INT16_MAX));
|
||||
dst->y = av_clip(src->y, av_clip(s->mv_min.y, INT16_MIN, INT16_MAX),
|
||||
av_clip(s->mv_max.y, INT16_MIN, INT16_MAX));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2687,6 +2694,9 @@ av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
|
||||
VP8Context *s = avctx->priv_data;
|
||||
int i;
|
||||
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
vp8_decode_flush_impl(avctx, 1);
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++)
|
||||
av_frame_free(&s->frames[i].tf.f);
|
||||
|
||||
+7
-2
@@ -134,6 +134,11 @@ typedef struct VP8Frame {
|
||||
AVBufferRef *seg_map;
|
||||
} VP8Frame;
|
||||
|
||||
typedef struct VP8intmv {
|
||||
int x;
|
||||
int y;
|
||||
} VP8intmv;
|
||||
|
||||
#define MAX_THREADS 8
|
||||
typedef struct VP8Context {
|
||||
VP8ThreadData *thread_data;
|
||||
@@ -152,8 +157,8 @@ typedef struct VP8Context {
|
||||
uint8_t deblock_filter;
|
||||
uint8_t mbskip_enabled;
|
||||
uint8_t profile;
|
||||
VP56mv mv_min;
|
||||
VP56mv mv_max;
|
||||
VP8intmv mv_min;
|
||||
VP8intmv mv_max;
|
||||
|
||||
int8_t sign_bias[4]; ///< one state [0, 1] per ref frame type
|
||||
int ref_count[3];
|
||||
|
||||
+4
-3
@@ -410,7 +410,7 @@ static av_always_inline int inv_recenter_nonneg(int v, int m)
|
||||
// differential forward probability updates
|
||||
static int update_prob(VP56RangeCoder *c, int p)
|
||||
{
|
||||
static const int inv_map_table[254] = {
|
||||
static const int inv_map_table[255] = {
|
||||
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
|
||||
189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
|
||||
@@ -429,7 +429,7 @@ static int update_prob(VP56RangeCoder *c, int p)
|
||||
207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
|
||||
222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
|
||||
237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
|
||||
252, 253,
|
||||
252, 253, 253,
|
||||
};
|
||||
int d;
|
||||
|
||||
@@ -459,6 +459,7 @@ static int update_prob(VP56RangeCoder *c, int p)
|
||||
if (d >= 65)
|
||||
d = (d << 1) - 65 + vp8_rac_get(c);
|
||||
d += 64;
|
||||
av_assert2(d < FF_ARRAY_ELEMS(inv_map_table));
|
||||
}
|
||||
|
||||
return p <= 128 ? 1 + inv_recenter_nonneg(inv_map_table[d], p - 1) :
|
||||
@@ -3856,7 +3857,7 @@ static int vp9_decode_frame(AVCodecContext *ctx, void *frame,
|
||||
tile_row, s->tiling.log2_tile_rows, s->sb_rows);
|
||||
if (s->pass != 2) {
|
||||
for (tile_col = 0; tile_col < s->tiling.tile_cols; tile_col++) {
|
||||
unsigned tile_size;
|
||||
int64_t tile_size;
|
||||
|
||||
if (tile_col == s->tiling.tile_cols - 1 &&
|
||||
tile_row == s->tiling.tile_rows - 1) {
|
||||
|
||||
@@ -486,7 +486,7 @@ static int decode_cdlms(WmallDecodeCtx *s)
|
||||
if ((1 << cbits) < s->cdlms[c][i].scaling + 1)
|
||||
cbits++;
|
||||
|
||||
s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2;
|
||||
s->cdlms[c][i].bitsend = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
|
||||
shift_l = 32 - s->cdlms[c][i].bitsend;
|
||||
shift_r = 32 - s->cdlms[c][i].scaling - 2;
|
||||
for (j = 0; j < s->cdlms[c][i].coefsend; j++)
|
||||
@@ -1028,6 +1028,7 @@ static int decode_frame(WmallDecodeCtx *s)
|
||||
if ((ret = ff_get_buffer(s->avctx, s->frame, 0)) < 0) {
|
||||
/* return an error if no frame could be decoded at all */
|
||||
s->packet_loss = 1;
|
||||
s->frame->nb_samples = 0;
|
||||
return ret;
|
||||
}
|
||||
for (i = 0; i < s->num_channels; i++) {
|
||||
|
||||
+16
-2
@@ -1982,7 +1982,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
|
||||
*got_frame_ptr) {
|
||||
cnt += s->spillover_nbits;
|
||||
s->skip_bits_next = cnt & 7;
|
||||
return cnt >> 3;
|
||||
res = cnt >> 3;
|
||||
if (res > avpkt->size) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Trying to skip %d bytes in packet of size %d\n",
|
||||
res, avpkt->size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
return res;
|
||||
} else
|
||||
skip_bits_long (gb, s->spillover_nbits - cnt +
|
||||
get_bits_count(gb)); // resync
|
||||
@@ -2001,7 +2008,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
|
||||
} else if (*got_frame_ptr) {
|
||||
int cnt = get_bits_count(gb);
|
||||
s->skip_bits_next = cnt & 7;
|
||||
return cnt >> 3;
|
||||
res = cnt >> 3;
|
||||
if (res > avpkt->size) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Trying to skip %d bytes in packet of size %d\n",
|
||||
res, avpkt->size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
return res;
|
||||
} else if ((s->sframe_cache_size = pos) > 0) {
|
||||
/* rewind bit reader to start of last (incomplete) superframe... */
|
||||
init_get_bits(gb, avpkt->data, size << 3);
|
||||
|
||||
@@ -135,8 +135,11 @@ WEIGHT_FUNC_HALF_MM 8, 8
|
||||
add off_regd, 1
|
||||
or off_regd, 1
|
||||
add r4, 1
|
||||
cmp r6d, 128
|
||||
je .nonnormal
|
||||
cmp r5, 128
|
||||
jne .normal
|
||||
.nonnormal
|
||||
sar r5, 1
|
||||
sar r6, 1
|
||||
sar off_regd, 1
|
||||
|
||||
+1
-1
@@ -339,7 +339,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
|
||||
continue;
|
||||
} else if (ret < 0)
|
||||
return ret;
|
||||
d = av_rescale_q(frame->pts, tb, AV_TIME_BASE_Q);
|
||||
d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
av_dlog(avctx, "sink_idx:%d time:%f\n", i, d);
|
||||
av_frame_unref(frame);
|
||||
|
||||
|
||||
@@ -87,15 +87,24 @@ static int query_formats(AVFilterContext *ctx)
|
||||
AVFilterLink *inlink = ctx->inputs[0];
|
||||
AVFilterLink *outlink = ctx->outputs[0];
|
||||
|
||||
AVFilterFormats *in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
|
||||
AVFilterFormats *out_formats;
|
||||
AVFilterFormats *in_samplerates = ff_all_samplerates();
|
||||
AVFilterFormats *out_samplerates;
|
||||
AVFilterChannelLayouts *in_layouts = ff_all_channel_counts();
|
||||
AVFilterChannelLayouts *out_layouts;
|
||||
AVFilterFormats *in_formats, *out_formats;
|
||||
AVFilterFormats *in_samplerates, *out_samplerates;
|
||||
AVFilterChannelLayouts *in_layouts, *out_layouts;
|
||||
|
||||
|
||||
in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
|
||||
if (!in_formats)
|
||||
return AVERROR(ENOMEM);
|
||||
ff_formats_ref (in_formats, &inlink->out_formats);
|
||||
|
||||
in_samplerates = ff_all_samplerates();
|
||||
if (!in_samplerates)
|
||||
return AVERROR(ENOMEM);
|
||||
ff_formats_ref (in_samplerates, &inlink->out_samplerates);
|
||||
|
||||
in_layouts = ff_all_channel_counts();
|
||||
if (!in_layouts)
|
||||
return AVERROR(ENOMEM);
|
||||
ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts);
|
||||
|
||||
if(out_rate > 0) {
|
||||
|
||||
@@ -152,7 +152,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
|
||||
int hsub = plane == 1 || plane == 2 ? trans->hsub : 0;
|
||||
int vsub = plane == 1 || plane == 2 ? trans->vsub : 0;
|
||||
int pixstep = trans->pixsteps[plane];
|
||||
int inh = in->height >> vsub;
|
||||
int inh = FF_CEIL_RSHIFT(in->height, vsub);
|
||||
int outw = FF_CEIL_RSHIFT(out->width, hsub);
|
||||
int outh = FF_CEIL_RSHIFT(out->height, vsub);
|
||||
int start = (outh * jobnr ) / nb_jobs;
|
||||
|
||||
@@ -27,8 +27,8 @@ SECTION .text
|
||||
%if lut_bits != 8
|
||||
sar %1q, 8-lut_bits
|
||||
%endif
|
||||
movsx %1d, word [%3q+%1q*2]
|
||||
add %1d, %2d
|
||||
movsx %1q, word [%3q+%1q*2]
|
||||
add %1q, %2q
|
||||
%endmacro
|
||||
|
||||
%macro LOAD 3 ; dstreg, x, bitdepth
|
||||
|
||||
@@ -448,6 +448,7 @@ static int calculate_bitrate(AVFormatContext *s)
|
||||
int64_t len = 0;
|
||||
AVStream *st = s->streams[i];
|
||||
int64_t duration;
|
||||
int64_t bitrate;
|
||||
|
||||
for (j = 0; j < st->nb_index_entries; j++)
|
||||
len += st->index_entries[j].size;
|
||||
@@ -455,7 +456,10 @@ static int calculate_bitrate(AVFormatContext *s)
|
||||
if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)
|
||||
continue;
|
||||
duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
|
||||
st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
|
||||
bitrate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
|
||||
if (bitrate <= INT_MAX && bitrate > 0) {
|
||||
st->codec->bit_rate = bitrate;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -785,6 +785,7 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
|
||||
int max_buffer_size = s->max_packet_size ?
|
||||
s->max_packet_size : IO_BUFFER_SIZE;
|
||||
int filled = s->buf_end - s->buffer;
|
||||
ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - s->buffer : -1;
|
||||
|
||||
buf_size += s->buf_ptr - s->buffer + max_buffer_size;
|
||||
|
||||
@@ -802,6 +803,8 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
|
||||
s->buf_end = buffer + (s->buf_end - s->buffer);
|
||||
s->buffer = buffer;
|
||||
s->buffer_size = buf_size;
|
||||
if (checksum_ptr_offset >= 0)
|
||||
s->checksum_ptr = s->buffer + checksum_ptr_offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,9 @@ static int ffm_read_data(AVFormatContext *s,
|
||||
retry_read:
|
||||
if (pb->buffer_size != ffm->packet_size) {
|
||||
int64_t tell = avio_tell(pb);
|
||||
ffio_set_buf_size(pb, ffm->packet_size);
|
||||
int ret = ffio_set_buf_size(pb, ffm->packet_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
avio_seek(pb, tell, SEEK_SET);
|
||||
}
|
||||
id = avio_rb16(pb); /* PACKET_ID */
|
||||
|
||||
+1
-1
@@ -449,7 +449,7 @@ static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
|
||||
*
|
||||
* NumDeltaPocs[RefRpsIdx]: num_delta_pocs[rps_idx - 1]
|
||||
*/
|
||||
for (i = 0; i < num_delta_pocs[rps_idx - 1]; i++) {
|
||||
for (i = 0; i <= num_delta_pocs[rps_idx - 1]; i++) {
|
||||
uint8_t use_delta_flag = 0;
|
||||
uint8_t used_by_curr_pic_flag = get_bits1(gb);
|
||||
if (!used_by_curr_pic_flag)
|
||||
|
||||
@@ -1604,6 +1604,14 @@ static int matroska_parse_tracks(AVFormatContext *s)
|
||||
if (!track->codec_id)
|
||||
continue;
|
||||
|
||||
if (track->audio.samplerate < 0 || track->audio.samplerate > INT_MAX ||
|
||||
isnan(track->audio.samplerate)) {
|
||||
av_log(matroska->ctx, AV_LOG_WARNING,
|
||||
"Invalid sample rate %f, defaulting to 8000 instead.\n",
|
||||
track->audio.samplerate);
|
||||
track->audio.samplerate = 8000;
|
||||
}
|
||||
|
||||
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
|
||||
if (!track->default_duration && track->video.frame_rate > 0)
|
||||
track->default_duration = 1000000000 / track->video.frame_rate;
|
||||
@@ -1799,6 +1807,18 @@ static int matroska_parse_tracks(AVFormatContext *s)
|
||||
NULL, NULL, NULL, NULL);
|
||||
avio_write(&b, "TTA1", 4);
|
||||
avio_wl16(&b, 1);
|
||||
if (track->audio.channels > UINT16_MAX ||
|
||||
track->audio.bitdepth > UINT16_MAX) {
|
||||
av_log(matroska->ctx, AV_LOG_WARNING,
|
||||
"Too large audio channel number %"PRIu64
|
||||
" or bitdepth %"PRIu64". Skipping track.\n",
|
||||
track->audio.channels, track->audio.bitdepth);
|
||||
av_freep(&extradata);
|
||||
if (matroska->ctx->error_recognition & AV_EF_EXPLODE)
|
||||
return AVERROR_INVALIDDATA;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
avio_wl16(&b, track->audio.channels);
|
||||
avio_wl16(&b, track->audio.bitdepth);
|
||||
if (track->audio.out_samplerate < 0 || track->audio.out_samplerate > INT_MAX)
|
||||
|
||||
@@ -3162,6 +3162,7 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
goto free_and_return;
|
||||
if (ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
|
||||
goto free_and_return;
|
||||
ctx.seekable = AVIO_SEEKABLE_NORMAL;
|
||||
atom.type = MKTAG('m','o','o','v');
|
||||
atom.size = moov_len;
|
||||
ret = mov_read_default(c, &ctx, atom);
|
||||
@@ -3716,6 +3717,9 @@ static int mov_read_close(AVFormatContext *s)
|
||||
AVStream *st = s->streams[i];
|
||||
MOVStreamContext *sc = st->priv_data;
|
||||
|
||||
if (!sc)
|
||||
continue;
|
||||
|
||||
av_freep(&sc->ctts_data);
|
||||
for (j = 0; j < sc->drefs_count; j++) {
|
||||
av_freep(&sc->drefs[j].path);
|
||||
|
||||
@@ -566,6 +566,11 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
|
||||
label_mask = 0;
|
||||
for (i = 0; i < num_descr; i++) {
|
||||
uint32_t label;
|
||||
if (pb->eof_reached) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"reached EOF while reading channel layout\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
label = avio_rb32(pb); // mChannelLabel
|
||||
avio_rb32(pb); // mChannelFlags
|
||||
avio_rl32(pb); // mCoordinates[0]
|
||||
|
||||
@@ -1840,9 +1840,10 @@ static int mxf_write_header(AVFormatContext *s)
|
||||
return ret;
|
||||
sc->video_bit_rate = st->codec->bit_rate ? st->codec->bit_rate : st->codec->rc_max_rate;
|
||||
if (s->oformat == &ff_mxf_d10_muxer) {
|
||||
if (sc->video_bit_rate == 50000000) {
|
||||
if (mxf->time_base.den == 25) sc->index = 3;
|
||||
else sc->index = 5;
|
||||
if ((sc->video_bit_rate == 50000000) && (mxf->time_base.den == 25)) {
|
||||
sc->index = 3;
|
||||
} else if ((sc->video_bit_rate == 49999840 || sc->video_bit_rate == 50000000) && (mxf->time_base.den != 25)) {
|
||||
sc->index = 5;
|
||||
} else if (sc->video_bit_rate == 40000000) {
|
||||
if (mxf->time_base.den == 25) sc->index = 7;
|
||||
else sc->index = 9;
|
||||
|
||||
@@ -182,6 +182,7 @@ const AVCodecTag ff_nut_audio_extra_tags[] = {
|
||||
{ AV_CODEC_ID_PCM_ALAW, MKTAG('A', 'L', 'A', 'W') },
|
||||
{ AV_CODEC_ID_PCM_MULAW, MKTAG('U', 'L', 'A', 'W') },
|
||||
{ AV_CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') },
|
||||
{ AV_CODEC_ID_WAVPACK, MKTAG('w', 'v', 'p', 'k') },
|
||||
{ AV_CODEC_ID_NONE, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -31,14 +31,19 @@ static int dirac_header(AVFormatContext *s, int idx)
|
||||
AVStream *st = s->streams[idx];
|
||||
dirac_source_params source;
|
||||
GetBitContext gb;
|
||||
int ret;
|
||||
|
||||
// already parsed the header
|
||||
if (st->codec->codec_id == AV_CODEC_ID_DIRAC)
|
||||
return 0;
|
||||
|
||||
init_get_bits(&gb, os->buf + os->pstart + 13, (os->psize - 13) * 8);
|
||||
if (avpriv_dirac_parse_sequence_header(st->codec, &gb, &source) < 0)
|
||||
return -1;
|
||||
ret = init_get_bits8(&gb, os->buf + os->pstart + 13, (os->psize - 13));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = avpriv_dirac_parse_sequence_header(st->codec, &gb, &source);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
st->codec->codec_id = AV_CODEC_ID_DIRAC;
|
||||
|
||||
@@ -188,10 +188,10 @@ static int mjpeg_probe(AVProbeData *p)
|
||||
}
|
||||
|
||||
if (nb_invalid*4 + 1 < nb_frames) {
|
||||
static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n\r\n";
|
||||
static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n";
|
||||
int i;
|
||||
|
||||
for (i=0; i<FFMIN(p->buf_size - sizeof(ct_jpeg), 100); i++)
|
||||
for (i=0; i<FFMIN(p->buf_size - (int)sizeof(ct_jpeg), 100); i++)
|
||||
if (!memcmp(p->buf + i, ct_jpeg, sizeof(ct_jpeg) - 1))
|
||||
return AVPROBE_SCORE_EXTENSION;
|
||||
|
||||
|
||||
@@ -576,10 +576,6 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
|
||||
const uint8_t *mb_info =
|
||||
av_packet_get_side_data(pkt, AV_PKT_DATA_H263_MB_INFO,
|
||||
&mb_info_size);
|
||||
if (!mb_info) {
|
||||
av_log(s1, AV_LOG_ERROR, "failed to allocate side data\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
ff_rtp_send_h263_rfc2190(s1, pkt->data, size, mb_info, mb_info_size);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -390,10 +390,8 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
if (st->codec->pix_fmt != AV_PIX_FMT_NONE && st->codec->pix_fmt != pix_fmt) {
|
||||
av_log(s, AV_LOG_ERROR, "pixel format change unsupported\n");
|
||||
res = AVERROR_PATCHWELCOME;
|
||||
goto bitmap_end;
|
||||
}
|
||||
st->codec->pix_fmt = pix_fmt;
|
||||
}else
|
||||
st->codec->pix_fmt = pix_fmt;
|
||||
|
||||
if (linesize * height > pkt->size) {
|
||||
res = AVERROR_INVALIDDATA;
|
||||
|
||||
@@ -114,7 +114,7 @@ static void handle_stream_probing(AVStream *st)
|
||||
{
|
||||
if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
|
||||
st->request_probe = AVPROBE_SCORE_EXTENSION;
|
||||
st->probe_packets = FFMIN(st->probe_packets, 14);
|
||||
st->probe_packets = FFMIN(st->probe_packets, 32);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ int ff_get_cpu_flags_arm(void)
|
||||
trickle down. */
|
||||
if (flags & (AV_CPU_FLAG_VFPV3 | AV_CPU_FLAG_NEON))
|
||||
flags |= AV_CPU_FLAG_ARMV6T2;
|
||||
else
|
||||
else if (flags & (AV_CPU_FLAG_ARMV6T2 | AV_CPU_FLAG_ARMV6))
|
||||
/* Some functions use the 'setend' instruction which is deprecated on ARMv8
|
||||
* and serializing on some ARMv7 cores. This ensures such functions
|
||||
* are only enabled on ARMv6. */
|
||||
|
||||
@@ -138,8 +138,8 @@ static uint64_t get_channel_layout_single(const char *name, int name_len)
|
||||
"switch to the syntax '%.*sc' otherwise it will be interpreted as a "
|
||||
"channel layout number in a later version\n",
|
||||
name_len, name, name_len, name);
|
||||
return layout;
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
|
||||
+2
-1
@@ -129,7 +129,8 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size,
|
||||
do {
|
||||
int len = FFMIN(f->end - wptr, size);
|
||||
if (func) {
|
||||
if (func(src, wptr, len) <= 0)
|
||||
len = func(src, wptr, len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
} else {
|
||||
memcpy(wptr, src, len);
|
||||
|
||||
@@ -59,7 +59,7 @@ static av_const SoftFloat av_normalize_sf(SoftFloat a){
|
||||
|
||||
static inline av_const SoftFloat av_normalize1_sf(SoftFloat a){
|
||||
#if 1
|
||||
if((int32_t)(a.mant + 0x40000000U) < 0){
|
||||
if((int32_t)(a.mant + 0x40000000U) <= 0){
|
||||
a.exp++;
|
||||
a.mant>>=1;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks
|
||||
#include "config.h"
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -1024,7 +1025,7 @@ void pp_postprocess(const uint8_t * src[3], const int srcStride[3],
|
||||
int i;
|
||||
const int count= FFMAX(mbHeight * QPStride, mbWidth);
|
||||
for(i=0; i<(count>>2); i++){
|
||||
((uint32_t*)c->nonBQPTable)[i] = ((const uint32_t*)QP_store)[i] & 0x3F3F3F3F;
|
||||
AV_WN32(c->nonBQPTable + (i<<2), AV_RN32(QP_store + (i<<2)) & 0x3F3F3F3F);
|
||||
}
|
||||
for(i<<=2; i<count; i++){
|
||||
c->nonBQPTable[i] = QP_store[i] & 0x3F;
|
||||
|
||||
@@ -23,12 +23,15 @@
|
||||
|
||||
#include "noise_shaping_data.c"
|
||||
|
||||
void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {
|
||||
int swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {
|
||||
double scale = s->dither.noise_scale;
|
||||
#define TMP_EXTRA 2
|
||||
double *tmp = av_malloc_array(len + TMP_EXTRA, sizeof(double));
|
||||
int i;
|
||||
|
||||
if (!tmp)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for(i=0; i<len + TMP_EXTRA; i++){
|
||||
double v;
|
||||
seed = seed* 1664525 + 1013904223;
|
||||
@@ -70,6 +73,7 @@ void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSa
|
||||
}
|
||||
|
||||
av_free(tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt)
|
||||
|
||||
@@ -49,8 +49,8 @@ static const AVOption options[]={
|
||||
{"in_sample_fmt" , "set input sample format" , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"osf" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"out_sample_fmt" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"tsf" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"internal_sample_fmt" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"tsf" , "set internal sample format" , OFFSET(user_int_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"internal_sample_fmt" , "set internal sample format" , OFFSET(user_int_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"icl" , "set input channel layout" , OFFSET(user_in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"in_channel_layout" , "set input channel layout" , OFFSET(user_in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"ocl" , "set output channel layout" , OFFSET(user_out_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
|
||||
+32
-11
@@ -173,6 +173,8 @@ av_cold int swr_init(struct SwrContext *s){
|
||||
s-> in_ch_layout = s-> user_in_ch_layout;
|
||||
s->out_ch_layout = s->user_out_ch_layout;
|
||||
|
||||
s->int_sample_fmt= s->user_int_sample_fmt;
|
||||
|
||||
if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) {
|
||||
av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout);
|
||||
s->in_ch_layout = 0;
|
||||
@@ -255,6 +257,10 @@ av_cold int swr_init(struct SwrContext *s){
|
||||
|
||||
if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){
|
||||
s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->precision, s->cheby);
|
||||
if (!s->resample) {
|
||||
av_log(s, AV_LOG_ERROR, "Failed to initilaize resampler\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
}else
|
||||
s->resampler->free(&s->resample);
|
||||
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
|
||||
@@ -263,7 +269,8 @@ av_cold int swr_init(struct SwrContext *s){
|
||||
&& s->int_sample_fmt != AV_SAMPLE_FMT_DBLP
|
||||
&& s->resample){
|
||||
av_log(s, AV_LOG_ERROR, "Resampling only supported with internal s16/s32/flt/dbl\n");
|
||||
return -1;
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#define RSC 1 //FIXME finetune
|
||||
@@ -277,24 +284,28 @@ av_cold int swr_init(struct SwrContext *s){
|
||||
if(!s-> in.ch_count){
|
||||
av_assert0(!s->in_ch_layout);
|
||||
av_log(s, AV_LOG_ERROR, "Input channel count and layout are unset\n");
|
||||
return -1;
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
|
||||
av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
|
||||
if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {
|
||||
av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
|
||||
return AVERROR(EINVAL);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {
|
||||
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_count);
|
||||
return AVERROR(EINVAL);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
|
||||
av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
|
||||
"but there is not enough information to do it\n", l1, l2);
|
||||
return -1;
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
av_assert0(s->used_ch_count);
|
||||
@@ -316,8 +327,10 @@ av_assert0(s->out.ch_count);
|
||||
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
|
||||
s->int_sample_fmt, s->out.ch_count, NULL, 0);
|
||||
|
||||
if (!s->in_convert || !s->out_convert)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!s->in_convert || !s->out_convert) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
s->postin= s->in;
|
||||
s->preout= s->out;
|
||||
@@ -344,12 +357,19 @@ av_assert0(s->out.ch_count);
|
||||
}
|
||||
|
||||
if ((ret = swri_dither_init(s, s->out_sample_fmt, s->int_sample_fmt)) < 0)
|
||||
return ret;
|
||||
goto fail;
|
||||
|
||||
if(s->rematrix || s->dither.method)
|
||||
return swri_rematrix_init(s);
|
||||
if(s->rematrix || s->dither.method) {
|
||||
ret = swri_rematrix_init(s);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
swr_close(s);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
int swri_realloc_audio(AudioData *a, int count){
|
||||
@@ -624,7 +644,8 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
|
||||
return ret;
|
||||
if(ret)
|
||||
for(ch=0; ch<s->dither.noise.ch_count; ch++)
|
||||
swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt);
|
||||
if((ret=swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt))<0)
|
||||
return ret;
|
||||
av_assert0(s->dither.noise.ch_count == preout->ch_count);
|
||||
|
||||
if(s->dither.noise_pos + out_count > s->dither.noise.count)
|
||||
|
||||
@@ -95,6 +95,7 @@ struct SwrContext {
|
||||
int user_used_ch_count; ///< User set used channel count
|
||||
int64_t user_in_ch_layout; ///< User set input channel layout
|
||||
int64_t user_out_ch_layout; ///< User set output channel layout
|
||||
enum AVSampleFormat user_int_sample_fmt; ///< User set internal sample format
|
||||
|
||||
struct DitherContext dither;
|
||||
|
||||
@@ -191,7 +192,7 @@ void swri_rematrix_free(SwrContext *s);
|
||||
int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);
|
||||
void swri_rematrix_init_x86(struct SwrContext *s);
|
||||
|
||||
void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt);
|
||||
int swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt);
|
||||
int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt);
|
||||
|
||||
void swri_audio_convert_init_aarch64(struct AudioConvert *ac,
|
||||
|
||||
@@ -51,6 +51,7 @@ void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
void (*shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
@@ -333,7 +334,6 @@ void shuffle_bytes_ ## a ## b ## c ## d(const uint8_t *src, \
|
||||
} \
|
||||
}
|
||||
|
||||
DEFINE_SHUFFLE_BYTES(0, 3, 2, 1)
|
||||
DEFINE_SHUFFLE_BYTES(1, 2, 3, 0)
|
||||
DEFINE_SHUFFLE_BYTES(3, 0, 1, 2)
|
||||
DEFINE_SHUFFLE_BYTES(3, 2, 1, 0)
|
||||
|
||||
@@ -50,6 +50,7 @@ extern void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
extern void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
extern void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
extern void (*shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
extern void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
@@ -71,7 +72,6 @@ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void shuffle_bytes_1230(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
@@ -322,12 +322,26 @@ static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst,
|
||||
uint8_t *d = dst - idx;
|
||||
|
||||
for (; idx < 15; idx += 4) {
|
||||
register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
|
||||
register unsigned v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
|
||||
v &= 0xff00ff;
|
||||
*(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void shuffle_bytes_0321_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
int idx = 15 - src_size;
|
||||
const uint8_t *s = src - idx;
|
||||
uint8_t *d = dst - idx;
|
||||
|
||||
for (; idx < 15; idx += 4) {
|
||||
register unsigned v = *(const uint32_t *)&s[idx], g = v & 0x00ff00ff;
|
||||
v &= 0xff00ff00;
|
||||
*(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
unsigned i;
|
||||
@@ -929,7 +943,13 @@ static av_cold void rgb2rgb_init_c(void)
|
||||
rgb24to15 = rgb24to15_c;
|
||||
rgb24to16 = rgb24to16_c;
|
||||
rgb24tobgr24 = rgb24tobgr24_c;
|
||||
#if HAVE_BIGENDIAN
|
||||
shuffle_bytes_0321 = shuffle_bytes_2103_c;
|
||||
shuffle_bytes_2103 = shuffle_bytes_0321_c;
|
||||
#else
|
||||
shuffle_bytes_0321 = shuffle_bytes_0321_c;
|
||||
shuffle_bytes_2103 = shuffle_bytes_2103_c;
|
||||
#endif
|
||||
rgb32tobgr16 = rgb32tobgr16_c;
|
||||
rgb32tobgr15 = rgb32tobgr15_c;
|
||||
yv12toyuy2 = yv12toyuy2_c;
|
||||
|
||||
@@ -1242,6 +1242,11 @@ static rgbConvFn findRgbConvFn(SwsContext *c)
|
||||
if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0)
|
||||
return NULL;
|
||||
|
||||
// Maintain symmetry between endianness
|
||||
if (c->flags & SWS_BITEXACT)
|
||||
if ((dstFormat == AV_PIX_FMT_RGB32 || dstFormat == AV_PIX_FMT_BGR32 ) && !isRGBA32(srcFormat) && ALT32_CORR>0)
|
||||
return NULL;
|
||||
|
||||
return conv;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1410,9 +1410,9 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
|
||||
|
||||
/* Allocate pixbufs (we use dynamic allocation because otherwise we would
|
||||
* need to allocate several megabytes to handle all possible cases) */
|
||||
FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail);
|
||||
FF_ALLOC_OR_GOTO(c, c->chrUPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
|
||||
FF_ALLOC_OR_GOTO(c, c->chrVPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
|
||||
FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail);
|
||||
FF_ALLOCZ_OR_GOTO(c, c->chrUPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
|
||||
FF_ALLOCZ_OR_GOTO(c, c->chrVPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
|
||||
if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
|
||||
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail);
|
||||
/* Note we need at least one pixel more at the end because of the MMX code
|
||||
|
||||
@@ -1090,7 +1090,7 @@ static inline void RENAME(shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst,
|
||||
: "r" (s), "r" (d), "m" (mask32b), "m" (mask32r), "m" (mmx_one)
|
||||
: "memory");
|
||||
for (; idx<15; idx+=4) {
|
||||
register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
|
||||
register unsigned v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
|
||||
v &= 0xff00ff;
|
||||
*(uint32_t *)&d[idx] = (v>>16) + g + (v<<16);
|
||||
}
|
||||
@@ -1905,7 +1905,7 @@ static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, ui
|
||||
"cmp %3, %%"REG_a" \n\t"
|
||||
" jb 1b \n\t"
|
||||
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
|
||||
: "memory", "%"REG_a""
|
||||
: "memory", XMM_CLOBBERS("xmm0", "xmm1", "xmm2",) "%"REG_a
|
||||
);
|
||||
#else
|
||||
__asm__(
|
||||
|
||||
Reference in New Issue
Block a user