Compare commits
50 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4dfd4399ea | ||
![]() |
f0d56d4f55 | ||
![]() |
71a4a9183f | ||
![]() |
80588930ff | ||
![]() |
bd2266975c | ||
![]() |
e68114868f | ||
![]() |
4533e8b30a | ||
![]() |
a8dd7fe5b9 | ||
![]() |
503322f97c | ||
![]() |
574bf2ce4c | ||
![]() |
1f2f6b247a | ||
![]() |
724deeb7a8 | ||
![]() |
62899d79a3 | ||
![]() |
45283653a3 | ||
![]() |
6af1793dd5 | ||
![]() |
4310ba273d | ||
![]() |
ba8ab4e7ae | ||
![]() |
e0fcad7761 | ||
![]() |
9455a023be | ||
![]() |
03bda44689 | ||
![]() |
8e8dc210cd | ||
![]() |
3af977d4d6 | ||
![]() |
cb0d255e2f | ||
![]() |
d2ceca6e8b | ||
![]() |
e8411c3b6d | ||
![]() |
3d5c38ca7d | ||
![]() |
8713b8e3fb | ||
![]() |
714dd84f20 | ||
![]() |
ebd74c42a2 | ||
![]() |
0597f05237 | ||
![]() |
227ac71a60 | ||
![]() |
d4e85004ec | ||
![]() |
514917bf1c | ||
![]() |
9ae26ef9c3 | ||
![]() |
b9be91c03d | ||
![]() |
d844179141 | ||
![]() |
707cfea374 | ||
![]() |
ebefc92a3d | ||
![]() |
11b3462aa3 | ||
![]() |
2340ce6954 | ||
![]() |
1f5678c5e4 | ||
![]() |
9a2387cfb1 | ||
![]() |
696a74e815 | ||
![]() |
3938b67621 | ||
![]() |
eb89e1b98d | ||
![]() |
05de372350 | ||
![]() |
b5f92f9603 | ||
![]() |
42a8d32697 | ||
![]() |
945a1b7ab9 | ||
![]() |
cf7bb6ceb1 |
@@ -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 = 1.1.10
|
||||
PROJECT_NUMBER = 1.1.12
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify an logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
34
ffmpeg.c
34
ffmpeg.c
@@ -578,6 +578,25 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
|
||||
bsfc = bsfc->next;
|
||||
}
|
||||
|
||||
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS) &&
|
||||
ost->last_mux_dts != AV_NOPTS_VALUE &&
|
||||
pkt->dts < ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT)) {
|
||||
av_log(NULL, AV_LOG_WARNING, "Non-monotonous DTS in output stream "
|
||||
"%d:%d; previous: %"PRId64", current: %"PRId64"; ",
|
||||
ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts);
|
||||
if (exit_on_error) {
|
||||
av_log(NULL, AV_LOG_FATAL, "aborting.\n");
|
||||
exit(1);
|
||||
}
|
||||
av_log(NULL, AV_LOG_WARNING, "changing to %"PRId64". This may result "
|
||||
"in incorrect timestamps in the output file.\n",
|
||||
ost->last_mux_dts + 1);
|
||||
pkt->dts = ost->last_mux_dts + 1;
|
||||
if (pkt->pts != AV_NOPTS_VALUE)
|
||||
pkt->pts = FFMAX(pkt->pts, pkt->dts);
|
||||
}
|
||||
ost->last_mux_dts = pkt->dts;
|
||||
|
||||
pkt->stream_index = ost->index;
|
||||
|
||||
if (debug_ts) {
|
||||
@@ -996,6 +1015,19 @@ static void do_video_stats(OutputStream *ost, int frame_size)
|
||||
}
|
||||
}
|
||||
|
||||
static void finish_output_stream(OutputStream *ost)
|
||||
{
|
||||
OutputFile *of = output_files[ost->file_index];
|
||||
int i;
|
||||
|
||||
ost->finished = 1;
|
||||
|
||||
if (of->shortest) {
|
||||
for (i = 0; i < of->ctx->nb_streams; i++)
|
||||
output_streams[of->ost_index + i]->finished = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and encode new output from any of the filtergraphs, without causing
|
||||
* activity.
|
||||
@@ -2764,7 +2796,7 @@ static int process_input(int file_index)
|
||||
|
||||
if (ost->source_index == ifile->ist_index + i &&
|
||||
(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
|
||||
close_output_stream(ost);
|
||||
finish_output_stream(ost);
|
||||
}
|
||||
}
|
||||
|
||||
|
2
ffmpeg.h
2
ffmpeg.h
@@ -300,6 +300,8 @@ typedef struct OutputStream {
|
||||
/* pts of the first frame encoded for this stream, used for limiting
|
||||
* recording time */
|
||||
int64_t first_pts;
|
||||
/* dts of the last packet sent to the muxer */
|
||||
int64_t last_mux_dts;
|
||||
AVBitStreamFilterContext *bitstream_filters;
|
||||
AVCodec *enc;
|
||||
int64_t max_frames;
|
||||
|
@@ -41,12 +41,15 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFo
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target);
|
||||
int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
|
||||
enum AVPixelFormat best= AV_PIX_FMT_NONE;
|
||||
const enum AVPixelFormat mjpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
||||
const enum AVPixelFormat ljpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
||||
|
||||
if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
|
||||
if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
|
||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
||||
p = mjpeg_formats;
|
||||
} else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {
|
||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
||||
p =ljpeg_formats;
|
||||
}
|
||||
}
|
||||
for (; *p != AV_PIX_FMT_NONE; p++) {
|
||||
|
@@ -1021,6 +1021,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
input_streams[source_index]->discard = 0;
|
||||
input_streams[source_index]->st->discard = AVDISCARD_NONE;
|
||||
}
|
||||
ost->last_mux_dts = AV_NOPTS_VALUE;
|
||||
|
||||
return ost;
|
||||
}
|
||||
|
@@ -285,7 +285,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
GetBitContext gb;
|
||||
uint64_t ht_size;
|
||||
int i, config_offset;
|
||||
MPEG4AudioConfig m4ac;
|
||||
MPEG4AudioConfig m4ac = {0};
|
||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||
AVCodecContext *avctx = ctx->avctx;
|
||||
uint32_t als_id, header_size, trailer_size;
|
||||
|
@@ -200,6 +200,7 @@ typedef struct DiracContext {
|
||||
|
||||
uint16_t *mctmp; /* buffer holding the MC data multipled by OBMC weights */
|
||||
uint8_t *mcscratch;
|
||||
int buffer_stride;
|
||||
|
||||
DECLARE_ALIGNED(16, uint8_t, obmc_weight)[3][MAX_BLOCKSIZE*MAX_BLOCKSIZE];
|
||||
|
||||
@@ -342,22 +343,44 @@ static int alloc_sequence_buffers(DiracContext *s)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
w = s->source.width;
|
||||
h = s->source.height;
|
||||
|
||||
/* fixme: allocate using real stride here */
|
||||
s->sbsplit = av_malloc(sbwidth * sbheight);
|
||||
s->blmotion = av_malloc(sbwidth * sbheight * 16 * sizeof(*s->blmotion));
|
||||
s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE);
|
||||
s->sbsplit = av_malloc_array(sbwidth, sbheight);
|
||||
s->blmotion = av_malloc_array(sbwidth, sbheight * 16 * sizeof(*s->blmotion));
|
||||
|
||||
s->mctmp = av_malloc((w+64+MAX_BLOCKSIZE) * (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
|
||||
s->mcscratch = av_malloc((w+64)*MAX_BLOCKSIZE);
|
||||
|
||||
if (!s->sbsplit || !s->blmotion || !s->mctmp || !s->mcscratch)
|
||||
if (!s->sbsplit || !s->blmotion)
|
||||
return AVERROR(ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int alloc_buffers(DiracContext *s, int stride)
|
||||
{
|
||||
int w = s->source.width;
|
||||
int h = s->source.height;
|
||||
|
||||
av_assert0(stride >= w);
|
||||
stride += 64;
|
||||
|
||||
if (s->buffer_stride >= stride)
|
||||
return 0;
|
||||
s->buffer_stride = 0;
|
||||
|
||||
av_freep(&s->edge_emu_buffer_base);
|
||||
memset(s->edge_emu_buffer, 0, sizeof(s->edge_emu_buffer));
|
||||
av_freep(&s->mctmp);
|
||||
av_freep(&s->mcscratch);
|
||||
|
||||
s->edge_emu_buffer_base = av_malloc_array(stride, MAX_BLOCKSIZE);
|
||||
|
||||
s->mctmp = av_malloc_array((stride+MAX_BLOCKSIZE), (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
|
||||
s->mcscratch = av_malloc_array(stride, MAX_BLOCKSIZE);
|
||||
|
||||
if (!s->edge_emu_buffer_base || !s->mctmp || !s->mcscratch)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
s->buffer_stride = stride;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_sequence_buffers(DiracContext *s)
|
||||
{
|
||||
int i, j, k;
|
||||
@@ -381,6 +404,7 @@ static void free_sequence_buffers(DiracContext *s)
|
||||
av_freep(&s->plane[i].idwt_tmp);
|
||||
}
|
||||
|
||||
s->buffer_stride = 0;
|
||||
av_freep(&s->sbsplit);
|
||||
av_freep(&s->blmotion);
|
||||
av_freep(&s->edge_emu_buffer_base);
|
||||
@@ -1817,6 +1841,9 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
|
||||
s->plane[1].stride = pic->avframe.linesize[1];
|
||||
s->plane[2].stride = pic->avframe.linesize[2];
|
||||
|
||||
if (alloc_buffers(s, FFMAX3(FFABS(s->plane[0].stride), FFABS(s->plane[1].stride), FFABS(s->plane[2].stride))) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
/* [DIRAC_STD] 11.1 Picture parse. picture_parse() */
|
||||
if (dirac_decode_picture_header(s))
|
||||
return -1;
|
||||
|
@@ -1337,6 +1337,8 @@ int ff_h264_frame_start(H264Context *h)
|
||||
int i;
|
||||
const int pixel_shift = h->pixel_shift;
|
||||
|
||||
h->next_output_pic = NULL;
|
||||
|
||||
if (ff_MPV_frame_start(s, s->avctx) < 0)
|
||||
return -1;
|
||||
ff_er_frame_start(s);
|
||||
@@ -1389,8 +1391,6 @@ int ff_h264_frame_start(H264Context *h)
|
||||
s->current_picture_ptr->field_poc[0] =
|
||||
s->current_picture_ptr->field_poc[1] = INT_MAX;
|
||||
|
||||
h->next_output_pic = NULL;
|
||||
|
||||
assert(s->current_picture_ptr->long_ref == 0);
|
||||
|
||||
return 0;
|
||||
|
@@ -362,7 +362,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
avctx->delay = duration;
|
||||
av_assert0(!s->afq.remaining_delay);
|
||||
s->afq.frames->duration += duration;
|
||||
s->afq.frames->pts -= duration;
|
||||
if (s->afq.frames->pts != AV_NOPTS_VALUE)
|
||||
s->afq.frames->pts -= duration;
|
||||
s->afq.remaining_samples += duration;
|
||||
}
|
||||
ff_af_queue_remove(&s->afq, duration, &avpkt->pts, &avpkt->duration);
|
||||
|
@@ -1140,7 +1140,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
|
||||
}
|
||||
|
||||
if (!Al) {
|
||||
s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss);
|
||||
s->coefs_finished[c] |= (2LL << se) - (1LL << ss);
|
||||
last_scan = !~s->coefs_finished[c];
|
||||
}
|
||||
|
||||
|
@@ -908,6 +908,8 @@ void ff_thread_flush(AVCodecContext *avctx)
|
||||
if (fctx->prev_thread) {
|
||||
if (fctx->prev_thread != &fctx->threads[0])
|
||||
update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
|
||||
if (avctx->codec->flush)
|
||||
avctx->codec->flush(fctx->threads[0].avctx);
|
||||
}
|
||||
|
||||
fctx->next_decoding = fctx->next_finished = 0;
|
||||
@@ -919,9 +921,6 @@ void ff_thread_flush(AVCodecContext *avctx)
|
||||
p->got_frame = 0;
|
||||
|
||||
release_delayed_buffers(p);
|
||||
|
||||
if (avctx->codec->flush)
|
||||
avctx->codec->flush(p->avctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -249,6 +249,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
static av_cold int sgi_init(AVCodecContext *avctx){
|
||||
SgiState *s = avctx->priv_data;
|
||||
|
||||
s->avctx = avctx;
|
||||
|
||||
avcodec_get_frame_defaults(&s->picture);
|
||||
avctx->coded_frame = &s->picture;
|
||||
|
||||
@@ -265,15 +267,6 @@ static av_cold int sgi_end(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold int sgi_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
SgiState *s = avctx->priv_data;
|
||||
|
||||
s->avctx = avctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodec ff_sgi_decoder = {
|
||||
.name = "sgi",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
@@ -283,6 +276,5 @@ AVCodec ff_sgi_decoder = {
|
||||
.close = sgi_end,
|
||||
.decode = decode_frame,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("SGI image"),
|
||||
.init = sgi_decode_init,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
};
|
||||
|
@@ -31,9 +31,10 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
|
||||
{
|
||||
char *format;
|
||||
char layout[64];
|
||||
AVBPrint dummy_buffer = { 0 };
|
||||
|
||||
if (!buf)
|
||||
buf = &(AVBPrint){ 0 }; /* dummy buffer */
|
||||
buf = &dummy_buffer;
|
||||
switch (link->type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
format = av_x_if_null(av_get_pix_fmt_name(link->format), "?");
|
||||
|
@@ -218,6 +218,18 @@ static int flv_write_header(AVFormatContext *s)
|
||||
avcodec_get_name(enc->codec_id), i);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (enc->codec_id == AV_CODEC_ID_MPEG4 ||
|
||||
enc->codec_id == AV_CODEC_ID_H263) {
|
||||
int error = enc->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL;
|
||||
av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING,
|
||||
"Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(enc->codec_id));
|
||||
|
||||
if (error) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"use vstrict=-1 / -strict -1 to use it anyway.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
audio_enc = enc;
|
||||
|
@@ -35,7 +35,7 @@ static int h263_probe(AVProbeData *p)
|
||||
for(i=0; i<p->buf_size; i++){
|
||||
code = (code<<8) + p->buf[i];
|
||||
if ((code & 0xfffffc0000) == 0x800000) {
|
||||
src_fmt= (code>>2)&3;
|
||||
src_fmt= (code>>2)&7;
|
||||
if( src_fmt != last_src_fmt
|
||||
&& last_src_fmt>0 && last_src_fmt<6
|
||||
&& src_fmt<6)
|
||||
|
@@ -279,6 +279,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
|
||||
{ AV_CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') },
|
||||
{ AV_CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') },
|
||||
{ AV_CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') },
|
||||
{ AV_CODEC_ID_PCM_S16BE, MKTAG('l', 'p', 'c', 'm') },
|
||||
{ AV_CODEC_ID_PCM_S16LE, MKTAG('l', 'p', 'c', 'm') },
|
||||
{ AV_CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') },
|
||||
{ AV_CODEC_ID_PCM_S24LE, MKTAG('i', 'n', '2', '4') },
|
||||
|
@@ -35,7 +35,7 @@ const CodecTags ff_mkv_codec_tags[]={
|
||||
{"A_MPEG/L2" , AV_CODEC_ID_MP2},
|
||||
{"A_MPEG/L1" , AV_CODEC_ID_MP2},
|
||||
{"A_MPEG/L3" , AV_CODEC_ID_MP3},
|
||||
{"A_OPUS", AV_CODEC_ID_OPUS},
|
||||
{"A_OPUS" , AV_CODEC_ID_OPUS},
|
||||
{"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F32LE},
|
||||
{"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F64LE},
|
||||
{"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S16BE},
|
||||
|
@@ -95,6 +95,8 @@ typedef struct MatroskaMuxContext {
|
||||
AVPacket cur_audio_pkt;
|
||||
|
||||
int have_attachments;
|
||||
|
||||
int64_t ts_offset;
|
||||
} MatroskaMuxContext;
|
||||
|
||||
|
||||
@@ -1265,9 +1267,18 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
AVIOContext *pb = s->pb->seekable ? s->pb : mkv->dyn_bc;
|
||||
AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
|
||||
int ret, keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
|
||||
int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
|
||||
int64_t ts;
|
||||
int cluster_size = avio_tell(pb) - (s->pb->seekable ? mkv->cluster_pos : 0);
|
||||
|
||||
if (pkt->dts < 0 && !mkv->ts_offset)
|
||||
mkv->ts_offset = -pkt->dts;
|
||||
|
||||
pkt->dts += mkv->ts_offset;
|
||||
if (pkt->pts != AV_NOPTS_VALUE)
|
||||
pkt->pts += mkv->ts_offset;
|
||||
|
||||
ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
|
||||
|
||||
// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
|
||||
// after 4k and on a keyframe
|
||||
if (mkv->cluster_pos != -1 &&
|
||||
|
@@ -119,15 +119,16 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
{
|
||||
MP3Context *mp3 = s->priv_data;
|
||||
AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
|
||||
int bitrate_idx;
|
||||
int best_bitrate_idx = -1;
|
||||
int best_bitrate_error= INT_MAX;
|
||||
int xing_offset;
|
||||
int32_t header, mask;
|
||||
MPADecodeHeader c;
|
||||
int srate_idx, ver = 0, i, channels;
|
||||
int needed;
|
||||
const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;
|
||||
int32_t header;
|
||||
MPADecodeHeader mpah;
|
||||
int srate_idx, i, channels;
|
||||
int bitrate_idx;
|
||||
int best_bitrate_idx = -1;
|
||||
int best_bitrate_error = INT_MAX;
|
||||
int xing_offset;
|
||||
int ver = 0;
|
||||
int bytes_needed;
|
||||
const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;
|
||||
|
||||
if (!s->pb->seekable)
|
||||
return 0;
|
||||
@@ -159,28 +160,29 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
/* dummy MPEG audio header */
|
||||
header = 0xffU << 24; // sync
|
||||
header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; // sync/audio-version/layer 3/no crc*/
|
||||
header |= (srate_idx << 2) << 8;
|
||||
header |= (srate_idx << 2) << 8;
|
||||
header |= channels << 6;
|
||||
|
||||
for (bitrate_idx=1; bitrate_idx<15; bitrate_idx++) {
|
||||
int error;
|
||||
avpriv_mpegaudio_decode_header(&c, header | (bitrate_idx << (4+8)));
|
||||
error= FFABS(c.bit_rate - codec->bit_rate);
|
||||
if(error < best_bitrate_error){
|
||||
best_bitrate_error= error;
|
||||
best_bitrate_idx = bitrate_idx;
|
||||
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
|
||||
int bit_rate = 1000 * avpriv_mpa_bitrate_tab[ver != 3][3 - 1][bitrate_idx];
|
||||
int error = FFABS(bit_rate - codec->bit_rate);
|
||||
|
||||
if (error < best_bitrate_error) {
|
||||
best_bitrate_error = error;
|
||||
best_bitrate_idx = bitrate_idx;
|
||||
}
|
||||
}
|
||||
av_assert0(best_bitrate_idx >= 0);
|
||||
|
||||
for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) {
|
||||
for (bitrate_idx = best_bitrate_idx; ; bitrate_idx++) {
|
||||
int32_t mask = bitrate_idx << (4 + 8);
|
||||
if (15 == bitrate_idx)
|
||||
return -1;
|
||||
mask = bitrate_idx << (4+8);
|
||||
header |= mask;
|
||||
avpriv_mpegaudio_decode_header(&c, header);
|
||||
xing_offset=xing_offtbl[c.lsf == 1][c.nb_channels == 1];
|
||||
needed = 4 // header
|
||||
|
||||
avpriv_mpegaudio_decode_header(&mpah, header);
|
||||
xing_offset=xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
|
||||
bytes_needed = 4 // header
|
||||
+ xing_offset
|
||||
+ 4 // xing tag
|
||||
+ 4 // frames/size/toc flags
|
||||
@@ -190,8 +192,9 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
+ 24
|
||||
;
|
||||
|
||||
if (needed <= c.frame_size)
|
||||
if (bytes_needed <= mpah.frame_size)
|
||||
break;
|
||||
|
||||
header &= ~mask;
|
||||
}
|
||||
|
||||
@@ -202,7 +205,7 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
ffio_wfourcc(s->pb, "Xing");
|
||||
avio_wb32(s->pb, 0x01 | 0x02 | 0x04); // frames / size / TOC
|
||||
|
||||
mp3->size = c.frame_size;
|
||||
mp3->size = mpah.frame_size;
|
||||
mp3->want=1;
|
||||
mp3->seen=0;
|
||||
mp3->pos=0;
|
||||
@@ -220,7 +223,7 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
avio_w8(s->pb, 0);
|
||||
avio_wb24(s->pb, FFMAX(codec->delay - 528 - 1, 0)<<12);
|
||||
|
||||
ffio_fill(s->pb, 0, c.frame_size - needed);
|
||||
ffio_fill(s->pb, 0, mpah.frame_size - bytes_needed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -260,7 +263,7 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
MP3Context *mp3 = s->priv_data;
|
||||
|
||||
if (pkt->data && pkt->size >= 4) {
|
||||
MPADecodeHeader c;
|
||||
MPADecodeHeader mpah;
|
||||
int av_unused base;
|
||||
uint32_t head = AV_RB32(pkt->data);
|
||||
|
||||
@@ -269,16 +272,16 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
"is invalid, writing it anyway.\n", pkt->size, head);
|
||||
return ff_raw_write_packet(s, pkt);
|
||||
}
|
||||
avpriv_mpegaudio_decode_header(&c, head);
|
||||
avpriv_mpegaudio_decode_header(&mpah, head);
|
||||
|
||||
if (!mp3->initial_bitrate)
|
||||
mp3->initial_bitrate = c.bit_rate;
|
||||
if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
|
||||
mp3->initial_bitrate = mpah.bit_rate;
|
||||
if ((mpah.bit_rate == 0) || (mp3->initial_bitrate != mpah.bit_rate))
|
||||
mp3->has_variable_bitrate = 1;
|
||||
|
||||
#ifdef FILTER_VBR_HEADERS
|
||||
/* filter out XING and INFO headers. */
|
||||
base = 4 + xing_offtbl[c.lsf == 1][c.nb_channels == 1];
|
||||
base = 4 + xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
|
||||
|
||||
if (base + 4 <= pkt->size) {
|
||||
uint32_t v = AV_RB32(pkt->data + base);
|
||||
|
@@ -153,7 +153,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
c->curbits = (curbits + size2) & 0x1F;
|
||||
|
||||
if ((ret = av_new_packet(pkt, size)) < 0)
|
||||
if ((ret = av_new_packet(pkt, size + 4)) < 0)
|
||||
return ret;
|
||||
|
||||
pkt->data[0] = curbits;
|
||||
|
@@ -410,6 +410,12 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
|
||||
av_dlog(s, "compute_pkt_fields2: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
|
||||
av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index);
|
||||
|
||||
if (pkt->duration < 0 && st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
|
||||
av_log(s, AV_LOG_WARNING, "Packet with invalid duration %d in stream %d\n",
|
||||
pkt->duration, pkt->stream_index);
|
||||
pkt->duration = 0;
|
||||
}
|
||||
|
||||
/* duration field */
|
||||
if (pkt->duration == 0) {
|
||||
ff_compute_frame_duration(&num, &den, st, NULL, pkt);
|
||||
|
@@ -36,11 +36,11 @@ struct oggopus_private {
|
||||
|
||||
static int opus_header(AVFormatContext *avf, int idx)
|
||||
{
|
||||
struct ogg *ogg = avf->priv_data;
|
||||
struct ogg_stream *os = &ogg->streams[idx];
|
||||
AVStream *st = avf->streams[idx];
|
||||
struct ogg *ogg = avf->priv_data;
|
||||
struct ogg_stream *os = &ogg->streams[idx];
|
||||
AVStream *st = avf->streams[idx];
|
||||
struct oggopus_private *priv = os->private;
|
||||
uint8_t *packet = os->buf + os->pstart;
|
||||
uint8_t *packet = os->buf + os->pstart;
|
||||
uint8_t *extradata;
|
||||
|
||||
if (!priv) {
|
||||
@@ -48,22 +48,24 @@ static int opus_header(AVFormatContext *avf, int idx)
|
||||
if (!priv)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
if (os->flags & OGG_FLAG_BOS) {
|
||||
if (os->psize < OPUS_HEAD_SIZE || (AV_RL8(packet + 8) & 0xF0) != 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
st->codec->codec_id = AV_CODEC_ID_OPUS;
|
||||
st->codec->channels = AV_RL8 (packet + 9);
|
||||
priv->pre_skip = AV_RL16(packet + 10);
|
||||
/*orig_sample_rate = AV_RL32(packet + 12);*/
|
||||
/*gain = AV_RL16(packet + 16);*/
|
||||
/*channel_map = AV_RL8 (packet + 18);*/
|
||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
st->codec->codec_id = AV_CODEC_ID_OPUS;
|
||||
st->codec->channels = AV_RL8 (packet + 9);
|
||||
priv->pre_skip = AV_RL16(packet + 10);
|
||||
/*orig_sample_rate = AV_RL32(packet + 12);*/
|
||||
/*gain = AV_RL16(packet + 16);*/
|
||||
/*channel_map = AV_RL8 (packet + 18);*/
|
||||
|
||||
extradata = av_malloc(os->psize + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!extradata)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
memcpy(extradata, packet, os->psize);
|
||||
st->codec->extradata = extradata;
|
||||
st->codec->extradata = extradata;
|
||||
st->codec->extradata_size = os->psize;
|
||||
|
||||
st->codec->sample_rate = 48000;
|
||||
@@ -79,21 +81,23 @@ static int opus_header(AVFormatContext *avf, int idx)
|
||||
priv->need_comments--;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int opus_packet(AVFormatContext *avf, int idx)
|
||||
{
|
||||
struct ogg *ogg = avf->priv_data;
|
||||
struct ogg_stream *os = &ogg->streams[idx];
|
||||
AVStream *st = avf->streams[idx];
|
||||
struct ogg *ogg = avf->priv_data;
|
||||
struct ogg_stream *os = &ogg->streams[idx];
|
||||
AVStream *st = avf->streams[idx];
|
||||
struct oggopus_private *priv = os->private;
|
||||
uint8_t *packet = os->buf + os->pstart;
|
||||
uint8_t *packet = os->buf + os->pstart;
|
||||
unsigned toc, toc_config, toc_count, frame_size, nb_frames = 1;
|
||||
|
||||
if (!os->psize)
|
||||
return AVERROR_INVALIDDATA;
|
||||
toc = *packet;
|
||||
|
||||
toc = *packet;
|
||||
toc_config = toc >> 3;
|
||||
toc_count = toc & 3;
|
||||
frame_size = toc_config < 12 ? FFMAX(480, 960 * (toc_config & 3)) :
|
||||
@@ -106,12 +110,14 @@ static int opus_packet(AVFormatContext *avf, int idx)
|
||||
} else if (toc_count) {
|
||||
nb_frames = 2;
|
||||
}
|
||||
|
||||
os->pduration = frame_size * nb_frames;
|
||||
if (os->lastpts != AV_NOPTS_VALUE) {
|
||||
if (st->start_time == AV_NOPTS_VALUE)
|
||||
st->start_time = os->lastpts;
|
||||
priv->cur_dts = os->lastdts = os->lastpts -= priv->pre_skip;
|
||||
}
|
||||
|
||||
priv->cur_dts += os->pduration;
|
||||
if ((os->flags & OGG_FLAG_EOS)) {
|
||||
int64_t skip = priv->cur_dts - os->granule + priv->pre_skip;
|
||||
@@ -123,13 +129,14 @@ static int opus_packet(AVFormatContext *avf, int idx)
|
||||
os->pduration);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct ogg_codec ff_opus_codec = {
|
||||
.name = "Opus",
|
||||
.magic = "OpusHead",
|
||||
.magicsize = 8,
|
||||
.header = opus_header,
|
||||
.packet = opus_packet,
|
||||
.name = "Opus",
|
||||
.magic = "OpusHead",
|
||||
.magicsize = 8,
|
||||
.header = opus_header,
|
||||
.packet = opus_packet,
|
||||
};
|
||||
|
@@ -23,6 +23,24 @@
|
||||
static int flags, checked;
|
||||
|
||||
void av_force_cpu_flags(int arg){
|
||||
if ( (arg & ( AV_CPU_FLAG_3DNOW |
|
||||
AV_CPU_FLAG_3DNOWEXT |
|
||||
AV_CPU_FLAG_SSE |
|
||||
AV_CPU_FLAG_SSE2 |
|
||||
AV_CPU_FLAG_SSE2SLOW |
|
||||
AV_CPU_FLAG_SSE3 |
|
||||
AV_CPU_FLAG_SSE3SLOW |
|
||||
AV_CPU_FLAG_SSSE3 |
|
||||
AV_CPU_FLAG_SSE4 |
|
||||
AV_CPU_FLAG_SSE42 |
|
||||
AV_CPU_FLAG_AVX |
|
||||
AV_CPU_FLAG_XOP |
|
||||
AV_CPU_FLAG_FMA4 ))
|
||||
&& !(arg & AV_CPU_FLAG_MMX)) {
|
||||
av_log(NULL, AV_LOG_WARNING, "MMX implied by specified flags\n");
|
||||
arg |= AV_CPU_FLAG_MMX;
|
||||
}
|
||||
|
||||
flags = arg;
|
||||
checked = arg != -1;
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "avutil.h"
|
||||
#include "avassert.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "lzo.h"
|
||||
@@ -65,8 +66,13 @@ static inline int get_len(LZOContext *c, int x, int mask)
|
||||
{
|
||||
int cnt = x & mask;
|
||||
if (!cnt) {
|
||||
while (!(x = get_byte(c)))
|
||||
while (!(x = get_byte(c))) {
|
||||
if (cnt >= INT_MAX - 1000) {
|
||||
c->error |= AV_LZO_ERROR;
|
||||
break;
|
||||
}
|
||||
cnt += 255;
|
||||
}
|
||||
cnt += mask + x;
|
||||
}
|
||||
return cnt;
|
||||
@@ -80,6 +86,7 @@ static inline void copy(LZOContext *c, int cnt)
|
||||
{
|
||||
register const uint8_t *src = c->in;
|
||||
register uint8_t *dst = c->out;
|
||||
av_assert0(cnt >= 0);
|
||||
if (cnt > c->in_end - src) {
|
||||
cnt = FFMAX(c->in_end - src, 0);
|
||||
c->error |= AV_LZO_INPUT_DEPLETED;
|
||||
@@ -103,7 +110,7 @@ static inline void copy(LZOContext *c, int cnt)
|
||||
/**
|
||||
* @brief Copies previously decoded bytes to current position.
|
||||
* @param back how many bytes back we start, must be > 0
|
||||
* @param cnt number of bytes to copy, must be >= 0
|
||||
* @param cnt number of bytes to copy, must be > 0
|
||||
*
|
||||
* cnt > back is valid, this will copy the bytes we just copied,
|
||||
* thus creating a repeating pattern with a period length of back.
|
||||
@@ -111,6 +118,7 @@ static inline void copy(LZOContext *c, int cnt)
|
||||
static inline void copy_backptr(LZOContext *c, int back, int cnt)
|
||||
{
|
||||
register uint8_t *dst = c->out;
|
||||
av_assert0(cnt > 0);
|
||||
if (dst - c->out_start < back) {
|
||||
c->error |= AV_LZO_INVALID_BACKPTR;
|
||||
return;
|
||||
|
@@ -122,6 +122,11 @@ av_cold static int auto_matrix(SwrContext *s)
|
||||
)
|
||||
out_ch_layout = AV_CH_LAYOUT_STEREO;
|
||||
|
||||
if( in_ch_layout == AV_CH_LAYOUT_STEREO_DOWNMIX
|
||||
&& (out_ch_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == 0
|
||||
)
|
||||
in_ch_layout = AV_CH_LAYOUT_STEREO;
|
||||
|
||||
if(!sane_layout(in_ch_layout)){
|
||||
av_get_channel_layout_string(buf, sizeof(buf), -1, s->in_ch_layout);
|
||||
av_log(s, AV_LOG_ERROR, "Input channel layout '%s' is not supported\n", buf);
|
||||
|
@@ -943,7 +943,7 @@ void ff_get_unscaled_swscale(SwsContext *c)
|
||||
c->swScale = ff_yuv2rgb_get_func_ptr(c);
|
||||
}
|
||||
|
||||
if (srcFormat == AV_PIX_FMT_YUV410P &&
|
||||
if (srcFormat == AV_PIX_FMT_YUV410P && !(dstH & 3) &&
|
||||
(dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
|
||||
!(flags & SWS_BITEXACT)) {
|
||||
c->swScale = yvu9ToYv12Wrapper;
|
||||
|
@@ -342,7 +342,7 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos,
|
||||
|
||||
xDstInSrc = xInc - 0x10000;
|
||||
for (i = 0; i < dstW; i++) {
|
||||
int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17);
|
||||
int xx = (xDstInSrc - ((int64_t)(filterSize - 2) << 16)) / (1 << 17);
|
||||
int j;
|
||||
(*filterPos)[i] = xx;
|
||||
for (j = 0; j < filterSize; j++) {
|
||||
|
Reference in New Issue
Block a user