From 6a73f3bbdfa0ea4984d8df280411d3e0e185c792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 Jan 2012 22:53:18 +0200 Subject: [PATCH 01/15] aviocat: Flush the output before closing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this, the end of the file might not be transmitted/written. Signed-off-by: Martin Storsjö --- tools/aviocat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/aviocat.c b/tools/aviocat.c index c43c69d1be..183cdf70dd 100644 --- a/tools/aviocat.c +++ b/tools/aviocat.c @@ -89,6 +89,7 @@ int main(int argc, char **argv) } } + avio_flush(output); avio_close(output); fail: avio_close(input); From 1f712e6a056f8015129ee786ab2ee3319774fb3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 Jan 2012 16:57:23 +0200 Subject: [PATCH 02/15] rtsp: Remove extern declarations for variables that don't exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtsp.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 662407f299..9d05289a91 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -405,9 +405,6 @@ typedef struct RTSPStream { void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf, RTSPState *rt, const char *method); -extern int rtsp_rtp_port_min; -extern int rtsp_rtp_port_max; - /** * Send a command to the RTSP server without waiting for the reply. * From 5d95112d926760046bc0b07aeda5cfc766ba54a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 Jan 2012 20:48:19 +0200 Subject: [PATCH 03/15] movenc: Reorder entries in the MOVIentry struct, for tigheter packing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally, sizeof(struct MOVIentry) was 48, after the reordering, it is 40 in my build configuration. When writing really long mov/mp4 files, this can make a difference - this saves a bit over 2 MB of memory per hour of video (down to 10.3 MB per hour from 12.3 MB per hour initially) for a video with 75 packets per second - 25 fps + 50 audio packets (which is the case for AMR audio). Signed-off-by: Martin Storsjö --- libavformat/movenc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 5ca5631c5a..5595ac71a8 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -40,12 +40,12 @@ #define MODE_IPOD 0x20 typedef struct MOVIentry { - unsigned int size; uint64_t pos; + int64_t dts; + unsigned int size; unsigned int samplesInChunk; unsigned int entries; int cts; - int64_t dts; #define MOV_SYNC_SAMPLE 0x0001 #define MOV_PARTIAL_SYNC_SAMPLE 0x0002 uint32_t flags; From 9b6aafba6c06ef62783dd5e9c5ed668f3a095128 Mon Sep 17 00:00:00 2001 From: John Brooks Date: Mon, 12 Dec 2011 17:04:14 -0700 Subject: [PATCH 04/15] mpegvideo: fix invalid memory access for small video dimensions When either video dimension is only one macroblock, subtractions based on v_edge_pos and the macroblock size may be negative. In that situation, an unsigned comparison isn't sufficent to test for MV overruns, because a limit of (unsigned)-1 will let any other value pass. Signed-off-by: Anton Khirnov --- libavcodec/mpegvideo.c | 12 ++++++------ libavcodec/mpegvideo_common.h | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index f711d36aec..50e6ad6da4 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1843,8 +1843,8 @@ static inline int hpel_motion_lowres(MpegEncContext *s, src += src_y * stride + src_x; - if ((unsigned)src_x > h_edge_pos - (!!sx) - w || - (unsigned)src_y > (v_edge_pos >> field_based) - (!!sy) - h) { + if ((unsigned)src_x > FFMAX( h_edge_pos - (!!sx) - w, 0) || + (unsigned)src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w + 1, (h + 1) << field_based, src_x, src_y << field_based, @@ -1928,8 +1928,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; - if ((unsigned) src_x > h_edge_pos - (!!sx) - 2 * block_s || - (unsigned) src_y > (v_edge_pos >> field_based) - (!!sy) - h) { + if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || + (unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17 + field_based, src_x, src_y << field_based, h_edge_pos, @@ -2011,8 +2011,8 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s, offset = src_y * s->uvlinesize + src_x; ptr = ref_picture[1] + offset; if (s->flags & CODEC_FLAG_EMU_EDGE) { - if ((unsigned) src_x > h_edge_pos - (!!sx) - block_s || - (unsigned) src_y > v_edge_pos - (!!sy) - block_s) { + if ((unsigned) src_x > FFMAX(h_edge_pos - (!!sx) - block_s, 0) || + (unsigned) src_y > FFMAX(v_edge_pos - (!!sy) - block_s, 0)) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos); ptr = s->edge_emu_buffer; diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h index d64404d8c5..9f6307ea7c 100644 --- a/libavcodec/mpegvideo_common.h +++ b/libavcodec/mpegvideo_common.h @@ -81,8 +81,8 @@ static inline void gmc1_motion(MpegEncContext *s, ptr = ref_picture[0] + (src_y * linesize) + src_x; if(s->flags&CODEC_FLAG_EMU_EDGE){ - if( (unsigned)src_x >= s->h_edge_pos - 17 - || (unsigned)src_y >= s->v_edge_pos - 17){ + if( (unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) + || (unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos); ptr= s->edge_emu_buffer; } @@ -120,8 +120,8 @@ static inline void gmc1_motion(MpegEncContext *s, offset = (src_y * uvlinesize) + src_x; ptr = ref_picture[1] + offset; if(s->flags&CODEC_FLAG_EMU_EDGE){ - if( (unsigned)src_x >= (s->h_edge_pos>>1) - 9 - || (unsigned)src_y >= (s->v_edge_pos>>1) - 9){ + if( (unsigned)src_x >= FFMAX((s->h_edge_pos>>1) - 9, 0) + || (unsigned)src_y >= FFMAX((s->v_edge_pos>>1) - 9, 0)){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr= s->edge_emu_buffer; emu=1; @@ -221,8 +221,8 @@ static inline int hpel_motion(MpegEncContext *s, src += src_y * stride + src_x; if(s->unrestricted_mv && (s->flags&CODEC_FLAG_EMU_EDGE)){ - if( (unsigned)src_x > h_edge_pos - (motion_x&1) - w - || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){ + if( (unsigned)src_x > FFMAX(h_edge_pos - (motion_x&1) - w, 0) + || (unsigned)src_y > FFMAX(v_edge_pos - (motion_y&1) - h, 0)){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<v_edge_pos); src= s->edge_emu_buffer; @@ -307,8 +307,8 @@ if(s->quarter_sample) ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; - if( (unsigned)src_x > s->h_edge_pos - (motion_x&1) - 16 - || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){ + if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&1) - 16, 0) + || (unsigned)src_y > FFMAX( v_edge_pos - (motion_y&1) - h , 0)){ if(is_mpeg12 || s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MPEG1VIDEO){ av_log(s->avctx,AV_LOG_DEBUG, @@ -510,8 +510,8 @@ static inline void qpel_motion(MpegEncContext *s, ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; - if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 16 - || (unsigned)src_y > v_edge_pos - (motion_y&3) - h ){ + if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&3) - 16, 0) + || (unsigned)src_y > FFMAX( v_edge_pos - (motion_y&3) - h , 0)){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based, src_x, src_y<h_edge_pos, s->v_edge_pos); @@ -588,8 +588,8 @@ static inline void chroma_4mv_motion(MpegEncContext *s, offset = src_y * s->uvlinesize + src_x; ptr = ref_picture[1] + offset; if(s->flags&CODEC_FLAG_EMU_EDGE){ - if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8 - || (unsigned)src_y > (s->v_edge_pos>>1) - (dxy>>1) - 8){ + if( (unsigned)src_x > FFMAX((s->h_edge_pos>>1) - (dxy &1) - 8, 0) + || (unsigned)src_y > FFMAX((s->v_edge_pos>>1) - (dxy>>1) - 8, 0)){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); @@ -760,8 +760,8 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, ptr = ref_picture[0] + (src_y * s->linesize) + (src_x); if(s->flags&CODEC_FLAG_EMU_EDGE){ - if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 8 - || (unsigned)src_y > s->v_edge_pos - (motion_y&3) - 8 ){ + if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&3) - 8, 0) + || (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y&3) - 8, 0)){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, From f88949214cea6b23a6f48e5d1b032cd6cf0f78cb Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Fri, 20 Jan 2012 03:57:32 -0500 Subject: [PATCH 05/15] lavc: rename err_filter option to err_detect and document it Signed-off-by: Anton Khirnov --- libavcodec/options.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/options.c b/libavcodec/options.c index 00d80e07c3..0d41da52ac 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -208,11 +208,11 @@ static const AVOption options[]={ {"very_aggressive", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, {"explode", "abort decoding on error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"}, #endif /* FF_API_ER */ -{"err_filter", "set error detection filter flags", OFFSET(err_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, A|V|D, "err_filter"}, -{"crccheck", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, V|D, "err_filter"}, -{"bitstream", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, V|D, "err_filter"}, -{"buffer", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BUFFER }, INT_MIN, INT_MAX, V|D, "err_filter"}, -{"explode", "abort decoding on minor error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, V|D, "err_filter"}, +{"err_detect", "set error detection flags", OFFSET(err_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, A|V|D, "err_detect"}, +{"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, V|D, "err_detect"}, +{"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, V|D, "err_detect"}, +{"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BUFFER }, INT_MIN, INT_MAX, V|D, "err_detect"}, +{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, V|D, "err_detect"}, {"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, #if FF_API_PARSE_FRAME From 5124423ec3bd71be5643e78cd953828266bc5059 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Fri, 20 Jan 2012 03:53:54 -0500 Subject: [PATCH 06/15] lavf: rename fer option and document resulting (f_)err_detect options Signed-off-by: Anton Khirnov --- libavformat/options.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavformat/options.c b/libavformat/options.c index a9e2c1cd93..7c75bf48fc 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -109,10 +109,15 @@ static const AVOption options[]={ {"fdebug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"}, {"ts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"}, {"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D}, -{"fer", "set error detection aggressivity", OFFSET(error_recognition), AV_OPT_TYPE_INT, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, -{"careful", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, -{"explode", "abort decoding on error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, D, "fer"}, {"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D}, +/* this is a crutch for avconv, since it cannot deal with identically named options in different contexts. + * to be removed when avconv is fixed */ +{"f_err_detect", "set error detection flags (deprecated; use err_detect, save via avconv)", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"}, +{"err_detect", "set error detection flags", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"}, +{"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"}, +{"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, D, "err_detect"}, +{"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BUFFER }, INT_MIN, INT_MAX, D, "err_detect"}, +{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, D, "err_detect"}, {NULL}, }; From d2a0041c2075a553bb8d4f94591f8556680190c8 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Mon, 16 Jan 2012 08:25:04 -0500 Subject: [PATCH 07/15] mpegaudiodec: switch error detection check to AV_EF_BUFFER Signed-off-by: Anton Khirnov --- libavcodec/mpegaudiodec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 6a06afa680..a83b1621fd 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -985,7 +985,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g, /* skip extension bits */ bits_left = end_pos2 - get_bits_count(&s->gb); //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer); - if (bits_left < 0 && (s->err_recognition & AV_EF_BITSTREAM)) { + if (bits_left < 0 && (s->err_recognition & AV_EF_BUFFER)) { av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left); s_index=0; } else if (bits_left > 0 && (s->err_recognition & AV_EF_BUFFER)) { From 97e3f94b61abb4148bbd33eda1b2540ea4e7cbdf Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 21 Jan 2012 08:40:47 +0100 Subject: [PATCH 08/15] Revert "avserver: fix build after the next bump." This temporarily (until 0.8 is released) reverts commit 8e1340abc316e038bb89e5a3b46e92ff58c98a88. That commit breaks shared builds because of symbol hiding. Reverting it will enable shared builds for 0.8 --- avserver.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/avserver.c b/avserver.c index f3ac319ef9..15fa64c144 100644 --- a/avserver.c +++ b/avserver.c @@ -26,16 +26,13 @@ #include #include #include "libavformat/avformat.h" -// FIXME those are internal headers, avserver _really_ shouldn't use them #include "libavformat/ffm.h" #include "libavformat/network.h" #include "libavformat/os_support.h" #include "libavformat/rtpdec.h" #include "libavformat/rtsp.h" +// XXX for ffio_open_dyn_packet_buffer, to be removed #include "libavformat/avio_internal.h" -#include "libavformat/internal.h" -#include "libavformat/url.h" - #include "libavutil/avstring.h" #include "libavutil/lfg.h" #include "libavutil/dict.h" @@ -870,7 +867,7 @@ static void close_connection(HTTPContext *c) } h = c->rtp_handles[i]; if (h) - ffurl_close(h); + url_close(h); } ctx = &c->fmt_ctx; @@ -2251,6 +2248,7 @@ static int http_prepare_data(HTTPContext *c) * Default value from Libav * Try to set it use configuration option */ + c->fmt_ctx.preload = (int)(0.5*AV_TIME_BASE); c->fmt_ctx.max_delay = (int)(0.7*AV_TIME_BASE); if (avformat_write_header(&c->fmt_ctx, NULL) < 0) { @@ -2369,7 +2367,7 @@ static int http_prepare_data(HTTPContext *c) if (c->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; else - max_packet_size = c->rtp_handles[c->packet_stream_index]->max_packet_size; + max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]); ret = ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size); } else { ret = avio_open_dyn_buf(&ctx->pb); @@ -2522,8 +2520,8 @@ static int http_send_data(HTTPContext *c) } else { /* send RTP packet directly in UDP */ c->buffer_ptr += 4; - ffurl_write(c->rtp_handles[c->packet_stream_index], - c->buffer_ptr, len); + url_write(c->rtp_handles[c->packet_stream_index], + c->buffer_ptr, len); c->buffer_ptr += len; /* here we continue as we can send several packets per 10 ms slot */ } @@ -3406,10 +3404,10 @@ static int rtp_new_av_stream(HTTPContext *c, "rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port)); } - if (ffurl_open(&h, ctx->filename, AVIO_FLAG_WRITE, NULL, NULL) < 0) + if (url_open(&h, ctx->filename, AVIO_FLAG_WRITE) < 0) goto fail; c->rtp_handles[stream_index] = h; - max_packet_size = h->max_packet_size; + max_packet_size = url_get_max_packet_size(h); break; case RTSP_LOWER_TRANSPORT_TCP: /* RTP/TCP case */ @@ -3432,7 +3430,7 @@ static int rtp_new_av_stream(HTTPContext *c, if (avformat_write_header(ctx, NULL) < 0) { fail: if (h) - ffurl_close(h); + url_close(h); av_free(ctx); return -1; } @@ -3469,7 +3467,7 @@ static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int cop } fst->priv_data = av_mallocz(sizeof(FeedData)); fst->index = stream->nb_streams; - avpriv_set_pts_info(fst, 33, 1, 90000); + av_set_pts_info(fst, 33, 1, 90000); fst->sample_aspect_ratio = codec->sample_aspect_ratio; stream->streams[stream->nb_streams++] = fst; return fst; From 7512bb74f242ae9da90c90203a904b65d6f040b8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 21 Jan 2012 08:48:53 +0100 Subject: [PATCH 09/15] doc/APIChanges: fill in missing dates and hashes --- doc/APIchanges | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 2d7832430f..904e3462f7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,15 +13,15 @@ libavutil: 2011-04-18 API changes, most recent first: -2012-xx-xx - lavc 53.34.0 +2012-01-15 - lavc 53.34.0 New audio encoding API: - xxxxxxx Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio + b2c75b6 Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio encoders. - xxxxxxx Add avcodec_fill_audio_frame() as a convenience function. - xxxxxxx Add avcodec_encode_audio2() and deprecate avcodec_encode_audio(). + 5ee5fa0 Add avcodec_fill_audio_frame() as a convenience function. + b2c75b6 Add avcodec_encode_audio2() and deprecate avcodec_encode_audio(). Add AVCodec.encode2(). -2012-01-xx - xxxxxxx - lavfi 2.15.0 +2012-01-12 - 3167dc9 - lavfi 2.15.0 Add a new installed header -- libavfilter/version.h -- with version macros. 2011-01-03 - b73ec05 - lavu 51.21.0 From 7ba34575fd3831315b9aa6eba2935800cfccbd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sat, 21 Jan 2012 11:33:35 +0200 Subject: [PATCH 10/15] aviocat: Remove useless includes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also include stdlib.h explicitly - currently it is used implicitly via avformat.h. Signed-off-by: Martin Storsjö --- tools/aviocat.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/aviocat.c b/tools/aviocat.c index 183cdf70dd..92483c345a 100644 --- a/tools/aviocat.c +++ b/tools/aviocat.c @@ -19,13 +19,9 @@ */ #include -#include +#include #include -#include #include "libavformat/avformat.h" -#include "libavformat/riff.h" -#include "libavutil/intreadwrite.h" -#include "libavutil/mathematics.h" static int usage(const char *argv0, int ret) { From afb8b207d6c82bc063ab984b2875074457db2e4f Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Fri, 20 Jan 2012 13:37:00 +0100 Subject: [PATCH 11/15] threads: update slice_count and slice_offset from user context They are used to signal the number of slices and offsets of each slice out of band to the decoder. --- libavcodec/pthread.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 0688d9d8f0..a4e3081272 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -413,7 +413,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, dst->has_b_frames = src->has_b_frames; dst->idct_algo = src->idct_algo; - dst->slice_count = src->slice_count; dst->bits_per_coded_sample = src->bits_per_coded_sample; dst->sample_aspect_ratio = src->sample_aspect_ratio; @@ -447,8 +446,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, * * @param dst The destination context. * @param src The source context. + * @return 0 on success, negative error code on failure */ -static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src) +static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src) { #define copy_fields(s, e) memcpy(&dst->s, &src->s, (char*)&dst->e - (char*)&dst->s); dst->flags = src->flags; @@ -469,6 +469,22 @@ static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src) dst->frame_number = src->frame_number; dst->reordered_opaque = src->reordered_opaque; + + if (src->slice_count && src->slice_offset) { + if (dst->slice_count < src->slice_count) { + int *tmp = av_realloc(dst->slice_offset, src->slice_count * + sizeof(*dst->slice_offset)); + if (!tmp) { + av_free(dst->slice_offset); + return AVERROR(ENOMEM); + } + dst->slice_offset = tmp; + } + memcpy(dst->slice_offset, src->slice_offset, + src->slice_count * sizeof(*dst->slice_offset)); + } + dst->slice_count = src->slice_count; + return 0; #undef copy_fields } @@ -579,7 +595,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx, */ p = &fctx->threads[fctx->next_decoding]; - update_context_from_user(p->avctx, avctx); + err = update_context_from_user(p->avctx, avctx); + if (err) return err; err = submit_packet(p, avpkt); if (err) return err; @@ -750,6 +767,7 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) if (i) { av_freep(&p->avctx->priv_data); av_freep(&p->avctx->internal); + av_freep(&p->avctx->slice_offset); } av_freep(&p->avctx); From 2473a45c85dce6872617b33fce396dbbd6347e8e Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 18 Jan 2012 10:53:41 +0100 Subject: [PATCH 12/15] threads: change the default for threads back to 1 Using threaded decoding by default breaks backward compatibility if AVHWAccel is used or if an appliction sets threadunsafe callbacks. Avconv and avplay still use -threads auto if not specified. --- avconv.c | 4 ++++ avplay.c | 2 ++ libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/avconv.c b/avconv.c index 008cfe0275..46f3090755 100644 --- a/avconv.c +++ b/avconv.c @@ -2210,6 +2210,8 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb ist->st->codec->opaque = ist; } + if (!av_dict_get(ist->opts, "threads", NULL, 0)) + av_dict_set(&ist->opts, "threads", "auto", 0); if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d", ist->file_index, ist->st->index); @@ -2512,6 +2514,8 @@ static int transcode_init(OutputFile *output_files, memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } + if (!av_dict_get(ost->opts, "threads", NULL, 0)) + av_dict_set(&ost->opts, "threads", "auto", 0); if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); diff --git a/avplay.c b/avplay.c index 85e03770e5..432afc11b3 100644 --- a/avplay.c +++ b/avplay.c @@ -2194,6 +2194,8 @@ static int stream_component_open(VideoState *is, int stream_index) if (lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE; if (fast) avctx->flags2 |= CODEC_FLAG2_FAST; + if (!av_dict_get(opts, "threads", NULL, 0)) + av_dict_set(&opts, "threads", "auto", 0); if (!codec || avcodec_open2(avctx, codec, &opts) < 0) return -1; diff --git a/libavcodec/options.c b/libavcodec/options.c index 0d41da52ac..2689d32a92 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -372,7 +372,7 @@ static const AVOption options[]={ {"float", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"}, #endif {"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E|D, "threads"}, +{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, 0, INT_MAX, V|E|D, "threads"}, {"auto", "detect a good number of threads", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"}, {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, From fd1a1f1484420379f27ec5dea8ae28dd0063d531 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 21 Jan 2012 14:54:31 +0100 Subject: [PATCH 13/15] Prepare for 0.8 Release --- RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index ce377b1f07..aec258df73 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -0.8_beta2 +0.8 From 4b63cc18bc44517f0f9e04b39ab873cbc3c6aee5 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sat, 21 Jan 2012 18:37:25 +0100 Subject: [PATCH 14/15] Finalize changelog for 0.8 Release --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 3515ba55b1..f1530749de 100644 --- a/Changelog +++ b/Changelog @@ -2,7 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. -version : +version 0.8: - GSM audio parser - SMJPEG muxer From ad7beb2cac1563e87171a4d044a6d526527d81d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sat, 21 Jan 2012 17:20:45 +0200 Subject: [PATCH 15/15] rtpdec: Use our own SSRC in the SDES field when sending RRs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The s->ssrc field is the sender's SSRC, we use ssrc + 1 to get a collision free "unique" SSRC for ourselves in the RR part. The SDES block in the RTCP packet should describe ourselves, not the sender. This was fixed for the RR part in 952139a3226b, but wasn't fixed for the SDES part until now. This could cause some Axis cameras to send RTCP BYE packets to us due to the SSRC collision. Signed-off-by: Martin Storsjö --- libavformat/rtpdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 7e8b52adad..3442c9b2b1 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -299,7 +299,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) avio_w8(pb, RTCP_SDES); len = strlen(s->hostname); avio_wb16(pb, (6 + len + 3) / 4); /* length in words - 1 */ - avio_wb32(pb, s->ssrc); + avio_wb32(pb, s->ssrc + 1); avio_w8(pb, 0x01); avio_w8(pb, len); avio_write(pb, s->hostname, len);