Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen.
Hi, - Mail original - > On Mon, Sep 29, 2014 at 03:31:36PM +0200, Benoit Fouet wrote: > [...] > does this ensure that the sps is before the pps ? > if not that might be the reason for the warnings > It does not. I can update this so that when the pps is seen and not the sps, it prepends the sps to the pps. -- Ben ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] patch 1/4: libavcodec/ppc/pixblockdsp.c: fix get_pixels_altivec() and diff_pixels_altivec() for POWER LE
Hi, I present 4 patches to fix bugs for POWER8 little endian. I will send 4 patches in 4 different email. This is the first. The fate test result after merge these 4 patches can be found on http://fate.ffmpeg.org/ by search "ibmcrl", also attached here to facilitate the review: The passed test cases increased from 1649/2169 to 1675/2174. Rong Yan -- The world has enough for everyone's need, but not enough for everyone's greed. 0001-libavcodec-ppc-pixblockdsp.c-fix-get_pixels_altivec-.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] patch1/4: libavcodec/ppc/pixblockdsp.c: fix get_pixels_altivec() and diff_pixels_altivec() for POWER LE
Hi, I present 4 patches to fix bugs for POWER8 little endian. I will send 4 patches in 4 different email. This is the first. The fate test result after merge these 4 patches can be found on http://fate.ffmpeg.org/ by search "ibmcrl", also attached here to facilitate the review: The passed test cases increased from 1649/2169 to 1675/2174. Rong Yan 0001-libavcodec-ppc-pixblockdsp.c-fix-get_pixels_altivec-.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2] Add SUP/PGS subtitle muxer
From: Petri Hintukainen Fixes ticket #2208 --- Changelog| 2 +- doc/general.texi | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 2 +- libavformat/supenc.c | 96 5 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 libavformat/supenc.c diff --git a/Changelog b/Changelog index 039d1ca..f171c17 100644 --- a/Changelog +++ b/Changelog @@ -3,7 +3,7 @@ releases are sorted from youngest to oldest. version : - HEVC/H.265 RTP payload format (draft v6) packetizer -- SUP/PGS subtitle demuxer +- SUP/PGS subtitle demuxer and muxer version 2.4: - Icecast protocol diff --git a/doc/general.texi b/doc/general.texi index 2252f7b..b848e7e 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -454,7 +454,7 @@ library: @item Sony Wave64 (W64) @tab X @tab X @item SoX native format @tab X @tab X @item SUN AU format @tab X @tab X -@item SUP raw PGS subtitles @tab @tab X +@item SUP raw PGS subtitles @tab X @tab X @item Text files@tab @tab X @item THP @tab @tab X @tab Used on the Nintendo GameCube. diff --git a/libavformat/Makefile b/libavformat/Makefile index 86064ea..7385b67 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -407,6 +407,7 @@ OBJS-$(CONFIG_SRT_MUXER) += srtenc.o OBJS-$(CONFIG_STR_DEMUXER) += psxstr.o OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)+= subviewer1dec.o subtitles.o OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o +OBJS-$(CONFIG_SUP_MUXER) += supenc.o OBJS-$(CONFIG_SUP_DEMUXER) += supdec.o OBJS-$(CONFIG_SWF_DEMUXER) += swfdec.o swf.o OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index d54ed9b..0b64355 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -280,7 +280,7 @@ void av_register_all(void) REGISTER_DEMUXER (STR, str); REGISTER_DEMUXER (SUBVIEWER1, subviewer1); REGISTER_DEMUXER (SUBVIEWER,subviewer); -REGISTER_DEMUXER (SUP, sup); +REGISTER_MUXDEMUX(SUP, sup); REGISTER_MUXDEMUX(SWF, swf); REGISTER_DEMUXER (TAK, tak); REGISTER_MUXER (TEE, tee); diff --git a/libavformat/supenc.c b/libavformat/supenc.c new file mode 100644 index 000..f5f6b58 --- /dev/null +++ b/libavformat/supenc.c @@ -0,0 +1,96 @@ +/* + * SUP muxer + * Copyright (c) 2014 Petri Hintukainen + * + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" + +#define SUP_PGS_MAGIC 0x5047 /* "PG", big endian */ + +static int sup_write_packet(AVFormatContext *s, AVPacket *pkt) +{ +uint8_t *data = pkt->data; +size_t size = pkt->size; +uint32_t pts = 0, dts = 0; + +if (pkt->pts != AV_NOPTS_VALUE) { +pts = (uint32_t)pkt->pts; +} +if (pkt->dts != AV_NOPTS_VALUE) { +dts = (uint32_t)pkt->dts; +} + +/* + Split frame to segments. + mkvmerge stores multiple segments in one frame. +*/ +while (size > 2) { +size_t len = AV_RB16(data + 1) + 3; + +if (len > size) { +av_log(s, AV_LOG_ERROR, "Not enough data, skipping %d bytes\n", + (int)size); +return AVERROR_INVALIDDATA; +} + +/* header */ +avio_wb16(s->pb, SUP_PGS_MAGIC); +avio_wb32(s->pb, pts); +avio_wb32(s->pb, dts); + +avio_write(s->pb, data, len); + +data += len; +size -= len; +} + +if (size > 0) { +av_log(s, AV_LOG_ERROR, "Skipping %d bytes after last segment in frame\n", + (int)size); +return AVERROR_INVALIDDATA; +} + +return 0; +} + +static int sup_write_header(AVFormatContext *s) +{ +if (s->nb_streams != 1) { +av_log(s, AV_LOG_ERROR, "%s files have exactly one stream\n", + s->oformat->name); +return AVERROR(EINVAL); +} + +avpriv_set_pts_info(s->streams[0], 32, 1, 9); + +re
[FFmpeg-devel] patch 2/4: libavcodec/ppc/mpegvideoencdsp.c: fix pix_normal_altivec() and pix_sum_altivec() for POWER LE
Hi, I present 4 patches to fix bugs for POWER8 little endian. I will send 4 patches in 4 different email. This is the second. The fate test result after merge these 4 patches can be found on http://fate.ffmpeg.org/ by search "ibmcrl", also attached here to facilitate the review: The passed test cases increased from 1649/2169 to 1675/2174. Rong Yan 0002-libavcodec-ppc-mpegvideoencdsp.c-fix-pix_norm1_altiv.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] patch 3/4: libavcodec/ppc/me_cmp.c: fixe sad16_altivec(), sad16_altivec(), sad16_xy2_altivec(), sad16_x2_altivec(), sad16_y2_altivec(), sad8_altivec() for POWER LE
Hi, I present 4 patches to fix bugs for POWER8 little endian. I will send 4 patches in 4 different email. This is the third. The fate test result after merge these 4 patches can be found on http://fate.ffmpeg.org/ by search "ibmcrl", also attached here to facilitate the review: The passed test cases increased from 1649/2169 to 1675/2174. 0003-libavcodec-ppc-me_cmp.c-fix-sad16_altivec-sse16_alti.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] patch 4/4: libavcodec/ppc/hpeldsp_altivec.c: fix ff_put_pixels16_altivec() for POWER LE
Hi, I present 4 patches to fix bugs for POWER8 little endian. I will send 4 patches in 4 different email. This is the fourth. The fate test result after merge these 4 patches can be found on http://fate.ffmpeg.org/ by search "ibmcrl", also attached here to facilitate the review: The passed test cases increased from 1649/2169 to 1675/2174. Rong Yan 0004-libavcodec-ppc-hpeldsp_altivec.c-fix-ff_put_pixels16.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen.
On Tue, Sep 30, 2014 at 09:45:47AM +0200, Benoit Fouet wrote: > Hi, > > - Mail original - > > On Mon, Sep 29, 2014 at 03:31:36PM +0200, Benoit Fouet wrote: > > > > [...] > > > does this ensure that the sps is before the pps ? > > if not that might be the reason for the warnings > > > > It does not. I can update this so that when the pps is seen and not the sps, > it prepends the sps to the pps. please do, sps should be before the pps [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/movenc: AVC Intra support
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 28/09/14 02:59, Michael Niedermayer wrote: > On Sun, Sep 28, 2014 at 03:53:15AM +0200, Michael Niedermayer wrote: >> On Sun, Sep 28, 2014 at 02:00:00AM +0100, Kieran Kunhya wrote: >>> On 28 September 2014 00:49, Michael Niedermayer wrote: This allows remuxing AVC intra into mov it does not work with libx264 encoded AVC Intra for unknown reason >>> >>> 1080i should work. 1080p needs some random magic numbers in the >>> bitstream which are probably different for all the >>> framerate/resolution combinations. Blame Apple for having a decoder >>> that violates the H.264 spec - specifically requiring SEIs to have >>> certain information in them. >> >> i tried various avcintra 50 and 100 and i didnt find any that >> worked. They all crashed fcpx (in apples avci decoder in the case i >> looked at) >> its of course very possible that i made some systematic mistake > > if someone has a known to be good set of command line options for > x264 to generate a working stream + input + output .h264 streams > that might (or might not) help identify what is at fault > > [...] Some of the DPP AVCI100 test samples were created using x264* so could be used for reference. Or I could knock up something if I can find my reference CL I used last time. *Using libx264 in ffmbc. - -- Tim. Key Fingerprint 38CF DB09 3ED0 F607 8B67 6CED 0C0B FC44 8B0B FC83 -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.19 (GNU/Linux) iQEcBAEBAgAGBQJUKm7yAAoJEAwL/ESLC/yD/mgIALrkpV2zGILv5X3TAslK6KMl 2f9czw70hPQ6uBXLUiUf3Dr2Fmg7GQ5gP/rZpPIKNiZPXcrdQwTsrU6k1FNNUUZi OnR9BR3dfwjrH8ekYyy5i3ZjHRktlGBPD3adyQWpENahHtui0jdGMpnMeSc5Mro9 yN3FTRLlB01GHmTR4KG2QO2H6qenMe5jVShAPJbQ2crvJdSI/4mxNpEjLSYBgA5W Fe09SdNx+1xnHuM15Uq7W2yG3N+lmRQZlscB+eWwo1zwb6SpjUYCjcuggnWaBQl8 qxfXuwIMOT0DgVdVVt5gcARZ43cM14e9rZ+eOc9Qq6RJ4/s44Ua3OYfneQurJPw= =yTRs -END PGP SIGNATURE- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v7] Add SUP/PGS subtitle demuxer
Hello, Missing DTS combined with non-monotonic PTS seems to cause some problems. This is with the file from ticket #2208 (I added dumping timestamps to demuxer and muxer): $ ../ffmpeg -i orig/track_06\ -\ Subtitle.sup -scodec copy 6.sup ffmpeg version N-66546-gea74007 Copyright (c) 2000-2014 the FFmpeg developers built on Sep 30 2014 11:10:08 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1) configuration: libavutil 54. 7.101 / 54. 7.101 libavcodec 56. 1.101 / 56. 1.101 libavformat56. 7.101 / 56. 7.101 libavdevice56. 1.100 / 56. 1.100 libavfilter 5. 1.102 / 5. 1.102 libswscale 3. 1.100 / 3. 1.100 libswresample 1. 1.100 / 1. 1.100 IN pts 00255314 dts Input #0, sup, from 'orig/track_06 - Subtitle.sup': Duration: N/A, start: 2.836822, bitrate: N/A Stream #0:0: Subtitle: hdmv_pgs_subtitle, 1920x1080 Output #0, sup, to '6.sup': Metadata: encoder : Lavf56.7.101 Stream #0:0: Subtitle: hdmv_pgs_subtitle, 1920x1080 Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help OUT pts dts IN pts 00255037 dts OUT pts dts IN pts 00249205 dts [sup @ 0x241f4e0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: -277 >= -6109 av_interleaved_write_frame(): Invalid argument size= 0kB time=00:00:00.00 bitrate=N/A video:0kB audio:0kB subtitle:1kB other streams:0kB global headers:0kB muxing overhead: unknown Conversion failed! Also note that timestamps are re-positioned to start from 0. This may be problematic, it requires manually synchronizing subtitles to the video. Remuxing from the original .m2ts file works just well: $ ffmpeg -i orig/00038.m2ts -map 0:6 -scodec copy 6.sup ffmpeg version N-66546-gea74007 Copyright (c) 2000-2014 the FFmpeg developers built on Sep 30 2014 11:10:08 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1) configuration: libavutil 54. 7.101 / 54. 7.101 libavcodec 56. 1.101 / 56. 1.101 libavformat56. 7.101 / 56. 7.101 libavdevice56. 1.100 / 56. 1.100 libavfilter 5. 1.102 / 5. 1.102 libswscale 3. 1.100 / 3. 1.100 libswresample 1. 1.100 / 1. 1.100 [NULL @ 0x1bf9ba0] start time for stream 6 is not set in estimate_timings_from_pts [NULL @ 0x1c146e0] start time for stream 7 is not set in estimate_timings_from_pts [NULL @ 0x1c151c0] start time for stream 8 is not set in estimate_timings_from_pts [mpegts @ 0x1bf1ca0] Could not find codec parameters for stream 6 (Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options [mpegts @ 0x1bf1ca0] Could not find codec parameters for stream 7 (Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options [mpegts @ 0x1bf1ca0] Could not find codec parameters for stream 8 (Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, mpegts, from 'orig/00038.m2ts': Duration: 00:00:43.90, start: 11.650667, bitrate: 35145 kb/s Program 1 Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc Stream #0:1[0x1100]: Audio: truehd (AC-3 / 0x332D4341), 48000 Hz, 7.1, s32 (24 bit) Stream #0:2[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 640 kb/s Stream #0:3[0x1101]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 320 kb/s Stream #0:4[0x1102]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 320 kb/s Stream #0:5[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080 Stream #0:6[0x1201]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) Stream #0:7[0x1202]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) Stream #0:8[0x1203]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) Output #0, sup, to '6.sup': Metadata: encoder : Lavf56.7.101 Stream #0:0: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) Stream mapping: Stream #0:6 -> #0:0 (copy) Press [q] to stop, [?] for help OUT pts 00255255 dts 00249146 OUT pts 00254978 dts 00249146 OUT pts 00249146 dts 00249146 OUT pts 00249699 dts 00249146 OUT pts 00249699 dts 00249699 ... Also, remuxing this file again (.sup->.sup) with ffmpeg works. Well, except that timestamps are again repositioned. Is this something that can be handled in muxer ? - Petri ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] RTMP Play file descriptor leak
Hi! In our project we uses FFmpeg to demux RTMP streams. Input stream takes from Wowza/nginx-rtmp. Our application is a daemon that try to connect to source periodicaly if it does not present (does not published to Wowza, for example). We also use interrupt callback to break connection if timeout is occured. So in this situation: - Alive server - Alive streaming application - Configured inerrupt callback with timeout - Disalive stream TCP socket to server does not closes. I look into code with debugger and found place where error is occured: rtmpproto.c, rtmp_open() L:2672 Root couse: return from function without resources clean up Solution: replace return with 'goto fail' Path is attached. -- WBR, Alexander Drozdov http://htrd.su From f742012ea22bf684fe0ae8e153749bd7339503d6 Mon Sep 17 00:00:00 2001 From: Alexander Drozdov Date: Fri, 26 Sep 2014 09:45:08 +1100 Subject: [PATCH] RTMP: fix FD leak in rtmp_open() If we setup AVIO interrupt callback and it will be returns 1 on socket timeouts and we try to connect to non-existing streams on some servers (like nginx-rtmp) we got FD leak. --- libavformat/rtmpproto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 3cde966..6122548 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -2670,7 +2670,7 @@ reconnect: // audio or video packet arrives. while (!rt->has_audio && !rt->has_video && !rt->received_metadata) { if ((ret = get_packet(s, 0)) < 0) - return ret; + goto fail; } // Either after we have read the metadata or (if there is none) the -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/movenc: AVC Intra support
On Tue, Sep 30, 2014 at 09:50:58AM +0100, tim nicholson wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 28/09/14 02:59, Michael Niedermayer wrote: > > On Sun, Sep 28, 2014 at 03:53:15AM +0200, Michael Niedermayer wrote: > >> On Sun, Sep 28, 2014 at 02:00:00AM +0100, Kieran Kunhya wrote: > >>> On 28 September 2014 00:49, Michael Niedermayer wrote: > > This allows remuxing AVC intra into mov > it does not work with libx264 encoded AVC Intra for unknown reason > >>> > >>> 1080i should work. 1080p needs some random magic numbers in the > >>> bitstream which are probably different for all the > >>> framerate/resolution combinations. Blame Apple for having a decoder > >>> that violates the H.264 spec - specifically requiring SEIs to have > >>> certain information in them. > >> > >> i tried various avcintra 50 and 100 and i didnt find any that > >> worked. They all crashed fcpx (in apples avci decoder in the case i > >> looked at) > >> its of course very possible that i made some systematic mistake > > > > if someone has a known to be good set of command line options for > > x264 to generate a working stream + input + output .h264 streams > > that might (or might not) help identify what is at fault > > > > [...] > > Some of the DPP AVCI100 test samples were created using x264* so could > be used for reference. Do you have a link to such sample ? > Or I could knock up something if I can find my > reference CL I used last time. > > *Using libx264 in ffmbc. > > > - -- > Tim. > Key Fingerprint 38CF DB09 3ED0 F607 8B67 6CED 0C0B FC44 8B0B FC83 > -BEGIN PGP SIGNATURE- > Version: GnuPG v2.0.19 (GNU/Linux) > > iQEcBAEBAgAGBQJUKm7yAAoJEAwL/ESLC/yD/mgIALrkpV2zGILv5X3TAslK6KMl > 2f9czw70hPQ6uBXLUiUf3Dr2Fmg7GQ5gP/rZpPIKNiZPXcrdQwTsrU6k1FNNUUZi > OnR9BR3dfwjrH8ekYyy5i3ZjHRktlGBPD3adyQWpENahHtui0jdGMpnMeSc5Mro9 > yN3FTRLlB01GHmTR4KG2QO2H6qenMe5jVShAPJbQ2crvJdSI/4mxNpEjLSYBgA5W > Fe09SdNx+1xnHuM15Uq7W2yG3N+lmRQZlscB+eWwo1zwb6SpjUYCjcuggnWaBQl8 > qxfXuwIMOT0DgVdVVt5gcARZ43cM14e9rZ+eOc9Qq6RJ4/s44Ua3OYfneQurJPw= > =yTRs > -END PGP SIGNATURE- > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen.
Hi, - Mail original - > On Tue, Sep 30, 2014 at 09:45:47AM +0200, Benoit Fouet wrote: > > Hi, > > > > - Mail original - > > > On Mon, Sep 29, 2014 at 03:31:36PM +0200, Benoit Fouet wrote: > > > > > > > [...] > > > > > does this ensure that the sps is before the pps ? > > > if not that might be the reason for the warnings > > > > > > > It does not. I can update this so that when the pps is seen and not > > the sps, it prepends the sps to the pps. > > please do, sps should be before the pps > Done, new patch attached. Also, it would be cool if someone had a sample with only SPS in the stream, to check that the copy of PPS from AVCC works fine too. -- Ben From d53efe2d0474a032813b71d5c6485f174d7659f6 Mon Sep 17 00:00:00 2001 From: Benoit Fouet Date: Mon, 29 Sep 2014 15:18:50 +0200 Subject: [PATCH] avcodec/h264_mp4toannexb_bsf: add a case when only SPS/PPS is in the stream. When only SPS or PPS is present in the stream, copy the missing one from AVCC before insertion to the output stream. --- libavcodec/h264_mp4toannexb_bsf.c | 57 --- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 739ff95..3ec4170 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -26,9 +26,12 @@ #include "avcodec.h" typedef struct H264BSFContext { +int32_t sps_offset; +int32_t pps_offset; uint8_t length_size; uint8_t new_idr; -uint8_t idr_sps_pps_seen; +uint8_t idr_sps_seen; +uint8_t idr_pps_seen; int extradata_parsed; } H264BSFContext; @@ -60,7 +63,7 @@ static int alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size, return 0; } -static int h264_extradata_to_annexb(AVCodecContext *avctx, const int padding) +static int h264_extradata_to_annexb(H264BSFContext *ctx, AVCodecContext *avctx, const int padding) { uint16_t unit_size; uint64_t total_size = 0; @@ -70,11 +73,14 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx, const int padding) static const uint8_t nalu_header[4] = { 0, 0, 0, 1 }; int length_size = (*extradata++ & 0x3) + 1; // retrieve length coded size +ctx->sps_offset = ctx->pps_offset = -1; + /* retrieve sps and pps unit(s) */ unit_nb = *extradata++ & 0x1f; /* number of sps unit(s) */ if (!unit_nb) { goto pps; } else { +ctx->sps_offset = 0; sps_seen = 1; } @@ -103,8 +109,10 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx, const int padding) pps: if (!unit_nb && !sps_done++) { unit_nb = *extradata++; /* number of pps unit(s) */ -if (unit_nb) +if (unit_nb) { +ctx->pps_offset = (extradata - 1) - (avctx->extradata + 4); pps_seen = 1; +} } } @@ -151,12 +159,13 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, /* retrieve sps and pps NAL units from extradata */ if (!ctx->extradata_parsed) { -ret = h264_extradata_to_annexb(avctx, FF_INPUT_BUFFER_PADDING_SIZE); +ret = h264_extradata_to_annexb(ctx, avctx, FF_INPUT_BUFFER_PADDING_SIZE); if (ret < 0) return ret; ctx->length_size = ret; ctx->new_idr = 1; -ctx->idr_sps_pps_seen = 0; +ctx->idr_sps_seen = 0; +ctx->idr_pps_seen = 0; ctx->extradata_parsed = 1; } @@ -176,8 +185,25 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, if (buf + nal_size > buf_end || nal_size < 0) goto fail; -if (unit_type == 7 || unit_type == 8) -ctx->idr_sps_pps_seen = 1; +if (unit_type == 7) +ctx->idr_sps_seen = 1; +else if (unit_type == 8) { +ctx->idr_pps_seen = 1; +/* if SPS has not been seen yet, prepend the AVCC one to PPS */ +if (!ctx->idr_sps_seen) { +if (ctx->sps_offset == -1) +av_log(avctx, AV_LOG_WARNING, "SPS not present in the stream, nor in AVCC, stream may be unreadable\n"); +else { +if ((ret = alloc_and_copy(poutbuf, poutbuf_size, + avctx->extradata + ctx->sps_offset, + ctx->pps_offset != -1 ? ctx->pps_offset : avctx->extradata_size - ctx->sps_offset, + buf, nal_size)) < 0) +goto fail; +ctx->idr_sps_seen = 1; +goto next_nal; +} +} +} /* if this is a new IDR picture following an IDR picture, reset the idr flag. * Just check first_mb_in_slice to be 0 as this is the simplest solution. @@ -186,22 +212,35 @@ static int h264_mp4toannexb_filter(AVBitSt
Re: [FFmpeg-devel] RTMP Play file descriptor leak
On Tue, Sep 30, 2014 at 08:01:23PM +1100, Alexander Drozdov wrote: > Hi! > > In our project we uses FFmpeg to demux RTMP streams. Input stream takes > from Wowza/nginx-rtmp. Our application is a daemon that try to connect to > source periodicaly if it does not present (does not published to Wowza, for > example). We also use interrupt callback to break connection if timeout is > occured. So in this situation: > - Alive server > - Alive streaming application > - Configured inerrupt callback with timeout > - Disalive stream > > TCP socket to server does not closes. > > I look into code with debugger and found place where error is occured: > rtmpproto.c, rtmp_open() L:2672 > > Root couse: return from function without resources clean up > > Solution: replace return with 'goto fail' > > Path is attached. > > -- > WBR, Alexander Drozdov > http://htrd.su > rtmpproto.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > 9c7952d92224b4a905c54b1f6a02dd83e6ea083f > 0001-RTMP-fix-FD-leak-in-rtmp_open.patch > From f742012ea22bf684fe0ae8e153749bd7339503d6 Mon Sep 17 00:00:00 2001 > From: Alexander Drozdov > Date: Fri, 26 Sep 2014 09:45:08 +1100 > Subject: [PATCH] RTMP: fix FD leak in rtmp_open() > > If we setup AVIO interrupt callback and it will be returns 1 on socket > timeouts and we try to connect to non-existing streams on some servers > (like nginx-rtmp) we got FD leak. applied thanks PS: i think theres another case in there that needs a similar change [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen.
On Tue, Sep 30, 2014 at 11:15:06AM +0200, Benoit Fouet wrote: > Hi, > > - Mail original - > > On Tue, Sep 30, 2014 at 09:45:47AM +0200, Benoit Fouet wrote: > > > Hi, > > > > > > - Mail original - > > > > On Mon, Sep 29, 2014 at 03:31:36PM +0200, Benoit Fouet wrote: > > > > > > > > > > [...] > > > > > > > does this ensure that the sps is before the pps ? > > > > if not that might be the reason for the warnings > > > > > > > > > > It does not. I can update this so that when the pps is seen and not > > > the sps, it prepends the sps to the pps. > > > > please do, sps should be before the pps > > > > Done, new patch attached. probably ok, should i apply it ? > Also, it would be cool if someone had a sample with only SPS in the stream, > to check that the copy of PPS from AVCC works fine too. yes, but i suspect this could be more rare [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] RTMP Play file descriptor leak
2014-09-30 20:25 GMT+11:00 Michael Niedermayer : > > applied > > thanks > You are welcome! > > PS: i think theres another case in there that needs a similar change > > Does you regard return at the top of this function? It seems that there is no resource allocation before so it is safe to do return. -- WBR, Alexander Drozdov http://htrd.su ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/movenc: AVC Intra support
> Some of the DPP AVCI100 test samples were created using x264* so could > be used for reference. Or I could knock up something if I can find my > reference CL I used last time. www.obe.tv/about-us/obe-blog/item/1-oss-dpp-creation Remember to use the latest x264. Even then the values in the "UMID" SEI that FCP is probably looking for are just a guess. Kieran ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] RTMP Play file descriptor leak
On Tue, Sep 30, 2014 at 08:46:54PM +1100, Alexander Drozdov wrote: > 2014-09-30 20:25 GMT+11:00 Michael Niedermayer : > > > > > applied > > > > thanks > > > You are welcome! > > > > > > PS: i think theres another case in there that needs a similar change > > > > Does you regard return at the top of this function? It seems that there is > no resource allocation before so it is safe to do return. i was thiking of the av_reallocp fail it does free flv_data but nothing else [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: fix glob pattern detection.
Hi, - Mail original - > The is_glob() function was not working with unescaped glob patterns, > which is the way only glob_sequence (which is deprecated) works. > Fixes ticket #3948 > --- > libavformat/img2dec.c | 14 +- > 1 file changed, 1 insertion(+), 13 deletions(-) > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > index a21429f..64ebc31 100644 > --- a/libavformat/img2dec.c > +++ b/libavformat/img2dec.c > @@ -75,19 +75,7 @@ static int infer_size(int *width_ptr, int > *height_ptr, int size) > static int is_glob(const char *path) > { > #if HAVE_GLOB > -size_t span = 0; > -const char *p = path; > - > -while (p = strchr(p, '%')) { > -if (*(++p) == '%') { > -++p; > -continue; > -} > -if (span = strspn(p, "*?[]{}")) > -break; > -} > -/* Did we hit a glob char or get to the end? */ > -return span != 0; > +return strspn(path, "%*?[]{}") != 0; > #else > return 0; > #endif > Any opinion on this one? -- Ben ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen.
Hi, - Mail original - > On Tue, Sep 30, 2014 at 11:15:06AM +0200, Benoit Fouet wrote: > > Hi, > > > > - Mail original - > > > On Tue, Sep 30, 2014 at 09:45:47AM +0200, Benoit Fouet wrote: > > > > Hi, > > > > > > > > - Mail original - > > > > > On Mon, Sep 29, 2014 at 03:31:36PM +0200, Benoit Fouet wrote: > > > > > > > > > > > > > [...] > > > > > > > > > does this ensure that the sps is before the pps ? > > > > > if not that might be the reason for the warnings > > > > > > > > > > > > > It does not. I can update this so that when the pps is seen and > > > > not > > > > the sps, it prepends the sps to the pps. > > > > > > please do, sps should be before the pps > > > > > > > Done, new patch attached. > > probably ok, should i apply it ? > I guess so. I have 2 more patches to this BSF, I'll send them shortly. > > > Also, it would be cool if someone had a sample with only SPS in the > > stream, to check that the copy of PPS from AVCC works fine too. > > yes, but i suspect this could be more rare > When/if we have one, we can test this anyway. Thanks, -- Ben ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] avcodec/h264_mp4toannexb_bsf: use the given padding in h264_extradata_to_annexb().
--- libavcodec/h264_mp4toannexb_bsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 3ec4170..be42304 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -117,7 +117,7 @@ pps: } if (out) -memset(out + total_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); +memset(out + total_size, 0, padding); if (!sps_seen) av_log(avctx, AV_LOG_WARNING, -- 2.1.0.127.g0c72b98 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] avcodec/h264_mp4toannexb_bsf: reset the new IDR flag when SPS/PPS is seen.
--- libavcodec/h264_mp4toannexb_bsf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index be42304..ae96ee9 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -186,9 +186,9 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, goto fail; if (unit_type == 7) -ctx->idr_sps_seen = 1; +ctx->idr_sps_seen = ctx->new_idr = 1; else if (unit_type == 8) { -ctx->idr_pps_seen = 1; +ctx->idr_pps_seen = ctx->new_idr = 1; /* if SPS has not been seen yet, prepend the AVCC one to PPS */ if (!ctx->idr_sps_seen) { if (ctx->sps_offset == -1) -- 2.1.0.127.g0c72b98 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen.
On Tue, Sep 30, 2014 at 01:05:09PM +0200, Benoit Fouet wrote: > Hi, > > - Mail original - > > On Tue, Sep 30, 2014 at 11:15:06AM +0200, Benoit Fouet wrote: > > > Hi, > > > > > > - Mail original - > > > > On Tue, Sep 30, 2014 at 09:45:47AM +0200, Benoit Fouet wrote: > > > > > Hi, > > > > > > > > > > - Mail original - > > > > > > On Mon, Sep 29, 2014 at 03:31:36PM +0200, Benoit Fouet wrote: > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > does this ensure that the sps is before the pps ? > > > > > > if not that might be the reason for the warnings > > > > > > > > > > > > > > > > It does not. I can update this so that when the pps is seen and > > > > > not > > > > > the sps, it prepends the sps to the pps. > > > > > > > > please do, sps should be before the pps > > > > > > > > > > Done, new patch attached. > > > > probably ok, should i apply it ? > > > > I guess so. I have 2 more patches to this BSF, I'll send them shortly. applied -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/h264_mp4toannexb_bsf: use the given padding in h264_extradata_to_annexb().#
On Tue, Sep 30, 2014 at 01:06:30PM +0200, Benoit Fouet wrote: > --- > libavcodec/h264_mp4toannexb_bsf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/mxfenc: add jpeg2000 support
Hi, this patch adds support for j2k muxing in MXF. tested with: $ ffmpeg -t 5 -f lavfi -i testsrc -y -c:v libopenjpeg -y out.mxf Played back in ffplay (linux), vlc (windows), Acrok MXF converter (windows). I have no idea against what other players this should be tested. -- Ben From 448810ec5b39e7b95d7a43a76ed7994e7fca3b27 Mon Sep 17 00:00:00 2001 From: Benoit Fouet Date: Tue, 30 Sep 2014 14:16:52 +0200 Subject: [PATCH] avformat/mxfenc: add jpeg2000 support. Fixes ticket #1542 --- libavformat/mxfenc.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 6a6b7c2..d808e4d 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -26,6 +26,7 @@ * SMPTE 377M MXF File Format Specifications * SMPTE 379M MXF Generic Container * SMPTE 381M Mapping MPEG Streams into the MXF Generic Container + * SMPTE 422M Mapping JPEG 2000 Codestreams into the MXF Generic Container * SMPTE RP210: SMPTE Metadata Dictionary * SMPTE RP224: Registry of SMPTE Universal Labels */ @@ -95,6 +96,7 @@ static const struct { { AV_CODEC_ID_PCM_S16LE, 1 }, { AV_CODEC_ID_DVVIDEO, 15 }, { AV_CODEC_ID_DNXHD, 24 }, +{ AV_CODEC_ID_JPEG2000, 34 }, { AV_CODEC_ID_NONE } }; @@ -266,6 +268,11 @@ static const MXFContainerEssenceEntry mxf_essence_container_uls[] = { { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x15,0x01,0x05,0x00 }, { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x71,0x13,0x00,0x00 }, mxf_write_cdci_desc }, +// JPEG2000 +{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 }, + { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x15,0x01,0x08,0x00 }, + { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, + mxf_write_cdci_desc }, { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, -- 2.1.0.127.g0c72b98 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [RFC] Direct Stream Transfer (DST) decoder
Signed-off-by: Peter Ross --- DST (described in 14496 Part 3 Subpart 10) is the lossless compression standard for DSD samples. My implementation is ~45% faster than the reference decoder. Even so, single threaded decoding is still very demanding and there does not appear to much scope for SIMD optimisation. The decoder outputs to AV_SAMPLE_FMT_DSD, which is not in FFmpeg yet. (I guess it could be converted to output PCM, though that kind of defeats the purpose having 1-bit audio.) Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 + libavcodec/dst.h| 28 libavcodec/dstdec.c | 346 7 files changed, 385 insertions(+) create mode 100644 libavcodec/dst.h create mode 100644 libavcodec/dstdec.c diff --git a/Changelog b/Changelog index 8964774..9d8e2b3 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ version : - SUP/PGS subtitle demuxer - DoP (DSD-over-PCM) - Wideband Single-bit Data (WSD) demuxer +- Direct Stream Transfer (DST) decoder version 2.4: - Icecast protocol diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 08f724e..325ebe1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -204,6 +204,7 @@ OBJS-$(CONFIG_DSD_MSBF_PLANAR_DECODER) += dsddec.o OBJS-$(CONFIG_DSD_MSBF_PLANAR_ENCODER) += dsddec.o OBJS-$(CONFIG_DSICINAUDIO_DECODER) += dsicinaudio.o OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinvideo.o +OBJS-$(CONFIG_DST_DECODER) += dstdec.o OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index c988bd1..a1b699d 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -343,6 +343,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (DSD_MSBF, dsd_msbf); REGISTER_ENCDEC (DSD_LSBF_PLANAR, dsd_lsbf_planar); REGISTER_ENCDEC (DSD_MSBF_PLANAR, dsd_msbf_planar); +REGISTER_DECODER(DST, dst); REGISTER_DECODER(DSICINAUDIO, dsicinaudio); REGISTER_ENCDEC (EAC3, eac3); REGISTER_DECODER(EVRC, evrc); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ccffbd0..2d176d6 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -498,6 +498,7 @@ enum AVCodecID { AV_CODEC_ID_DSD_LSBF_PLANAR = MKBETAG('D','S','D','1'), AV_CODEC_ID_DSD_MSBF_PLANAR = MKBETAG('D','S','D','8'), AV_CODEC_ID_DOP_S24LE = MKBETAG('D','O','P','L'), +AV_CODEC_ID_DST = MKBETAG('D','S','T',' '), /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 7c202cc..6d0813e 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2515,6 +2515,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("DoP (DSD-over-PCM); signed 24-bit little-endian"), .props = AV_CODEC_PROP_LOSSLESS, }, +{ +.id= AV_CODEC_ID_DST, +.type = AVMEDIA_TYPE_AUDIO, +.name = "dst", +.long_name = NULL_IF_CONFIG_SMALL("DST (Direct Stream Transfer)"), +.props = AV_CODEC_PROP_LOSSLESS, +}, /* subtitle codecs */ { diff --git a/libavcodec/dst.h b/libavcodec/dst.h new file mode 100644 index 000..83c3f7f --- /dev/null +++ b/libavcodec/dst.h @@ -0,0 +1,28 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * Calculate FS44 ratio + */ +#define DSD_FS44(sample_rate) (sample_rate / 44100) + +/** + * Calculate DST frame size + * @return samples per frame (1-bit samples) + */ +#define DST_SAMPLES_PER_FRAME(sample_rate) (588 * DSD_FS44(sample_rate)) diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c new file mode 100644 index 000..51802ac --- /dev/null +++ b/libavcodec/dstdec.c @@ -0,0 +1,346 @@ +/* + * Direct Stream Transfer (DST) decoder + * Copyright (c) 2014 Peter Ross + * + * This file is part of FFmpe
Re: [FFmpeg-devel] [PATCH 1/2] avformat/aviobuf: fix avio_flush() for read streams
On Tue, 30 Sep 2014 01:02:45 +0200 Michael Niedermayer wrote: > On Mon, Sep 29, 2014 at 07:41:27PM +0200, wm4 wrote: > > avio_flush() did nothing useful for read streams. Fix it to behave as > > expected, and discard the currently read buffer properly. > > --- > > Since avio_flush() was just broken for read streams, I don't think this > > needs to be treated as an API-change. > > --- > > libavformat/avio.h| 8 ++-- > > libavformat/aviobuf.c | 2 ++ > > 2 files changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/libavformat/avio.h b/libavformat/avio.h > > index 2210c01..86f754e 100644 > > --- a/libavformat/avio.h > > +++ b/libavformat/avio.h > > @@ -289,10 +289,14 @@ int url_feof(AVIOContext *s); > > int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, > > 3); > > > > /** > > - * Force flushing of buffered data to the output s. > > + * Force flushing of buffered data. > > * > > - * Force the buffered data to be immediately written to the output, > > + * For write streams, force the buffered data to be immediately written to > > the output, > > * without to wait to fill the internal buffer. > > + * > > + * For read streams, discard all currently buffered data, and advance the > > + * reported file position to that of the underlying stream. This does not > > + * read new data, and does not perform any seeks. > > */ > > void avio_flush(AVIOContext *s); > > > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c > > index 9795ba4..b8586bd 100644 > > --- a/libavformat/aviobuf.c > > +++ b/libavformat/aviobuf.c > > @@ -148,6 +148,8 @@ static void flush_buffer(AVIOContext *s) > > } > > } > > this is calling writeout(), for a read flush avio_close() called avio_flush() already. So I was assuming that it had no bad consequences. On a closer look, this makes no sense though, and writeout should only ever be called if write_flag is set. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add avcodec_register_one() to register one codec/parser/bsf/hwaccel by its char* name
On Tue, 30 Sep 2014 02:02:49 +0200 Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer > --- > libavcodec/allcodecs.c | 51 > +--- > libavcodec/avcodec.h |5 + > 2 files changed, 40 insertions(+), 16 deletions(-) > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index 7650543..019d5ea 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -29,49 +29,55 @@ > #include "version.h" > > #define REGISTER_HWACCEL(X, x) \ > -{ \ > +if (!name || !strcmp(name, AV_STRINGIFY(x##_hwaccel))) {\ > extern AVHWAccel ff_##x##_hwaccel; \ > -if (CONFIG_##X##_HWACCEL) \ > +if (CONFIG_##X##_HWACCEL) { \ > av_register_hwaccel(&ff_##x##_hwaccel); \ > +found++;\ > +} \ > } > > #define REGISTER_ENCODER(X, x) \ > -{ \ > +if (!name || !strcmp(name, AV_STRINGIFY(x##_encoder))) {\ > extern AVCodec ff_##x##_encoder;\ > -if (CONFIG_##X##_ENCODER) \ > +if (CONFIG_##X##_ENCODER) { \ > avcodec_register(&ff_##x##_encoder);\ > +found++;\ > +} \ > } > > #define REGISTER_DECODER(X, x) \ > -{ \ > +if (!name || !strcmp(name, AV_STRINGIFY(x##_decoder))) {\ > extern AVCodec ff_##x##_decoder;\ > -if (CONFIG_##X##_DECODER) \ > +if (CONFIG_##X##_DECODER) { \ > avcodec_register(&ff_##x##_decoder);\ > +found++;\ > +} \ > } > > #define REGISTER_ENCDEC(X, x) REGISTER_ENCODER(X, x); REGISTER_DECODER(X, x) > > #define REGISTER_PARSER(X, x) \ > -{ \ > +if (!name || !strcmp(name, AV_STRINGIFY(x##_parser))) { \ > extern AVCodecParser ff_##x##_parser; \ > -if (CONFIG_##X##_PARSER)\ > +if (CONFIG_##X##_PARSER) { \ > av_register_codec_parser(&ff_##x##_parser); \ > +found++;\ > +} \ > } > > #define REGISTER_BSF(X, x) \ > -{ \ > +if (!name || !strcmp(name, AV_STRINGIFY(x##_bsf))) {\ > extern AVBitStreamFilter ff_##x##_bsf; \ > -if (CONFIG_##X##_BSF) \ > +if (CONFIG_##X##_BSF) { \ > av_register_bitstream_filter(&ff_##x##_bsf);\ > +found++;\ > +} \ > } > > -void avcodec_register_all(void) > +int avcodec_register_one(const char *name) > { > -static int initialized; > - > -if (initialized) > -return; > -initialized = 1; > +int found = 0; > > /* hardware accelerators */ > REGISTER_HWACCEL(H263_VAAPI,h263_vaapi); > @@ -588,4 +594,17 @@ void avcodec_register_all(void) > REGISTER_BSF(NOISE, noise); > REGISTER_BSF(REMOVE_EXTRADATA, remove_extradata); > REGISTER_BSF(TEXT2MOVSUB, text2movsub); > + > +return found; > } > + > +void avcodec_register_all(void) > +{ > +static int initialized; > + > +if (initialized) > +return; > +initialized = 1; > + > +avcodec_register_one(NULL); > +} > \ No newline at end of file > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 94e82f7..de936a5 100644 > --- a/libavcodec
Re: [FFmpeg-devel] [PATCH v2] Add SUP/PGS subtitle muxer
On Tue, 30 Sep 2014 11:01:17 +0300 phint...@gmail.com wrote: > From: Petri Hintukainen > > Fixes ticket #2208 > --- > Changelog| 2 +- > doc/general.texi | 2 +- > libavformat/Makefile | 1 + > libavformat/allformats.c | 2 +- > libavformat/supenc.c | 96 > > 5 files changed, 100 insertions(+), 3 deletions(-) > create mode 100644 libavformat/supenc.c > > diff --git a/Changelog b/Changelog > index 039d1ca..f171c17 100644 > --- a/Changelog > +++ b/Changelog > @@ -3,7 +3,7 @@ releases are sorted from youngest to oldest. > > version : > - HEVC/H.265 RTP payload format (draft v6) packetizer > -- SUP/PGS subtitle demuxer > +- SUP/PGS subtitle demuxer and muxer > > version 2.4: > - Icecast protocol > diff --git a/doc/general.texi b/doc/general.texi > index 2252f7b..b848e7e 100644 > --- a/doc/general.texi > +++ b/doc/general.texi > @@ -454,7 +454,7 @@ library: > @item Sony Wave64 (W64) @tab X @tab X > @item SoX native format @tab X @tab X > @item SUN AU format @tab X @tab X > -@item SUP raw PGS subtitles @tab @tab X > +@item SUP raw PGS subtitles @tab X @tab X > @item Text files@tab @tab X > @item THP @tab @tab X > @tab Used on the Nintendo GameCube. > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 86064ea..7385b67 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -407,6 +407,7 @@ OBJS-$(CONFIG_SRT_MUXER) += srtenc.o > OBJS-$(CONFIG_STR_DEMUXER) += psxstr.o > OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)+= subviewer1dec.o subtitles.o > OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o > +OBJS-$(CONFIG_SUP_MUXER) += supenc.o > OBJS-$(CONFIG_SUP_DEMUXER) += supdec.o > OBJS-$(CONFIG_SWF_DEMUXER) += swfdec.o swf.o > OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index d54ed9b..0b64355 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -280,7 +280,7 @@ void av_register_all(void) > REGISTER_DEMUXER (STR, str); > REGISTER_DEMUXER (SUBVIEWER1, subviewer1); > REGISTER_DEMUXER (SUBVIEWER,subviewer); > -REGISTER_DEMUXER (SUP, sup); > +REGISTER_MUXDEMUX(SUP, sup); > REGISTER_MUXDEMUX(SWF, swf); > REGISTER_DEMUXER (TAK, tak); > REGISTER_MUXER (TEE, tee); > diff --git a/libavformat/supenc.c b/libavformat/supenc.c > new file mode 100644 > index 000..f5f6b58 > --- /dev/null > +++ b/libavformat/supenc.c > @@ -0,0 +1,96 @@ > +/* > + * SUP muxer > + * Copyright (c) 2014 Petri Hintukainen > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg 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. > + * > + * FFmpeg 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 FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#include "avformat.h" > +#include "internal.h" > +#include "libavutil/intreadwrite.h" > + > +#define SUP_PGS_MAGIC 0x5047 /* "PG", big endian */ > + > +static int sup_write_packet(AVFormatContext *s, AVPacket *pkt) > +{ > +uint8_t *data = pkt->data; > +size_t size = pkt->size; > +uint32_t pts = 0, dts = 0; > + > +if (pkt->pts != AV_NOPTS_VALUE) { > +pts = (uint32_t)pkt->pts; > +} > +if (pkt->dts != AV_NOPTS_VALUE) { > +dts = (uint32_t)pkt->dts; > +} > + > +/* > + Split frame to segments. > + mkvmerge stores multiple segments in one frame. > +*/ > +while (size > 2) { > +size_t len = AV_RB16(data + 1) + 3; > + > +if (len > size) { > +av_log(s, AV_LOG_ERROR, "Not enough data, skipping %d bytes\n", > + (int)size); > +return AVERROR_INVALIDDATA; > +} > + > +/* header */ > +avio_wb16(s->pb, SUP_PGS_MAGIC); > +avio_wb32(s->pb, pts); > +avio_wb32(s->pb, dts); > + > +avio_write(s->pb, data, len); > + > +data += len; > +size -= len; > +} Ah, I see now why you wanted to add a parser. But yeah, a separate parser would probably be overkill in this case. Are you sure the additional segments should have t
Re: [FFmpeg-devel] [RFC] Direct Stream Transfer (DST) decoder
On Tue, 30 Sep 2014 23:42:20 +1000 Peter Ross wrote: > +++ b/libavcodec/allcodecs.c > @@ -343,6 +343,7 @@ void avcodec_register_all(void) > REGISTER_ENCDEC (DSD_MSBF, dsd_msbf); > REGISTER_ENCDEC (DSD_LSBF_PLANAR, dsd_lsbf_planar); > REGISTER_ENCDEC (DSD_MSBF_PLANAR, dsd_msbf_planar); > +REGISTER_DECODER(DST, dst); > REGISTER_DECODER(DSICINAUDIO, dsicinaudio); > REGISTER_ENCDEC (EAC3, eac3); dsi > dst > +#if 0 > +/* 'run_length' upper bound is not specified; we can never be > sure it will fit into get_bits cache */ > +int v = get_ur_golomb(gb, k, INT_MAX, 0); > +#else > +int v = 0; > +while (!get_bits1(gb)) > +v++; > +if (k) > +v = (v << k) | get_bits(gb, k); > +#endif keeping if 0? (i dont know, i'm just pointing it out) -compn ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v7] Add SUP/PGS subtitle demuxer
On Tue, 30 Sep 2014 12:01:33 +0300 Petri Hintukainen wrote: > Hello, > > Missing DTS combined with non-monotonic PTS seems to cause some > problems. This is with the file from ticket #2208 (I added dumping > timestamps to demuxer and muxer): > > > $ ../ffmpeg -i orig/track_06\ -\ Subtitle.sup -scodec copy 6.sup > ffmpeg version N-66546-gea74007 Copyright (c) 2000-2014 the FFmpeg > developers > built on Sep 30 2014 11:10:08 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1) > configuration: > libavutil 54. 7.101 / 54. 7.101 > libavcodec 56. 1.101 / 56. 1.101 > libavformat56. 7.101 / 56. 7.101 > libavdevice56. 1.100 / 56. 1.100 > libavfilter 5. 1.102 / 5. 1.102 > libswscale 3. 1.100 / 3. 1.100 > libswresample 1. 1.100 / 1. 1.100 > IN pts 00255314 dts > Input #0, sup, from 'orig/track_06 - Subtitle.sup': > Duration: N/A, start: 2.836822, bitrate: N/A > Stream #0:0: Subtitle: hdmv_pgs_subtitle, 1920x1080 > Output #0, sup, to '6.sup': > Metadata: > encoder : Lavf56.7.101 > Stream #0:0: Subtitle: hdmv_pgs_subtitle, 1920x1080 > Stream mapping: > Stream #0:0 -> #0:0 (copy) > Press [q] to stop, [?] for help > OUT pts dts > IN pts 00255037 dts > OUT pts dts > IN pts 00249205 dts > [sup @ 0x241f4e0] Application provided invalid, non monotonically > increasing dts to muxer in stream 0: -277 >= -6109 > av_interleaved_write_frame(): Invalid argument > size= 0kB time=00:00:00.00 bitrate=N/A > video:0kB audio:0kB subtitle:1kB other streams:0kB global headers:0kB > muxing overhead: unknown > Conversion failed! The DTS in this file are indeed decreasing sometimes. First packet: pts=255314 pts_time=2.836822 dts=255314 dts_time=2.836822 Second packet: pts=255037 pts_time=2.833744 dts=255037 dts_time=2.833744 > > Also note that timestamps are re-positioned to start from 0. This may be > problematic, it requires manually synchronizing subtitles to the video. "Rebasing" the timestamps is apparently the normal operation of ffmpeg.c, there's probably a way to make it stop doing that. > Remuxing from the original .m2ts file works just well: > > > $ ffmpeg -i orig/00038.m2ts -map 0:6 -scodec copy 6.sup > ffmpeg version N-66546-gea74007 Copyright (c) 2000-2014 the FFmpeg developers > built on Sep 30 2014 11:10:08 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1) > configuration: > libavutil 54. 7.101 / 54. 7.101 > libavcodec 56. 1.101 / 56. 1.101 > libavformat56. 7.101 / 56. 7.101 > libavdevice56. 1.100 / 56. 1.100 > libavfilter 5. 1.102 / 5. 1.102 > libswscale 3. 1.100 / 3. 1.100 > libswresample 1. 1.100 / 1. 1.100 > [NULL @ 0x1bf9ba0] start time for stream 6 is not set in > estimate_timings_from_pts > [NULL @ 0x1c146e0] start time for stream 7 is not set in > estimate_timings_from_pts > [NULL @ 0x1c151c0] start time for stream 8 is not set in > estimate_timings_from_pts > [mpegts @ 0x1bf1ca0] Could not find codec parameters for stream 6 (Subtitle: > hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)): unspecified size > Consider increasing the value for the 'analyzeduration' and 'probesize' > options > [mpegts @ 0x1bf1ca0] Could not find codec parameters for stream 7 (Subtitle: > hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)): unspecified size > Consider increasing the value for the 'analyzeduration' and 'probesize' > options > [mpegts @ 0x1bf1ca0] Could not find codec parameters for stream 8 (Subtitle: > hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)): unspecified size > Consider increasing the value for the 'analyzeduration' and 'probesize' > options > Input #0, mpegts, from 'orig/00038.m2ts': > Duration: 00:00:43.90, start: 11.650667, bitrate: 35145 kb/s > Program 1 > Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, > 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc > Stream #0:1[0x1100]: Audio: truehd (AC-3 / 0x332D4341), 48000 Hz, 7.1, > s32 (24 bit) > Stream #0:2[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), > fltp, 640 kb/s > Stream #0:3[0x1101]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, > fltp, 320 kb/s > Stream #0:4[0x1102]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, > fltp, 320 kb/s > Stream #0:5[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / > 0x0090), 1920x1080 > Stream #0:6[0x1201]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) > Stream #0:7[0x1202]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) > Stream #0:8[0x1203]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) > Output #0, sup, to '6.sup': > Metadata: > encoder : Lavf56.7.101 > Stream #0:0: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090) > Stream mapping: > Stream #0:6 -> #0:0 (copy) > Press [q] to stop, [?] for help > OUT pts 00255255 dts 00249146 > OUT pts 00254978 dts 00249
Re: [FFmpeg-devel] [PATCH] avformat/mxfenc: add jpeg2000 support
On Tue, Sep 30, 2014 at 3:37 PM, Benoit Fouet wrote: > Hi, > Hi Benoit, Thanks for your patch. I've reviewed the ULs values and they look good to me. > > this patch adds support for j2k muxing in MXF. > tested with: > $ ffmpeg -t 5 -f lavfi -i testsrc -y -c:v libopenjpeg -y out.mxf > > Played back in ffplay (linux), vlc (windows), Acrok MXF converter > (windows). > I have no idea against what other players this should be tested. > Maybe some testing can be done with the bmx tool and check if it reports the stream correctly and is able to extract the video bytestream. Best regards, Matthieu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] More specific error codes
2014-09-29 21:06 GMT+04:00 Nicolas George : > L'octidi 8 vendémiaire, an CCXXIII, Andrey Utkin a écrit : >> At last I got back to this issue. >> First I thought of adding such new error codes: > >> What do you think about it? Which would you prefer? > > I am sorry to have to say your proposal has the taste of "add whatever I > need for my specific use case, and if it can be useful for others lucky > them". Which does not mean the proposal does not have merit, just that it is > not obviously the best one. > > Before enhancing the error code system, I believe you must answer a few > questions, and above all: > > What do you want more specific error codes for? > > Is it to provide the user with more accurate and less misleading error > messages (A)? > > Is it to allow the application to react to specific errors (example: > authentication failure => re-ask the password) (B)? > > Is it to allow part of the code to forward specific errors that can only > happen in a that small area of code (C)? "A" first. It will ease user support a lot: now we have users asking "why system doesn't work (e.g. doesn't dumps RTSP media stream) and says "Invalid data ..." (which is decoded error reason returned from avformat_open_input() or av_read_frame()) ?" and we need to turn on debug logging and/or even sniff traffic to figure out the reason. And compare it with better situation when system gives something exact for cases of "401 Unauthorized", "404 Not Found", giving a smart user an idea to check his settings and giving technical support an idea what to advise to not-so-smart user. It is easier to implement than dumping some amount of latest errors related to certain AVFormatContext (or maybe better errors+warnings? or errors+...+debug? AFAIR nothing special is printed out for a lot of specific 40x cases, and debug loglevel is the one which is likely to dump reasonable amount of network messages exchange.) "B" usage will appear automatically when it gets possible, i believe. I didn't think about that actually, thanks for the idea. "C" was not considered. Thank you for your thoughts regarding GError. I think it could be useful to have error storage to be like a stack; both initial (the most low level) and last (the highest level) entries will be preserved, and also almost complete stack trace will be here, which will help in debugging. This way it gets not so important that every act of returning of error value up by stack is accompanied by storing error in the context. The downside is a big amount of places in code to edit. -- Andrey Utkin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add avcodec_register_one() to register one codec/parser/bsf/hwaccel by its char* name
Hi On Tue, Sep 30, 2014 at 03:51:13PM +0200, wm4 wrote: > On Tue, 30 Sep 2014 02:02:49 +0200 > Michael Niedermayer wrote: > > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/allcodecs.c | 51 > > +--- > > libavcodec/avcodec.h |5 + > > 2 files changed, 40 insertions(+), 16 deletions(-) > > > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > > index 7650543..019d5ea 100644 > > --- a/libavcodec/allcodecs.c > > +++ b/libavcodec/allcodecs.c > > @@ -29,49 +29,55 @@ > > #include "version.h" > > > > #define REGISTER_HWACCEL(X, x) \ > > -{ \ > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_hwaccel))) {\ > > extern AVHWAccel ff_##x##_hwaccel; \ > > -if (CONFIG_##X##_HWACCEL) \ > > +if (CONFIG_##X##_HWACCEL) { \ > > av_register_hwaccel(&ff_##x##_hwaccel); \ > > +found++;\ > > +} \ > > } > > > > #define REGISTER_ENCODER(X, x) \ > > -{ \ > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_encoder))) {\ > > extern AVCodec ff_##x##_encoder;\ > > -if (CONFIG_##X##_ENCODER) \ > > +if (CONFIG_##X##_ENCODER) { \ > > avcodec_register(&ff_##x##_encoder);\ > > +found++;\ > > +} \ > > } > > > > #define REGISTER_DECODER(X, x) \ > > -{ \ > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_decoder))) {\ > > extern AVCodec ff_##x##_decoder;\ > > -if (CONFIG_##X##_DECODER) \ > > +if (CONFIG_##X##_DECODER) { \ > > avcodec_register(&ff_##x##_decoder);\ > > +found++;\ > > +} \ > > } > > > > #define REGISTER_ENCDEC(X, x) REGISTER_ENCODER(X, x); REGISTER_DECODER(X, > > x) > > > > #define REGISTER_PARSER(X, x) \ > > -{ \ > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_parser))) { \ > > extern AVCodecParser ff_##x##_parser; \ > > -if (CONFIG_##X##_PARSER)\ > > +if (CONFIG_##X##_PARSER) { \ > > av_register_codec_parser(&ff_##x##_parser); \ > > +found++;\ > > +} \ > > } > > > > #define REGISTER_BSF(X, x) \ > > -{ \ > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_bsf))) {\ > > extern AVBitStreamFilter ff_##x##_bsf; \ > > -if (CONFIG_##X##_BSF) \ > > +if (CONFIG_##X##_BSF) { \ > > av_register_bitstream_filter(&ff_##x##_bsf);\ > > +found++;\ > > +} \ > > } > > > > -void avcodec_register_all(void) > > +int avcodec_register_one(const char *name) > > { > > -static int initialized; > > - > > -if (initialized) > > -return; > > -initialized = 1; > > +int found = 0; > > > > /* hardware accelerators */ > > REGISTER_HWACCEL(H263_VAAPI,h263_vaapi); > > @@ -588,4 +594,17 @@ void avcodec_register_all(void) > > REGISTER_BSF(NOISE, noise); > > REGISTER_BSF(REMOVE_EXTRADATA, remove_extradata); > > REGISTER_BSF(TEXT2MOVSUB, text2movsub); > > + > > +return found; > > } > > + > > +void avcodec_register_all(void) > > +{ > > +static int initialized
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add avcodec_register_one() to register one codec/parser/bsf/hwaccel by its char* name
On Tue, 30 Sep 2014 17:21:20 +0200 Michael Niedermayer wrote: > Hi > > On Tue, Sep 30, 2014 at 03:51:13PM +0200, wm4 wrote: > > On Tue, 30 Sep 2014 02:02:49 +0200 > > Michael Niedermayer wrote: > > > > > Signed-off-by: Michael Niedermayer > > > --- > > > libavcodec/allcodecs.c | 51 > > > +--- > > > libavcodec/avcodec.h |5 + > > > 2 files changed, 40 insertions(+), 16 deletions(-) > > > > > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > > > index 7650543..019d5ea 100644 > > > --- a/libavcodec/allcodecs.c > > > +++ b/libavcodec/allcodecs.c > > > @@ -29,49 +29,55 @@ > > > #include "version.h" > > > > > > #define REGISTER_HWACCEL(X, x) \ > > > -{ \ > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_hwaccel))) {\ > > > extern AVHWAccel ff_##x##_hwaccel; \ > > > -if (CONFIG_##X##_HWACCEL) \ > > > +if (CONFIG_##X##_HWACCEL) { \ > > > av_register_hwaccel(&ff_##x##_hwaccel); \ > > > +found++;\ > > > +} \ > > > } > > > > > > #define REGISTER_ENCODER(X, x) \ > > > -{ \ > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_encoder))) {\ > > > extern AVCodec ff_##x##_encoder;\ > > > -if (CONFIG_##X##_ENCODER) \ > > > +if (CONFIG_##X##_ENCODER) { \ > > > avcodec_register(&ff_##x##_encoder);\ > > > +found++;\ > > > +} \ > > > } > > > > > > #define REGISTER_DECODER(X, x) \ > > > -{ \ > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_decoder))) {\ > > > extern AVCodec ff_##x##_decoder;\ > > > -if (CONFIG_##X##_DECODER) \ > > > +if (CONFIG_##X##_DECODER) { \ > > > avcodec_register(&ff_##x##_decoder);\ > > > +found++;\ > > > +} \ > > > } > > > > > > #define REGISTER_ENCDEC(X, x) REGISTER_ENCODER(X, x); > > > REGISTER_DECODER(X, x) > > > > > > #define REGISTER_PARSER(X, x) \ > > > -{ \ > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_parser))) { \ > > > extern AVCodecParser ff_##x##_parser; \ > > > -if (CONFIG_##X##_PARSER)\ > > > +if (CONFIG_##X##_PARSER) { \ > > > av_register_codec_parser(&ff_##x##_parser); \ > > > +found++;\ > > > +} \ > > > } > > > > > > #define REGISTER_BSF(X, x) \ > > > -{ \ > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_bsf))) {\ > > > extern AVBitStreamFilter ff_##x##_bsf; \ > > > -if (CONFIG_##X##_BSF) \ > > > +if (CONFIG_##X##_BSF) { \ > > > av_register_bitstream_filter(&ff_##x##_bsf);\ > > > +found++;\ > > > +} \ > > > } > > > > > > -void avcodec_register_all(void) > > > +int avcodec_register_one(const char *name) > > > { > > > -static int initialized; > > > - > > > -if (initialized) > > > -return; > > > -initialized = 1; > > > +int found = 0; > > > > > > /* hardware accelerators */ > > > REGISTER_HWACCEL(H263_VAAPI,h263_vaapi); > > > @@ -588,4 +594,17 @@ void avcodec_register_all(void) > > > REGISTER_BSF(NOISE,
Re: [FFmpeg-devel] [PATCH] avformat/mxfdec: read reel_name and source timecode from physical source package
On Sun, Sep 28, 2014 at 3:16 AM, Michael Niedermayer wrote: > On Sun, Sep 28, 2014 at 11:04:34AM +0200, Tomas Härdin wrote: > > On Thu, 2014-09-25 at 16:13 -0700, Mark Reid wrote: > > > --- > > > libavformat/mxfdec.c | 118 > ++- > > > 1 file changed, 97 insertions(+), 21 deletions(-) > > > > > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > > > index 7a4633f..3a1889f 100644 > > > --- a/libavformat/mxfdec.c > > > +++ b/libavformat/mxfdec.c > > > @@ -188,6 +188,7 @@ typedef struct { > > > int tracks_count; > > > MXFDescriptor *descriptor; /* only one */ > > > UID descriptor_ref; > > > +char *name; > > > } MXFPackage; > > > > > > typedef struct { > > > @@ -731,6 +732,27 @@ static int mxf_read_sequence(void *arg, > AVIOContext *pb, int tag, int size, UID > > > return 0; > > > } > > > > > > +static int mxf_read_utf16_string(AVIOContext *pb, int size, char** > str) > > > +{ > > > +int ret; > > > +size_t buf_size; > > > + > > > +if (size < 0) > > > +return AVERROR(EINVAL); > > > + > > > +buf_size = size + size / 2 + 1; > > > > This should be a function, like ff_utf16_buflen() or something. I see > > that this hunk is just moving the function though, so don't let that > > hold this patch up. > > > > > +*str = av_malloc(buf_size); > > > +if (!*str) > > > +return AVERROR(ENOMEM); > > > + > > > +if ((ret = avio_get_str16be(pb, size, *str, buf_size)) < 0) { > > > +av_freep(str); > > > +return ret; > > > +} > > > + > > > +return ret; > > > +} > > > > > > > +static int mxf_parse_physical_source_package(MXFContext *mxf, > MXFTrack *source_track, AVStream *st) > > > +{ > > > [...] > > > > + > > > +for (k = 0; k < > physical_track->sequence->structural_components_count; k++) { > > > +component = mxf_resolve_strong_ref(mxf, > &physical_track->sequence->structural_components_refs[k], > TimecodeComponent); > > > +if (!component) > > > +continue; > > > + > > > +mxf_tc = (MXFTimecodeComponent*)component; > > > +flags = mxf_tc->drop_frame == 1 ? > AV_TIMECODE_FLAG_DROPFRAME : 0; > > > +/* scale sourceclip start_position to match physical > track edit rate */ > > > +start_position = > av_rescale_q(sourceclip->start_position, av_inv_q(source_track->edit_rate), > av_inv_q(physical_track->edit_rate)); > > > > av_rescale() > > edit_rate is a AVRational, so av_rescale_q() seems fitting to me > or do i misunderstand ? > the av_inv_q() could be avoided though by exchanging the 2 arguments > > [...] > yeah, the arguments should simply be reversed, i was just thinking backwards, I'll fix it and send a new patch. I did a bit of fuzz testing with zzuf, but I'll do a bit more before submitting again. Thanks for taking the time to review. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 2/2] avformat: add avformat_flush()
TODO: add entry to APIchanges, bump minor version. --- Updated the doxygen. --- libavformat/avformat.h | 17 + libavformat/utils.c| 6 ++ 2 files changed, 23 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 78054de..550cc50 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2173,6 +2173,23 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); /** + * Discard all internally buffered data. This can be useful when dealing with + * discontinuities in the byte stream. Generally works only with headerless + * formats. + * + * The set of streams, the detected duration, stream parameters and codecs do + * not change when calling this function. If you want a complete reset, it's + * better to open a new AVFormatContext. + * + * This does not flush the AVIOContext (s->pb). If necessary, call + * avio_flush(s->pb) before calling this function. + * + * @param s media file handle + * @return >=0 on success, error code otherwise + */ +int avformat_flush(AVFormatContext *s); + +/** * Start playing a network-based stream (e.g. RTSP stream) at the * current position. */ diff --git a/libavformat/utils.c b/libavformat/utils.c index e0e78a7..9689aa0 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2159,6 +2159,12 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, return -1; //unreachable } +int avformat_flush(AVFormatContext *s) +{ +ff_read_frame_flush(s); +return 0; +} + /***/ /** -- 2.1.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 1/2] avformat/aviobuf: fix avio_flush() for read streams
avio_flush() did nothing useful for read streams. Fix it to behave as expected, and discard the currently read buffer properly. --- In addition to v1, also make sure that avio_flush() never enters the write path with read streams. This wasn't ensured before. avio_close() calls avio_flush() unconditionally, so this might even fix a bug. --- libavformat/avio.h| 8 ++-- libavformat/aviobuf.c | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 2210c01..86f754e 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -289,10 +289,14 @@ int url_feof(AVIOContext *s); int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); /** - * Force flushing of buffered data to the output s. + * Force flushing of buffered data. * - * Force the buffered data to be immediately written to the output, + * For write streams, force the buffered data to be immediately written to the output, * without to wait to fill the internal buffer. + * + * For read streams, discard all currently buffered data, and advance the + * reported file position to that of the underlying stream. This does not + * read new data, and does not perform any seeks. */ void avio_flush(AVIOContext *s); diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 9795ba4..f01ed88 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -139,7 +139,7 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) static void flush_buffer(AVIOContext *s) { -if (s->buf_ptr > s->buffer) { +if (s->write_flag && s->buf_ptr > s->buffer) { writeout(s, s->buffer, s->buf_ptr - s->buffer); if (s->update_checksum) { s->checksum = s->update_checksum(s->checksum, s->checksum_ptr, @@ -148,6 +148,8 @@ static void flush_buffer(AVIOContext *s) } } s->buf_ptr = s->buffer; +if (!s->write_flag) +s->buf_end = s->buffer; } void avio_w8(AVIOContext *s, int b) -- 2.1.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] avutil/avstring: Factor av_match_list() out
Signed-off-by: Michael Niedermayer --- doc/APIchanges |3 +++ libavformat/format.c | 20 +++- libavutil/avstring.c | 21 + libavutil/avstring.h |7 +++ 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7fadab3..7b2f484 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2014-08-09 API changes, most recent first: +2014-10-xx - xxx - lavu - avstring.h + Add av_match_list() + 2014-09-24 - xxx - libpostproc 53.1.100 Add visualization support diff --git a/libavformat/format.c b/libavformat/format.c index 1026c8f..2d56e6d 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -80,28 +80,14 @@ void av_register_output_format(AVOutputFormat *format) int av_match_ext(const char *filename, const char *extensions) { -const char *ext, *p; -char ext1[32], *q; +const char *ext; if (!filename) return 0; ext = strrchr(filename, '.'); -if (ext) { -ext++; -p = extensions; -for (;;) { -q = ext1; -while (*p != '\0' && *p != ',' && q - ext1 < sizeof(ext1) - 1) -*q++ = *p++; -*q = '\0'; -if (!av_strcasecmp(ext1, ext)) -return 1; -if (*p == '\0') -break; -p++; -} -} +if (ext) +return av_match_list(ext + 1, extensions, ','); return 0; } diff --git a/libavutil/avstring.c b/libavutil/avstring.c index fd010e4..fe5958b 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -402,6 +402,27 @@ end: return ret; } +int av_match_list(const char *name, const char *list, char seperator) +{ +const char *p; +char ext1[128], *q; +int i; + +p = list; +for (i = 1;; i++) { +q = ext1; +while (*p != '\0' && *p != seperator && q - ext1 < sizeof(ext1) - 1) +*q++ = *p++; +*q = '\0'; +if (!av_strcasecmp(ext1, name)) +return i; +if (*p == '\0') +break; +p++; +} +return 0; +} + #ifdef TEST int main(void) diff --git a/libavutil/avstring.h b/libavutil/avstring.h index 616c066..b33b82e 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -358,6 +358,13 @@ int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, unsigned int flags); /** + * Check if a name is in a list. + * @returns 0 if not found, or the 1 based index where it has been found in the + *list. + */ +int av_match_list(const char *name, const char *list, char seperator); + +/** * @} */ -- 1.7.9.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] avcodec: add avcodec_register_list() to register a list of codec/parser/bsf/hwaccel
This allows globally limiting the allowed entities for security purposes by the application Signed-off-by: Michael Niedermayer --- libavcodec/allcodecs.c | 49 ++-- libavcodec/avcodec.h | 20 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 7650543..9fea0b9 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -27,51 +27,65 @@ #include "config.h" #include "avcodec.h" #include "version.h" +#include "libavutil/avstring.h" #define REGISTER_HWACCEL(X, x) \ -{ \ +if (!list || av_match_list(AV_STRINGIFY(x##_hwaccel), list, ',')) { \ extern AVHWAccel ff_##x##_hwaccel; \ -if (CONFIG_##X##_HWACCEL) \ +if (CONFIG_##X##_HWACCEL) { \ av_register_hwaccel(&ff_##x##_hwaccel); \ +found++;\ +} \ } #define REGISTER_ENCODER(X, x) \ -{ \ +if (!list || av_match_list(AV_STRINGIFY(x##_encoder), list, ',')) { \ extern AVCodec ff_##x##_encoder;\ -if (CONFIG_##X##_ENCODER) \ +if (CONFIG_##X##_ENCODER) { \ avcodec_register(&ff_##x##_encoder);\ +found++;\ +} \ } #define REGISTER_DECODER(X, x) \ -{ \ +if (!list || av_match_list(AV_STRINGIFY(x##_decoder), list, ',')) { \ extern AVCodec ff_##x##_decoder;\ -if (CONFIG_##X##_DECODER) \ +if (CONFIG_##X##_DECODER) { \ avcodec_register(&ff_##x##_decoder);\ +found++;\ +} \ } #define REGISTER_ENCDEC(X, x) REGISTER_ENCODER(X, x); REGISTER_DECODER(X, x) #define REGISTER_PARSER(X, x) \ -{ \ +if (!list || av_match_list(AV_STRINGIFY(x##_parser), list, ',')) { \ extern AVCodecParser ff_##x##_parser; \ -if (CONFIG_##X##_PARSER)\ +if (CONFIG_##X##_PARSER) { \ av_register_codec_parser(&ff_##x##_parser); \ +found++;\ +} \ } #define REGISTER_BSF(X, x) \ -{ \ +if (!list || av_match_list(AV_STRINGIFY(x##_bsf), list, ',')) { \ extern AVBitStreamFilter ff_##x##_bsf; \ -if (CONFIG_##X##_BSF) \ +if (CONFIG_##X##_BSF) { \ av_register_bitstream_filter(&ff_##x##_bsf);\ +found++;\ +} \ } -void avcodec_register_all(void) +int avcodec_register_list(const char *list) { -static int initialized; +static const char *initialized; +const char *nonnull_list = list ? list : "all"; +int found = 0; if (initialized) -return; -initialized = 1; +return strcmp(nonnull_list, initialized) ? -1 : 0; + +initialized = nonnull_list; /* hardware accelerators */ REGISTER_HWACCEL(H263_VAAPI,h263_vaapi); @@ -588,4 +602,11 @@ void avcodec_register_all(void) REGISTER_BSF(NOISE, noise); REGISTER_BSF(REMOVE_EXTRADATA, remove_extradata); REGISTER_BSF(TEXT2MOVSUB, text2movsub); + +return found; +} + +void avcodec_register_all(void) +{ +avcodec_register_list(NULL); } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 94e82f7..b804460 100644 --- a/libavcodec/avcodec.h +++ b/libavcode
Re: [FFmpeg-devel] patch 1/4: libavcodec/ppc/pixblockdsp.c: fix get_pixels_altivec() and diff_pixels_altivec() for POWER LE
On Tue, Sep 30, 2014 at 03:51:55PM +0800, rongyan wrote: > Hi, > I present 4 patches to fix bugs for POWER8 little endian. > I will send 4 patches in 4 different email. This is the first. > The fate test result after merge these 4 patches can be found on > http://fate.ffmpeg.org/ by search "ibmcrl", also attached here to facilitate > the review: > > > > The passed test cases increased from 1649/2169 to 1675/2174. This one seems wrong. I assume HAVE_VSX is a feature related define, which means it should be possible to disable it without breaking anything. If the altivec implementation is broken on little-endian, the correct bug-fix is to disable it. Then as a next step can a different optimized implementation be added. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add avcodec_register_one() to register one codec/parser/bsf/hwaccel by its char* name
On Tue, Sep 30, 2014 at 06:23:38PM +0200, wm4 wrote: > On Tue, 30 Sep 2014 17:21:20 +0200 > Michael Niedermayer wrote: > > > Hi > > > > On Tue, Sep 30, 2014 at 03:51:13PM +0200, wm4 wrote: > > > On Tue, 30 Sep 2014 02:02:49 +0200 > > > Michael Niedermayer wrote: > > > > > > > Signed-off-by: Michael Niedermayer > > > > --- > > > > libavcodec/allcodecs.c | 51 > > > > +--- > > > > libavcodec/avcodec.h |5 + > > > > 2 files changed, 40 insertions(+), 16 deletions(-) > > > > > > > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > > > > index 7650543..019d5ea 100644 > > > > --- a/libavcodec/allcodecs.c > > > > +++ b/libavcodec/allcodecs.c > > > > @@ -29,49 +29,55 @@ > > > > #include "version.h" > > > > > > > > #define REGISTER_HWACCEL(X, x) > > > > \ > > > > -{ > > > > \ > > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_hwaccel))) { > > > > \ > > > > extern AVHWAccel ff_##x##_hwaccel; > > > > \ > > > > -if (CONFIG_##X##_HWACCEL) > > > > \ > > > > +if (CONFIG_##X##_HWACCEL) { > > > > \ > > > > av_register_hwaccel(&ff_##x##_hwaccel); > > > > \ > > > > +found++; > > > > \ > > > > +} > > > > \ > > > > } > > > > > > > > #define REGISTER_ENCODER(X, x) > > > > \ > > > > -{ > > > > \ > > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_encoder))) { > > > > \ > > > > extern AVCodec ff_##x##_encoder; > > > > \ > > > > -if (CONFIG_##X##_ENCODER) > > > > \ > > > > +if (CONFIG_##X##_ENCODER) { > > > > \ > > > > avcodec_register(&ff_##x##_encoder); > > > > \ > > > > +found++; > > > > \ > > > > +} > > > > \ > > > > } > > > > > > > > #define REGISTER_DECODER(X, x) > > > > \ > > > > -{ > > > > \ > > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_decoder))) { > > > > \ > > > > extern AVCodec ff_##x##_decoder; > > > > \ > > > > -if (CONFIG_##X##_DECODER) > > > > \ > > > > +if (CONFIG_##X##_DECODER) { > > > > \ > > > > avcodec_register(&ff_##x##_decoder); > > > > \ > > > > +found++; > > > > \ > > > > +} > > > > \ > > > > } > > > > > > > > #define REGISTER_ENCDEC(X, x) REGISTER_ENCODER(X, x); > > > > REGISTER_DECODER(X, x) > > > > > > > > #define REGISTER_PARSER(X, x) > > > > \ > > > > -{ > > > > \ > > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_parser))) { > > > > \ > > > > extern AVCodecParser ff_##x##_parser; > > > > \ > > > > -if (CONFIG_##X##_PARSER) > > > > \ > > > > +if (CONFIG_##X##_PARSER) { > > > > \ > > > > av_register_codec_parser(&ff_##x##_parser); > > > > \ > > > > +found++; > > > > \ > > > > +} > > > > \ > > > > } > > > > > > > > #define REGISTER_BSF(X, x) > > > > \ > > > > -{ > > > > \ > > > > +if (!name || !strcmp(name, AV_STRINGIFY(x##_bsf))) { > > > > \ > > > > extern AVBitStreamFilter ff_##x##_bsf; > > > > \ > > > > -if (CONFIG_##X##_BSF) > > > > \ > > > > +if (CONFIG_##X##_BSF) { > > > > \ > > > > av_register_bitstream_filter(&ff_##x##_bsf); > > > > \ > > > > +found++;
Re: [FFmpeg-devel] [PATCH v2] Add SUP/PGS subtitle muxer
Hello, I didn't see any real issues either. On Tue, Sep 30, 2014 at 11:01:17AM +0300, phint...@gmail.com wrote: > +static int sup_write_packet(AVFormatContext *s, AVPacket *pkt) > +{ > +uint8_t *data = pkt->data; const uint8_t * would be a bit nicer though, to make sure nobody gets any bad ideas. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add avcodec_register_one() to register one codec/parser/bsf/hwaccel by its char* name
On Tue, Sep 30, 2014 at 06:23:38PM +0200, wm4 wrote: [...] > But then you might as well create a better API, like a per > AV(Codec/Format)Context whitelist of allowed codecs. The goal is security, and for that its neccessary to ensure it cannot easily or through plausible programming mistakes be circumvented. If what you suggest here requires every codec lookup and every demuxer lookup to check against a "local" whitelist. And requires this whitelist to be passed around so that all libs have it then this is quite easy to mess up, only one such passing around or check has to be forgotten, thats quite easy to happen but maybe i misunderstand what you meant we have code in libavformat that uses libavfilter we have code in libavfilter that uses libavformat+libavcodec We have ff_load_image() we have src_movie, we have demuxers opening other demuxers the lists would have to be passed through these and various other cases without missing anything Making security depend on "none of this being missed" feels like russian roulet -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] Kill timed SRT
On Mon, Sep 29, 2014 at 07:27:02PM +0200, Clément Bœsch wrote: > On Mon, Sep 29, 2014 at 05:42:09PM +0200, Nicolas George wrote: > > L'octidi 28 fructidor, an CCXXII, Clément Bœsch a écrit : > > > --- > > > libavcodec/srtdec.c | 33 +++ > > > libavcodec/srtenc.c | 49 > > > ++- > > > libavformat/matroska.c| 1 - > > > libavformat/matroskaenc.c | 45 > > > +-- > > > libavformat/srtenc.c | 11 --- > > > 5 files changed, 10 insertions(+), 129 deletions(-) > > > > I am in favour of doing this, and a quick glance at the code seems ok. > > > > I have a small doubt about the handling of "move": it seems that with the > > timed srt case, \move(x,y) is translated into "X: Y:" in the timestamp line > > of the packet payload, while in the clean srt case it is dropped: should it > > not be translated into side data? That is not something changed by the > > patch, but the patch removes the "move" callback altogether, making the > > issue less obvious, if there is one. > > > > Ah you are right. But it's indeed not a regression, and fixing that would > mean to rework the subtitles encode API: it currently takes a buffer and > not an AVPacket, so the encoder is not able to set the side data... > Added a TODO in the empty callback and pushed. -- Clément B. pgp0NMpoo621T.pgp Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/srtdec: use AVBPrint API
On Mon, Sep 29, 2014 at 05:36:15PM +0200, Nicolas George wrote: > Le septidi 7 vendémiaire, an CCXXIII, Clément Bœsch a écrit : > > --- > > Can only be applied after timed SRT is dropped. > > --- > > libavcodec/srtdec.c | 78 > > - > > 1 file changed, 35 insertions(+), 43 deletions(-) > > The changes look right to me. > Pushed, thanks -- Clément B. pgphJg1mN3wBd.pgp Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] mlpdec: move rematrix_channels code to output_data()
Signed-off-by: James Almer --- libavcodec/mlpdec.c | 45 ++--- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index e443f81..2c5426c 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -1038,15 +1038,27 @@ static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr) s->noisegen_seed = seed; } +/** Write the audio data into the output buffer. */ -/** Apply the channel matrices in turn to reconstruct the original audio - * samples. */ - -static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) +static int output_data(MLPDecodeContext *m, unsigned int substr, + AVFrame *frame, int *got_frame_ptr) { +AVCodecContext *avctx = m->avctx; SubStream *s = &m->substream[substr]; unsigned int mat; unsigned int maxchan; +int ret; +int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); + +if (m->avctx->channels != s->max_matrix_channel + 1) { +av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n"); +return AVERROR_INVALIDDATA; +} + +if (!s->blockpos) { +av_log(avctx, AV_LOG_ERROR, "No samples to output.\n"); +return AVERROR_INVALIDDATA; +} maxchan = s->max_matrix_channel; if (!s->noise_type) { @@ -1056,6 +1068,8 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) fill_noise_buffer(m, substr); } +/* Apply the channel matrices in turn to reconstruct the original audio + * samples. */ for (mat = 0; mat < s->num_primitive_matrices; mat++) { unsigned int dest_ch = s->matrix_out_ch[mat]; m->dsp.mlp_rematrix_channel(&m->sample_buffer[0][0], @@ -1070,27 +1084,6 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) m->access_unit_size_pow2, MSB_MASK(s->quant_step_size[dest_ch])); } -} - -/** Write the audio data into the output buffer. */ - -static int output_data(MLPDecodeContext *m, unsigned int substr, - AVFrame *frame, int *got_frame_ptr) -{ -AVCodecContext *avctx = m->avctx; -SubStream *s = &m->substream[substr]; -int ret; -int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); - -if (m->avctx->channels != s->max_matrix_channel + 1) { -av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n"); -return AVERROR_INVALIDDATA; -} - -if (!s->blockpos) { -av_log(avctx, AV_LOG_ERROR, "No samples to output.\n"); -return AVERROR_INVALIDDATA; -} /* get output buffer */ frame->nb_samples = s->blockpos; @@ -1298,8 +1291,6 @@ next_substr: buf += substream_data_len[substr]; } -rematrix_channels(m, m->max_decoded_substream); - if ((ret = output_data(m, m->max_decoded_substream, data, got_frame_ptr)) < 0) return ret; -- 1.8.5.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] x86/mlpdec: add ff_mlp_rematrix_channel_{sse4, avx2}
2x to 2.5x faster than the C version. Signed-off-by: James Almer --- libavcodec/mlpdec.c| 4 +- libavcodec/x86/Makefile| 6 +- libavcodec/x86/mlpdsp.asm | 198 + libavcodec/x86/{mlpdsp.c => mlpdsp_init.c} | 22 +++- 4 files changed, 225 insertions(+), 5 deletions(-) create mode 100644 libavcodec/x86/mlpdsp.asm rename libavcodec/x86/{mlpdsp.c => mlpdsp_init.c} (86%) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 2c5426c..d26c277 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -105,7 +105,7 @@ typedef struct SubStream { /// Whether the LSBs of the matrix output are encoded in the bitstream. uint8_t lsb_bypass[MAX_MATRICES]; /// Matrix coefficients, stored as 2.14 fixed point. -int32_t matrix_coeff[MAX_MATRICES][MAX_CHANNELS]; +DECLARE_ALIGNED(32, int32_t, matrix_coeff)[MAX_MATRICES][MAX_CHANNELS]; /// Left shift to apply to noise values in 0x31eb substreams. uint8_t matrix_noise_shift[MAX_MATRICES]; //@} @@ -159,7 +159,7 @@ typedef struct MLPDecodeContext { int8_t noise_buffer[MAX_BLOCKSIZE_POW2]; int8_t bypassed_lsbs[MAX_BLOCKSIZE][MAX_CHANNELS]; -int32_t sample_buffer[MAX_BLOCKSIZE][MAX_CHANNELS]; +DECLARE_ALIGNED(32, int32_t, sample_buffer)[MAX_BLOCKSIZE][MAX_CHANNELS]; MLPDSPContext dsp; } MLPDecodeContext; diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 9f34abd..2fa56b9 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -41,7 +41,7 @@ OBJS-$(CONFIG_CAVS_DECODER)+= x86/cavsdsp.o OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc_init.o OBJS-$(CONFIG_HEVC_DECODER)+= x86/hevcdsp_init.o -OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp.o +OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp_init.o OBJS-$(CONFIG_MPEG4_DECODER) += x86/xvididct_init.o OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp_init.o OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o @@ -52,7 +52,7 @@ OBJS-$(CONFIG_RV40_DECODER)+= x86/rv34dsp_init.o \ OBJS-$(CONFIG_SVQ1_ENCODER)+= x86/svq1enc_init.o OBJS-$(CONFIG_V210_DECODER)+= x86/v210-init.o OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp_init.o -OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o +OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp_init.o OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_init.o OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp_init.o OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp_init.o @@ -132,6 +132,7 @@ YASM-OBJS-$(CONFIG_HEVC_DECODER) += x86/hevc_mc.o \ x86/hevc_deblock.o\ x86/hevc_idct.o \ x86/hevc_res_add.o +YASM-OBJS-$(CONFIG_MLP_DECODER)+= x86/mlpdsp.o YASM-OBJS-$(CONFIG_PNG_DECODER)+= x86/pngdsp.o YASM-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp.o YASM-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp.o @@ -139,6 +140,7 @@ YASM-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp.o YASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp.o \ x86/rv40dsp.o YASM-OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc.o +YASM-OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o YASM-OBJS-$(CONFIG_TTA_DECODER)+= x86/ttadsp.o YASM-OBJS-$(CONFIG_V210_DECODER) += x86/v210.o YASM-OBJS-$(CONFIG_VC1_DECODER)+= x86/vc1dsp.o diff --git a/libavcodec/x86/mlpdsp.asm b/libavcodec/x86/mlpdsp.asm new file mode 100644 index 000..c2b53a7 --- /dev/null +++ b/libavcodec/x86/mlpdsp.asm @@ -0,0 +1,198 @@ +;** +;* SIMD-optimized MLP DSP functions +;* Copyright (c) 2014 James Almer +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg 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. +;* +;* FFmpeg 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 FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;** + +%include "libavutil/x86/x86util.asm" + +S
Re: [FFmpeg-devel] [RFC] Direct Stream Transfer (DST) decoder
On Tue, Sep 30, 2014 at 11:42:20PM +1000, Peter Ross wrote: > +/** > + * Calculate FS44 ratio > + */ > +#define DSD_FS44(sample_rate) (sample_rate / 44100) > + > +/** > + * Calculate DST frame size > + * @return samples per frame (1-bit samples) > + */ > +#define DST_SAMPLES_PER_FRAME(sample_rate) (588 * DSD_FS44(sample_rate)) A header for just these seems a bit overkill. Also I'd prefer static inline functions over macros when there is no reason to use macros. > +static int read_map(GetBitContext *gb, Table *t, unsigned int > map[DST_MAX_CHANNELS], int channels) > +{ > +int ch; > +t->elements = 1; > +if (!get_bits1(gb)){ > +map[0] = 0; > +for (ch = 1; ch < channels; ch++) { > +int bits = av_log2(t->elements) + 1; > +map[ch] = get_bits(gb, bits); > +if (map[ch] == t->elements) { > +t->elements++; > +if (t->elements >= DST_MAX_ELEMENTS) > +return AVERROR_INVALIDDATA; > +} else if (map[ch] > t->elements) { > +return AVERROR_INVALIDDATA; > +} > +} > +} else { > +memset(map, 0, sizeof(*map) * DST_MAX_CHANNELS); > +} Maybe I just don't understand how this should be used (in that case a comment would be nice), but I find it suspicious that the if part initializes channels elements while the else part does initialize DST_MAX_CHANNELS elements. Personally I also prefer to have one-liners always in the "if" branch. > +static av_always_inline int get_sr_golomb_dst(GetBitContext *gb, unsigned > int k) > +{ > +#if 0 > +/* 'run_length' upper bound is not specified; we can never be sure it > will fit into get_bits cache */ > +int v = get_ur_golomb(gb, k, INT_MAX, 0); The code is too hard to read for the time of day (a comment on those different golomb variants sure would help), but sure that get_ur_golomb_shorten doesn't happen to do what you need? > +if (x >= 0) > +c -= (x + 4) / 8; > +else > +c += (-x + 3) / 8; Uh, isn't this actually c -= (x + 4) >> 3; ? > +static uint8_t prob_dst_x_bit(int c) > +{ > +return (ff_reverse[c & 127] >> 1) + 1; > +} Since this seems to be in the inner loop, making your own table might be worth it... > +static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const > Table *fsets) > +{ > +int i, j, k, l; > +for (i = 0; i < fsets->elements; i++) { > +int length = fsets->length[i]; > +for (j = 0; j < 16; j++) { > +int total = FFMAX(0, FFMIN(length - j * 8, 8)); av_clip? > +for (k = 0; k < 256; k++) { > +int v = 0; > +for (l = 0; l < total; l++) > +v += (((k >> l) & 1) * 2 - 1) * fsets->coeff[i][j * 8 + > l]; Is this faster in a relevant way than something more readable like coeff = fsets->coeff[i][j * 8 + l]; v += k & (1 << l) ? coeff : -coeff; ? > +unsigned int half_prob[DST_MAX_CHANNELS]; > +unsigned int map_ch_to_felem[DST_MAX_CHANNELS]; > +unsigned int map_ch_to_pelem[DST_MAX_CHANNELS]; > +DECLARE_ALIGNED(16, uint8_t, status)[DST_MAX_CHANNELS][16]; > +DECLARE_ALIGNED(16, int16_t, filter)[DST_MAX_ELEMENTS][16][256]; At least the last one is quite large I think. Please consider putting it in the context or so instead. That's also less problematic with alignment. > +if (!(avpkt->data[0] & 1)) { > +if (frame->nb_samples > avpkt->size - 1) > +av_log(avctx, AV_LOG_WARNING, "short frame"); > +memcpy(frame->data[0], avpkt->data + 1, FFMIN(frame->nb_samples * > avctx->channels, avpkt->size - 1)); Hm, shouldn't there be a check for avpkt->size > 0 somewhere first? > +if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0) > +if ((ret = read_map(&gb, &fsets, map_ch_to_felem, avctx->channels)) < 0) > +if ((ret = read_map(&gb, &probs, map_ch_to_pelem, avctx->channels)) > < 0) I still think putting assignments into an if is really bad idea all around. > +if (same) { > +probs.elements = fsets.elements; > +memcpy(map_ch_to_pelem, map_ch_to_felem, sizeof(map_ch_to_felem)); > +} else { > +avpriv_request_sample(avctx, "Same_Mapping=0"); > +return ret; > +} Simpler as > if (!same) { > avpriv_request_sample(avctx, "Same_Mapping=0"); > return ret; > } and no else. Also, paranoia: for memcpy preferably use sizeof(dst) over sizeof(src), the effects are less bad if it goes wrong. > +uint64_t * s = (uint64_t*)status[ch]; That looks like a strict aliasing violation. > +v = ((predict >> 15) ^ residual) & 1; > +frame->data[0][ (i >> 3) * avctx->channels + ch] |= v << (7 > - (i & 0x7 )); > + > +#if HAVE_BIGENDIAN > +/* FIXME: not tested */ > +s[0] = (s[0] << 1) | ((s[1] >> 63) & 1); > +
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add avcodec_register_one() to register one codec/parser/bsf/hwaccel by its char* name
On Tue, Sep 30, 2014 at 05:21:20PM +0200, Michael Niedermayer wrote: > > with no > > global mutable state. > > i disagree, applications that care about security must > restrict used entities globally, thus by definition want to change > global state. maybe not the way its done in this patch yes, ill > think about it and submit something better but > A security critical application does not want a mysterious unknown > library to load and use a unrestricted libavcodec behind its back > that would likely bypass the whole idea of restricting the decoders > and demuxers In that case I would think you'd at very least want to completely thrash the description structs of all demuxers and decoders you do not want to use. Or at the very least overwrite the function pointers with 0s, trashing flags might slightly decrease security I guess. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] x86/mlpdec: add ff_mlp_rematrix_channel_{sse4, avx2}
On 30/09/14 3:50 PM, James Almer wrote: > av_cold void ff_mlpdsp_init_x86(MLPDSPContext *c) > { > -#if HAVE_7REGS && HAVE_INLINE_ASM && HAVE_INLINE_ASM_NONLOCAL_LABELS > int cpu_flags = av_get_cpu_flags(); > +#if HAVE_7REGS && HAVE_INLINE_ASM && HAVE_INLINE_ASM_NONLOCAL_LABELS > if (INLINE_MMX(cpu_flags)) > c->mlp_filter_channel = mlp_filter_channel_x86; > #endif > +if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags)) > +c->mlp_rematrix_channel = ff_mlp_rematrix_channel_sse4; > +if (ARCH_X86_64 && EXTERNAL_AVX2(cpu_flags) && cpu_flags & > AV_CPU_FLAG_BMI2) > +c->mlp_rematrix_channel = ff_mlp_rematrix_channel_avx2_bmi2; > } I didn't write an x86_32 version because seven gprs for a function like this would need more work (what with eleven parameters, accum being 64 bits, etc). I may give it a go later if i feel in the mood, but if someone else wants to do it instead then that'd be great. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add avcodec_register_list() to register a list of codec/parser/bsf/hwaccel
On Tue, Sep 30, 2014 at 07:41:08PM +0200, Michael Niedermayer wrote: > + * @param list ',' seperated list of entities to register, the list used must > + * have a sufficient lifetime so future calls to > avcodec_register_list() > + * can access it for comparission. I think you can avoid that requirement if you follow my suggestion of trashing the descriptions. I kind of dislike that that would however kind of "forever" force use to keep the descriptions in .data instead of having them in .rodata where they should be also for (minor) security considerations. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Reset mutex to NULL after mutex destruction.
On Mon, Sep 29, 2014 at 09:57:02PM -0700, Manfred Georg wrote: > Answers inline. > > On Mon, Sep 29, 2014 at 7:07 PM, Michael Niedermayer > wrote: > > > On Mon, Sep 29, 2014 at 02:41:38PM -0700, Manfred Georg wrote: > > > A badly behaving user provided mutex manager (such as that in OpenCV) > > may not reset the mutex to NULL on destruction. This can cause a problem > > for a later mutex manager (which may assert that the mutex is NULL before > > creating). > > > --- > > > libavcodec/utils.c | 15 +-- > > > 1 file changed, 9 insertions(+), 6 deletions(-) > > > > > > diff --git a/libavcodec/utils.c b/libavcodec/utils.c > > > index 9eb2b5b..a1f7cfc 100644 > > > --- a/libavcodec/utils.c > > > +++ b/libavcodec/utils.c > > > @@ -3457,18 +3457,21 @@ AVHWAccel *av_hwaccel_next(const AVHWAccel > > *hwaccel) > > > int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) > > > { > > > if (lockmgr_cb) { > > > -if (lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) > > > -return -1; > > > -if (lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY)) > > > +void *old_codec_mutex = codec_mutex; > > > +void *old_avformat_mutex = avformat_mutex; > > > +int failure; > > > +codec_mutex = NULL; > > > +avformat_mutex = NULL; > > > +failure = lockmgr_cb(&old_codec_mutex, AV_LOCK_DESTROY); > > > +if (lockmgr_cb(&old_avformat_mutex, AV_LOCK_DESTROY) || failure) > > > return -1; > > > > why do you use temporary variables ? > > wouldnt simply setting them to NULL afterwards achieve the same ? > > > > The behavior on failure wouldn't be the same. In the original code the i meant this: failure = lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY); failure |= lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY); codec_mutex = NULL; avformat_mutex = NULL; if (failure) return -1; > second call is never made if the first one fails. I feel like this > implementation is at least a bit more symmetric. Really, we'd want to > define some sane semantics on failure (both for this function and the lock > manager function provided by the user) and specify what happens in the > function comment in the header (without that we could argue in circles for > hours about which implementation is less incorrect), but that seemed out of > scope for this change. > > > > > > > } > > > > > > lockmgr_cb = cb; > > > > > > if (lockmgr_cb) { > > > -if (lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) > > > -return -1; > > > -if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE)) > > > +int failure = lockmgr_cb(&codec_mutex, AV_LOCK_CREATE); > > > +if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE) || failure) > > > return -1; > > > > why, when the creation of the first lock manager fails you try to > > create the 2nd one ? > > > > isnt it more logic to leave the state as it was before the call on > > failure, instead of trying to half initialize things ? > > that would also require to first create the 2 new lock managers > > and then when both succeeded destroy the old > > though thats orthogonal to the stated intend of teh patch and > > should, if done, probably be in a seperate patch > > > > > As far as I know, it is never specified what state the lock manager > function should leave things in on failure. You may assume that failure > means a mutex wasn't created while I may assume that it may have been > anyway. This implementation seemed less likely to leave things in a bad > state given that we don't know what the lock manager function is actually > doing. At least both mutex will have had the same thing done on > them...hopefully...probably. hopefully...probably ? also before the patch failure means either both locks havnt been created or the 2nd hasnt been after the patch a failure means either both locks havnt been created or the 1st or the 2nd hasnt been maybe its just me but i think its better to have the locks in a deterministic state on failure [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] IRC meeting
On Mon, 29 Sep 2014 17:39:23 +0200, Stefano Sabatini wrote: > Hi, > > I want to propose to have an FFmpeg IRC meeting the next Saturday, 4th > October, UTC 16. Alternatively, I propose the Saturday of the next > week, Saturday October 11, same time. I can most likely show up on Oct 4. I'll be unavailable on Oct 11 if we choose that date, but don't consider me to be blocking whatever date is preferred by others. Lou ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/aviobuf: fix avio_flush() for read streams
On Tue, Sep 30, 2014 at 06:46:48PM +0200, wm4 wrote: > avio_flush() did nothing useful for read streams. Fix it to behave as > expected, and discard the currently read buffer properly. > --- > In addition to v1, also make sure that avio_flush() never enters the > write path with read streams. This wasn't ensured before. avio_close() > calls avio_flush() unconditionally, so this might even fix a bug. > --- > libavformat/avio.h| 8 ++-- > libavformat/aviobuf.c | 4 +++- > 2 files changed, 9 insertions(+), 3 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat: add avformat_flush()
On Tue, 30 Sep 2014 08:06:16 +0200 Reimar Döffinger wrote: > On 29.09.2014, at 22:02, Michael Niedermayer wrote: > > On Mon, Sep 29, 2014 at 08:34:44PM +0200, wm4 wrote: > >> On Mon, 29 Sep 2014 20:25:47 +0200 > >> Michael Niedermayer wrote: > >> > >>> On Mon, Sep 29, 2014 at 07:41:28PM +0200, wm4 wrote: > Useful for Bluray and DVD, since the libraries used to read them just > change the byte stream under your feet on seeking. > > Maybe there should be a AVInputFormat callback for this. But the > mpeg-ps (DVD) and the mpeg-ts (Bluray) demuxers don't change much > state during seeking - they just try to find a new packet with > timestamps (in read_timestamp), so I haven't found a need for this > yet. I don't want to add unused things. > > I've also thought about adding a flush callback, and implementing > them in mpeg.c and mpegts.c by just calling ff_read_frame_flush(). > Might be slightly better, because you can have avformat_flush() fail > on formats which don't support this? > > Or maybe a flag? > > TODO: add entry to APIchanges, bump minor version. > --- > libavformat/avformat.h | 13 + > libavformat/utils.c| 6 ++ > 2 files changed, 19 insertions(+) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 78054de..eaa52fa 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -2173,6 +2173,19 @@ int av_seek_frame(AVFormatContext *s, int > stream_index, int64_t timestamp, > int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t > min_ts, int64_t ts, int64_t max_ts, int flags); > > /** > + * Discard all internally buffered data. This can be useful when > dealing with > + * discontinuities in the byte stream. Generally works only with some > simple > + * formats. > >>> > >>> id call them stream based or without a central header instead of > >>> simple. > >> > >> I can change that and replace "simple" with "headerless". > > > > please do, headerless is more specific > > Why does it require headerless? > I would have expected this feature to work for e.g. Ogg as well, which > clearly is not headerless. > As such I'd claim headerless may be more specific, but it is also wrong. > It should work for all formats that can be read without index and can resync > reliably at least. Do you have any concrete suggestions? I'm not sure what documentation would be most appropriate. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] avcodec: add codec_whitelist
This allows restricting decoders to a list of needed ones for improved security Signed-off-by: Michael Niedermayer --- libavcodec/avcodec.h |8 libavcodec/options_table.h |1 + libavcodec/utils.c |6 ++ 3 files changed, 15 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 94e82f7..608de9c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3083,6 +3083,14 @@ typedef struct AVCodecContext { * - decoding: unused. */ uint16_t *chroma_intra_matrix; + +/** + * ',' seperated list of allowed decoders. + * If NULL then all are allowed + * - encoding: unused + * - decoding: set by user through AVOPtions (NO direct access) + */ +char *codec_whitelist; } AVCodecContext; AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index ad3d52e..ae217e5 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -468,6 +468,7 @@ static const AVOption avcodec_options[] = { {"bb", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_BB }, 0, 0, V|D|E, "field_order" }, {"tb", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_TB }, 0, 0, V|D|E, "field_order" }, {"bt", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_BT }, 0, 0, V|D|E, "field_order" }, +{"codec_whitelist", "List of decoders that are allowed to be used", OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D }, {NULL}, }; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9eb2b5b..f715f27 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1381,6 +1381,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) goto free_and_end; +if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) { +av_log(avctx, AV_LOG_ERROR, "Codec not on whitelist\n"); +ret = AVERROR(EINVAL); +goto free_and_end; +} + // only call ff_set_dimensions() for non H.264/VP6F codecs so as not to overwrite previously setup dimensions if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F))) { -- 1.7.9.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] avformat: Add format_whitelist
This allows restricting demuxers to a list of needed ones for improved security Note, some demuxers themselfs open other demuxers, these are only restricted if AVOptions are forwarded to them. Please check that your code does that. Signed-off-by: Michael Niedermayer --- libavformat/avformat.h | 16 libavformat/options_table.h |2 ++ libavformat/utils.c | 17 + 3 files changed, 35 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 78054de..875a1bd 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1584,6 +1584,22 @@ typedef struct AVFormatContext { */ int format_probesize; +/** + * ',' seperated list of allowed decoders. + * If NULL then all are allowed + * - encoding: unused + * - decoding: set by user through AVOPtions (NO direct access) + */ +char *codec_whitelist; + +/** + * ',' seperated list of allowed demuxers. + * If NULL then all are allowed + * - encoding: unused + * - decoding: set by user through AVOPtions (NO direct access) + */ +char *format_whitelist; + /* * All fields below this line are not part of the public API. They * may not be used outside of libavformat and can be changed and diff --git a/libavformat/options_table.h b/libavformat/options_table.h index eb4115c..b08e93a 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -95,6 +95,8 @@ static const AVOption avformat_options[] = { {"normal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_NORMAL }, INT_MIN, INT_MAX, D|E, "strict"}, {"experimental", "allow non-standardized experimental variants", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, D|E, "strict"}, {"max_ts_probe", "maximum number of packets to read while waiting for the first timestamp", OFFSET(max_ts_probe), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, INT_MAX, D }, +{"codec_whitelist", "List of decoders that are allowed to be used", OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D }, +{"format_whitelist", "List of demuxers that are allowed to be used", OFFSET(format_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D }, {NULL}, }; diff --git a/libavformat/utils.c b/libavformat/utils.c index 0fd1568..368e050 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -291,6 +291,11 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, int av_demuxer_open(AVFormatContext *ic) { int err; +if (ic->format_whitelist && av_match_list(ic->iformat->name, ic->format_whitelist, ',') <= 0) { +av_log(ic, AV_LOG_ERROR, "Format not on whitelist\n"); +return AVERROR(EINVAL); +} + if (ic->iformat->read_header) { err = ic->iformat->read_header(ic); if (err < 0) @@ -402,6 +407,13 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, if ((ret = init_input(s, filename, &tmp)) < 0) goto fail; s->probe_score = ret; + +if (s->format_whitelist && av_match_list(s->iformat->name, s->format_whitelist, ',') <= 0) { +av_log(s, AV_LOG_ERROR, "Format not on whitelist\n"); +ret = AVERROR(EINVAL); +goto fail; +} + avio_skip(s->pb, s->skip_initial_bytes); /* Check filename in case an image number is expected. */ @@ -2576,6 +2588,8 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt, /* Force thread count to 1 since the H.264 decoder will not extract * SPS and PPS to extradata during multi-threaded decoding. */ av_dict_set(options ? options : &thread_opt, "threads", "1", 0); +if (s->codec_whitelist) +av_dict_set(options ? options : &thread_opt, "codec_whitelist", s->codec_whitelist, 0); ret = avcodec_open2(st->codec, codec, options ? options : &thread_opt); if (!options) av_dict_free(&thread_opt); @@ -3016,6 +3030,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) * SPS and PPS to extradata during multi-threaded decoding. */ av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0); +if (ic->codec_whitelist) +av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0); + /* Ensure that subtitle_header is properly set. */ if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && codec && !st->codec->codec) { -- 1.7.9.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Reset mutex to NULL after mutex destruction.
I took a crack at the more general change (it will be arriving shortly). It's split into two patches, the first is a simplified version of this change and the second patch more strongly defines the behavior on failure of both the user supplied function and av_lockmgr_register. Please consider this patch dead. Manfred On Tue, Sep 30, 2014 at 12:13 PM, Michael Niedermayer wrote: > On Mon, Sep 29, 2014 at 09:57:02PM -0700, Manfred Georg wrote: > > Answers inline. > > > > On Mon, Sep 29, 2014 at 7:07 PM, Michael Niedermayer > > wrote: > > > > > On Mon, Sep 29, 2014 at 02:41:38PM -0700, Manfred Georg wrote: > > > > A badly behaving user provided mutex manager (such as that in OpenCV) > > > may not reset the mutex to NULL on destruction. This can cause a > problem > > > for a later mutex manager (which may assert that the mutex is NULL > before > > > creating). > > > > --- > > > > libavcodec/utils.c | 15 +-- > > > > 1 file changed, 9 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/libavcodec/utils.c b/libavcodec/utils.c > > > > index 9eb2b5b..a1f7cfc 100644 > > > > --- a/libavcodec/utils.c > > > > +++ b/libavcodec/utils.c > > > > @@ -3457,18 +3457,21 @@ AVHWAccel *av_hwaccel_next(const AVHWAccel > > > *hwaccel) > > > > int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) > > > > { > > > > if (lockmgr_cb) { > > > > -if (lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) > > > > -return -1; > > > > -if (lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY)) > > > > +void *old_codec_mutex = codec_mutex; > > > > +void *old_avformat_mutex = avformat_mutex; > > > > +int failure; > > > > +codec_mutex = NULL; > > > > +avformat_mutex = NULL; > > > > +failure = lockmgr_cb(&old_codec_mutex, AV_LOCK_DESTROY); > > > > +if (lockmgr_cb(&old_avformat_mutex, AV_LOCK_DESTROY) || > failure) > > > > return -1; > > > > > > why do you use temporary variables ? > > > wouldnt simply setting them to NULL afterwards achieve the same ? > > > > > > The behavior on failure wouldn't be the same. In the original code the > > i meant this: > > failure = lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY); > failure |= lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY); > codec_mutex = NULL; > avformat_mutex = NULL; > if (failure) > return -1; > > > > second call is never made if the first one fails. I feel like this > > implementation is at least a bit more symmetric. Really, we'd want to > > define some sane semantics on failure (both for this function and the > lock > > manager function provided by the user) and specify what happens in the > > function comment in the header (without that we could argue in circles > for > > hours about which implementation is less incorrect), but that seemed out > of > > scope for this change. > > > > > > > > > > > } > > > > > > > > lockmgr_cb = cb; > > > > > > > > if (lockmgr_cb) { > > > > -if (lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) > > > > -return -1; > > > > -if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE)) > > > > +int failure = lockmgr_cb(&codec_mutex, AV_LOCK_CREATE); > > > > +if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE) || failure) > > > > return -1; > > > > > > why, when the creation of the first lock manager fails you try to > > > create the 2nd one ? > > > > > > isnt it more logic to leave the state as it was before the call on > > > failure, instead of trying to half initialize things ? > > > that would also require to first create the 2 new lock managers > > > and then when both succeeded destroy the old > > > though thats orthogonal to the stated intend of teh patch and > > > should, if done, probably be in a seperate patch > > > > > > > > As far as I know, it is never specified what state the lock manager > > function should leave things in on failure. You may assume that failure > > means a mutex wasn't created while I may assume that it may have been > > anyway. This implementation seemed less likely to leave things in a bad > > state given that we don't know what the lock manager function is actually > > doing. At least both mutex will have had the same thing done on > > them...hopefully...probably. > > hopefully...probably ? > > also before the patch failure means either both locks havnt been > created or the 2nd hasnt been > > after the patch a failure means either both locks havnt been > created or the 1st or the 2nd hasnt been > > maybe its just me but i think its better to have the locks in a > deterministic state on failure > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > it is not once nor twice but times without number that the same ideas make > their appearance in the world. -- Aristotle > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-deve
Re: [FFmpeg-devel] [PATCH 2/2] avformat: Add format_whitelist
On Tue, 30 Sep 2014 23:33:51 +0200 Michael Niedermayer wrote: > This allows restricting demuxers to a list of needed ones for improved > security > Note, some demuxers themselfs open other demuxers, these are only restricted > if > AVOptions are forwarded to them. Please check that your code does that. > > Signed-off-by: Michael Niedermayer > --- > libavformat/avformat.h | 16 > libavformat/options_table.h |2 ++ > libavformat/utils.c | 17 + > 3 files changed, 35 insertions(+) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 78054de..875a1bd 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -1584,6 +1584,22 @@ typedef struct AVFormatContext { > */ > int format_probesize; > > +/** > + * ',' seperated list of allowed decoders. > + * If NULL then all are allowed > + * - encoding: unused > + * - decoding: set by user through AVOPtions (NO direct access) > + */ > +char *codec_whitelist; > + > +/** > + * ',' seperated list of allowed demuxers. > + * If NULL then all are allowed > + * - encoding: unused > + * - decoding: set by user through AVOPtions (NO direct access) > + */ > +char *format_whitelist; > + > /* > * All fields below this line are not part of the public API. They > * may not be used outside of libavformat and can be changed and > diff --git a/libavformat/options_table.h b/libavformat/options_table.h > index eb4115c..b08e93a 100644 > --- a/libavformat/options_table.h > +++ b/libavformat/options_table.h > @@ -95,6 +95,8 @@ static const AVOption avformat_options[] = { > {"normal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_NORMAL }, > INT_MIN, INT_MAX, D|E, "strict"}, > {"experimental", "allow non-standardized experimental variants", 0, > AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, > D|E, "strict"}, > {"max_ts_probe", "maximum number of packets to read while waiting for the > first timestamp", OFFSET(max_ts_probe), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, > INT_MAX, D }, > +{"codec_whitelist", "List of decoders that are allowed to be used", > OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, > CHAR_MAX, D }, > +{"format_whitelist", "List of demuxers that are allowed to be used", > OFFSET(format_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, > CHAR_MAX, D }, > {NULL}, > }; > > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 0fd1568..368e050 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -291,6 +291,11 @@ static int set_codec_from_probe_data(AVFormatContext *s, > AVStream *st, > int av_demuxer_open(AVFormatContext *ic) { > int err; > > +if (ic->format_whitelist && av_match_list(ic->iformat->name, > ic->format_whitelist, ',') <= 0) { > +av_log(ic, AV_LOG_ERROR, "Format not on whitelist\n"); > +return AVERROR(EINVAL); > +} > + > if (ic->iformat->read_header) { > err = ic->iformat->read_header(ic); > if (err < 0) > @@ -402,6 +407,13 @@ int avformat_open_input(AVFormatContext **ps, const char > *filename, > if ((ret = init_input(s, filename, &tmp)) < 0) > goto fail; > s->probe_score = ret; > + > +if (s->format_whitelist && av_match_list(s->iformat->name, > s->format_whitelist, ',') <= 0) { > +av_log(s, AV_LOG_ERROR, "Format not on whitelist\n"); > +ret = AVERROR(EINVAL); > +goto fail; > +} > + > avio_skip(s->pb, s->skip_initial_bytes); > > /* Check filename in case an image number is expected. */ > @@ -2576,6 +2588,8 @@ static int try_decode_frame(AVFormatContext *s, > AVStream *st, AVPacket *avpkt, > /* Force thread count to 1 since the H.264 decoder will not extract > * SPS and PPS to extradata during multi-threaded decoding. */ > av_dict_set(options ? options : &thread_opt, "threads", "1", 0); > +if (s->codec_whitelist) > +av_dict_set(options ? options : &thread_opt, "codec_whitelist", > s->codec_whitelist, 0); > ret = avcodec_open2(st->codec, codec, options ? options : > &thread_opt); > if (!options) > av_dict_free(&thread_opt); > @@ -3016,6 +3030,9 @@ int avformat_find_stream_info(AVFormatContext *ic, > AVDictionary **options) > * SPS and PPS to extradata during multi-threaded decoding. */ > av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0); > > +if (ic->codec_whitelist) > +av_dict_set(options ? &options[i] : &thread_opt, > "codec_whitelist", ic->codec_whitelist, 0); > + > /* Ensure that subtitle_header is properly set. */ > if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE > && codec && !st->codec->codec) { This doesn't suffer from glo
Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add avcodec_register_list() to register a list of codec/parser/bsf/hwaccel
On Tue, Sep 30, 2014 at 09:07:43PM +0200, Reimar Döffinger wrote: > On Tue, Sep 30, 2014 at 07:41:08PM +0200, Michael Niedermayer wrote: > > + * @param list ',' seperated list of entities to register, the list used > > must > > + * have a sufficient lifetime so future calls to > > avcodec_register_list() > > + * can access it for comparission. > > I think you can avoid that requirement if you follow my suggestion of > trashing the descriptions. > I kind of dislike that that would however kind of "forever" force use to > keep the descriptions in .data instead of having them in .rodata where > they should be also for (minor) security considerations. I think its better we dont trash the AVCodec structs at least not without a very good reason [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat: Add format_whitelist
On Wed, Oct 01, 2014 at 12:12:43AM +0200, wm4 wrote: > On Tue, 30 Sep 2014 23:33:51 +0200 > Michael Niedermayer wrote: > > > This allows restricting demuxers to a list of needed ones for improved > > security > > Note, some demuxers themselfs open other demuxers, these are only > > restricted if > > AVOptions are forwarded to them. Please check that your code does that. > > > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/avformat.h | 16 > > libavformat/options_table.h |2 ++ > > libavformat/utils.c | 17 + > > 3 files changed, 35 insertions(+) > > > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > > index 78054de..875a1bd 100644 > > --- a/libavformat/avformat.h > > +++ b/libavformat/avformat.h > > @@ -1584,6 +1584,22 @@ typedef struct AVFormatContext { > > */ > > int format_probesize; > > > > +/** > > + * ',' seperated list of allowed decoders. > > + * If NULL then all are allowed > > + * - encoding: unused > > + * - decoding: set by user through AVOPtions (NO direct access) > > + */ > > +char *codec_whitelist; > > + > > +/** > > + * ',' seperated list of allowed demuxers. > > + * If NULL then all are allowed > > + * - encoding: unused > > + * - decoding: set by user through AVOPtions (NO direct access) > > + */ > > +char *format_whitelist; > > + > > /* > > * All fields below this line are not part of the public API. They > > * may not be used outside of libavformat and can be changed and > > diff --git a/libavformat/options_table.h b/libavformat/options_table.h > > index eb4115c..b08e93a 100644 > > --- a/libavformat/options_table.h > > +++ b/libavformat/options_table.h > > @@ -95,6 +95,8 @@ static const AVOption avformat_options[] = { > > {"normal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_NORMAL }, > > INT_MIN, INT_MAX, D|E, "strict"}, > > {"experimental", "allow non-standardized experimental variants", 0, > > AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, > > D|E, "strict"}, > > {"max_ts_probe", "maximum number of packets to read while waiting for the > > first timestamp", OFFSET(max_ts_probe), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, > > INT_MAX, D }, > > +{"codec_whitelist", "List of decoders that are allowed to be used", > > OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, > > CHAR_MAX, D }, > > +{"format_whitelist", "List of demuxers that are allowed to be used", > > OFFSET(format_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, > > CHAR_MAX, D }, > > {NULL}, > > }; > > > > diff --git a/libavformat/utils.c b/libavformat/utils.c > > index 0fd1568..368e050 100644 > > --- a/libavformat/utils.c > > +++ b/libavformat/utils.c > > @@ -291,6 +291,11 @@ static int set_codec_from_probe_data(AVFormatContext > > *s, AVStream *st, > > int av_demuxer_open(AVFormatContext *ic) { > > int err; > > > > +if (ic->format_whitelist && av_match_list(ic->iformat->name, > > ic->format_whitelist, ',') <= 0) { > > +av_log(ic, AV_LOG_ERROR, "Format not on whitelist\n"); > > +return AVERROR(EINVAL); > > +} > > + > > if (ic->iformat->read_header) { > > err = ic->iformat->read_header(ic); > > if (err < 0) > > @@ -402,6 +407,13 @@ int avformat_open_input(AVFormatContext **ps, const > > char *filename, > > if ((ret = init_input(s, filename, &tmp)) < 0) > > goto fail; > > s->probe_score = ret; > > + > > +if (s->format_whitelist && av_match_list(s->iformat->name, > > s->format_whitelist, ',') <= 0) { > > +av_log(s, AV_LOG_ERROR, "Format not on whitelist\n"); > > +ret = AVERROR(EINVAL); > > +goto fail; > > +} > > + > > avio_skip(s->pb, s->skip_initial_bytes); > > > > /* Check filename in case an image number is expected. */ > > @@ -2576,6 +2588,8 @@ static int try_decode_frame(AVFormatContext *s, > > AVStream *st, AVPacket *avpkt, > > /* Force thread count to 1 since the H.264 decoder will not extract > > * SPS and PPS to extradata during multi-threaded decoding. */ > > av_dict_set(options ? options : &thread_opt, "threads", "1", 0); > > +if (s->codec_whitelist) > > +av_dict_set(options ? options : &thread_opt, > > "codec_whitelist", s->codec_whitelist, 0); > > ret = avcodec_open2(st->codec, codec, options ? options : > > &thread_opt); > > if (!options) > > av_dict_free(&thread_opt); > > @@ -3016,6 +3030,9 @@ int avformat_find_stream_info(AVFormatContext *ic, > > AVDictionary **options) > > * SPS and PPS to extradata during multi-threaded decoding. */ > > av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", > > 0); > > > > +if (ic->codec_whitelist) > > +av_dict
Re: [FFmpeg-devel] [PATCH 1/2] Force mutex to NULL after destruction.
On Tue, Sep 30, 2014 at 03:20:42PM -0700, Manfred Georg wrote: > A badly behaving user provided mutex manager (such as that in OpenCV) may not > reset the mutex to NULL on destruction. This can cause a problem for a later > mutex manager (which may assert that the mutex is NULL before creating). > --- > libavcodec/utils.c | 2 ++ > 1 file changed, 2 insertions(+) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When the tyrant has disposed of foreign enemies by conquest or treaty, and there is nothing more to fear from them, then he is always stirring up some war or other, in order that the people may require a leader. -- Plato signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] av_lockmgr_register defines behavior on failure.
On Tue, Sep 30, 2014 at 03:20:43PM -0700, Manfred Georg wrote: > The register function now specifies that the user callback should > leave things in the same state that it found them on failure but > that failure to destroy is ignored by ffmpeg. The register > function is also now explicit about its behavior on failure (it now > unregisters the previous callback and destroys all mutex). > --- > libavcodec/avcodec.h | 24 +++- > libavcodec/utils.c | 31 +-- > 2 files changed, 36 insertions(+), 19 deletions(-) > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 94e82f7..69e7012 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -5120,16 +5120,22 @@ enum AVLockOp { > > /** > * Register a user provided lock manager supporting the operations > - * specified by AVLockOp. mutex points to a (void *) where the > - * lockmgr should store/get a pointer to a user allocated mutex. It's > - * NULL upon AV_LOCK_CREATE and != NULL for all other ops. > - * > - * @param cb User defined callback. Note: FFmpeg may invoke calls to this > - * callback during the call to av_lockmgr_register(). > - * Thus, the application must be prepared to handle that. > + * specified by AVLockOp. The "mutex" argument to the function points > + * to a (void *) where the lockmgr should store/get a pointer to a user > + * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the > + * value left by the last call for all other ops. If the lock manager > + * is unable to perform the op then it should leave the mutex in the same > + * state as when it was called. However, when called with AV_LOCK_DESTROY > + * the mutex will always be assumed to have been successfully destroyed. > + * If av_lockmgr_register succeeds it will return 0, if it fails it will > + * return -1 and destroy all mutex and unregister all callbacks. generally ffmpeg uses negative for errors, so this shouldnt specifically use just -1. This allows providing richer error codes at any later point [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] x86/mpegvideoencdsp: improve ff_pix_sum16_sse2
~15 faster. Also add an mmxext version that takes advantage of the new code, and build it alongside with the mmx version only on x86_32. Signed-off-by: James Almer --- libavcodec/x86/mpegvideoencdsp.asm| 51 +++ libavcodec/x86/mpegvideoencdsp_init.c | 7 + 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/libavcodec/x86/mpegvideoencdsp.asm b/libavcodec/x86/mpegvideoencdsp.asm index 4fe6cfe..aec73f8 100644 --- a/libavcodec/x86/mpegvideoencdsp.asm +++ b/libavcodec/x86/mpegvideoencdsp.asm @@ -29,16 +29,16 @@ cextern pw_1 SECTION .text ; int ff_pix_sum16_mmx(uint8_t *pix, int line_size) -; %1 = number of xmm registers used -; %2 = number of loops -; %3 = number of GPRs used -%macro PIX_SUM16 4 -cglobal pix_sum16, 2, %3, %1 +; %1 = number of loops +; %2 = number of GPRs used +%macro PIX_SUM16 3 +cglobal pix_sum16, 2, %2, 6 movsxdifnidn r1, r1d -mov r2, %2 -%if cpuflag(xop) +mov r2, %1 +%if mmsize == 16 lea r3, [r1*3] -%else +%endif +%if notcpuflag(xop) pxor m5, m5 %endif pxor m4, m4 @@ -52,42 +52,59 @@ cglobal pix_sum16, 2, %3, %1 mova m0, [r0] %if mmsize == 8 mova m1, [r0+8] -%else +%if cpuflag(mmxext) +mova m2, [r0+r1] +mova m3, [r0+r1+8] +%endif +%else ; sse2 mova m1, [r0+r1] +mova m2, [r0+r1*2] +mova m3, [r0+r3] %endif +%if cpuflag(mmxext) +psadbw m0, m5 +psadbw m1, m5 +psadbw m2, m5 +psadbw m3, m5 +%else ; mmx punpckhbwm2, m0, m5 punpcklbwm0, m5 punpckhbwm3, m1, m5 punpcklbwm1, m5 +%endif ; cpuflag(mmxext) %endif ; cpuflag(xop) paddwm1, m0 paddwm3, m2 paddwm3, m1 paddwm4, m3 -%if mmsize == 8 -add r0, r1 +%if cpuflag(mmxext) +lea r0, [r0+r1*%3] %else -lea r0, [r0+r1*%4] +add r0, r1 %endif dec r2 jne .loop -%if cpuflag(xop) +%if mmsize == 16 pshufd m0, m4, q0032 padddm4, m0 -%else +%elif notcpuflag(mmxext) HADDWm4, m5 %endif movdeax, m4 RET %endmacro +%if ARCH_X86_32 INIT_MMX mmx -PIX_SUM16 0, 16, 3, 0 +PIX_SUM16 16, 3, 0 +INIT_MMX mmxext +PIX_SUM16 8, 4, 2 +%endif INIT_XMM sse2 -PIX_SUM16 6, 8, 3, 2 +PIX_SUM16 4, 4, 4 %if HAVE_XOP_EXTERNAL INIT_XMM xop -PIX_SUM16 5, 4, 4, 4 +PIX_SUM16 4, 4, 4 %endif ; int ff_pix_norm1_mmx(uint8_t *pix, int line_size) diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c index d91b902..2a4db61 100644 --- a/libavcodec/x86/mpegvideoencdsp_init.c +++ b/libavcodec/x86/mpegvideoencdsp_init.c @@ -24,6 +24,7 @@ #include "libavcodec/mpegvideoencdsp.h" int ff_pix_sum16_mmx(uint8_t *pix, int line_size); +int ff_pix_sum16_mmxext(uint8_t *pix, int line_size); int ff_pix_sum16_sse2(uint8_t *pix, int line_size); int ff_pix_sum16_xop(uint8_t *pix, int line_size); int ff_pix_norm1_mmx(uint8_t *pix, int line_size); @@ -218,11 +219,17 @@ av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, { int cpu_flags = av_get_cpu_flags(); +#if ARCH_X86_32 if (EXTERNAL_MMX(cpu_flags)) { c->pix_sum = ff_pix_sum16_mmx; c->pix_norm1 = ff_pix_norm1_mmx; } +if (EXTERNAL_MMXEXT(cpu_flags)) { +c->pix_sum = ff_pix_sum16_mmxext; +} +#endif + if (EXTERNAL_SSE2(cpu_flags)) { c->pix_sum = ff_pix_sum16_sse2; c->pix_norm1 = ff_pix_norm1_sse2; -- 1.8.5.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] av_lockmgr_register defines behavior on failure.
Sure, I've made the change to the comment within my local code. I'm sorry, but I'm not familiar with FFmpeg development cycle: how would you like me to post it? 1) A patch on top of the patch that is already in this thread (i.e. something that will be squished into this patch). 2) A new patch in a new thread. 3) A new patch in this thread. 4) Something else. Although I kind of doubt that's what you want, here is method (1): Subject: [PATCH] Say av_lockmgr_register returns non-zero on error. --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 69e7012..2899ba0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5128,7 +5128,7 @@ enum AVLockOp { * state as when it was called. However, when called with AV_LOCK_DESTROY * the mutex will always be assumed to have been successfully destroyed. * If av_lockmgr_register succeeds it will return 0, if it fails it will - * return -1 and destroy all mutex and unregister all callbacks. + * return non-zero and destroy all mutex and unregister all callbacks. * * @param cb User defined callback. FFmpeg invokes calls to this * callback and the previously registered callback during the -- 2.1.0.rc2.206.gedb03e5 Manfred On Tue, Sep 30, 2014 at 4:02 PM, Michael Niedermayer wrote: > On Tue, Sep 30, 2014 at 03:20:43PM -0700, Manfred Georg wrote: > > The register function now specifies that the user callback should > > leave things in the same state that it found them on failure but > > that failure to destroy is ignored by ffmpeg. The register > > function is also now explicit about its behavior on failure (it now > > unregisters the previous callback and destroys all mutex). > > --- > > libavcodec/avcodec.h | 24 +++- > > libavcodec/utils.c | 31 +-- > > 2 files changed, 36 insertions(+), 19 deletions(-) > > > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > > index 94e82f7..69e7012 100644 > > --- a/libavcodec/avcodec.h > > +++ b/libavcodec/avcodec.h > > @@ -5120,16 +5120,22 @@ enum AVLockOp { > > > > /** > > * Register a user provided lock manager supporting the operations > > - * specified by AVLockOp. mutex points to a (void *) where the > > - * lockmgr should store/get a pointer to a user allocated mutex. It's > > - * NULL upon AV_LOCK_CREATE and != NULL for all other ops. > > - * > > - * @param cb User defined callback. Note: FFmpeg may invoke calls to > this > > - * callback during the call to av_lockmgr_register(). > > - * Thus, the application must be prepared to handle that. > > + * specified by AVLockOp. The "mutex" argument to the function points > > + * to a (void *) where the lockmgr should store/get a pointer to a user > > + * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the > > + * value left by the last call for all other ops. If the lock manager > > + * is unable to perform the op then it should leave the mutex in the > same > > + * state as when it was called. However, when called with > AV_LOCK_DESTROY > > + * the mutex will always be assumed to have been successfully destroyed. > > + * If av_lockmgr_register succeeds it will return 0, if it fails it will > > + * return -1 and destroy all mutex and unregister all callbacks. > > generally ffmpeg uses negative for errors, so this shouldnt > specifically use just -1. This allows providing richer error codes > at any later point > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Rewriting code that is poorly written but fully understood is good. > Rewriting code that one doesnt understand is a sign that one is less smart > then the original author, trying to rewrite it will not make it better. > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] av_lockmgr_register defines behavior on failure.
On 30/09/14 10:46 PM, Manfred Georg wrote: > Sure, I've made the change to the comment within my local code. I'm sorry, > but I'm not familiar with FFmpeg development cycle: how would you like me > to post it? > 1) A patch on top of the patch that is already in this thread (i.e. > something that will be squished into this patch). > 2) A new patch in a new thread. > 3) A new patch in this thread. > 4) Something else. New patch in this thread, as a reply to either the mail that reviewed/asked for changes, or to the first version you sent. Starting a new thread is ok when you're posting a new iteration of an entire patchset, since it's cleaner and easier to follow on email clients that sort by thread. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] av_lockmgr_register defines behavior on failure.
Here's the updated patch. Of note is the fact that I'm not sure it's actually legal to have a mutex manager which uses a single static mutex (and hence has all created mutex backed by the same underlying locking mechanism). Hopefully this patch is legible: Subject: [PATCH] av_lockmgr_register defines behavior on failure. The register function now specifies that the user callback should leave things in the same state that it found them on failure but that failure to destroy is ignored by ffmpeg. The register function is also now explicit about its behavior on failure (it now unregisters the previous callback and destroys all mutex). --- libavcodec/avcodec.h | 24 +++- libavcodec/utils.c | 31 +-- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 94e82f7..2899ba0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5120,16 +5120,22 @@ enum AVLockOp { /** * Register a user provided lock manager supporting the operations - * specified by AVLockOp. mutex points to a (void *) where the - * lockmgr should store/get a pointer to a user allocated mutex. It's - * NULL upon AV_LOCK_CREATE and != NULL for all other ops. - * - * @param cb User defined callback. Note: FFmpeg may invoke calls to this - * callback during the call to av_lockmgr_register(). - * Thus, the application must be prepared to handle that. + * specified by AVLockOp. The "mutex" argument to the function points + * to a (void *) where the lockmgr should store/get a pointer to a user + * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the + * value left by the last call for all other ops. If the lock manager + * is unable to perform the op then it should leave the mutex in the same + * state as when it was called. However, when called with AV_LOCK_DESTROY + * the mutex will always be assumed to have been successfully destroyed. + * If av_lockmgr_register succeeds it will return 0, if it fails it will + * return non-zero and destroy all mutex and unregister all callbacks. + * + * @param cb User defined callback. FFmpeg invokes calls to this + * callback and the previously registered callback during the + * call to av_lockmgr_register(). The callback will be used to + * create more than one mutex; however, it is legal for all the + * created mutex to use the same underlying locking mechanism. * If cb is set to NULL the lockmgr will be unregistered. - * Also note that during unregistration the previously registered - * lockmgr callback may also be invoked. */ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 778bdc6..717c5b1 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -3457,22 +3457,33 @@ AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel) int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) { if (lockmgr_cb) { -if (lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) -return -1; -if (lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY)) -return -1; -codec_mutex = NULL; -avformat_mutex = NULL; +// There is no good way to rollback a failure to destroy the +// mutex, so we ignore failures. +lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY); +lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY); } -lockmgr_cb = cb; +lockmgr_cb = NULL; +codec_mutex = NULL; +avformat_mutex = NULL; -if (lockmgr_cb) { -if (lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) +if (cb) { +void *new_codec_mutex = NULL; +void *new_avformat_mutex = NULL; +if (cb(&new_codec_mutex, AV_LOCK_CREATE)) { return -1; -if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE)) +} +if (cb(&new_avformat_mutex, AV_LOCK_CREATE)) +{ +// Ignore failures to destroy the newly created mutex. +cb(&new_codec_mutex, AV_LOCK_DESTROY); return -1; +} +lockmgr_cb = cb; +codec_mutex = new_codec_mutex; +avformat_mutex = new_avformat_mutex; } + return 0; } -- 2.1.0.rc2.206.gedb03e5 On Tue, Sep 30, 2014 at 4:02 PM, Michael Niedermayer wrote: > On Tue, Sep 30, 2014 at 03:20:43PM -0700, Manfred Georg wrote: > > The register function now specifies that the user callback should > > leave things in the same state that it found them on failure but > > that failure to destroy is ignored by ffmpeg. The register > > function is also now explicit about its behavior on failure (it now > > unregisters the previous callback and destroys all mutex). > > --- > > libavcodec/avcodec.h | 24 +++- > > libavcodec/utils.c | 31 +-- > > 2 files changed, 36 insertions(+), 19 deletions(-) > > > > diff
Re: [FFmpeg-devel] [PATCH 2/2] av_lockmgr_register defines behavior on failure.
On Tue, Sep 30, 2014 at 07:00:19PM -0700, Manfred Georg wrote: > Here's the updated patch. Of note is the fact that I'm not sure it's > actually legal to have a mutex manager which uses a single > static mutex (and hence has all created mutex backed by the > same underlying locking mechanism). i dont think thats legal, and certainly its not a good idea [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/18] avcodec: remove obsolete FF_API_FAST_MALLOC cruft
On Mon, Sep 15, 2014 at 10:59:39PM +0200, Andreas Cadhalpun wrote: > On 15.09.2014 22:03, Michael Niedermayer wrote: > >On Mon, Sep 15, 2014 at 04:08:49PM -0300, James Almer wrote: > >>On 15/09/14 6:07 AM, Michael Niedermayer wrote: > >>>On Sun, Sep 14, 2014 at 10:46:03PM -0300, James Almer wrote: > Signed-off-by: James Almer > >>> > >>>about the patchset as a whole, not specifically this one > >>> > >>>we should check if theres any software left around that still uses > >>>the symbols before removing the code completely and if so consider > >>>to reintroduce them in a 2.4.1 while removing whats unused > >> > >>Pushed the three you reviewed since either no code depended on them, or in > >>the > >>OpenCL case it's an API that nobody has ever been able to use anyway. > >> > >>I'm not exactly interested in looking around to see if any of this > >>deprecated > >>stuff is still used. And IMO reintroducing them in a point release is quite > >>ugly. > >>An exception could be FF_API_DRAWTEXT_OLD_TIMELINE since as Clément pointed > >>in > >>another email might be needed to remain compatible with libav. > > > >probably you only have to wait, as i suspect andreas (in CC) will > >test building all dependant packages in debian against 2.4 > > You're right that I'm currently rebuilding those against 2.4, but I > don't expect any problems there, since I already have rebuilt them > against a git snapshot about two weeks ago and didn't notice > anything problematic. any news ? can these be applied ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB DNS cache poisoning attacks, popular search engine, Google internet authority dont be evil, please signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/18] avcodec: remove obsolete FF_API_FAST_MALLOC cruft
On 30/09/14 11:34 PM, Michael Niedermayer wrote: > On Mon, Sep 15, 2014 at 10:59:39PM +0200, Andreas Cadhalpun wrote: >> On 15.09.2014 22:03, Michael Niedermayer wrote: >>> On Mon, Sep 15, 2014 at 04:08:49PM -0300, James Almer wrote: On 15/09/14 6:07 AM, Michael Niedermayer wrote: > On Sun, Sep 14, 2014 at 10:46:03PM -0300, James Almer wrote: >> Signed-off-by: James Almer > > about the patchset as a whole, not specifically this one > > we should check if theres any software left around that still uses > the symbols before removing the code completely and if so consider > to reintroduce them in a 2.4.1 while removing whats unused Pushed the three you reviewed since either no code depended on them, or in the OpenCL case it's an API that nobody has ever been able to use anyway. I'm not exactly interested in looking around to see if any of this deprecated stuff is still used. And IMO reintroducing them in a point release is quite ugly. An exception could be FF_API_DRAWTEXT_OLD_TIMELINE since as Clément pointed in another email might be needed to remain compatible with libav. >>> >>> probably you only have to wait, as i suspect andreas (in CC) will >>> test building all dependant packages in debian against 2.4 >> >> You're right that I'm currently rebuilding those against 2.4, but I >> don't expect any problems there, since I already have rebuilt them >> against a git snapshot about two weeks ago and didn't notice >> anything problematic. > > any news ? can these be applied ? Debian packages are all meant to work with libav 9 or 11 api, and all this deprecated code removed in 2.4 was ffmpeg exclusive, so it's unlikely they used any of it. Also, 2.4 has been out for two weeks and nobody complained about their applications breaking because these are no longer available. We could wait a bit more in any case. The entire patchset is just dead code removal. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] av_lockmgr_register defines behavior on failure.
On Tue, Sep 30, 2014 at 07:34:28PM -0700, Manfred Georg wrote: > Yeah, that seemed a bit odd to meI guess I get to go correct some > calling code. > > Here is yet another update with a comment which tells you not to use a > static mutex. > > Subject: [PATCH] av_lockmgr_register defines behavior on failure. > > The register function now specifies that the user callback should > leave things in the same state that it found them on failure but > that failure to destroy is ignored by ffmpeg. The register > function is also now explicit about its behavior on failure (it now > unregisters the previous callback and destroys all mutex). > --- > libavcodec/avcodec.h | 25 - > libavcodec/utils.c | 31 +-- > 2 files changed, 37 insertions(+), 19 deletions(-) > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 94e82f7..dae3612 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -5120,16 +5120,23 @@ enum AVLockOp { > > /** > * Register a user provided lock manager supporting the operations > - * specified by AVLockOp. mutex points to a (void *) where the > - * lockmgr should store/get a pointer to a user allocated mutex. It's > - * NULL upon AV_LOCK_CREATE and != NULL for all other ops. > - * > - * @param cb User defined callback. Note: FFmpeg may invoke calls to this > - * callback during the call to av_lockmgr_register(). > - * Thus, the application must be prepared to handle that. > + * specified by AVLockOp. The "mutex" argument to the function points > + * to a (void *) where the lockmgr should store/get a pointer to a user > + * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the > + * value left by the last call for all other ops. If the lock manager > + * is unable to perform the op then it should leave the mutex in the same > + * state as when it was called. However, when called with AV_LOCK_DESTROY > + * the mutex will always be assumed to have been successfully destroyed. > + * If av_lockmgr_register succeeds it will return 0, if it fails it will > + * return non-zero and destroy all mutex and unregister all callbacks. we have no positve error codes, the positive values could be used as success like 0 giving us the ability to extend/use them for something in the future > + * > + * @param cb User defined callback. FFmpeg invokes calls to this > + * callback and the previously registered callback during the > + * call to av_lockmgr_register(). The callback will be used to > + * create more than one mutex each of which must be backed > + * by its own underlying locking mechanism (i.e. do not > + * use a single static object to implement your lock manager). > * If cb is set to NULL the lockmgr will be unregistered. > - * Also note that during unregistration the previously registered > - * lockmgr callback may also be invoked. > */ > int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); > > diff --git a/libavcodec/utils.c b/libavcodec/utils.c > index 778bdc6..717c5b1 100644 > --- a/libavcodec/utils.c > +++ b/libavcodec/utils.c > @@ -3457,22 +3457,33 @@ AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel) > int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) > { > if (lockmgr_cb) { > -if (lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) > -return -1; > -if (lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY)) > -return -1; > -codec_mutex = NULL; > -avformat_mutex = NULL; > +// There is no good way to rollback a failure to destroy the > +// mutex, so we ignore failures. > +lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY); > +lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY); > } > > -lockmgr_cb = cb; > +lockmgr_cb = NULL; > +codec_mutex = NULL; > +avformat_mutex = NULL; why is this moved outside "if (lockmgr_cb)" ? > > -if (lockmgr_cb) { > -if (lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) > +if (cb) { > +void *new_codec_mutex = NULL; > +void *new_avformat_mutex = NULL; > +if (cb(&new_codec_mutex, AV_LOCK_CREATE)) { > return -1; > -if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE)) > +} > +if (cb(&new_avformat_mutex, AV_LOCK_CREATE)) > +{ > +// Ignore failures to destroy the newly created mutex. > +cb(&new_codec_mutex, AV_LOCK_DESTROY); > return -1; > +} > +lockmgr_cb = cb; > +codec_mutex = new_codec_mutex; > +avformat_mutex = new_avformat_mutex; these probably should use avpriv_atomic_ptr_cas() to ensure the values where NULL that are replaced. this could provide usefull debug information if someone misuses av_lockmgr_register() like calling it from 2 threads at the same time [...] -- Michael GnuPG finger
Re: [FFmpeg-devel] [PATCH 1/18] avcodec: remove obsolete FF_API_FAST_MALLOC cruft
On Tue, Sep 30, 2014 at 11:57:14PM -0300, James Almer wrote: > On 30/09/14 11:34 PM, Michael Niedermayer wrote: > > On Mon, Sep 15, 2014 at 10:59:39PM +0200, Andreas Cadhalpun wrote: > >> On 15.09.2014 22:03, Michael Niedermayer wrote: > >>> On Mon, Sep 15, 2014 at 04:08:49PM -0300, James Almer wrote: > On 15/09/14 6:07 AM, Michael Niedermayer wrote: > > On Sun, Sep 14, 2014 at 10:46:03PM -0300, James Almer wrote: > >> Signed-off-by: James Almer > > > > about the patchset as a whole, not specifically this one > > > > we should check if theres any software left around that still uses > > the symbols before removing the code completely and if so consider > > to reintroduce them in a 2.4.1 while removing whats unused > > Pushed the three you reviewed since either no code depended on them, or > in the > OpenCL case it's an API that nobody has ever been able to use anyway. > > I'm not exactly interested in looking around to see if any of this > deprecated > stuff is still used. And IMO reintroducing them in a point release is > quite ugly. > An exception could be FF_API_DRAWTEXT_OLD_TIMELINE since as Clément > pointed in > another email might be needed to remain compatible with libav. > >>> > >>> probably you only have to wait, as i suspect andreas (in CC) will > >>> test building all dependant packages in debian against 2.4 > >> > >> You're right that I'm currently rebuilding those against 2.4, but I > >> don't expect any problems there, since I already have rebuilt them > >> against a git snapshot about two weeks ago and didn't notice > >> anything problematic. > > > > any news ? can these be applied ? > > Debian packages are all meant to work with libav 9 or 11 api, and all this > deprecated > code removed in 2.4 was ffmpeg exclusive, so it's unlikely they used any of > it. > Also, 2.4 has been out for two weeks and nobody complained about their > applications > breaking because these are no longer available. > > We could wait a bit more in any case. The entire patchset is just dead code > removal. ok, just dont forget about them, i wont keep track of them anymore too much stuff to keep track off [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB What does censorship reveal? It reveals fear. -- Julian Assange signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/18] avcodec: remove obsolete FF_API_FAST_MALLOC cruft
On 01/10/14 12:18 AM, Michael Niedermayer wrote: > On Tue, Sep 30, 2014 at 11:57:14PM -0300, James Almer wrote: >> On 30/09/14 11:34 PM, Michael Niedermayer wrote: >>> On Mon, Sep 15, 2014 at 10:59:39PM +0200, Andreas Cadhalpun wrote: On 15.09.2014 22:03, Michael Niedermayer wrote: > On Mon, Sep 15, 2014 at 04:08:49PM -0300, James Almer wrote: >> On 15/09/14 6:07 AM, Michael Niedermayer wrote: >>> On Sun, Sep 14, 2014 at 10:46:03PM -0300, James Almer wrote: Signed-off-by: James Almer >>> >>> about the patchset as a whole, not specifically this one >>> >>> we should check if theres any software left around that still uses >>> the symbols before removing the code completely and if so consider >>> to reintroduce them in a 2.4.1 while removing whats unused >> >> Pushed the three you reviewed since either no code depended on them, or >> in the >> OpenCL case it's an API that nobody has ever been able to use anyway. >> >> I'm not exactly interested in looking around to see if any of this >> deprecated >> stuff is still used. And IMO reintroducing them in a point release is >> quite ugly. >> An exception could be FF_API_DRAWTEXT_OLD_TIMELINE since as Clément >> pointed in >> another email might be needed to remain compatible with libav. > > probably you only have to wait, as i suspect andreas (in CC) will > test building all dependant packages in debian against 2.4 You're right that I'm currently rebuilding those against 2.4, but I don't expect any problems there, since I already have rebuilt them against a git snapshot about two weeks ago and didn't notice anything problematic. >>> >>> any news ? can these be applied ? >> >> Debian packages are all meant to work with libav 9 or 11 api, and all this >> deprecated >> code removed in 2.4 was ffmpeg exclusive, so it's unlikely they used any of >> it. >> Also, 2.4 has been out for two weeks and nobody complained about their >> applications >> breaking because these are no longer available. >> >> We could wait a bit more in any case. The entire patchset is just dead code >> removal. > > ok, just dont forget about them, i wont keep track of them anymore > too much stuff to keep track off I'll apply them this weekend, then. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] IRC meeting
Hi, On Mon, Sep 29, 2014 at 8:39 AM, Stefano Sabatini wrote: > Hi, > > I want to propose to have an FFmpeg IRC meeting the next Saturday, 4th > October, UTC 16. Alternatively, I propose the Saturday of the next > week, Saturday October 11, same time. I don't think I will be available for the entire meeting on either Saturdays, but I slightly prefer October 4th. Do not take my availability as a blocker as I won't say much during the FFmeetings anyway. > > Candidate topics of the day: > - VDD 2014 report and discussion, in particular with regards to > relationships with libav > - OPW program organization > - technical development issues > - misc topics > > Feel free to propose other topics. I can't think of anything else right now. Thank you for organizing the meetings. I have created a wiki page for this FFmeeting here: http://trac.ffmpeg.org/wiki/FFmeeting/2014-10. Feel free to add more stuff to it. Timothy ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat: add avformat_flush()
On 30.09.2014, at 22:25, wm4 wrote: > On Tue, 30 Sep 2014 08:06:16 +0200 > Reimar Döffinger wrote: > >> On 29.09.2014, at 22:02, Michael Niedermayer wrote: >>> On Mon, Sep 29, 2014 at 08:34:44PM +0200, wm4 wrote: On Mon, 29 Sep 2014 20:25:47 +0200 Michael Niedermayer wrote: > On Mon, Sep 29, 2014 at 07:41:28PM +0200, wm4 wrote: >> Useful for Bluray and DVD, since the libraries used to read them just >> change the byte stream under your feet on seeking. >> >> Maybe there should be a AVInputFormat callback for this. But the >> mpeg-ps (DVD) and the mpeg-ts (Bluray) demuxers don't change much >> state during seeking - they just try to find a new packet with >> timestamps (in read_timestamp), so I haven't found a need for this >> yet. I don't want to add unused things. >> >> I've also thought about adding a flush callback, and implementing >> them in mpeg.c and mpegts.c by just calling ff_read_frame_flush(). >> Might be slightly better, because you can have avformat_flush() fail >> on formats which don't support this? >> >> Or maybe a flag? >> >> TODO: add entry to APIchanges, bump minor version. >> --- >> libavformat/avformat.h | 13 + >> libavformat/utils.c| 6 ++ >> 2 files changed, 19 insertions(+) >> >> diff --git a/libavformat/avformat.h b/libavformat/avformat.h >> index 78054de..eaa52fa 100644 >> --- a/libavformat/avformat.h >> +++ b/libavformat/avformat.h >> @@ -2173,6 +2173,19 @@ int av_seek_frame(AVFormatContext *s, int >> stream_index, int64_t timestamp, >> int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t >> min_ts, int64_t ts, int64_t max_ts, int flags); >> >> /** >> + * Discard all internally buffered data. This can be useful when >> dealing with >> + * discontinuities in the byte stream. Generally works only with some >> simple >> + * formats. > > id call them stream based or without a central header instead of > simple. I can change that and replace "simple" with "headerless". >>> >>> please do, headerless is more specific >> >> Why does it require headerless? >> I would have expected this feature to work for e.g. Ogg as well, which >> clearly is not headerless. >> As such I'd claim headerless may be more specific, but it is also wrong. >> It should work for all formats that can be read without index and can resync >> reliably at least. > > Do you have any concrete suggestions? I'm not sure what documentation > would be most appropriate. Maybe "formats that can resync. This includes headerless formats like MPEG-TS/TS but should also work with NUT, Ogg and in a limited way AVI for example" Not sure that's the best way to do it either though. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel