Compare commits
103 Commits
n2.3.5
...
release/2.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
49fb1f66f1 | ||
![]() |
f8b25be7f7 | ||
![]() |
633bf6246c | ||
![]() |
0fde898f16 | ||
![]() |
1fff994709 | ||
![]() |
eb0a9cd68a | ||
![]() |
f450caf057 | ||
![]() |
f6006295c0 | ||
![]() |
5279f5d068 | ||
![]() |
d40ab18c07 | ||
![]() |
80a467b452 | ||
![]() |
9e1b493916 | ||
![]() |
44184226ac | ||
![]() |
e2f0443af0 | ||
![]() |
f57a595024 | ||
![]() |
d88a85c493 | ||
![]() |
bf4fa00162 | ||
![]() |
17d9157c82 | ||
![]() |
e1afd6ed60 | ||
![]() |
7d97587b1a | ||
![]() |
86c85b6f1a | ||
![]() |
ac4126decd | ||
![]() |
db27f50e06 | ||
![]() |
8327bef1c9 | ||
![]() |
a620c463f0 | ||
![]() |
63b5cb1fb0 | ||
![]() |
7959b9a0f3 | ||
![]() |
bbfe0f7b08 | ||
![]() |
27a910a857 | ||
![]() |
ffe915b6f5 | ||
![]() |
22558d6f6e | ||
![]() |
f03888b449 | ||
![]() |
11c0531099 | ||
![]() |
0b033cd3a1 | ||
![]() |
c9a25ff5a0 | ||
![]() |
3ee4a610c2 | ||
![]() |
d071c1f0e1 | ||
![]() |
15601df419 | ||
![]() |
103cf56c62 | ||
![]() |
d4c45f9249 | ||
![]() |
841ce9a838 | ||
![]() |
8a01fb3729 | ||
![]() |
b5dbe93c8b | ||
![]() |
185e55279c | ||
![]() |
730826275f | ||
![]() |
afd7fac3f1 | ||
![]() |
3353a00d58 | ||
![]() |
b052ea0f5b | ||
![]() |
c8fb53357d | ||
![]() |
30e7dae22c | ||
![]() |
a74a0a5c0c | ||
![]() |
0f77303c57 | ||
![]() |
dbe690b572 | ||
![]() |
6eca20aaec | ||
![]() |
7ef11e8221 | ||
![]() |
942806cbe4 | ||
![]() |
557e3790ef | ||
![]() |
2b15ceec62 | ||
![]() |
c3cd7b8a29 | ||
![]() |
0621421ee2 | ||
![]() |
0e9fe8510e | ||
![]() |
1f59cfe65b | ||
![]() |
a6f808b36a | ||
![]() |
4a495766d1 | ||
![]() |
cedb96db37 | ||
![]() |
de75b4063d | ||
![]() |
bb70b6673f | ||
![]() |
a07dfcdd6d | ||
![]() |
5630d5cdc2 | ||
![]() |
87d0339d67 | ||
![]() |
fac6ae0814 | ||
![]() |
0c51b26729 | ||
![]() |
e0822b147f | ||
![]() |
1bfd23d2c9 | ||
![]() |
419bd6e303 | ||
![]() |
494d3d14db | ||
![]() |
6c63eb5909 | ||
![]() |
142896f2d0 | ||
![]() |
dca70c5931 | ||
![]() |
17ff5d3f88 | ||
![]() |
693d0d3ac5 | ||
![]() |
bb2c09310c | ||
![]() |
66261cfa77 | ||
![]() |
b89b136c00 | ||
![]() |
6ed35a6674 | ||
![]() |
d4c70c8b50 | ||
![]() |
05bc6f8ba6 | ||
![]() |
c2517fb363 | ||
![]() |
0cc15f7c83 | ||
![]() |
b6ff3acafc | ||
![]() |
8047380514 | ||
![]() |
b152305bb3 | ||
![]() |
a0605792c2 | ||
![]() |
4b8cb3fe51 | ||
![]() |
48bf926bad | ||
![]() |
ab43652c67 | ||
![]() |
48b586ca4e | ||
![]() |
4e2e997faf | ||
![]() |
19ccc06d8b | ||
![]() |
193b949f71 | ||
![]() |
63ed7e09dd | ||
![]() |
10464ca0eb | ||
![]() |
4f515913a2 |
@@ -14,7 +14,6 @@ patches and related discussions.
|
||||
Project Leader
|
||||
==============
|
||||
|
||||
Michael Niedermayer
|
||||
final design decisions
|
||||
|
||||
|
||||
|
2
Makefile
2
Makefile
@@ -110,7 +110,7 @@ endef
|
||||
|
||||
$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
|
||||
|
||||
ffprobe.o cmdutils.o : libavutil/ffversion.h
|
||||
ffprobe.o cmdutils.o libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
|
||||
|
||||
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
|
||||
$(CP) $< $@
|
||||
|
@@ -1857,7 +1857,7 @@ int read_yesno(void)
|
||||
|
||||
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
|
||||
{
|
||||
int ret;
|
||||
int64_t ret;
|
||||
FILE *f = av_fopen_utf8(filename, "rb");
|
||||
|
||||
if (!f) {
|
||||
|
1
configure
vendored
1
configure
vendored
@@ -5535,6 +5535,7 @@ enabled getenv || echo "#define getenv(x) NULL" >> $TMPH
|
||||
|
||||
|
||||
mkdir -p doc
|
||||
mkdir -p tests
|
||||
echo "@c auto-generated by configure" > doc/config.texi
|
||||
|
||||
print_config ARCH_ "$config_files" $ARCH_LIST
|
||||
|
@@ -105,10 +105,10 @@ API changes, most recent first:
|
||||
2014-05-11 - 14aef38 / 66e6c8a - lavu 52.83.100 / 53.14.0 - pixfmt.h
|
||||
Add AV_PIX_FMT_VDA for new-style VDA acceleration.
|
||||
|
||||
2014-05-xx - xxxxxxx - lavu 52.82.0 - fifo.h
|
||||
2014-05-xx - xxxxxxx - lavu 52.82.100 - fifo.h
|
||||
Add av_fifo_freep() function.
|
||||
|
||||
2014-05-02 - ba52fb11 - lavu 52.81.0 - opt.h
|
||||
2014-05-02 - ba52fb11 - lavu 52.81.100 - opt.h
|
||||
Add av_opt_set_dict2() function.
|
||||
|
||||
2014-05-01 - e77b985 / a2941c8 - lavc 55.60.103 / 55.50.3 - avcodec.h
|
||||
|
@@ -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.3.5
|
||||
PROJECT_NUMBER = 2.3.6
|
||||
|
||||
# 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
|
||||
|
@@ -116,6 +116,10 @@ static int open_output_file(const char *filename)
|
||||
|| dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
/* in this example, we choose transcoding to same codec */
|
||||
encoder = avcodec_find_encoder(dec_ctx->codec_id);
|
||||
if (!encoder) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Neccessary encoder not found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* In this example, we transcode to same properties (picture size,
|
||||
* sample rate etc.). These properties can be changed for output
|
||||
|
@@ -3968,7 +3968,7 @@ within the parameter list.
|
||||
@item
|
||||
Show the text at the center of the video frame:
|
||||
@example
|
||||
drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
|
||||
drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
|
||||
@end example
|
||||
|
||||
@item
|
||||
|
@@ -858,7 +858,7 @@ Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise.
|
||||
Return the maximum between @var{x} and @var{y}.
|
||||
|
||||
@item min(x, y)
|
||||
Return the maximum between @var{x} and @var{y}.
|
||||
Return the minimum between @var{x} and @var{y}.
|
||||
|
||||
@item mod(x, y)
|
||||
Compute the remainder of division of @var{x} by @var{y}.
|
||||
|
8
ffmpeg.c
8
ffmpeg.c
@@ -578,6 +578,14 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
|
||||
AVCodecContext *avctx = ost->st->codec;
|
||||
int ret;
|
||||
|
||||
if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) {
|
||||
ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (ost->st->codec->extradata) {
|
||||
memcpy(ost->st->codec->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size);
|
||||
ost->st->codec->extradata_size = ost->enc_ctx->extradata_size;
|
||||
}
|
||||
}
|
||||
|
||||
if ((avctx->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) ||
|
||||
(avctx->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
|
||||
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
|
||||
|
@@ -2359,6 +2359,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#else
|
||||
if (s->xch_present && !s->xch_disable) {
|
||||
#endif
|
||||
if (avctx->channel_layout & AV_CH_BACK_CENTER) {
|
||||
avpriv_request_sample(avctx, "XCh with Back center channel");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avctx->channel_layout |= AV_CH_BACK_CENTER;
|
||||
if (s->lfe) {
|
||||
avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
|
||||
|
@@ -105,6 +105,9 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
|
||||
int x, y, len, color;
|
||||
uint8_t *d;
|
||||
|
||||
if (start >= buf_size)
|
||||
return -1;
|
||||
|
||||
bit_len = (buf_size - start) * 8;
|
||||
init_get_bits(&gb, buf + start, bit_len);
|
||||
|
||||
@@ -356,10 +359,12 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
|
||||
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
|
||||
sub_header->num_rects = 1;
|
||||
sub_header->rects[0]->pict.data[0] = bitmap;
|
||||
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
|
||||
buf, offset1, buf_size, is_8bit);
|
||||
decode_rle(bitmap + w, w * 2, w, h / 2,
|
||||
buf, offset2, buf_size, is_8bit);
|
||||
if (decode_rle(bitmap, w * 2, w, (h + 1) / 2,
|
||||
buf, offset1, buf_size, is_8bit) < 0)
|
||||
goto fail;
|
||||
if (decode_rle(bitmap + w, w * 2, w, h / 2,
|
||||
buf, offset2, buf_size, is_8bit) < 0)
|
||||
goto fail;
|
||||
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
|
||||
if (is_8bit) {
|
||||
if (yuv_palette == 0)
|
||||
|
@@ -1011,6 +1011,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;
|
||||
@@ -1351,21 +1367,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 ) {
|
||||
|
@@ -101,7 +101,7 @@ av_cold int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
|
||||
av_cold int ffv1_init_slices_state(FFV1Context *f)
|
||||
{
|
||||
int i, ret;
|
||||
for (i = 0; i < f->slice_count; i++) {
|
||||
for (i = 0; i < f->max_slice_count; i++) {
|
||||
FFV1Context *fs = f->slice_context[i];
|
||||
if ((ret = ffv1_init_slice_state(f, fs)) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -113,10 +113,10 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
|
||||
{
|
||||
int i;
|
||||
|
||||
f->slice_count = f->num_h_slices * f->num_v_slices;
|
||||
av_assert0(f->slice_count > 0);
|
||||
f->max_slice_count = f->num_h_slices * f->num_v_slices;
|
||||
av_assert0(f->max_slice_count > 0);
|
||||
|
||||
for (i = 0; i < f->slice_count; i++) {
|
||||
for (i = 0; i < f->max_slice_count; i++) {
|
||||
FFV1Context *fs = av_mallocz(sizeof(*fs));
|
||||
int sx = i % f->num_h_slices;
|
||||
int sy = i / f->num_h_slices;
|
||||
@@ -201,7 +201,7 @@ av_cold int ffv1_close(AVCodecContext *avctx)
|
||||
ff_thread_release_buffer(avctx, &s->last_picture);
|
||||
av_frame_free(&s->last_picture.f);
|
||||
|
||||
for (j = 0; j < s->slice_count; j++) {
|
||||
for (j = 0; j < s->max_slice_count; j++) {
|
||||
FFV1Context *fs = s->slice_context[j];
|
||||
for (i = 0; i < s->plane_count; i++) {
|
||||
PlaneContext *p = &fs->plane[i];
|
||||
@@ -215,14 +215,14 @@ av_cold int ffv1_close(AVCodecContext *avctx)
|
||||
av_freep(&avctx->stats_out);
|
||||
for (j = 0; j < s->quant_table_count; j++) {
|
||||
av_freep(&s->initial_states[j]);
|
||||
for (i = 0; i < s->slice_count; i++) {
|
||||
for (i = 0; i < s->max_slice_count; i++) {
|
||||
FFV1Context *sf = s->slice_context[i];
|
||||
av_freep(&sf->rc_stat2[j]);
|
||||
}
|
||||
av_freep(&s->rc_stat2[j]);
|
||||
}
|
||||
|
||||
for (i = 0; i < s->slice_count; i++)
|
||||
for (i = 0; i < s->max_slice_count; i++)
|
||||
av_freep(&s->slice_context[i]);
|
||||
|
||||
return 0;
|
||||
|
@@ -117,6 +117,7 @@ typedef struct FFV1Context {
|
||||
|
||||
struct FFV1Context *slice_context[MAX_SLICES];
|
||||
int slice_count;
|
||||
int max_slice_count;
|
||||
int num_v_slices;
|
||||
int num_h_slices;
|
||||
int slice_width;
|
||||
|
@@ -554,8 +554,11 @@ static int read_extra_header(FFV1Context *f)
|
||||
}
|
||||
|
||||
f->quant_table_count = get_symbol(c, state, 0);
|
||||
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES)
|
||||
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES || !f->quant_table_count) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "quant table count %d is invalid\n", f->quant_table_count);
|
||||
f->quant_table_count = 0;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (i = 0; i < f->quant_table_count; i++) {
|
||||
f->context_count[i] = read_quant_tables(c, f->quant_tables[i]);
|
||||
@@ -758,6 +761,7 @@ static int read_header(FFV1Context *f)
|
||||
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
f->slice_count = f->max_slice_count;
|
||||
} else if (f->version < 3) {
|
||||
f->slice_count = get_symbol(c, state, 0);
|
||||
} else {
|
||||
@@ -772,8 +776,8 @@ static int read_header(FFV1Context *f)
|
||||
p -= size + trailer;
|
||||
}
|
||||
}
|
||||
if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid\n", f->slice_count);
|
||||
if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0 || f->slice_count > f->max_slice_count) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid (max=%d)\n", f->slice_count, f->max_slice_count);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
@@ -996,6 +1000,7 @@ static int init_thread_copy(AVCodecContext *avctx)
|
||||
f->picture.f = NULL;
|
||||
f->last_picture.f = NULL;
|
||||
f->sample_buffer = NULL;
|
||||
f->max_slice_count = 0;
|
||||
f->slice_count = 0;
|
||||
|
||||
for (i = 0; i < f->quant_table_count; i++) {
|
||||
@@ -1066,7 +1071,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
|
||||
av_assert0(!fdst->sample_buffer);
|
||||
}
|
||||
|
||||
av_assert1(fdst->slice_count == fsrc->slice_count);
|
||||
av_assert1(fdst->max_slice_count == fsrc->max_slice_count);
|
||||
|
||||
|
||||
ff_thread_release_buffer(dst, &fdst->picture);
|
||||
|
@@ -955,6 +955,7 @@ slices_ok:
|
||||
|
||||
if ((ret = ffv1_init_slice_contexts(s)) < 0)
|
||||
return ret;
|
||||
s->slice_count = s->max_slice_count;
|
||||
if ((ret = ffv1_init_slices_state(s)) < 0)
|
||||
return ret;
|
||||
|
||||
@@ -964,7 +965,7 @@ slices_ok:
|
||||
if (!avctx->stats_out)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < s->quant_table_count; i++)
|
||||
for (j = 0; j < s->slice_count; j++) {
|
||||
for (j = 0; j < s->max_slice_count; j++) {
|
||||
FFV1Context *sf = s->slice_context[j];
|
||||
av_assert0(!sf->rc_stat2[i]);
|
||||
sf->rc_stat2[i] = av_mallocz(s->context_count[i] *
|
||||
@@ -1188,6 +1189,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
for (i = 0; i < f->quant_table_count; i++)
|
||||
memset(f->rc_stat2[i], 0, f->context_count[i] * sizeof(*f->rc_stat2[i]));
|
||||
|
||||
av_assert0(f->slice_count == f->max_slice_count);
|
||||
for (j = 0; j < f->slice_count; j++) {
|
||||
FFV1Context *fs = f->slice_context[j];
|
||||
for (i = 0; i < 256; i++) {
|
||||
|
@@ -471,10 +471,10 @@ static int decode_frame(FLACContext *s)
|
||||
ret = allocate_buffers(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
|
||||
s->got_streaminfo = 1;
|
||||
dump_headers(s->avctx, (FLACStreaminfo *)s);
|
||||
}
|
||||
ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
|
||||
|
||||
// dump_headers(s->avctx, (FLACStreaminfo *)s);
|
||||
|
||||
|
@@ -392,6 +392,7 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp)
|
||||
if (free_rbsp && h->DPB) {
|
||||
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
|
||||
ff_h264_unref_picture(h, &h->DPB[i]);
|
||||
memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
|
||||
av_freep(&h->DPB);
|
||||
} else if (h->DPB) {
|
||||
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
|
||||
@@ -990,6 +991,16 @@ int ff_pred_weight_table(H264Context *h)
|
||||
h->luma_log2_weight_denom = get_ue_golomb(&h->gb);
|
||||
if (h->sps.chroma_format_idc)
|
||||
h->chroma_log2_weight_denom = get_ue_golomb(&h->gb);
|
||||
|
||||
if (h->luma_log2_weight_denom > 7U) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", h->luma_log2_weight_denom);
|
||||
h->luma_log2_weight_denom = 0;
|
||||
}
|
||||
if (h->chroma_log2_weight_denom > 7U) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of range\n", h->chroma_log2_weight_denom);
|
||||
h->chroma_log2_weight_denom = 0;
|
||||
}
|
||||
|
||||
luma_def = 1 << h->luma_log2_weight_denom;
|
||||
chroma_def = 1 << h->chroma_log2_weight_denom;
|
||||
|
||||
@@ -1330,43 +1341,6 @@ int ff_set_ref_count(H264Context *h)
|
||||
|
||||
static const uint8_t start_code[] = { 0x00, 0x00, 0x01 };
|
||||
|
||||
static int find_start_code(const uint8_t *buf, int buf_size,
|
||||
int buf_index, int next_avc)
|
||||
{
|
||||
// start code prefix search
|
||||
for (; buf_index + 3 < next_avc; buf_index++)
|
||||
// This should always succeed in the first iteration.
|
||||
if (buf[buf_index] == 0 &&
|
||||
buf[buf_index + 1] == 0 &&
|
||||
buf[buf_index + 2] == 1)
|
||||
break;
|
||||
|
||||
buf_index += 3;
|
||||
|
||||
if (buf_index >= buf_size)
|
||||
return buf_size;
|
||||
|
||||
return buf_index;
|
||||
}
|
||||
|
||||
static int get_avc_nalsize(H264Context *h, const uint8_t *buf,
|
||||
int buf_size, int *buf_index)
|
||||
{
|
||||
int i, nalsize = 0;
|
||||
|
||||
if (*buf_index >= buf_size - h->nal_length_size)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < h->nal_length_size; i++)
|
||||
nalsize = (nalsize << 8) | buf[(*buf_index)++];
|
||||
if (nalsize <= 0 || nalsize > buf_size - *buf_index) {
|
||||
av_log(h->avctx, AV_LOG_ERROR,
|
||||
"AVC: nal size %d\n", nalsize);
|
||||
return -1;
|
||||
}
|
||||
return nalsize;
|
||||
}
|
||||
|
||||
static int get_bit_length(H264Context *h, const uint8_t *buf,
|
||||
const uint8_t *ptr, int dst_length,
|
||||
int i, int next_avc)
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include "h264dsp.h"
|
||||
#include "h264pred.h"
|
||||
#include "h264qpel.h"
|
||||
#include "internal.h" // for avpriv_find_start_code()
|
||||
#include "mpegutils.h"
|
||||
#include "parser.h"
|
||||
#include "qpeldsp.h"
|
||||
@@ -337,6 +338,7 @@ typedef struct H264Picture {
|
||||
* H264Context
|
||||
*/
|
||||
typedef struct H264Context {
|
||||
AVClass *av_class;
|
||||
AVCodecContext *avctx;
|
||||
VideoDSPContext vdsp;
|
||||
H264DSPContext h264dsp;
|
||||
@@ -1092,6 +1094,34 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h)
|
||||
0x0001000100010001ULL));
|
||||
}
|
||||
|
||||
static inline int find_start_code(const uint8_t *buf, int buf_size,
|
||||
int buf_index, int next_avc)
|
||||
{
|
||||
uint32_t state = -1;
|
||||
|
||||
buf_index = avpriv_find_start_code(buf + buf_index, buf + next_avc + 1, &state) - buf - 1;
|
||||
|
||||
return FFMIN(buf_index, buf_size);
|
||||
}
|
||||
|
||||
static inline int get_avc_nalsize(H264Context *h, const uint8_t *buf,
|
||||
int buf_size, int *buf_index)
|
||||
{
|
||||
int i, nalsize = 0;
|
||||
|
||||
if (*buf_index >= buf_size - h->nal_length_size)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < h->nal_length_size; i++)
|
||||
nalsize = ((unsigned)nalsize << 8) | buf[(*buf_index)++];
|
||||
if (nalsize <= 0 || nalsize > buf_size - *buf_index) {
|
||||
av_log(h->avctx, AV_LOG_ERROR,
|
||||
"AVC: nal size %d\n", nalsize);
|
||||
return -1;
|
||||
}
|
||||
return nalsize;
|
||||
}
|
||||
|
||||
int ff_h264_field_end(H264Context *h, int in_setup);
|
||||
|
||||
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
|
||||
|
@@ -173,7 +173,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
||||
buf += ctx->length_size;
|
||||
unit_type = *buf & 0x1f;
|
||||
|
||||
if (buf + nal_size > buf_end || nal_size < 0)
|
||||
if (nal_size > buf_end - buf || nal_size < 0)
|
||||
goto fail;
|
||||
|
||||
if (ctx->first_idr && (unit_type == 7 || unit_type == 8))
|
||||
|
@@ -203,10 +203,10 @@ static int scan_mmco_reset(AVCodecParserContext *s)
|
||||
*/
|
||||
static inline int parse_nal_units(AVCodecParserContext *s,
|
||||
AVCodecContext *avctx,
|
||||
const uint8_t *buf, int buf_size)
|
||||
const uint8_t * const buf, int buf_size)
|
||||
{
|
||||
H264Context *h = s->priv_data;
|
||||
const uint8_t *buf_end = buf + buf_size;
|
||||
int buf_index, next_avc;
|
||||
unsigned int pps_id;
|
||||
unsigned int slice_type;
|
||||
int state = -1, got_reset = 0;
|
||||
@@ -226,26 +226,26 @@ static inline int parse_nal_units(AVCodecParserContext *s,
|
||||
if (!buf_size)
|
||||
return 0;
|
||||
|
||||
buf_index = 0;
|
||||
next_avc = h->is_avc ? 0 : buf_size;
|
||||
for (;;) {
|
||||
int src_length, dst_length, consumed, nalsize = 0;
|
||||
if (h->is_avc) {
|
||||
int i;
|
||||
if (h->nal_length_size >= buf_end - buf) break;
|
||||
nalsize = 0;
|
||||
for (i = 0; i < h->nal_length_size; i++)
|
||||
nalsize = (nalsize << 8) | *buf++;
|
||||
if (nalsize <= 0 || nalsize > buf_end - buf) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
|
||||
|
||||
if (buf_index >= next_avc) {
|
||||
nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
|
||||
if (nalsize < 0)
|
||||
break;
|
||||
}
|
||||
src_length = nalsize;
|
||||
next_avc = buf_index + nalsize;
|
||||
} else {
|
||||
buf = avpriv_find_start_code(buf, buf_end, &state);
|
||||
if (buf >= buf_end)
|
||||
break;
|
||||
--buf;
|
||||
src_length = buf_end - buf;
|
||||
buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
|
||||
if (buf_index >= buf_size)
|
||||
break;
|
||||
if (buf_index >= next_avc)
|
||||
continue;
|
||||
}
|
||||
src_length = next_avc - buf_index;
|
||||
|
||||
state = buf[buf_index];
|
||||
switch (state & 0x1f) {
|
||||
case NAL_SLICE:
|
||||
case NAL_IDR_SLICE:
|
||||
@@ -262,10 +262,13 @@ static inline int parse_nal_units(AVCodecParserContext *s,
|
||||
}
|
||||
break;
|
||||
}
|
||||
ptr = ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);
|
||||
ptr = ff_h264_decode_nal(h, buf + buf_index, &dst_length,
|
||||
&consumed, src_length);
|
||||
if (ptr == NULL || dst_length < 0)
|
||||
break;
|
||||
|
||||
buf_index += consumed;
|
||||
|
||||
init_get_bits(&h->gb, ptr, 8 * dst_length);
|
||||
switch (h->nal_unit_type) {
|
||||
case NAL_SPS:
|
||||
@@ -440,7 +443,6 @@ static inline int parse_nal_units(AVCodecParserContext *s,
|
||||
|
||||
return 0; /* no need to evaluate the rest */
|
||||
}
|
||||
buf += h->is_avc ? nalsize : consumed;
|
||||
}
|
||||
if (q264)
|
||||
return 0;
|
||||
|
@@ -586,6 +586,17 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
|
||||
h->mb_type_pool = NULL;
|
||||
h->ref_index_pool = NULL;
|
||||
h->motion_val_pool = NULL;
|
||||
h->intra4x4_pred_mode= NULL;
|
||||
h->non_zero_count = NULL;
|
||||
h->slice_table_base = NULL;
|
||||
h->slice_table = NULL;
|
||||
h->cbp_table = NULL;
|
||||
h->chroma_pred_mode_table = NULL;
|
||||
memset(h->mvd_table, 0, sizeof(h->mvd_table));
|
||||
h->direct_table = NULL;
|
||||
h->list_counts = NULL;
|
||||
h->mb2b_xy = NULL;
|
||||
h->mb2br_xy = NULL;
|
||||
for (i = 0; i < 2; i++) {
|
||||
h->rbsp_buffer[i] = NULL;
|
||||
h->rbsp_buffer_size[i] = 0;
|
||||
|
@@ -108,7 +108,7 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
|
||||
if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm)
|
||||
goto fail;
|
||||
|
||||
s->filter_slice_edges = av_malloc(ctb_count);
|
||||
s->filter_slice_edges = av_mallocz(ctb_count);
|
||||
s->tab_slice_address = av_malloc_array(pic_size_in_ctb,
|
||||
sizeof(*s->tab_slice_address));
|
||||
s->qp_y_tab = av_malloc_array(pic_size_in_ctb,
|
||||
@@ -746,6 +746,8 @@ static int hls_slice_header(HEVCContext *s)
|
||||
s->HEVClc->tu.cu_qp_offset_cb = 0;
|
||||
s->HEVClc->tu.cu_qp_offset_cr = 0;
|
||||
|
||||
s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == NAL_CRA_NUT && s->last_eos);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2378,6 +2380,8 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
|
||||
|
||||
if (more_data < 0) {
|
||||
s->tab_slice_address[ctb_addr_rs] = -1;
|
||||
avpriv_atomic_int_set(&s1->wpp_err, 1);
|
||||
ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP);
|
||||
return more_data;
|
||||
}
|
||||
|
||||
@@ -3306,6 +3310,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
|
||||
s->pocTid0 = s0->pocTid0;
|
||||
s->max_ra = s0->max_ra;
|
||||
s->eos = s0->eos;
|
||||
s->no_rasl_output_flag = s0->no_rasl_output_flag;
|
||||
|
||||
s->is_nalff = s0->is_nalff;
|
||||
s->nal_length_size = s0->nal_length_size;
|
||||
@@ -3400,6 +3405,7 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
|
||||
|
||||
s->enable_parallel_tiles = 0;
|
||||
s->picture_struct = 0;
|
||||
s->eos = 1;
|
||||
|
||||
if(avctx->active_thread_type & FF_THREAD_SLICE)
|
||||
s->threads_number = avctx->thread_count;
|
||||
@@ -3441,6 +3447,7 @@ static void hevc_decode_flush(AVCodecContext *avctx)
|
||||
HEVCContext *s = avctx->priv_data;
|
||||
ff_hevc_flush_dpb(s);
|
||||
s->max_ra = INT_MAX;
|
||||
s->eos = 1;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(HEVCContext, x)
|
||||
|
@@ -850,6 +850,7 @@ typedef struct HEVCContext {
|
||||
int bs_height;
|
||||
|
||||
int is_decoded;
|
||||
int no_rasl_output_flag;
|
||||
|
||||
HEVCPredContext hpc;
|
||||
HEVCDSPContext hevcdsp;
|
||||
|
@@ -865,6 +865,11 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
||||
sps->long_term_ref_pics_present_flag = get_bits1(gb);
|
||||
if (sps->long_term_ref_pics_present_flag) {
|
||||
sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
|
||||
if (sps->num_long_term_ref_pics_sps > 31U) {
|
||||
av_log(0, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out of range.\n",
|
||||
sps->num_long_term_ref_pics_sps);
|
||||
goto err;
|
||||
}
|
||||
for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
|
||||
sps->lt_ref_pic_poc_lsb_sps[i] = get_bits(gb, sps->log2_max_poc_lsb);
|
||||
sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb);
|
||||
@@ -1164,6 +1169,14 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
|
||||
if (pps->cu_qp_delta_enabled_flag)
|
||||
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
|
||||
|
||||
if (pps->diff_cu_qp_delta_depth < 0 ||
|
||||
pps->diff_cu_qp_delta_depth > sps->log2_diff_max_min_coding_block_size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "diff_cu_qp_delta_depth %d is invalid\n",
|
||||
pps->diff_cu_qp_delta_depth);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto err;
|
||||
}
|
||||
|
||||
pps->cb_qp_offset = get_se_golomb(gb);
|
||||
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
|
||||
@@ -1289,7 +1302,8 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
|
||||
if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && pps_range_extensions_flag) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"PPS extension flag is partially implemented.\n");
|
||||
pps_range_extensions(s, pps, sps);
|
||||
if ((ret = pps_range_extensions(s, pps, sps)) < 0)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -163,7 +163,7 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
|
||||
int min_poc = INT_MAX;
|
||||
int i, min_idx, ret;
|
||||
|
||||
if (s->sh.no_output_of_prior_pics_flag == 1) {
|
||||
if (s->sh.no_output_of_prior_pics_flag == 1 && s->no_rasl_output_flag == 1) {
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
|
||||
HEVCFrame *frame = &s->DPB[i];
|
||||
if ((frame->flags & HEVC_FRAME_FLAG_OUTPUT) && frame->poc != s->poc &&
|
||||
|
@@ -94,7 +94,7 @@ typedef struct Indeo3DecodeContext {
|
||||
|
||||
int16_t width, height;
|
||||
uint32_t frame_num; ///< current frame number (zero-based)
|
||||
uint32_t data_size; ///< size of the frame data in bytes
|
||||
int data_size; ///< size of the frame data in bytes
|
||||
uint16_t frame_flags; ///< frame properties
|
||||
uint8_t cb_offset; ///< needed for selecting VQ tables
|
||||
uint8_t buf_sel; ///< active frame buffer: 0 - primary, 1 -secondary
|
||||
@@ -899,7 +899,8 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
||||
GetByteContext gb;
|
||||
const uint8_t *bs_hdr;
|
||||
uint32_t frame_num, word2, check_sum, data_size;
|
||||
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
|
||||
int y_offset, u_offset, v_offset;
|
||||
uint32_t starts[3], ends[3];
|
||||
uint16_t height, width;
|
||||
int i, j;
|
||||
|
||||
@@ -981,7 +982,8 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
||||
ctx->y_data_size = ends[0] - starts[0];
|
||||
ctx->v_data_size = ends[1] - starts[1];
|
||||
ctx->u_data_size = ends[2] - starts[2];
|
||||
if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
|
||||
if (FFMIN3(y_offset, v_offset, u_offset) < 0 ||
|
||||
FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
|
||||
FFMIN3(y_offset, v_offset, u_offset) < gb.buffer - bs_hdr + 16 ||
|
||||
FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
|
||||
|
@@ -43,6 +43,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
JvContext *s = avctx->priv_data;
|
||||
|
||||
if (!avctx->width || !avctx->height ||
|
||||
(avctx->width & 7) || (avctx->height & 7)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid video dimensions: %dx%d\n",
|
||||
avctx->width, avctx->height);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
s->frame = av_frame_alloc();
|
||||
if (!s->frame)
|
||||
return AVERROR(ENOMEM);
|
||||
|
@@ -244,7 +244,8 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
|
||||
|
||||
int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
||||
{
|
||||
int len, nb_components, i, width, height, bits, pix_fmt_id, ret;
|
||||
int len, nb_components, i, width, height, bits, ret;
|
||||
unsigned pix_fmt_id;
|
||||
int h_count[MAX_COMPONENTS];
|
||||
int v_count[MAX_COMPONENTS];
|
||||
|
||||
@@ -378,7 +379,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
||||
else if (!s->lossless)
|
||||
s->rgb = 0;
|
||||
/* XXX: not complete test ! */
|
||||
pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) |
|
||||
pix_fmt_id = ((unsigned)s->h_count[0] << 28) | (s->v_count[0] << 24) |
|
||||
(s->h_count[1] << 20) | (s->v_count[1] << 16) |
|
||||
(s->h_count[2] << 12) | (s->v_count[2] << 8) |
|
||||
(s->h_count[3] << 4) | s->v_count[3];
|
||||
@@ -513,6 +514,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
||||
else s->avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
|
||||
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
|
||||
if (pix_fmt_id == 0x42111100) {
|
||||
if (s->bits > 8)
|
||||
goto unk_pixfmt;
|
||||
s->upscale_h = 6;
|
||||
s->chroma_height = s->height / 2;
|
||||
}
|
||||
@@ -1593,6 +1596,8 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
|
||||
}
|
||||
|
||||
if (id == AV_RB32("LJIF")) {
|
||||
int rgb = s->rgb;
|
||||
int pegasus_rct = s->pegasus_rct;
|
||||
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
|
||||
av_log(s->avctx, AV_LOG_INFO,
|
||||
"Pegasus lossless jpeg header found\n");
|
||||
@@ -1602,17 +1607,27 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
|
||||
skip_bits(&s->gb, 16); /* unknown always 0? */
|
||||
switch (i=get_bits(&s->gb, 8)) {
|
||||
case 1:
|
||||
s->rgb = 1;
|
||||
s->pegasus_rct = 0;
|
||||
rgb = 1;
|
||||
pegasus_rct = 0;
|
||||
break;
|
||||
case 2:
|
||||
s->rgb = 1;
|
||||
s->pegasus_rct = 1;
|
||||
rgb = 1;
|
||||
pegasus_rct = 1;
|
||||
break;
|
||||
default:
|
||||
av_log(s->avctx, AV_LOG_ERROR, "unknown colorspace %d\n", i);
|
||||
}
|
||||
|
||||
len -= 9;
|
||||
if (s->got_picture)
|
||||
if (rgb != s->rgb || pegasus_rct != s->pegasus_rct) {
|
||||
av_log(s->avctx, AV_LOG_WARNING, "Mismatching LJIF tag\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
s->rgb = rgb;
|
||||
s->pegasus_rct = pegasus_rct;
|
||||
|
||||
goto out;
|
||||
}
|
||||
if (id == AV_RL32("colr") && len > 0) {
|
||||
@@ -2128,7 +2143,7 @@ the_end:
|
||||
if (!(s->upscale_v & (1<<p)))
|
||||
continue;
|
||||
if (p==1 || p==2)
|
||||
w >>= hshift;
|
||||
w = FF_CEIL_RSHIFT(w, hshift);
|
||||
for (i = s->height - 1; i; i--) {
|
||||
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[p])[i / 2 * s->linesize[p]];
|
||||
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[p])[(i + 1) / 2 * s->linesize[p]];
|
||||
|
@@ -61,6 +61,13 @@ static av_cold int mm_decode_init(AVCodecContext *avctx)
|
||||
|
||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||
|
||||
if (!avctx->width || !avctx->height ||
|
||||
(avctx->width & 1) || (avctx->height & 1)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid video dimensions: %dx%d\n",
|
||||
avctx->width, avctx->height);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
s->frame = av_frame_alloc();
|
||||
if (!s->frame)
|
||||
return AVERROR(ENOMEM);
|
||||
|
@@ -190,7 +190,13 @@ static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int
|
||||
int uvdxy; /* no, it might not be used uninitialized */
|
||||
if(dxy){
|
||||
if(qpel){
|
||||
c->qpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride); //FIXME prototype (add h)
|
||||
if (h << size == 16) {
|
||||
c->qpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride); //FIXME prototype (add h)
|
||||
} else if (size == 0 && h == 8) {
|
||||
c->qpel_put[1][dxy](c->temp , ref[0] + x + y*stride , stride);
|
||||
c->qpel_put[1][dxy](c->temp + 8, ref[0] + x + y*stride + 8, stride);
|
||||
} else
|
||||
av_assert2(0);
|
||||
if(chroma){
|
||||
int cx= hx/2;
|
||||
int cy= hy/2;
|
||||
|
@@ -73,20 +73,21 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
|
||||
if (i > 4)
|
||||
s->header_count = -2;
|
||||
} else {
|
||||
int header_threshold = avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec_id;
|
||||
if((state&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)
|
||||
s->header_count= -3;
|
||||
s->header= state;
|
||||
s->header_count++;
|
||||
s->frame_size = ret-4;
|
||||
|
||||
if (s->header_count > 0 + (avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec_id)) {
|
||||
if (s->header_count > header_threshold) {
|
||||
avctx->sample_rate= sr;
|
||||
avctx->channels = channels;
|
||||
s1->duration = frame_size;
|
||||
avctx->codec_id = codec_id;
|
||||
if (s->no_bitrate || !avctx->bit_rate) {
|
||||
s->no_bitrate = 1;
|
||||
avctx->bit_rate += (bit_rate - avctx->bit_rate) / s->header_count;
|
||||
avctx->bit_rate += (bit_rate - avctx->bit_rate) / (s->header_count - header_threshold);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@@ -1642,9 +1642,11 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
|
||||
uint32_t header;
|
||||
int ret;
|
||||
|
||||
int skipped = 0;
|
||||
while(buf_size && !*buf){
|
||||
buf++;
|
||||
buf_size--;
|
||||
skipped++;
|
||||
}
|
||||
|
||||
if (buf_size < HEADER_SIZE)
|
||||
@@ -1699,7 +1701,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
|
||||
return ret;
|
||||
}
|
||||
s->frame_size = 0;
|
||||
return buf_size;
|
||||
return buf_size + skipped;
|
||||
}
|
||||
|
||||
static void mp_flush(MPADecodeContext *ctx)
|
||||
|
@@ -102,8 +102,8 @@ static const AVOption avcodec_options[] = {
|
||||
{"extradata_size", NULL, OFFSET(extradata_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
|
||||
{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX},
|
||||
{"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
|
||||
{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|D|E},
|
||||
{"ac", "set number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|D|E},
|
||||
{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
|
||||
{"ac", "set number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
|
||||
{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|E},
|
||||
{"frame_size", NULL, OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|E},
|
||||
{"frame_number", NULL, OFFSET(frame_number), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
|
||||
|
@@ -499,6 +499,12 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
|
||||
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
|
||||
return ret;
|
||||
}
|
||||
if (coded_samples != s->packet.frame_count * s->packet.frame_duration) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Mismatching coded sample count in substream %d.\n", i);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
s->silk_samplerate = get_silk_samplerate(s->packet.config);
|
||||
}
|
||||
|
||||
|
@@ -576,6 +576,12 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
case MKTAG('I', 'H', 'D', 'R'):
|
||||
if (length != 13)
|
||||
goto fail;
|
||||
|
||||
if (s->state & PNG_IDAT) {
|
||||
av_log(avctx, AV_LOG_ERROR, "IHDR after IDAT\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
s->width = bytestream2_get_be32(&s->gb);
|
||||
s->height = bytestream2_get_be32(&s->gb);
|
||||
if (av_image_check_size(s->width, s->height, 0, avctx)) {
|
||||
|
@@ -117,6 +117,9 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
|
||||
context->frame_size = avpicture_get_size(avctx->pix_fmt, avctx->width,
|
||||
avctx->height);
|
||||
}
|
||||
if (context->frame_size < 0)
|
||||
return context->frame_size;
|
||||
|
||||
|
||||
if ((avctx->extradata_size >= 9 &&
|
||||
!memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9)) ||
|
||||
|
@@ -66,6 +66,9 @@
|
||||
#include "compat/os2threads.h"
|
||||
#endif
|
||||
|
||||
#include "libavutil/ffversion.h"
|
||||
const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
|
||||
|
||||
#if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
|
||||
static int default_lockmgr_cb(void **arg, enum AVLockOp op)
|
||||
{
|
||||
@@ -297,7 +300,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
int i;
|
||||
int w_align = 1;
|
||||
int h_align = 1;
|
||||
AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
|
||||
AVPixFmtDescriptor const *desc = av_pix_fmt_desc_get(s->pix_fmt);
|
||||
|
||||
if (desc) {
|
||||
w_align = 1 << desc->log2_chroma_w;
|
||||
@@ -3601,6 +3604,11 @@ int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
|
||||
ret = av_bprint_finalize(buf, &str);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!av_bprint_is_complete(buf)) {
|
||||
av_free(str);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
avctx->extradata = str;
|
||||
/* Note: the string is NUL terminated (so extradata can be read as a
|
||||
* string), but the ending character is not accounted in the size (in
|
||||
|
@@ -214,6 +214,8 @@ static void restore_median(uint8_t *src, int step, int stride,
|
||||
slice_height = ((((slice + 1) * height) / slices) & cmask) -
|
||||
slice_start;
|
||||
|
||||
if (!slice_height)
|
||||
continue;
|
||||
bsrc = src + slice_start * stride;
|
||||
|
||||
// first line - left neighbour prediction
|
||||
@@ -224,7 +226,7 @@ static void restore_median(uint8_t *src, int step, int stride,
|
||||
A = bsrc[i];
|
||||
}
|
||||
bsrc += stride;
|
||||
if (slice_height == 1)
|
||||
if (slice_height <= 1)
|
||||
continue;
|
||||
// second line - first element has top prediction, the rest uses median
|
||||
C = bsrc[-stride];
|
||||
@@ -269,6 +271,8 @@ static void restore_median_il(uint8_t *src, int step, int stride,
|
||||
slice_height = ((((slice + 1) * height) / slices) & cmask) -
|
||||
slice_start;
|
||||
slice_height >>= 1;
|
||||
if (!slice_height)
|
||||
continue;
|
||||
|
||||
bsrc = src + slice_start * stride;
|
||||
|
||||
@@ -284,7 +288,7 @@ static void restore_median_il(uint8_t *src, int step, int stride,
|
||||
A = bsrc[stride + i];
|
||||
}
|
||||
bsrc += stride2;
|
||||
if (slice_height == 1)
|
||||
if (slice_height <= 1)
|
||||
continue;
|
||||
// second line - first element has top prediction, the rest uses median
|
||||
C = bsrc[-stride2];
|
||||
|
@@ -339,6 +339,9 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
|
||||
ofs += slen;
|
||||
bytestream2_skip(&gb, len);
|
||||
} else {
|
||||
if (ofs + len > frame_width ||
|
||||
bytestream2_get_bytes_left(&gb) < len)
|
||||
return AVERROR_INVALIDDATA;
|
||||
bytestream2_get_buffer(&gb, &dp[ofs], len);
|
||||
ofs += len;
|
||||
}
|
||||
|
@@ -422,6 +422,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
offset &= ~3;
|
||||
if (offset > s->sfb_offsets[i][band - 1])
|
||||
s->sfb_offsets[i][band++] = offset;
|
||||
|
||||
if (offset >= subframe_len)
|
||||
break;
|
||||
}
|
||||
s->sfb_offsets[i][band - 1] = subframe_len;
|
||||
s->num_sfb[i] = band - 1;
|
||||
|
@@ -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
|
||||
|
@@ -185,8 +185,12 @@ hvar_fn
|
||||
%elif (%2-%%off) == 2
|
||||
mov valw, [srcq+%2-2]
|
||||
%elifidn %1, body
|
||||
mov vald, [srcq+%2-3]
|
||||
%else
|
||||
mov valb, [srcq+%2-1]
|
||||
sal vald, 16
|
||||
mov valw, [srcq+%2-3]
|
||||
%elifidn %1, bottom
|
||||
movd mm %+ %%mmx_idx, [srcq+%2-4]
|
||||
%else ; top
|
||||
movd mm %+ %%mmx_idx, [srcq+%2-3]
|
||||
%endif
|
||||
%endif ; (%2-%%off) >= 1
|
||||
@@ -242,12 +246,15 @@ hvar_fn
|
||||
mov [dstq+%2-2], valw
|
||||
%elifidn %1, body
|
||||
mov [dstq+%2-3], valw
|
||||
shr vald, 16
|
||||
sar vald, 16
|
||||
mov [dstq+%2-1], valb
|
||||
%else
|
||||
movd vald, mm %+ %%mmx_idx
|
||||
%ifidn %1, bottom
|
||||
sar vald, 8
|
||||
%endif
|
||||
mov [dstq+%2-3], valw
|
||||
shr vald, 16
|
||||
sar vald, 16
|
||||
mov [dstq+%2-1], valb
|
||||
%endif
|
||||
%endif ; (%2-%%off) >= 1
|
||||
|
@@ -34,7 +34,7 @@ OBJS-$(CONFIG_OPENGL_OUTDEV) += opengl_enc.o
|
||||
OBJS-$(CONFIG_OSS_INDEV) += oss_audio.o
|
||||
OBJS-$(CONFIG_OSS_OUTDEV) += oss_audio.o
|
||||
OBJS-$(CONFIG_PULSE_INDEV) += pulse_audio_dec.o \
|
||||
pulse_audio_common.o
|
||||
pulse_audio_common.o timefilter.o
|
||||
OBJS-$(CONFIG_PULSE_OUTDEV) += pulse_audio_enc.o \
|
||||
pulse_audio_common.o
|
||||
OBJS-$(CONFIG_QTKIT_INDEV) += qtkit.o
|
||||
|
@@ -23,6 +23,9 @@
|
||||
#include "avdevice.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "libavutil/ffversion.h"
|
||||
const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
|
||||
|
||||
#define E AV_OPT_FLAG_ENCODING_PARAM
|
||||
#define D AV_OPT_FLAG_DECODING_PARAM
|
||||
#define A AV_OPT_FLAG_AUDIO_PARAM
|
||||
|
@@ -868,9 +868,6 @@ static int v4l2_read_header(AVFormatContext *s1)
|
||||
|
||||
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
|
||||
|
||||
if ((res = v4l2_set_parameters(s1)) < 0)
|
||||
return res;
|
||||
|
||||
if (s->pixel_format) {
|
||||
AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format);
|
||||
|
||||
@@ -922,6 +919,9 @@ static int v4l2_read_header(AVFormatContext *s1)
|
||||
|
||||
s->frame_format = desired_format;
|
||||
|
||||
if ((res = v4l2_set_parameters(s1)) < 0)
|
||||
return res;
|
||||
|
||||
st->codec->pix_fmt = avpriv_fmt_v4l2ff(desired_format, codec_id);
|
||||
s->frame_size =
|
||||
avpicture_get_size(st->codec->pix_fmt, s->width, s->height);
|
||||
|
@@ -496,6 +496,8 @@ static av_cold int init(AVFilterContext *ctx)
|
||||
snprintf(name, sizeof(name), "input%d", i);
|
||||
pad.type = AVMEDIA_TYPE_AUDIO;
|
||||
pad.name = av_strdup(name);
|
||||
if (!pad.name)
|
||||
return AVERROR(ENOMEM);
|
||||
pad.filter_frame = filter_frame;
|
||||
|
||||
ff_insert_inpad(ctx, i, &pad);
|
||||
|
@@ -214,6 +214,8 @@ static av_cold int join_init(AVFilterContext *ctx)
|
||||
snprintf(name, sizeof(name), "input%d", i);
|
||||
pad.type = AVMEDIA_TYPE_AUDIO;
|
||||
pad.name = av_strdup(name);
|
||||
if (!pad.name)
|
||||
return AVERROR(ENOMEM);
|
||||
pad.filter_frame = filter_frame;
|
||||
|
||||
pad.needs_fifo = 1;
|
||||
|
@@ -37,6 +37,9 @@
|
||||
#include "formats.h"
|
||||
#include "internal.h"
|
||||
|
||||
#include "libavutil/ffversion.h"
|
||||
const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
|
||||
|
||||
static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame);
|
||||
|
||||
void ff_tlog_ref(void *ctx, AVFrame *ref, int end)
|
||||
|
@@ -52,6 +52,8 @@ static av_cold int split_init(AVFilterContext *ctx)
|
||||
snprintf(name, sizeof(name), "output%d", i);
|
||||
pad.type = ctx->filter->inputs[0].type;
|
||||
pad.name = av_strdup(name);
|
||||
if (!pad.name)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ff_insert_outpad(ctx, i, &pad);
|
||||
}
|
||||
|
@@ -292,6 +292,8 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
|
||||
snprintf(name, sizeof(name), "out%d", i);
|
||||
pad.type = movie->st[i].st->codec->codec_type;
|
||||
pad.name = av_strdup(name);
|
||||
if (!pad.name)
|
||||
return AVERROR(ENOMEM);
|
||||
pad.config_props = movie_config_output_props;
|
||||
pad.request_frame = movie_request_frame;
|
||||
ff_insert_outpad(ctx, i, &pad);
|
||||
|
@@ -138,7 +138,9 @@ static int config_props(AVFilterLink *inlink)
|
||||
s->hsub = pixdesc->log2_chroma_w;
|
||||
s->vsub = pixdesc->log2_chroma_h;
|
||||
|
||||
s->bpp = av_get_bits_per_pixel(pixdesc) >> 3;
|
||||
s->bpp = pixdesc->flags & AV_PIX_FMT_FLAG_PLANAR ?
|
||||
1 :
|
||||
av_get_bits_per_pixel(pixdesc) >> 3;
|
||||
s->alpha &= !!(pixdesc->flags & AV_PIX_FMT_FLAG_ALPHA);
|
||||
s->is_packed_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
|
||||
|
||||
|
@@ -220,6 +220,19 @@ static int config_props(AVFilterLink *inlink)
|
||||
|
||||
#define NB_PLANES 4
|
||||
|
||||
static inline int mirror(int x, int w)
|
||||
{
|
||||
if (!w)
|
||||
return 0;
|
||||
|
||||
while ((unsigned)x > (unsigned)w) {
|
||||
x = -x;
|
||||
if (x < 0)
|
||||
x += 2 * w;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
static void blur(uint8_t *dst, const int dst_linesize,
|
||||
const uint8_t *src, const int src_linesize,
|
||||
const int w, const int h, FilterParam *fp)
|
||||
@@ -253,8 +266,7 @@ static void blur(uint8_t *dst, const int dst_linesize,
|
||||
for (dy = 0; dy < radius*2 + 1; dy++) {
|
||||
int dx;
|
||||
int iy = y+dy - radius;
|
||||
if (iy < 0) iy = -iy;
|
||||
else if (iy >= h) iy = h+h-iy-1;
|
||||
iy = mirror(iy, h-1);
|
||||
|
||||
for (dx = 0; dx < radius*2 + 1; dx++) {
|
||||
const int ix = x+dx - radius;
|
||||
@@ -265,13 +277,11 @@ static void blur(uint8_t *dst, const int dst_linesize,
|
||||
for (dy = 0; dy < radius*2+1; dy++) {
|
||||
int dx;
|
||||
int iy = y+dy - radius;
|
||||
if (iy < 0) iy = -iy;
|
||||
else if (iy >= h) iy = h+h-iy-1;
|
||||
iy = mirror(iy, h-1);
|
||||
|
||||
for (dx = 0; dx < radius*2 + 1; dx++) {
|
||||
int ix = x+dx - radius;
|
||||
if (ix < 0) ix = -ix;
|
||||
else if (ix >= w) ix = w+w-ix-1;
|
||||
ix = mirror(ix, w-1);
|
||||
UPDATE_FACTOR;
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -1141,7 +1141,7 @@ start_sync:
|
||||
goto start_sync;
|
||||
}
|
||||
|
||||
n = avi->dv_demux ? 0 : get_stream_idx(d);
|
||||
n = get_stream_idx(d);
|
||||
|
||||
if (!((i - avi->last_pkt_pos) & 1) &&
|
||||
get_stream_idx(d + 1) < s->nb_streams)
|
||||
@@ -1153,6 +1153,9 @@ start_sync:
|
||||
goto start_sync;
|
||||
}
|
||||
|
||||
if (avi->dv_demux && n != 0)
|
||||
continue;
|
||||
|
||||
// parse ##dc/##wb
|
||||
if (n < s->nb_streams) {
|
||||
AVStream *st;
|
||||
@@ -1524,7 +1527,8 @@ static int avi_read_idx1(AVFormatContext *s, int size)
|
||||
ast = st->priv_data;
|
||||
|
||||
if (first_packet && first_packet_pos) {
|
||||
data_offset = first_packet_pos - pos;
|
||||
if (avi->movi_list + 4 != pos || pos + 500 > first_packet_pos)
|
||||
data_offset = first_packet_pos - pos;
|
||||
first_packet = 0;
|
||||
}
|
||||
pos += data_offset;
|
||||
|
@@ -220,6 +220,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
||||
return offset1;
|
||||
offset += offset1;
|
||||
}
|
||||
if (offset < 0)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
offset1 = offset - pos;
|
||||
if (!s->must_flush && (!s->direct || !s->seek) &&
|
||||
offset1 >= 0 && offset1 <= buffer_size) {
|
||||
@@ -666,7 +669,7 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
|
||||
if (c && i < maxlen-1)
|
||||
buf[i++] = c;
|
||||
} while (c != '\n' && c != '\r' && c);
|
||||
if (c == '\r' && avio_r8(s) != '\n')
|
||||
if (c == '\r' && avio_r8(s) != '\n' && !url_feof(s))
|
||||
avio_skip(s, -1);
|
||||
|
||||
buf[i] = 0;
|
||||
|
@@ -127,6 +127,8 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
height = AV_RB16(&cdxl->header[16]);
|
||||
palette_size = AV_RB16(&cdxl->header[20]);
|
||||
audio_size = AV_RB16(&cdxl->header[22]);
|
||||
if (FFALIGN(width, 16) * (uint64_t)height * cdxl->header[19] > INT_MAX)
|
||||
return AVERROR_INVALIDDATA;
|
||||
image_size = FFALIGN(width, 16) * height * cdxl->header[19] / 8;
|
||||
video_size = palette_size + image_size;
|
||||
|
||||
|
@@ -390,7 +390,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
|
||||
FLVContext *flv = s->priv_data;
|
||||
AVIOContext *ioc;
|
||||
AMFDataType amf_type;
|
||||
char str_val[256];
|
||||
char str_val[1024];
|
||||
double num_val;
|
||||
|
||||
num_val = 0;
|
||||
@@ -555,13 +555,13 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
|
||||
type = avio_r8(ioc);
|
||||
if (type != AMF_DATA_TYPE_STRING ||
|
||||
amf_get_string(ioc, buffer, sizeof(buffer)) < 0)
|
||||
return -1;
|
||||
return 2;
|
||||
|
||||
if (!strcmp(buffer, "onTextData"))
|
||||
return 1;
|
||||
|
||||
if (strcmp(buffer, "onMetaData"))
|
||||
return -1;
|
||||
return 2;
|
||||
|
||||
// find the streams now so that amf_parse_object doesn't need to do
|
||||
// the lookup every time it is called.
|
||||
@@ -620,7 +620,7 @@ static int flv_read_close(AVFormatContext *s)
|
||||
|
||||
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
|
||||
{
|
||||
av_free(st->codec->extradata);
|
||||
av_freep(&st->codec->extradata);
|
||||
if (ff_get_extradata(st->codec, s->pb, size) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
return 0;
|
||||
@@ -819,7 +819,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
stream_type=FLV_STREAM_TYPE_DATA;
|
||||
if (size > 13 + 1 + 4 && dts == 0) { // Header-type metadata stuff
|
||||
meta_pos = avio_tell(s->pb);
|
||||
if (flv_read_metabody(s, next) == 0) {
|
||||
if (flv_read_metabody(s, next) <= 0) {
|
||||
goto skip;
|
||||
}
|
||||
avio_seek(s->pb, meta_pos, SEEK_SET);
|
||||
|
@@ -314,9 +314,10 @@ static int hls_write_trailer(struct AVFormatContext *s)
|
||||
|
||||
av_write_trailer(oc);
|
||||
avio_closep(&oc->pb);
|
||||
avformat_free_context(oc);
|
||||
av_free(hls->basename);
|
||||
append_entry(hls, hls->duration);
|
||||
avformat_free_context(oc);
|
||||
hls->avf = NULL;
|
||||
hls_window(s, 1);
|
||||
|
||||
free_entries(hls);
|
||||
|
@@ -171,6 +171,7 @@ typedef struct MOVContext {
|
||||
int *bitrates; ///< bitrates read before streams creation
|
||||
int bitrates_count;
|
||||
int moov_retry;
|
||||
int atom_depth;
|
||||
} MOVContext;
|
||||
|
||||
int ff_mp4_read_descr_len(AVIOContext *pb);
|
||||
|
@@ -1078,7 +1078,7 @@ static void ebml_free(EbmlSyntax *syntax, void *data)
|
||||
for (j = 0; j < list->nb_elem;
|
||||
j++, ptr += syntax[i].list_elem_size)
|
||||
ebml_free(syntax[i].def.n, ptr);
|
||||
av_free(list->elem);
|
||||
av_freep(&list->elem);
|
||||
} else
|
||||
ebml_free(syntax[i].def.n, data_off);
|
||||
default:
|
||||
@@ -1471,13 +1471,17 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
|
||||
EbmlList *seekhead_list = &matroska->seekhead;
|
||||
int64_t before_pos = avio_tell(matroska->ctx->pb);
|
||||
int i;
|
||||
int nb_elem;
|
||||
|
||||
// we should not do any seeking in the streaming case
|
||||
if (!matroska->ctx->pb->seekable ||
|
||||
(matroska->ctx->flags & AVFMT_FLAG_IGNIDX))
|
||||
return;
|
||||
|
||||
for (i = 0; i < seekhead_list->nb_elem; i++) {
|
||||
// do not read entries that are added while parsing seekhead entries
|
||||
nb_elem = seekhead_list->nb_elem;
|
||||
|
||||
for (i = 0; i < nb_elem; i++) {
|
||||
MatroskaSeekhead *seekhead = seekhead_list->elem;
|
||||
if (seekhead[i].pos <= before_pos)
|
||||
continue;
|
||||
@@ -1979,7 +1983,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
|
||||
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
|
||||
1000000000, track->default_duration, 30000);
|
||||
#if FF_API_R_FRAME_RATE
|
||||
if (st->avg_frame_rate.num < st->avg_frame_rate.den * 1000L)
|
||||
if ( st->avg_frame_rate.num < st->avg_frame_rate.den * 1000L
|
||||
&& st->avg_frame_rate.num > st->avg_frame_rate.den * 5L)
|
||||
st->r_frame_rate = st->avg_frame_rate;
|
||||
#endif
|
||||
}
|
||||
@@ -2184,7 +2189,7 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska,
|
||||
{
|
||||
if (matroska->num_packets > 0) {
|
||||
memcpy(pkt, matroska->packets[0], sizeof(AVPacket));
|
||||
av_free(matroska->packets[0]);
|
||||
av_freep(&matroska->packets[0]);
|
||||
if (matroska->num_packets > 1) {
|
||||
void *newpackets;
|
||||
memmove(&matroska->packets[0], &matroska->packets[1],
|
||||
@@ -2215,7 +2220,7 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska)
|
||||
int n;
|
||||
for (n = 0; n < matroska->num_packets; n++) {
|
||||
av_free_packet(matroska->packets[n]);
|
||||
av_free(matroska->packets[n]);
|
||||
av_freep(&matroska->packets[n]);
|
||||
}
|
||||
av_freep(&matroska->packets);
|
||||
matroska->num_packets = 0;
|
||||
@@ -3063,7 +3068,7 @@ static int matroska_read_close(AVFormatContext *s)
|
||||
|
||||
for (n = 0; n < matroska->tracks.nb_elem; n++)
|
||||
if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO)
|
||||
av_free(tracks[n].audio.buf);
|
||||
av_freep(&tracks[n].audio.buf);
|
||||
ebml_free(matroska_cluster, &matroska->current_cluster);
|
||||
ebml_free(matroska_segment, matroska);
|
||||
|
||||
|
@@ -214,7 +214,11 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
|
||||
static int mov_metadata_raw(MOVContext *c, AVIOContext *pb,
|
||||
unsigned len, const char *key)
|
||||
{
|
||||
char *value = av_malloc(len + 1);
|
||||
char *value;
|
||||
// Check for overflow.
|
||||
if (len >= INT_MAX)
|
||||
return AVERROR(EINVAL);
|
||||
value = av_malloc(len + 1);
|
||||
if (!value)
|
||||
return AVERROR(ENOMEM);
|
||||
avio_read(pb, value, len);
|
||||
@@ -356,7 +360,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
if (!key)
|
||||
return 0;
|
||||
if (atom.size < 0)
|
||||
if (atom.size < 0 || str_size >= INT_MAX/2)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
|
||||
@@ -1173,10 +1177,12 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
if (!entries)
|
||||
return 0;
|
||||
if (entries >= UINT_MAX/sizeof(int64_t))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));
|
||||
if (sc->chunk_offsets)
|
||||
av_log(c->fc, AV_LOG_WARNING, "Duplicate STCO atom\n");
|
||||
av_free(sc->chunk_offsets);
|
||||
sc->chunk_count = 0;
|
||||
sc->chunk_offsets = av_malloc_array(entries, sizeof(*sc->chunk_offsets));
|
||||
if (!sc->chunk_offsets)
|
||||
return AVERROR(ENOMEM);
|
||||
sc->chunk_count = entries;
|
||||
@@ -1452,7 +1458,7 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
|
||||
|
||||
static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb,
|
||||
AVStream *st, MOVStreamContext *sc,
|
||||
int size)
|
||||
int64_t size)
|
||||
{
|
||||
// ttxt stsd contains display flags, justification, background
|
||||
// color, fonts, and default styles, so fake an atom to read it
|
||||
@@ -1517,10 +1523,10 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st)
|
||||
|
||||
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
|
||||
AVStream *st, MOVStreamContext *sc,
|
||||
int size)
|
||||
int64_t size)
|
||||
{
|
||||
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
|
||||
if (ff_get_extradata(st->codec, pb, size) < 0)
|
||||
if ((int)size != size || ff_get_extradata(st->codec, pb, size) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
if (size > 16) {
|
||||
MOVStreamContext *tmcd_ctx = st->priv_data;
|
||||
@@ -1745,9 +1751,11 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
if (!entries)
|
||||
return 0;
|
||||
if (entries >= UINT_MAX / sizeof(*sc->stsc_data))
|
||||
return AVERROR_INVALIDDATA;
|
||||
sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));
|
||||
if (sc->stsc_data)
|
||||
av_log(c->fc, AV_LOG_WARNING, "Duplicate STSC atom\n");
|
||||
av_free(sc->stsc_data);
|
||||
sc->stsc_count = 0;
|
||||
sc->stsc_data = av_malloc_array(entries, sizeof(*sc->stsc_data));
|
||||
if (!sc->stsc_data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -1779,9 +1787,11 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
avio_rb32(pb); // version + flags
|
||||
|
||||
entries = avio_rb32(pb);
|
||||
if (entries >= UINT_MAX / sizeof(*sc->stps_data))
|
||||
return AVERROR_INVALIDDATA;
|
||||
sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data));
|
||||
if (sc->stps_data)
|
||||
av_log(c->fc, AV_LOG_WARNING, "Duplicate STPS atom\n");
|
||||
av_free(sc->stps_data);
|
||||
sc->stps_count = 0;
|
||||
sc->stps_data = av_malloc_array(entries, sizeof(*sc->stps_data));
|
||||
if (!sc->stps_data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -1823,9 +1833,11 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
return 0;
|
||||
}
|
||||
if (entries >= UINT_MAX / sizeof(int))
|
||||
return AVERROR_INVALIDDATA;
|
||||
sc->keyframes = av_malloc(entries * sizeof(int));
|
||||
if (sc->keyframes)
|
||||
av_log(c->fc, AV_LOG_WARNING, "Duplicate STSS atom\n");
|
||||
av_free(sc->keyframes);
|
||||
sc->keyframe_count = 0;
|
||||
sc->keyframes = av_malloc_array(entries, sizeof(*sc->keyframes));
|
||||
if (!sc->keyframes)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -1884,9 +1896,13 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
if (!entries)
|
||||
return 0;
|
||||
if (entries >= UINT_MAX / sizeof(int) || entries >= (UINT_MAX - 4) / field_size)
|
||||
if (entries >= (UINT_MAX - 4) / field_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
sc->sample_sizes = av_malloc(entries * sizeof(int));
|
||||
if (sc->sample_sizes)
|
||||
av_log(c->fc, AV_LOG_WARNING, "Duplicate STSZ atom\n");
|
||||
av_free(sc->sample_sizes);
|
||||
sc->sample_count = 0;
|
||||
sc->sample_sizes = av_malloc_array(entries, sizeof(*sc->sample_sizes));
|
||||
if (!sc->sample_sizes)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -1940,11 +1956,11 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
av_dlog(c->fc, "track[%i].stts.entries = %i\n",
|
||||
c->fc->nb_streams-1, entries);
|
||||
|
||||
if (entries >= UINT_MAX / sizeof(*sc->stts_data))
|
||||
return -1;
|
||||
|
||||
if (sc->stts_data)
|
||||
av_log(c->fc, AV_LOG_WARNING, "Duplicate STTS atom\n");
|
||||
av_free(sc->stts_data);
|
||||
sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
|
||||
sc->stts_count = 0;
|
||||
sc->stts_data = av_malloc_array(entries, sizeof(*sc->stts_data));
|
||||
if (!sc->stts_data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -2083,9 +2099,11 @@ static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
entries = avio_rb32(pb);
|
||||
if (!entries)
|
||||
return 0;
|
||||
if (entries >= UINT_MAX / sizeof(*sc->rap_group))
|
||||
return AVERROR_INVALIDDATA;
|
||||
sc->rap_group = av_malloc(entries * sizeof(*sc->rap_group));
|
||||
if (sc->rap_group)
|
||||
av_log(c->fc, AV_LOG_WARNING, "Duplicate SBGP atom\n");
|
||||
av_free(sc->rap_group);
|
||||
sc->rap_group_count = 0;
|
||||
sc->rap_group = av_malloc_array(entries, sizeof(*sc->rap_group));
|
||||
if (!sc->rap_group)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -2935,6 +2953,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);
|
||||
@@ -3151,6 +3170,12 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
MOVAtom a;
|
||||
int i;
|
||||
|
||||
if (c->atom_depth > 10) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "Atoms too deeply nested\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
c->atom_depth ++;
|
||||
|
||||
if (atom.size < 0)
|
||||
atom.size = INT64_MAX;
|
||||
while (total_size + 8 <= atom.size && !url_feof(pb)) {
|
||||
@@ -3180,11 +3205,12 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
{
|
||||
av_log(c->fc, AV_LOG_ERROR, "Broken file, trak/mdat not at top-level\n");
|
||||
avio_skip(pb, -8);
|
||||
c->atom_depth --;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
total_size += 8;
|
||||
if (a.size == 1) { /* 64 bit extended size */
|
||||
if (a.size == 1 && total_size + 8 <= atom.size) { /* 64 bit extended size */
|
||||
a.size = avio_rb64(pb) - 8;
|
||||
total_size += 8;
|
||||
}
|
||||
@@ -3216,13 +3242,16 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
int64_t start_pos = avio_tell(pb);
|
||||
int64_t left;
|
||||
int err = parse(c, pb, a);
|
||||
if (err < 0)
|
||||
if (err < 0) {
|
||||
c->atom_depth --;
|
||||
return err;
|
||||
}
|
||||
if (c->found_moov && c->found_mdat &&
|
||||
((!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX) ||
|
||||
start_pos + a.size == avio_size(pb))) {
|
||||
if (!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX)
|
||||
c->next_root_atom = start_pos + a.size;
|
||||
c->atom_depth --;
|
||||
return 0;
|
||||
}
|
||||
left = a.size - avio_tell(pb) + start_pos;
|
||||
@@ -3242,6 +3271,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
if (total_size < atom.size && atom.size < 0x7ffff)
|
||||
avio_skip(pb, atom.size - total_size);
|
||||
|
||||
c->atom_depth --;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -398,6 +398,8 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
|
||||
int64_t ret = av_index_search_timestamp(st, timestamp, flags);
|
||||
int i, j;
|
||||
int dir = (flags&AVSEEK_FLAG_BACKWARD) ? -1 : 1;
|
||||
int64_t best_pos;
|
||||
int best_score;
|
||||
|
||||
if (mp3->is_cbr && st->duration > 0 && mp3->header_filesize > s->data_offset) {
|
||||
int64_t filesize = avio_size(s->pb);
|
||||
@@ -421,28 +423,37 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dir < 0)
|
||||
avio_seek(s->pb, FFMAX(ie->pos - 4096, 0), SEEK_SET);
|
||||
avio_seek(s->pb, FFMAX(ie->pos - 4096, 0), SEEK_SET);
|
||||
ret = avio_seek(s->pb, ie->pos, SEEK_SET);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
#define MIN_VALID 3
|
||||
best_pos = ie->pos;
|
||||
best_score = 999;
|
||||
for(i=0; i<4096; i++) {
|
||||
int64_t pos = ie->pos + i*dir;
|
||||
int64_t pos = ie->pos + (dir > 0 ? i - 1024 : -i);
|
||||
int64_t candidate = -1;
|
||||
int score = 999;
|
||||
for(j=0; j<MIN_VALID; j++) {
|
||||
ret = check(s, pos);
|
||||
if(ret < 0)
|
||||
break;
|
||||
if ((ie->pos - pos)*dir <= 0 && abs(MIN_VALID/2-j) < score) {
|
||||
candidate = pos;
|
||||
score = abs(MIN_VALID/2-j);
|
||||
}
|
||||
pos += ret;
|
||||
}
|
||||
if(j==MIN_VALID)
|
||||
break;
|
||||
if (best_score > score && j == MIN_VALID) {
|
||||
best_pos = candidate;
|
||||
best_score = score;
|
||||
if(score == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j!=MIN_VALID)
|
||||
i=0;
|
||||
|
||||
ret = avio_seek(s->pb, ie->pos + i*dir, SEEK_SET);
|
||||
ret = avio_seek(s->pb, best_pos, SEEK_SET);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ff_update_cur_dts(s, st, ie->timestamp);
|
||||
|
@@ -101,7 +101,7 @@ static int mpegps_probe(AVProbeData *p)
|
||||
|
||||
if (sys > invalid && sys * 9 <= pspack * 10)
|
||||
return (audio > 12 || vid > 3 || pspack > 2) ? AVPROBE_SCORE_EXTENSION + 2
|
||||
: AVPROBE_SCORE_EXTENSION / 2; // 1 more than .mpg
|
||||
: AVPROBE_SCORE_EXTENSION / 2 + 1; // 1 more than .mpg
|
||||
if (pspack > invalid && (priv1 + vid + audio) * 10 >= pspack * 9)
|
||||
return pspack > 2 ? AVPROBE_SCORE_EXTENSION + 2
|
||||
: AVPROBE_SCORE_EXTENSION / 2; // 1 more than .mpg
|
||||
|
@@ -504,9 +504,9 @@ static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
|
||||
static int analyze(const uint8_t *buf, int size, int packet_size, int *index)
|
||||
{
|
||||
int stat[TS_MAX_PACKET_SIZE];
|
||||
int stat_all = 0;
|
||||
int i;
|
||||
int best_score = 0;
|
||||
int best_score2 = 0;
|
||||
|
||||
memset(stat, 0, packet_size * sizeof(*stat));
|
||||
|
||||
@@ -514,17 +514,16 @@ static int analyze(const uint8_t *buf, int size, int packet_size, int *index)
|
||||
if (buf[i] == 0x47 && !(buf[i + 1] & 0x80) && buf[i + 3] != 0x47) {
|
||||
int x = i % packet_size;
|
||||
stat[x]++;
|
||||
stat_all++;
|
||||
if (stat[x] > best_score) {
|
||||
best_score = stat[x];
|
||||
if (index)
|
||||
*index = x;
|
||||
} else if (stat[x] > best_score2) {
|
||||
best_score2 = stat[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best_score - best_score2;
|
||||
return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
|
||||
}
|
||||
|
||||
/* autodetect fec presence. Must have at least 1024 bytes */
|
||||
|
@@ -249,7 +249,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
|
||||
if (i == total_segments)
|
||||
page->granule = granule;
|
||||
|
||||
if (!header) {
|
||||
{
|
||||
AVStream *st = s->streams[page->stream_index];
|
||||
|
||||
int64_t start = av_rescale_q(page->start_granule, st->time_base,
|
||||
@@ -257,10 +257,13 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
|
||||
int64_t next = av_rescale_q(page->granule, st->time_base,
|
||||
AV_TIME_BASE_Q);
|
||||
|
||||
if (page->segments_count == 255 ||
|
||||
(ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
|
||||
(ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
|
||||
if (page->segments_count == 255) {
|
||||
ogg_buffer_page(s, oggstream);
|
||||
} else if (!header) {
|
||||
if ((ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
|
||||
(ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
|
||||
ogg_buffer_page(s, oggstream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -93,6 +93,7 @@ static const AVOption avformat_options[] = {
|
||||
{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, D|E, "strict"},
|
||||
{"strict", "strictly conform to all the things in the spec no matter what the consequences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, D|E, "strict"},
|
||||
{"normal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_NORMAL }, INT_MIN, INT_MAX, D|E, "strict"},
|
||||
{"unofficial", "allow unofficial extensions", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_UNOFFICIAL }, INT_MIN, INT_MAX, D|E, "strict"},
|
||||
{"experimental", "allow non-standardized experimental variants", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, D|E, "strict"},
|
||||
{NULL},
|
||||
};
|
||||
|
@@ -312,6 +312,9 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb,
|
||||
int64_t codec_pos;
|
||||
int ret;
|
||||
|
||||
if (codec_data_size < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
avpriv_set_pts_info(st, 64, 1, 1000);
|
||||
codec_pos = avio_tell(pb);
|
||||
v = avio_rb32(pb);
|
||||
|
@@ -70,7 +70,7 @@ static int rsd_read_header(AVFormatContext *s)
|
||||
codec->codec_tag = avio_rl32(pb);
|
||||
codec->codec_id = ff_codec_get_id(rsd_tags, codec->codec_tag);
|
||||
if (!codec->codec_id) {
|
||||
char tag_buf[5];
|
||||
char tag_buf[32];
|
||||
|
||||
av_get_codec_tag_string(tag_buf, sizeof(tag_buf), codec->codec_tag);
|
||||
for (i=0; i < FF_ARRAY_ELEMS(rsd_unsupported_tags); i++) {
|
||||
|
@@ -336,7 +336,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
|
||||
if (seg->list_size && seg->segment_count > seg->list_size) {
|
||||
entry = seg->segment_list_entries;
|
||||
seg->segment_list_entries = seg->segment_list_entries->next;
|
||||
av_free(entry->filename);
|
||||
av_freep(&entry->filename);
|
||||
av_freep(&entry);
|
||||
}
|
||||
|
||||
@@ -494,10 +494,10 @@ static int open_null_ctx(AVIOContext **ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void close_null_ctx(AVIOContext *pb)
|
||||
static void close_null_ctxp(AVIOContext **pb)
|
||||
{
|
||||
av_free(pb->buffer);
|
||||
av_free(pb);
|
||||
av_freep(&(*pb)->buffer);
|
||||
av_freep(pb);
|
||||
}
|
||||
|
||||
static int select_reference_stream(AVFormatContext *s)
|
||||
@@ -562,6 +562,7 @@ static int seg_write_header(AVFormatContext *s)
|
||||
SegmentContext *seg = s->priv_data;
|
||||
AVFormatContext *oc = NULL;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
seg->segment_count = 0;
|
||||
if (!seg->write_header_trailer)
|
||||
@@ -649,11 +650,18 @@ static int seg_write_header(AVFormatContext *s)
|
||||
}
|
||||
seg->is_first_pkt = 1;
|
||||
|
||||
av_assert0(s->nb_streams == oc->nb_streams);
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
AVStream *inner_st = oc->streams[i];
|
||||
AVStream *outer_st = s->streams[i];
|
||||
avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, inner_st->time_base.num, inner_st->time_base.den);
|
||||
}
|
||||
|
||||
if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0)
|
||||
s->avoid_negative_ts = 1;
|
||||
|
||||
if (!seg->write_header_trailer) {
|
||||
close_null_ctx(oc->pb);
|
||||
close_null_ctxp(&oc->pb);
|
||||
if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
|
||||
&s->interrupt_callback, NULL)) < 0)
|
||||
goto fail;
|
||||
@@ -779,7 +787,7 @@ static int seg_write_trailer(struct AVFormatContext *s)
|
||||
goto fail;
|
||||
open_null_ctx(&oc->pb);
|
||||
ret = av_write_trailer(oc);
|
||||
close_null_ctx(oc->pb);
|
||||
close_null_ctxp(&oc->pb);
|
||||
} else {
|
||||
ret = segment_end(s, 1, 1);
|
||||
}
|
||||
@@ -794,7 +802,7 @@ fail:
|
||||
cur = seg->segment_list_entries;
|
||||
while (cur) {
|
||||
next = cur->next;
|
||||
av_free(cur->filename);
|
||||
av_freep(&cur->filename);
|
||||
av_free(cur);
|
||||
cur = next;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -53,6 +53,9 @@
|
||||
#include "riff.h"
|
||||
#include "url.h"
|
||||
|
||||
#include "libavutil/ffversion.h"
|
||||
const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
|
||||
|
||||
/**
|
||||
* @file
|
||||
* various utility functions for use within FFmpeg
|
||||
@@ -730,6 +733,8 @@ static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in
|
||||
int default_stream_index = av_find_default_stream_index(s);
|
||||
if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) {
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
if (av_find_program_from_stream(s, NULL, i))
|
||||
continue;
|
||||
s->streams[i]->pts_wrap_reference = pts_wrap_reference;
|
||||
s->streams[i]->pts_wrap_behavior = pts_wrap_behavior;
|
||||
}
|
||||
@@ -2949,6 +2954,7 @@ int ff_alloc_extradata(AVCodecContext *avctx, int size)
|
||||
int ret;
|
||||
|
||||
if (size < 0 || size >= INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
|
||||
avctx->extradata = NULL;
|
||||
avctx->extradata_size = 0;
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
@@ -503,6 +503,7 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
|
||||
free_side_data(&dst->side_data[i]);
|
||||
}
|
||||
av_freep(&dst->side_data);
|
||||
dst->nb_side_data = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
memcpy(sd_dst->data, sd_src->data, sd_src->size);
|
||||
|
@@ -711,6 +711,10 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
|
||||
return AVERROR(EINVAL);
|
||||
if (!(*out_val = av_malloc(len*2 + 1)))
|
||||
return AVERROR(ENOMEM);
|
||||
if (!len) {
|
||||
*out_val[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
bin = *(uint8_t**)dst;
|
||||
for (i = 0; i < len; i++)
|
||||
snprintf(*out_val + i*2, 3, "%02X", bin[i]);
|
||||
@@ -726,12 +730,14 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
|
||||
break;
|
||||
case AV_OPT_TYPE_DURATION:
|
||||
i64 = *(int64_t *)dst;
|
||||
ret = snprintf(buf, sizeof(buf), "%"PRIi64"d:%02d:%02d.%06d",
|
||||
ret = snprintf(buf, sizeof(buf), "%"PRIi64":%02d:%02d.%06d",
|
||||
i64 / 3600000000, (int)((i64 / 60000000) % 60),
|
||||
(int)((i64 / 1000000) % 60), (int)(i64 % 1000000));
|
||||
break;
|
||||
case AV_OPT_TYPE_COLOR:
|
||||
ret = snprintf(buf, sizeof(buf), "0x%02x%02x%02x%02x", ((int *)dst)[0], ((int *)dst)[1], ((int *)dst)[2], ((int *)dst)[3]);
|
||||
ret = snprintf(buf, sizeof(buf), "0x%02x%02x%02x%02x",
|
||||
(int)((uint8_t *)dst)[0], (int)((uint8_t *)dst)[1],
|
||||
(int)((uint8_t *)dst)[2], (int)((uint8_t *)dst)[3]);
|
||||
break;
|
||||
case AV_OPT_TYPE_CHANNEL_LAYOUT:
|
||||
i64 = *(int64_t *)dst;
|
||||
|
@@ -27,6 +27,9 @@
|
||||
* various utility functions
|
||||
*/
|
||||
|
||||
#include "libavutil/ffversion.h"
|
||||
const char av_util_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
|
||||
|
||||
unsigned avutil_version(void)
|
||||
{
|
||||
static int checks_done;
|
||||
|
@@ -89,6 +89,9 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks
|
||||
#include "postprocess_internal.h"
|
||||
#include "libavutil/avstring.h"
|
||||
|
||||
#include "libavutil/ffversion.h"
|
||||
const char postproc_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
|
||||
|
||||
unsigned postproc_version(void)
|
||||
{
|
||||
av_assert0(LIBPOSTPROC_VERSION_MICRO >= 100);
|
||||
|
@@ -76,8 +76,12 @@ static int process(
|
||||
AudioData *src, int src_size, int *consumed){
|
||||
size_t idone, odone;
|
||||
soxr_error_t error = soxr_set_error((soxr_t)c, soxr_set_num_channels((soxr_t)c, src->ch_count));
|
||||
error = soxr_process((soxr_t)c, src->ch, (size_t)src_size,
|
||||
&idone, dst->ch, (size_t)dst_size, &odone);
|
||||
if (!error)
|
||||
error = soxr_process((soxr_t)c, src->ch, (size_t)src_size,
|
||||
&idone, dst->ch, (size_t)dst_size, &odone);
|
||||
else
|
||||
idone = 0;
|
||||
|
||||
*consumed = (int)idone;
|
||||
return error? -1 : odone;
|
||||
}
|
||||
|
@@ -28,6 +28,9 @@
|
||||
|
||||
#define ALIGN 32
|
||||
|
||||
#include "libavutil/ffversion.h"
|
||||
const char swr_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
|
||||
|
||||
unsigned swresample_version(void)
|
||||
{
|
||||
av_assert0(LIBSWRESAMPLE_VERSION_MICRO >= 100);
|
||||
|
@@ -37,7 +37,7 @@
|
||||
|
||||
#define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
|
||||
|
||||
#define YUVRGB_TABLE_HEADROOM 128
|
||||
#define YUVRGB_TABLE_HEADROOM 256
|
||||
|
||||
#define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
|
||||
|
||||
|
@@ -1634,6 +1634,16 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
|
||||
#define BGR2V_IDX "16*4+16*34"
|
||||
int y;
|
||||
const x86_reg chromWidth= width>>1;
|
||||
|
||||
if (height > 2) {
|
||||
ff_rgb24toyv12_c(src, ydst, udst, vdst, width, 2, lumStride, chromStride, srcStride, rgb2yuv);
|
||||
src += 2*srcStride;
|
||||
ydst += 2*lumStride;
|
||||
udst += chromStride;
|
||||
vdst += chromStride;
|
||||
height -= 2;
|
||||
}
|
||||
|
||||
for (y=0; y<height-2; y+=2) {
|
||||
int i;
|
||||
for (i=0; i<2; i++) {
|
||||
@@ -1877,7 +1887,9 @@ static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, ui
|
||||
for (h=0; h < height; h++) {
|
||||
int w;
|
||||
|
||||
if (width >= 16) {
|
||||
#if COMPILE_TEMPLATE_SSE2
|
||||
if (!((((intptr_t)src1) | ((intptr_t)src2) | ((intptr_t)dest))&15)) {
|
||||
__asm__(
|
||||
"xor %%"REG_a", %%"REG_a" \n\t"
|
||||
"1: \n\t"
|
||||
@@ -1896,7 +1908,8 @@ static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, ui
|
||||
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
|
||||
: "memory", "%"REG_a""
|
||||
);
|
||||
#else
|
||||
} else
|
||||
#endif
|
||||
__asm__(
|
||||
"xor %%"REG_a", %%"REG_a" \n\t"
|
||||
"1: \n\t"
|
||||
@@ -1922,7 +1935,8 @@ static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, ui
|
||||
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
|
||||
: "memory", "%"REG_a
|
||||
);
|
||||
#endif
|
||||
|
||||
}
|
||||
for (w= (width&(~15)); w < width; w++) {
|
||||
dest[2*w+0] = src1[w];
|
||||
dest[2*w+1] = src2[w];
|
||||
|
Reference in New Issue
Block a user