Re: [libav-devel] [PATCH] mpjpegdec: don't try to alloc an AVIOContext when probe is guaranteed to fail
On 08/06/15 22:19, James Almer wrote: The first check is done without the AVIOContext, so alloc it only if said check succeeds Signed-off-by: James Almer jamr...@gmail.com --- libavformat/mpjpegdec.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) Shouldn't hurt. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] mpjpegdec: don't try to alloc an AVIOContext when probe is guaranteed to fail
The first check is done without the AVIOContext, so alloc it only if said check succeeds Signed-off-by: James Almer jamr...@gmail.com --- libavformat/mpjpegdec.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c index 72891e7..e2a2ece 100644 --- a/libavformat/mpjpegdec.c +++ b/libavformat/mpjpegdec.c @@ -83,13 +83,13 @@ static int mpjpeg_read_probe(AVProbeData *p) char line[128] = { 0 }; int ret = 0; +if (p-buf_size 2 || p-buf[0] != '-' || p-buf[1] != '-') +return 0; + pb = avio_alloc_context(p-buf, p-buf_size, 0, NULL, NULL, NULL, NULL); if (!pb) return AVERROR(ENOMEM); -if (p-buf_size 2 || p-buf[0] != '-' || p-buf[1] != '-') -goto end; - while (!pb-eof_reached) { ret = get_line(pb, line, sizeof(line)); if (ret 0) @@ -101,7 +101,7 @@ static int mpjpeg_read_probe(AVProbeData *p) break; } } -end: + av_free(pb); return ret; -- 2.4.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] configure: Support MSVC 2015
On 08/06/15 09:20, Martin Storsjö wrote: On Sun, 7 Jun 2015, Luca Barbato wrote: The C runtime C99 compatibility had been improved a lot and it now rejects some of the compatibility defines provided for the older versions. Many thanks to Ray for the time spent testing. Bug-Id: 864 CC: libav-sta...@libav.org --- Martin does it sound ok for you? Almost configure| 22 ++ libavutil/internal.h | 11 ++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 18f0518..c8a799d 100755 --- a/configure +++ b/configure @@ -3021,9 +3021,6 @@ probe_cc(){ _ld_path='-libpath:' _flags='-nologo' _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64' -if [ $pfx = hostcc ]; then -append _cflags -Dsnprintf=_snprintf -fi elif $_cc 21 | grep -q Intel; then _type=icl _ident=$($_cc 21 | head -n1) @@ -3047,9 +3044,6 @@ probe_cc(){ # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency # with MSVC which enables it by default. _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS' -if [ $pfx = hostcc ]; then -append _cflags -Dsnprintf=_snprintf -fi elif $_cc --version 2/dev/null | grep -q ^cparser; then _type=cparser _ident=$($_cc --version | head -n1) @@ -3743,6 +3737,16 @@ probe_libc(){ add_${pfx}cppflags -D__printf__=__gnu_printf__ elif check_${pfx}cpp_condition crtversion.h defined _VC_CRT_MAJOR_VERSION; then eval ${pfx}libc_type=msvcrt +if check_${pfx}cpp_condition crtversion.h _VC_CRT_MAJOR_VERSION 14; then +if [ $pfx = host_ ]; then You want to have quotes around $pfx here, since it will be empty once; this avoids warnings like this: configure: 3741: [: =: unexpected operator Other than that, this looks good. I had a similar patch locally that I wrote originally when the first preview of MSVC 2014 (as it was called back then) was made available a year ago, that I hadn't sent yet - originally since things were so much in flux (I think they've restructured the CRT a couple of times since that, although the fixes to our build system were the same). The 2015 version still isn't officially released, but it is getting closer though. At least a couple of users are having the problem so I'd fix the quoting and push it. Thanks for having a look! lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] lavf: add a format flag for separate carriers, and an event for detecting carrier presence.
On 08/06/15 06:09, John Högberg wrote: Luca Barbato wrote: I was waiting for Anton, I'm more and more convinced that the feature is important and I'm planning to fit it in the avformat API that will match the avcodec API I detailed here[1]. I'm not sure about the name, but they can be changed later. lu [1]: https://blogs.gentoo.org/lu_zero/2015/03/23/decoupling-an-api/ Cool, it looks like that might solve a few issues of mine. Aside from the blog, is there a discussion thread for this somewhere? On topic, should I go ahead with submitting the patch for MPEG-TS? Please do. I thought about the alternative to support your scenario (beside having a callback API that I'll blog about soonish) and another way to do that is to have an AVSTREAM_EVENT_FLAG_LOST to signal that the stream is gone and an AVFMT_EVENT_FLAG_ACTIVE_STREAM_CHANGED to signal the fact the number of active stream changed. The semantics compared to metadata update is changed slightly, since we want to keep the AVSTREAM_EVENT_FLAG_LOST as they are until they change while wiping the AVFMT_EVENT_FLAG_ACTIVE_STREAM_CHANGED. This should be enough to avoid to introduce a function to explicitly to check and reset even if I'd consider adding it nonetheless. Another option is having a generic AVFMT_EVENT_FLAG_STREAM_EVENT to signal that the stream event flags had been set (and spare some iterations over the stream list). How does it sound? lu PS: The spring^Wsummer Sprint will be almost surely held in Stockholm, if you are close and you want to drop by would be great =) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] configure: Support MSVC 2015
On Sun, 7 Jun 2015, Luca Barbato wrote: The C runtime C99 compatibility had been improved a lot and it now rejects some of the compatibility defines provided for the older versions. Many thanks to Ray for the time spent testing. Bug-Id: 864 CC: libav-sta...@libav.org --- Martin does it sound ok for you? Almost configure| 22 ++ libavutil/internal.h | 11 ++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 18f0518..c8a799d 100755 --- a/configure +++ b/configure @@ -3021,9 +3021,6 @@ probe_cc(){ _ld_path='-libpath:' _flags='-nologo' _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64' -if [ $pfx = hostcc ]; then -append _cflags -Dsnprintf=_snprintf -fi elif $_cc 21 | grep -q Intel; then _type=icl _ident=$($_cc 21 | head -n1) @@ -3047,9 +3044,6 @@ probe_cc(){ # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency # with MSVC which enables it by default. _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS' -if [ $pfx = hostcc ]; then -append _cflags -Dsnprintf=_snprintf -fi elif $_cc --version 2/dev/null | grep -q ^cparser; then _type=cparser _ident=$($_cc --version | head -n1) @@ -3743,6 +3737,16 @@ probe_libc(){ add_${pfx}cppflags -D__printf__=__gnu_printf__ elif check_${pfx}cpp_condition crtversion.h defined _VC_CRT_MAJOR_VERSION; then eval ${pfx}libc_type=msvcrt +if check_${pfx}cpp_condition crtversion.h _VC_CRT_MAJOR_VERSION 14; then +if [ $pfx = host_ ]; then You want to have quotes around $pfx here, since it will be empty once; this avoids warnings like this: configure: 3741: [: =: unexpected operator Other than that, this looks good. I had a similar patch locally that I wrote originally when the first preview of MSVC 2014 (as it was called back then) was made available a year ago, that I hadn't sent yet - originally since things were so much in flux (I think they've restructured the CRT a couple of times since that, although the fixes to our build system were the same). The 2015 version still isn't officially released, but it is getting closer though. // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] configure: Support MSVC 2015
On Mon, 8 Jun 2015, Luca Barbato wrote: On 08/06/15 09:20, Martin Storsjö wrote: On Sun, 7 Jun 2015, Luca Barbato wrote: The C runtime C99 compatibility had been improved a lot and it now rejects some of the compatibility defines provided for the older versions. Many thanks to Ray for the time spent testing. Bug-Id: 864 CC: libav-sta...@libav.org --- Martin does it sound ok for you? Almost configure| 22 ++ libavutil/internal.h | 11 ++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 18f0518..c8a799d 100755 --- a/configure +++ b/configure @@ -3021,9 +3021,6 @@ probe_cc(){ _ld_path='-libpath:' _flags='-nologo' _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64' -if [ $pfx = hostcc ]; then -append _cflags -Dsnprintf=_snprintf -fi elif $_cc 21 | grep -q Intel; then _type=icl _ident=$($_cc 21 | head -n1) @@ -3047,9 +3044,6 @@ probe_cc(){ # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency # with MSVC which enables it by default. _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS' -if [ $pfx = hostcc ]; then -append _cflags -Dsnprintf=_snprintf -fi elif $_cc --version 2/dev/null | grep -q ^cparser; then _type=cparser _ident=$($_cc --version | head -n1) @@ -3743,6 +3737,16 @@ probe_libc(){ add_${pfx}cppflags -D__printf__=__gnu_printf__ elif check_${pfx}cpp_condition crtversion.h defined _VC_CRT_MAJOR_VERSION; then eval ${pfx}libc_type=msvcrt +if check_${pfx}cpp_condition crtversion.h _VC_CRT_MAJOR_VERSION 14; then +if [ $pfx = host_ ]; then You want to have quotes around $pfx here, since it will be empty once; this avoids warnings like this: configure: 3741: [: =: unexpected operator Other than that, this looks good. I had a similar patch locally that I wrote originally when the first preview of MSVC 2014 (as it was called back then) was made available a year ago, that I hadn't sent yet - originally since things were so much in flux (I think they've restructured the CRT a couple of times since that, although the fixes to our build system were the same). The 2015 version still isn't officially released, but it is getting closer though. At least a couple of users are having the problem so I'd fix the quoting and push it. Yes, I think it is converging towards a release pretty soon; it does feel pretty ready by now. // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] lavf: add a format flag for separate carriers, and an event for detecting carrier presence.
Luca Barbato wrote: Please do. I thought about the alternative to support your scenario (beside having a callback API that I'll blog about soonish) and another way to do that is to have an AVSTREAM_EVENT_FLAG_LOST to signal that the stream is gone and an AVFMT_EVENT_FLAG_ACTIVE_STREAM_CHANGED to signal the fact the number of active stream changed. The semantics compared to metadata update is changed slightly, since we want to keep the AVSTREAM_EVENT_FLAG_LOST as they are until they change while wiping the AVFMT_EVENT_FLAG_ACTIVE_STREAM_CHANGED. This should be enough to avoid to introduce a function to explicitly to check and reset even if I'd consider adding it nonetheless. A general notification above stream level would be useful, yes. As an aside, the new semantics are present rather than lost as per Anton's feedback. It feels like I've submitted every possible way of implementing this right now. :| Another option is having a generic AVFMT_EVENT_FLAG_STREAM_EVENT to signal that the stream event flags had been set (and spare some iterations over the stream list). How does it sound? I'd prefer the generic solution. There's little to be gained by inheriting the specific flags of the underlying streams since you'll need to check them all anyway. lu PS: The spring^Wsummer Sprint will be almost surely held in Stockholm, if you are close and you want to drop by would be great =) When? I'll see if I can make it. Regards, John Högberg ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] mpegts: implement the CARRIER_PRESENT event
This patch implements the CARRIER_PRESENT event as outlined here; https://lists.libav.org/pipermail/libav-devel/2015-June/069889.html Regards, John Högberg From 163ff93fab1e0ec81f8f560d946dfe2a93e7c1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= john.hogb...@ericsson.com Date: Mon, 8 Jun 2015 11:04:35 +0200 Subject: [PATCH] mpegts: implement the CARRIER_PRESENT event. --- libavformat/mpegts.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 8f61f17..d1e0a7f 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -840,6 +840,10 @@ static int mpegts_push_data(MpegTSFilter *filter, av_log(pes-stream, AV_LOG_TRACE, pid=%x pes_code=%#x\n, pes-pid, code); +if(pes-st) { +pes-st-event_flags |= AVSTREAM_EVENT_FLAG_CARRIER_PRESENT; +} + if ((pes-st pes-st-discard == AVDISCARD_ALL (!pes-sub_st || pes-sub_st-discard == AVDISCARD_ALL)) || @@ -2379,7 +2383,7 @@ AVInputFormat ff_mpegts_demuxer = { .read_close = mpegts_read_close, .read_seek = read_seek, .read_timestamp = mpegts_get_pcr, -.flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT, +.flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT | AVFMT_SEPCARRIERS, .priv_class = mpegts_class, }; @@ -2392,6 +2396,6 @@ AVInputFormat ff_mpegtsraw_demuxer = { .read_close = mpegts_read_close, .read_seek = read_seek, .read_timestamp = mpegts_get_pcr, -.flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT, +.flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT | AVFMT_SEPCARRIERS, .priv_class = mpegtsraw_class, }; -- 1.9.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/3] aac_parser: add required padding for GetBitContext buffer
Fixes stack buffer overflow errors detected by address sanitizer in various fate tests. --- libavcodec/aac_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c index fdaa5f8..acb05d4 100644 --- a/libavcodec/aac_parser.c +++ b/libavcodec/aac_parser.c @@ -34,7 +34,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, int size; union { uint64_t u64; -uint8_t u8[8]; +uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE]; } tmp; tmp.u64 = av_be2ne64(state); -- 2.4.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/3] imc: add required padding for GetBitContext buffer
Fixes stack buffer overflow errors detected by address sanitizer in fate-imc. --- libavcodec/imc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 411bc85..c60fc7a 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -997,7 +997,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, IMCContext *q = avctx-priv_data; -LOCAL_ALIGNED_16(uint16_t, buf16, [IMC_BLOCK_SIZE / 2]); +LOCAL_ALIGNED_16(uint16_t, buf16, [(IMC_BLOCK_SIZE + FF_INPUT_BUFFER_PADDING_SIZE) / 2]); if (buf_size IMC_BLOCK_SIZE * avctx-channels) { av_log(avctx, AV_LOG_ERROR, frame too small!\n); -- 2.4.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/3] ac3_parser: add required padding for GetBitContext buffer
Fixes stack buffer overflow errors detected by address sanitizer in various fate tests. --- libavcodec/ac3_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c index 5ea09f8..69d88c1 100644 --- a/libavcodec/ac3_parser.c +++ b/libavcodec/ac3_parser.c @@ -150,7 +150,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info, int err; union { uint64_t u64; -uint8_t u8[8]; +uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE]; } tmp = { av_be2ne64(state) }; AC3HeaderInfo hdr; GetBitContext gbc; -- 2.4.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/1] mpjpgdec: free AVIOContext leak on early probe fail
On 08/06/15 13:32, Janne Grunau wrote: --- libavformat/mpjpegdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c index 354278c..72891e7 100644 --- a/libavformat/mpjpegdec.c +++ b/libavformat/mpjpegdec.c @@ -88,7 +88,7 @@ static int mpjpeg_read_probe(AVProbeData *p) return AVERROR(ENOMEM); if (p-buf_size 2 || p-buf[0] != '-' || p-buf[1] != '-') -return 0; +goto end; while (!pb-eof_reached) { ret = get_line(pb, line, sizeof(line)); @@ -101,7 +101,7 @@ static int mpjpeg_read_probe(AVProbeData *p) break; } } - +end: av_free(pb); return ret; Ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/7] stcp: Always initialize outmsg struct
On 03/06/15 15:16, Vittorio Giovara wrote: CC: libav-sta...@libav.org Bug-Id: CID 1302711 --- libavformat/sctp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/sctp.c b/libavformat/sctp.c index 71b3a4b..57fd044 100644 --- a/libavformat/sctp.c +++ b/libavformat/sctp.c @@ -116,7 +116,7 @@ static int ff_sctp_recvmsg(int s, void *msg, size_t len, struct sockaddr *from, static int ff_sctp_send(int s, const void *msg, size_t len, const struct sctp_sndrcvinfo *sinfo, int flags) { -struct msghdr outmsg; +struct msghdr outmsg = { 0 }; struct iovec iov; outmsg.msg_name = NULL; s*c*tp: The patch doesn't sound wrong. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/7] audiointerleave: Always initialize new_pkt
On 03/06/15 15:16, Vittorio Giovara wrote: CC: libav-sta...@libav.org Bug-Id: CID 609333 --- libavformat/audiointerleave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c index ba78d4e..fd07893 100644 --- a/libavformat/audiointerleave.c +++ b/libavformat/audiointerleave.c @@ -127,7 +127,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt for (i = 0; i s-nb_streams; i++) { AVStream *st = s-streams[i]; if (st-codec-codec_type == AVMEDIA_TYPE_AUDIO) { -AVPacket new_pkt; +AVPacket new_pkt = { 0 }; while (interleave_new_audio_packet(s, new_pkt, i, flush)) if ((ret = ff_interleave_add_packet(s, new_pkt, compare_ts)) 0) return ret; Sounds correct to me. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 4/4] mpegvideo: Mark one function as static
On 08/06/15 14:00, Vittorio Giovara wrote: --- libavcodec/mpegvideo.c | 6 +++--- libavcodec/mpegvideo.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) Seems fine. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/2] mpegvideo: Split picture allocation for encoding and decoding
On 04/06/15 17:02, Vittorio Giovara wrote: The main ff_alloc_picture() function is made more generic with all the parameters necessary as arguments. This will allows to move most of the related functions to a separate file later. Right now wrappers are provided to try and minimize the number of changes in the code. --- I missed a codec_id instance, here correctly updated. Vittorio Possibly Ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/2] mpegvideo: Move OutFormat enum to mpegutils.h
On 04/06/15 17:02, Vittorio Giovara wrote: It is necessary to avoid circular header dependencies. --- Header typo fixed. Vittorio As long oracle is happy, fine for me. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 5/7] mov: Check memory allocation
On 03/06/15 15:16, Vittorio Giovara wrote: CC: libav-sta...@libav.org Bug-Id: CID 1292518 --- libavformat/mov.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 80681b7..f603446 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1661,7 +1661,11 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, switch (st-codec-codec_id) { #if CONFIG_DV_DEMUXER case AV_CODEC_ID_DVAUDIO: -c-dv_fctx = avformat_alloc_context(); +c-dv_fctx = avformat_alloc_context(); +if (!c-dv_fctx) { +av_log(c-fc, AV_LOG_ERROR, dv demux context alloc error\n); +return AVERROR(ENOMEM); +} c-dv_demux = avpriv_dv_init_demux(c-dv_fctx); if (!c-dv_demux) { av_log(c-fc, AV_LOG_ERROR, dv demux context init error\n); Sure, why not? ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/4] mpegvideo: Move block permutation function where is used
On 08/06/15 14:00, Vittorio Giovara wrote: --- libavcodec/mpegvideo.c | 29 - libavcodec/mpegvideo.h | 6 -- libavcodec/mpegvideo_enc.c | 40 ++-- 3 files changed, 38 insertions(+), 37 deletions(-) Sure. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/4] mpegvideo: Drop release_unused_pictures() function
On 08/06/15 14:00, Vittorio Giovara wrote: It is only used in one place, and it is small enough that it might be called directly. --- libavcodec/mpegvideo.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) Ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/4] mpegvideo: Move Picture-related functions to a separate file
--- libavcodec/Makefile | 2 +- libavcodec/mpegpicture.c | 424 +++ libavcodec/mpegpicture.h | 109 libavcodec/mpegvideo.c | 397 +--- libavcodec/mpegvideo.h | 78 + 5 files changed, 536 insertions(+), 474 deletions(-) create mode 100644 libavcodec/mpegpicture.c create mode 100644 libavcodec/mpegpicture.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 629d25d..58f548a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -77,7 +77,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP)+= mpegaudiodsp.o \ mpegaudiodsp_float.o OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideodsp.o rl.o \ mpegvideo_motion.o mpegutils.o \ - mpegvideodata.o + mpegvideodata.o mpegpicture.o OBJS-$(CONFIG_MPEGVIDEOENC)+= mpegvideo_enc.o mpeg12data.o \ motion_est.o ratecontrol.o\ mpegvideoencdsp.o diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c new file mode 100644 index 000..9df1415 --- /dev/null +++ b/libavcodec/mpegpicture.c @@ -0,0 +1,424 @@ +/* + * Mpeg video formats-related picture management functions + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include stdint.h + +#include libavutil/avassert.h +#include libavutil/common.h + +#include avcodec.h +#include motion_est.h +#include mpegpicture.h +#include mpegutils.h + +static int make_tables_writable(Picture *pic) +{ +int ret, i; +#define MAKE_WRITABLE(table) \ +do {\ +if (pic-table \ + (ret = av_buffer_make_writable(pic-table)) 0)\ +return ret;\ +} while (0) + +MAKE_WRITABLE(mb_var_buf); +MAKE_WRITABLE(mc_mb_var_buf); +MAKE_WRITABLE(mb_mean_buf); +MAKE_WRITABLE(mbskip_table_buf); +MAKE_WRITABLE(qscale_table_buf); +MAKE_WRITABLE(mb_type_buf); + +for (i = 0; i 2; i++) { +MAKE_WRITABLE(motion_val_buf[i]); +MAKE_WRITABLE(ref_index_buf[i]); +} + +return 0; +} + +int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, +ScratchpadContext *sc, int linesize) +{ +int alloc_size = FFALIGN(FFABS(linesize) + 32, 32); + +// edge emu needs blocksize + filter length - 1 +// (= 17x17 for halfpel / 21x21 for h264) +// VC1 computes luma and chroma simultaneously and needs 19X19 + 9x9 +// at uvlinesize. It supports only YUV420 so 24x24 is enough +// linesize * interlaced * MBsize +FF_ALLOCZ_OR_GOTO(avctx, sc-edge_emu_buffer, alloc_size * 2 * 24, + fail); + +FF_ALLOCZ_OR_GOTO(avctx, me-scratchpad, alloc_size * 2 * 16 * 3, + fail) +me-temp= me-scratchpad; +sc-rd_scratchpad = me-scratchpad; +sc-b_scratchpad= me-scratchpad; +sc-obmc_scratchpad = me-scratchpad + 16; + +return 0; +fail: +av_freep(sc-edge_emu_buffer); +return AVERROR(ENOMEM); +} + +/** + * Allocate a frame buffer + */ +static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic, + MotionEstContext *me, ScratchpadContext *sc, + int chroma_x_shift, int chroma_y_shift, + int linesize, int uvlinesize) +{ +int edges_needed = av_codec_is_encoder(avctx-codec); +int r, ret; + +pic-tf.f = pic-f; +if (avctx-codec_id != AV_CODEC_ID_WMV3IMAGE +avctx-codec_id != AV_CODEC_ID_VC1IMAGE +avctx-codec_id != AV_CODEC_ID_MSS2) { +if (edges_needed) { +pic-f-width = avctx-width + 2 * EDGE_WIDTH; +pic-f-height = avctx-height + 2 * EDGE_WIDTH; +} + +r = ff_thread_get_buffer(avctx, pic-tf, + pic-reference ? AV_GET_BUFFER_FLAG_REF : 0); +} else { +pic-f-width = avctx-width; +pic-f-height = avctx-height; +pic-f-format = avctx-pix_fmt; +r = avcodec_default_get_buffer2(avctx, pic-f, 0); +} + +if (r 0 ||
[libav-devel] [PATCH 1/1] mpjpgdec: free AVIOContext leak on early probe fail
--- libavformat/mpjpegdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c index 354278c..72891e7 100644 --- a/libavformat/mpjpegdec.c +++ b/libavformat/mpjpegdec.c @@ -88,7 +88,7 @@ static int mpjpeg_read_probe(AVProbeData *p) return AVERROR(ENOMEM); if (p-buf_size 2 || p-buf[0] != '-' || p-buf[1] != '-') -return 0; +goto end; while (!pb-eof_reached) { ret = get_line(pb, line, sizeof(line)); @@ -101,7 +101,7 @@ static int mpjpeg_read_probe(AVProbeData *p) break; } } - +end: av_free(pb); return ret; -- 2.4.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 4/7] jack: Check memory allocation
On 03/06/15 15:16, Vittorio Giovara wrote: CC: libav-sta...@libav.org Bug-Id: CID 1292520 --- libavdevice/jack.c | 4 1 file changed, 4 insertions(+) diff --git a/libavdevice/jack.c b/libavdevice/jack.c index 5d000a3..aa9348d 100644 --- a/libavdevice/jack.c +++ b/libavdevice/jack.c @@ -202,6 +202,10 @@ static int start_jack(AVFormatContext *context) self-filled_pkts = av_fifo_alloc(FIFO_PACKETS_NUM * sizeof(AVPacket)); /* New packets FIFO with one extra packet for safety against underruns */ self-new_pkts= av_fifo_alloc((FIFO_PACKETS_NUM + 1) * sizeof(AVPacket)); +if (!self-new_pkts) { +jack_client_close(self-client); +return AVERROR(ENOMEM); +} if ((test = supply_new_packets(self, context))) { jack_client_close(self-client); return test; Sounds fine to me. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/4] mpegvideo: Move block permutation function where is used
--- libavcodec/mpegvideo.c | 29 - libavcodec/mpegvideo.h | 6 -- libavcodec/mpegvideo_enc.c | 40 ++-- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 1ea2b65..68f9568 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1840,35 +1840,6 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename } } -/** - * Permute an 8x8 block. - * @param block the block which will be permuted according to the given permutation vector - * @param permutation the permutation vector - * @param last the last non zero coefficient in scantable order, used to speed the permutation up - * @param scantable the used scantable, this is only used to speed the permutation up, the block is not - * (inverse) permutated to scantable order! - */ -void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last) -{ -int i; -int16_t temp[64]; - -if(last=0) return; -//if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations - -for(i=0; i=last; i++){ -const int j= scantable[i]; -temp[j]= block[j]; -block[j]=0; -} - -for(i=0; i=last; i++){ -const int j= scantable[i]; -const int perm_j= permutation[j]; -block[perm_j]= temp[j]; -} -} - void ff_mpeg_flush(AVCodecContext *avctx){ int i; MpegEncContext *s = avctx-priv_data; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index b2b2f6d..1a6857d 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -638,12 +638,6 @@ void ff_mpv_motion(MpegEncContext *s, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16]); -/** - * permute block according to permuatation. - * @param last last non zero element in scantable order - */ -void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last); - static inline void ff_update_block_index(MpegEncContext *s){ const int block_size = 8; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a206153..6fe34b5 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -4196,6 +4196,42 @@ STOP_TIMER(iterative search) return last_non_zero; } +/** + * Permute an 8x8 block according to permuatation. + * @param block the block which will be permuted according to + * the given permutation vector + * @param permutation the permutation vector + * @param last the last non zero coefficient in scantable order, used to + * speed the permutation up + * @param scantable the used scantable, this is only used to speed the + * permutation up, the block is not (inverse) permutated + * to scantable order! + */ +static void block_permute(int16_t *block, uint8_t *permutation, + const uint8_t *scantable, int last) +{ +int i; +int16_t temp[64]; + +if (last = 0) +return; +//FIXME it is ok but not clean and might fail for some permutations +// if (permutation[1] == 1) +// return; + +for (i = 0; i = last; i++) { +const int j = scantable[i]; +temp[j] = block[j]; +block[j] = 0; +} + +for (i = 0; i = last; i++) { +const int j = scantable[i]; +const int perm_j = permutation[j]; +block[perm_j] = temp[j]; +} +} + int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow) @@ -4271,8 +4307,8 @@ int ff_dct_quantize_c(MpegEncContext *s, /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */ if (s-idsp.perm_type != FF_IDCT_PERM_NONE) -ff_block_permute(block, s-idsp.idct_permutation, - scantable, last_non_zero); +block_permute(block, s-idsp.idct_permutation, + scantable, last_non_zero); return last_non_zero; } -- 1.9.5 (Apple Git-50.3) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 4/4] mpegvideo: Mark one function as static
--- libavcodec/mpegvideo.c | 6 +++--- libavcodec/mpegvideo.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 68f9568..0a4f5bb 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1448,7 +1448,7 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p) /** * find the lowest MB row referenced in the MVs */ -int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir) +static int lowest_referenced_row(MpegEncContext *s, int dir) { int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s-quarter_sample; int my, off, i, mvs; @@ -1646,12 +1646,12 @@ FF_ENABLE_DEPRECATION_WARNINGS if(HAVE_THREADS s-avctx-active_thread_typeFF_THREAD_FRAME) { if (s-mv_dir MV_DIR_FORWARD) { ff_thread_await_progress(s-last_picture_ptr-tf, - ff_mpv_lowest_referenced_row(s, 0), + lowest_referenced_row(s, 0), 0); } if (s-mv_dir MV_DIR_BACKWARD) { ff_thread_await_progress(s-next_picture_ptr-tf, - ff_mpv_lowest_referenced_row(s, 1), + lowest_referenced_row(s, 1), 0); } } diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 1a6857d..667566a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -605,8 +605,6 @@ void ff_mpv_report_decode_progress(MpegEncContext *s); int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); void ff_mpv_frame_end(MpegEncContext *s); -int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir); - int ff_mpv_encode_init(AVCodecContext *avctx); void ff_mpv_encode_init_x86(MpegEncContext *s); -- 1.9.5 (Apple Git-50.3) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/4] mpegvideo: Drop release_unused_pictures() function
It is only used in one place, and it is small enough that it might be called directly. --- libavcodec/mpegvideo.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 86eab07..1ea2b65 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1109,17 +1109,6 @@ void ff_mpv_common_end(MpegEncContext *s) s-linesize = s-uvlinesize = 0; } -static void release_unused_pictures(AVCodecContext *avctx, Picture *picture) -{ -int i; - -/* release non reference frames */ -for (i = 0; i MAX_PICTURE_COUNT; i++) { -if (!picture[i].reference) -ff_mpeg_unref_picture(avctx, picture[i]); -} -} - /** * generic function called after decoding * the header and before a frame is decoded. @@ -1152,7 +1141,11 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) ff_mpeg_unref_picture(s-avctx, s-current_picture); -release_unused_pictures(s-avctx, s-picture); +/* release non reference frames */ +for (i = 0; i MAX_PICTURE_COUNT; i++) { +if (!s-picture[i].reference) +ff_mpeg_unref_picture(s-avctx, s-picture[i]); +} if (s-current_picture_ptr !s-current_picture_ptr-f-buf[0]) { // we already have a unused image -- 1.9.5 (Apple Git-50.3) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/4] mpegvideo: Move Picture-related functions to a separate file
On 08/06/15 14:00, Vittorio Giovara wrote: --- libavcodec/Makefile | 2 +- libavcodec/mpegpicture.c | 424 +++ libavcodec/mpegpicture.h | 109 libavcodec/mpegvideo.c | 397 +--- libavcodec/mpegvideo.h | 78 + 5 files changed, 536 insertions(+), 474 deletions(-) create mode 100644 libavcodec/mpegpicture.c create mode 100644 libavcodec/mpegpicture.h Possibly Ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/3] aac_parser: add required padding for GetBitContext buffer
On 08/06/15 15:09, Janne Grunau wrote: Fixes stack buffer overflow errors detected by address sanitizer in various fate tests. --- libavcodec/aac_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c index fdaa5f8..acb05d4 100644 --- a/libavcodec/aac_parser.c +++ b/libavcodec/aac_parser.c @@ -34,7 +34,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, int size; union { uint64_t u64; -uint8_t u8[8]; +uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE]; } tmp; tmp.u64 = av_be2ne64(state); Set Ok. Thanks for fixing it =) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel