Re: [libav-devel] [PATCH] doc: fix dependencies in pod generation
On Wed, Jan 23, 2013 at 10:09:30AM +0100, Luca Barbato wrote: The script can and will change. --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) OK Diego ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/3] rtmp: fix buffer overflows in ff_amf_tag_contents()
From: Xi Wang xi.w...@gmail.com A negative `size' will bypass FFMIN(). In the subsequent memcpy() call, `size' will be considered as a large positive value, leading to a buffer overflow. Change the type of `size' to unsigned int to avoid buffer overflow, and simplify overflow checks accordingly. Also change a literal buffer size to use sizeof, and limit the amount of data copied in another memcpy call as well. Signed-off-by: Xi Wang xi.w...@gmail.com --- libavformat/rtmppkt.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index a9d0a0d..119cdfa 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -440,7 +440,7 @@ static const char* rtmp_packet_type(int type) static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *data_end) { -int size; +unsigned int size; char buf[1024]; if (data = data_end) @@ -459,7 +459,7 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d } else { size = bytestream_get_be32(data); } -size = FFMIN(size, 1023); +size = FFMIN(size, sizeof(buf) - 1); memcpy(buf, data, size); buf[size] = 0; av_log(ctx, AV_LOG_DEBUG, string '%s'\n, buf); @@ -472,16 +472,15 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d case AMF_DATA_TYPE_OBJECT: av_log(ctx, AV_LOG_DEBUG, {\n); for (;;) { -int size = bytestream_get_be16(data); int t; -memcpy(buf, data, size); -buf[size] = 0; +size = bytestream_get_be16(data); +av_strlcpy(buf, data, FFMIN(sizeof(buf), size + 1)); if (!size) { av_log(ctx, AV_LOG_DEBUG, }\n); data++; break; } -if (size 0 || size = data_end - data) +if (size = data_end - data) return; data += size; av_log(ctx, AV_LOG_DEBUG, %s: , buf); -- 1.7.9.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/3] rtmp: fix multiple broken overflow checks
From: Xi Wang xi.w...@gmail.com Sanity checks like `data + size = data_end || data + size data' are broken, because `data + size data' assumes pointer overflow, which is undefined behavior in C. Many compilers such as gcc/clang optimize such checks away. Use `size 0 || size = data_end - data' instead. Signed-off-by: Xi Wang xi.w...@gmail.com --- libavformat/rtmppkt.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index aed188d..a9d0a0d 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -356,11 +356,11 @@ int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end) data++; break; } -if (data + size = data_end || data + size data) +if (size 0 || size = data_end - data) return -1; data += size; t = ff_amf_tag_size(data, data_end); -if (t 0 || data + t = data_end) +if (t 0 || t = data_end - data) return -1; data += t; } @@ -389,7 +389,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, int size = bytestream_get_be16(data); if (!size) break; -if (data + size = data_end || data + size data) +if (size 0 || size = data_end - data) return -1; data += size; if (size == namelen !memcmp(data-size, name, namelen)) { @@ -410,7 +410,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, return 0; } len = ff_amf_tag_size(data, data_end); -if (len 0 || data + len = data_end || data + len data) +if (len 0 || len = data_end - data) return -1; data += len; } @@ -481,13 +481,13 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d data++; break; } -if (data + size = data_end || data + size data) +if (size 0 || size = data_end - data) return; data += size; av_log(ctx, AV_LOG_DEBUG, %s: , buf); ff_amf_tag_contents(ctx, data, data_end); t = ff_amf_tag_size(data, data_end); -if (t 0 || data + t = data_end) +if (t 0 || t = data_end - data) return; data += t; } -- 1.7.9.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/3] rtpenc: fix overflow checking in avc_mp4_find_startcode()
From: Xi Wang xi.w...@gmail.com The check `start + res start' is broken since pointer overflow is undefined behavior in C. Many compilers such as gcc/clang optimize away this check. Use `res end - start' instead. Also change `res' to unsigned int to avoid signed left-shift overflow. Signed-off-by: Xi Wang xi.w...@gmail.com --- libavformat/rtpenc_h264.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/rtpenc_h264.c b/libavformat/rtpenc_h264.c index ac74074..206d9ba 100644 --- a/libavformat/rtpenc_h264.c +++ b/libavformat/rtpenc_h264.c @@ -31,14 +31,14 @@ static const uint8_t *avc_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size) { -int res = 0; +unsigned int res = 0; if (end - start nal_length_size) return NULL; while (nal_length_size--) res = (res 8) | *start++; -if (start + res end || res 0 || start + res start) +if (res end - start) return NULL; return start + res; -- 1.7.9.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] doc: support multitable in texi2pod
--- I'm pondering of hacking texi2man and use it instead, this thing is nasty. doc/texi2pod.pl | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/texi2pod.pl b/doc/texi2pod.pl index 94323be..96d967b 100755 --- a/doc/texi2pod.pl +++ b/doc/texi2pod.pl @@ -161,7 +161,7 @@ INF: while($inf) { } elsif ($ended =~ /^(?:example|smallexample|display)$/) { $shift = ; $_ = ;# need a paragraph break -} elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) { +} elsif ($ended =~ /^(?:itemize|enumerate|(?:multi|[fv])?table)$/) { $_ = \n=back\n; $ic = pop @icstack; } else { @@ -262,7 +262,7 @@ INF: while($inf) { $endw = enumerate; }; -/^\@([fv]?table)\s+(\@[a-z]+)/ and do { +/^\@((?:multi|[fv])?table)\s+(\@[a-z]+)/ and do { push @endwstack, $endw; push @icstack, $ic; $endw = $1; @@ -271,6 +271,7 @@ INF: while($inf) { $ic =~ s/\@(?:code|kbd)/C/; $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/; $ic =~ s/\@(?:file)/F/; +$ic =~ s/\@(?:columnfractions)//; $_ = \n=over 4\n; }; @@ -281,6 +282,21 @@ INF: while($inf) { $_ = ;# need a paragraph break }; +/^\@item\s+(.*\S)\s*$/ and $endw eq multitable and do { +my $columns = $1; +$columns =~ s/\@tab/ : /; + +$_ = \n=item BLT;. $columns .GT;\n; +}; + +/^\@tab\s+(.*\S)\s*$/ and $endw eq multitable and do { +my $columns = $1; +$columns =~ s/\@tab/ : /; + +$_ = : . $columns; +$section =~ s/\n+\s+$//; +}; + /^\@itemx?\s*(.+)?$/ and do { if (defined $1) { # Entity escapes prevent munging by the processing below. -- 1.8.0.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/3] rtmp: fix multiple broken overflow checks
On 23/01/13 11:32, Martin Storsjö wrote: From: Xi Wang xi.w...@gmail.com Sanity checks like `data + size = data_end || data + size data' are broken, because `data + size data' assumes pointer overflow, which is undefined behavior in C. Many compilers such as gcc/clang optimize such checks away. Use `size 0 || size = data_end - data' instead. Signed-off-by: Xi Wang xi.w...@gmail.com --- libavformat/rtmppkt.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) Looks fine. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/2] libx264: introduce -x264-params private option
From: Gavriloaie Eugen-Andrei crtmpser...@gmail.com It is a shortcut to set all the params using x264_param_parse, makes simpler importing settings from other software using x264. --- Doc update follows. The patch looks quite useful to me. libavcodec/libx264.c | 28 1 file changed, 28 insertions(+) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index e9cbbad..34fe34b 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -70,6 +70,7 @@ typedef struct X264Context { int slice_max_size; char *stats; int nal_hrd; +char *x264_params; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -407,6 +408,32 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx-flags CODEC_FLAG_GLOBAL_HEADER) x4-params.b_repeat_headers = 0; +if (x4-x264_params) { +char *params= NULL; +char *keyvalues = NULL; +char *param = NULL; +char *key = NULL; +char *value = NULL; + +param = strtok_r(x4-x264_params, :, params); +while (param) { +param = strtok_r(NULL, :, params); +if (!param) +break; + +key = strtok_r(param, =, keyvalues); +value = strtok_r(NULL, =, keyvalues); + +if (!key || !value) +continue; + +if (x264_param_parse(x4-params, key, value) 0) +av_log(avctx, AV_LOG_WARNING, + Error parsing option '%s=%s'.\n, + key, value); +} +} + // update AVCodecContext with x264 parameters avctx-has_b_frames = x4-params.i_bframe ? x4-params.i_bframe_pyramid ? 2 : 1 : 0; @@ -527,6 +554,7 @@ static const AVOption options[] = { { none, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE}, INT_MIN, INT_MAX, VE, nal-hrd }, { vbr, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, nal-hrd }, { cbr, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, nal-hrd }, +{ x264-params, Override the x264 configuration using a :-separated list of key=value list of parameters, OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { NULL }, }; -- 1.8.0.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/2] doc: document libx264 options and mappings
--- Help in filling in missing parameters welcome. doc/encoders.texi | 182 ++ 1 file changed, 182 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 830981f..ab029cf 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -413,3 +413,185 @@ Selected by Encoder (default) @end table @c man end AUDIO ENCODERS + +@chapter Video Encoders +@c man begin VIDEO ENCODERS + +@section libx264 + +x264 H264/MPEG-4 AVC encoder wrapper + +x264 supports an impressive number of features, including 8x8 and 4x4 adaptive +spatial transform, adaptive B-frame placement, CAVLC/CABAC entropy coding, +interlacing (MBAFF), lossless mode, psy optimizations for detail retention +(adaptive quantization, psy-RD, psy-trellis). + +The Libav wrapper provides a mapping for most of them using global options +that match those of the encoders and provides private options for the unique +encoder options. Additionally an expert override is provided to pass directly +a list of key=value tuples as accepted by x264_param_parse. + +@subsection Option Mapping + +The following options are supported by the x264 wrapper, the x264-equivalent +options follow the Libav ones. + +@multitable @columnfractions .2 .2 +@item b @tab bitrate +Libav @code{b} option is expressed in bytes, x264 @code{bitrate} in Kilobytes. +@item bf@tab bframes +Maximum number of b frames +@item g @tab keyint +Maximum GOP size +@item qmin @tab qpmin +@item qmax @tab qpmax +@item qdiff @tab qpstep +@item qblur @tab qblur +@item qcomp @tab qcomp +@item refs @tab ref +@item sc_threshold @tab scenecut +@item trellis @tab trellis +@item nr@tab nr +Noise reduction +@item me_range @tab merange +@item me_method @tab me +@item subq @tab subme +@item b_strategy@tab b-adapt +@item keyint_min@tab keyint-min +@item coder @tab cabac +Set coder to @code{ac} to use CABAC. +@item cmp @tab chroma-me +Set to @code{chroma} to use chroma motion estimation. +@item threads @tab threads +@item thread_type @tab sliced_threads +Set to @code{slice} to use sliced threading instead of frame threading. +@item flags -cgop @tab open-gop +Set @code{-cgop} to use recovery points to close GOPs. +@item rc_init_occupancy @tab vbv-init +Initial buffer occupancy. +@end multitable + +@subsection Private Options +@table @option +@item -preset @var{string} +Set the encoding preset (cf. x264 --fullhelp) +@item -tune @var{string} +Tune the encoding params (cf. x264 --fullhelp) +@item -profile @var{string} +Set profile restrictions (cf. x264 --fullhelp) +@item -fastfirstpass @var{integer} +Use fast settings when encoding first pass +@item -crf @var{float} +Select the quality for constant quality mode +@item -crf_max @var{float} +In CRF mode, prevents VBV from lowering quality beyond this point. +@item -qp @var{integer} +Constant quantization parameter rate control method +@item -aq-mode @var{integer} +AQ method + +Possible values: +@table @samp +@item none + +@item variance +Variance AQ (complexity mask) +@item autovariance +Auto-variance AQ (experimental) +@end table +@item -aq-strength @var{float} +AQ strength. Reduces blocking and blurring in flat and textured areas. +@item -psy @var{integer} +Use psychovisual optimizations. +@item -psy-rd @var{string} +Strength of psychovisual optimization, in psy-rd:psy-trellis format. +@item -rc-lookahead @var{integer} +Number of frames to look ahead for frametype and ratecontrol +@item -weightb @var{integer} +Weighted prediction for B-frames. +@item -weightp @var{integer} +Weighted prediction analysis method. + +Possible values: +@table @samp +@item none + +@item simple + +@item smart + +@end table +@item -ssim @var{integer} +Calculate and print SSIM stats. +@item -intra-refresh @var{integer} +Use Periodic Intra Refresh instead of IDR frames. +@item -b-bias @var{integer} +Influences how often B-frames are used +@item -b-pyramid @var{integer} +Keep some B-frames as references. + +Possible values: +@table @samp +@item none + +@item strict +Strictly hierarchical pyramid +@item normal +Non-strict (not Blu-ray compatible) +@end table +@item -mixed-refs @var{integer} +One reference per partition, as opposed to one reference per macroblock +@item -8x8dct @var{integer} +High profile 8x8 transform. +@item -fast-pskip @var{integer} +@item -aud @var{integer} +Use access unit delimiters. +@item -mbtree @var{integer} +Use macroblock tree ratecontrol. +@item -deblock @var{string} +Loop filter parameters, in alpha:beta form. +@item -cplxblur @var{float} +Reduce fluctuations in QP (before curve compression) +@item -partitions @var{string} +A comma-separated list of partitions to consider. Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all +@item -direct-pred
Re: [libav-devel] [PATCH 1/2] libx264: introduce -x264-params private option
On Wed, 23 Jan 2013, Luca Barbato wrote: From: Gavriloaie Eugen-Andrei crtmpser...@gmail.com It is a shortcut to set all the params using x264_param_parse, makes simpler importing settings from other software using x264. --- Doc update follows. The patch looks quite useful to me. libavcodec/libx264.c | 28 1 file changed, 28 insertions(+) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index e9cbbad..34fe34b 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -70,6 +70,7 @@ typedef struct X264Context { int slice_max_size; char *stats; int nal_hrd; +char *x264_params; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -407,6 +408,32 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx-flags CODEC_FLAG_GLOBAL_HEADER) x4-params.b_repeat_headers = 0; +if (x4-x264_params) { +char *params= NULL; +char *keyvalues = NULL; +char *param = NULL; +char *key = NULL; +char *value = NULL; + +param = strtok_r(x4-x264_params, :, params); +while (param) { +param = strtok_r(NULL, :, params); strtok_r is not universally available, either this needs to go behind HAVE_STRTOK_R, or use some other function that does the equivalent. // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/2] libx264: introduce -x264-params private option
On 23/01/13 12:43, Martin Storsjö wrote: strtok_r is not universally available, either this needs to go behind HAVE_STRTOK_R, or use some other function that does the equivalent. The alternative is using the av_get_token or make a non-allocating variant. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] avfilter: allow setpts filter to use wallclock time for calculations
On Wed, 23 Jan 2013, Vladimir Pantelic wrote: I have a webcam that outputs raw MJPEG over HTTP and for which I need to create timestamps in order to properly avplay or avconv the stream. Thus I extended vf_setpts to allow to get the current wallclock time and use that as a timestamp with: setpts='(GETTIME - STARTTIME) / (TB * 100) Would it btw ever make sense to have GETTIME without -STARTTIME in this context? If not, perhaps the gettime variable should return that difference? (And would a name like REALTIMECLOCK or similar be better?) // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] avfilter: allow setpts filter to use wallclock time for calculations
Martin Storsjö wrote: On Wed, 23 Jan 2013, Vladimir Pantelic wrote: I have a webcam that outputs raw MJPEG over HTTP and for which I need to create timestamps in order to properly avplay or avconv the stream. Thus I extended vf_setpts to allow to get the current wallclock time and use that as a timestamp with: setpts='(GETTIME - STARTTIME) / (TB * 100) Would it btw ever make sense to have GETTIME without -STARTTIME in this context? If not, perhaps the gettime variable should return that difference? (And would a name like REALTIMECLOCK or similar be better?) I could imagine somebody wanting the absolute time recorded. GETTIME was picked after av_gettime(), I'm fine with e.g RTCTIME and RTCSTART ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] Add av_strnstr() function
see $subject From 28417b86f12b8cac79090a7b341b606e59635bbe Mon Sep 17 00:00:00 2001 From: Vladimir Pantelic vlado...@gmail.com Date: Wed, 23 Jan 2013 14:16:10 +0100 Subject: [PATCH] Add av_strnstr() function This is a length limited version of strstr() Signed-off-by: Vladimir Pantelic vlado...@gmail.com --- libavutil/avstring.c | 16 libavutil/avstring.h | 15 +++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 2c88bd3..db9eee2 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -64,6 +64,22 @@ char *av_stristr(const char *s1, const char *s2) return NULL; } +char *av_strnstr(const char *s1, const char *s2, size_t len) +{ +size_t l2; + +l2 = strlen(s2); +if (!l2) +return s1; +while (len = l2) { +len--; +if (!memcmp(s1, s2, l2)) +return s1; +s1++; +} +return NULL; +} + size_t av_strlcpy(char *dst, const char *src, size_t size) { size_t len = 0; diff --git a/libavutil/avstring.h b/libavutil/avstring.h index acd6610..da34105 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -67,6 +67,21 @@ int av_stristart(const char *str, const char *pfx, const char **ptr); char *av_stristr(const char *haystack, const char *needle); /** + * Locate the first occurrence in the string haystack of the string needle + * where not more than length characters are searched. A zero-length string + * needle is considered to match at the start of haystack. + * + * This function is a length limited version of the standard strstr(). + * + * @param haystack string to search in + * @param needle string to search for + * @param length length of string to search in + * @return pointer to the located match within haystack + * or a null pointer if no match + */ +char *av_strnstr(const char *haystack, const char *needle, size_t haystack_size); + +/** * Copy the string src to dst, but no more than size - 1 bytes, and * null-terminate dst. * -- 1.7.6.rc1.1.g2c162b ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [RFC][PATCH] probe for raw/mime MJPEG
I have a webcam that outputs raw MJPEG over HTTP, in fact not fully raw but as a mime attachment like: --Ba4oTvQMY8ew04N8dcnM Content-Type: image/jpeg 0xFFD8 JPEG frame --Ba4oTvQMY8ew04N8dcnM Content-Type: image/jpeg 0xFFD8 JPEG frame in order not to have to specify -f mjpeg, I added a probe function for it that detects either the JPEG header or the mime type info as above this also lets libav probe ordinary JPEG files for which is so far has relied on the file extension only. Similar probe functions could be added for all the supported formats in imgdec2 too. diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 5e95d10..f085b45 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -27,11 +27,13 @@ #include libavutil/opt.h #include libavutil/parseutils.h #include libavutil/pixdesc.h +#include libavutil/avstring.h #define RAW_PACKET_SIZE 1024 int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) { +FFRawVideoDemuxerContext *s1 = s-priv_data; int ret, size; size = RAW_PACKET_SIZE; @@ -41,6 +43,9 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) pkt-pos= avio_tell(s-pb); pkt-stream_index = 0; +if( s1-gen_ts ) +pkt-pts = (av_gettime() - s1-starttime) / 1000; +av_log(NULL, AV_LOG_ERROR, pts %lld\n, pkt-pts); ret = ffio_read_partial(s-pb, pkt-data, size); if (ret 0) { av_free_packet(pkt); @@ -92,6 +97,11 @@ int ff_raw_video_read_header(AVFormatContext *s) goto fail; } +if( s1-gen_ts ) { + framerate.den = 1; + framerate.num = 1000; + s1-starttime = av_gettime(); +} #if FF_API_R_FRAME_RATE st-r_frame_rate = #endif @@ -108,6 +118,7 @@ fail: #define DEC AV_OPT_FLAG_DECODING_PARAM const AVOption ff_rawvideo_options[] = { { framerate, , OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = 25}, 0, 0, DEC}, +{ generate_timestamps, , OFFSET(gen_ts), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC }, { NULL }, }; @@ -124,7 +135,43 @@ AVInputFormat ff_latm_demuxer = { #endif #if CONFIG_MJPEG_DEMUXER -FF_DEF_RAWVIDEO_DEMUXER(mjpeg, raw MJPEG video, NULL, mjpg,mjpeg, AV_CODEC_ID_MJPEG) + +static int mjpeg_probe(AVProbeData *p) +{ + int ofs = 0; + // possible attachment with mime type +if(!memcmp(p-buf , --, 2) || !memcmp(p-buf , \r\n--, 4)) { +if(av_strnstr(p-buf, image/jpeg, p-buf_size )) { +av_log(NULL, AV_LOG_ERROR, mjpeg_probe MIME\n); +return AVPROBE_SCORE_MAX; + } +} +if( p-buf[ofs] == 0xFF p-buf[ofs + 1] == 0xD8) { +av_log(NULL, AV_LOG_ERROR, mjpeg_probe FFD8\n); +return AVPROBE_SCORE_MAX; +} +return 0; +} + +static const AVClass mjpeg_demuxer_class = { +.class_name = mjpeg demuxer, +.item_name = av_default_item_name, +.option = ff_rawvideo_options, +.version= LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_mjpeg_demuxer = { +.name = mjpeg, +.long_name = NULL_IF_CONFIG_SMALL(raw MJPEG video), +.read_header= ff_raw_video_read_header, +.read_packet= ff_raw_read_partial_packet, +.read_probe = mjpeg_probe, +.flags = AVFMT_GENERIC_INDEX, +.extensions = mjpg,mjpeg, +.raw_codec_id = AV_CODEC_ID_MJPEG, +.priv_data_size = sizeof(FFRawVideoDemuxerContext), +.priv_class = mjpeg_demuxer_class, +}; #endif #if CONFIG_MLP_DEMUXER ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] libx264: introduce -x264-params private option
From: Gavriloaie Eugen-Andrei crtmpser...@gmail.com It is a shortcut to set all the params using x264_param_parse, makes simpler importing settings from other software using x264. --- now using strcspn libavcodec/libx264.c | 28 1 file changed, 28 insertions(+) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index e9cbbad..7ef8a08 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -70,6 +70,7 @@ typedef struct X264Context { int slice_max_size; char *stats; int nal_hrd; +char *x264_params; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -407,6 +408,32 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx-flags CODEC_FLAG_GLOBAL_HEADER) x4-params.b_repeat_headers = 0; +if (x4-x264_params) { +char *p = x4-x264_params; +char *key = NULL; +char *val = NULL; +int c, k; + +while (*p (c = strcspn(p, :))) { +p[c] = '\0'; +k = strcspn(p, =); +if (!k) { +av_log(avctx, AV_LOG_WARNING, Error parsing %s\n, p); +break; +} +key = p; +val = p + k + 1; + +p[k] = '\0'; + +if (x264_param_parse(x4-params, key, val) 0) +av_log(avctx, AV_LOG_WARNING, + Error parsing option '%s=%s'.\n, + key, val); +p += c + 1; +} +} + // update AVCodecContext with x264 parameters avctx-has_b_frames = x4-params.i_bframe ? x4-params.i_bframe_pyramid ? 2 : 1 : 0; @@ -527,6 +554,7 @@ static const AVOption options[] = { { none, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE}, INT_MIN, INT_MAX, VE, nal-hrd }, { vbr, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, nal-hrd }, { cbr, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, nal-hrd }, +{ x264-params, Override the x264 configuration using a :-separated list of key=value list of parameters, OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { NULL }, }; -- 1.8.0.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Add av_strnstr() function
On 23/01/13 15:16, Vladimir Pantelic wrote: see $subject The patch subject should be lavu: Add av_strnstr() And a minor bump is missing for the libavu should be added. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [RFC][PATCH] probe for raw/mime MJPEG
On 23/01/13 15:33, Vladimir Pantelic wrote: @@ -41,7 +43,10 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) pkt-pos= avio_tell(s-pb); pkt-stream_index = 0; + if( s1-gen_ts ) + pkt-pts = (av_gettime() - s1-starttime) / 1000; +av_log(NULL, AV_LOG_ERROR, pts %lld\n, pkt-pts); ret = ffio_read_partial(s-pb, pkt-data, size); if (ret 0) { av_free_packet(pkt); Unrelated hunk I think. @@ -92,7 +97,12 @@ int ff_raw_video_read_header(AVFormatContext *s) goto fail; } + if( s1-gen_ts ) { + framerate.den = 1; + framerate.num = 1000; + s1-starttime = av_gettime(); + } #if FF_API_R_FRAME_RATE st-r_frame_rate = #endif Ditto @@ -108,7 +118,8 @@ fail: #define DEC AV_OPT_FLAG_DECODING_PARAM const AVOption ff_rawvideo_options[] = { { framerate, , OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = 25}, 0, 0, DEC}, + { generate_timestamps, , OFFSET(gen_ts), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC }, { NULL }, }; Idem @@ -124,8 +135,44 @@ AVInputFormat ff_latm_demuxer = { #endif #if CONFIG_MJPEG_DEMUXER -FF_DEF_RAWVIDEO_DEMUXER(mjpeg, raw MJPEG video, NULL, mjpg,mjpeg, AV_CODEC_ID_MJPEG) + +static int mjpeg_probe(AVProbeData *p) Doesn't look bad, maybe few coding nits could be addressed but the concept isn't that bad. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] bfin: vp3: Separate VP3 initialization code
From: Diego Biurrun di...@biurrun.de Signed-off-by: Luca Barbato lu_z...@gentoo.org --- Rebased after the move to int16_t. En passant, adding the missing memsets as pointed by Ronald. libavcodec/bfin/Makefile | 4 ++-- libavcodec/bfin/dsputil_bfin.c | 8 +--- libavcodec/bfin/vp3_bfin.c | 13 - libavcodec/vp3dsp.c| 2 ++ libavcodec/vp3dsp.h| 1 + 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/libavcodec/bfin/Makefile b/libavcodec/bfin/Makefile index be81e6c..d1b41bc 100644 --- a/libavcodec/bfin/Makefile +++ b/libavcodec/bfin/Makefile @@ -2,7 +2,7 @@ OBJS += bfin/dsputil_bfin.o \ bfin/fdct_bfin.o\ bfin/idct_bfin.o\ bfin/pixels_bfin.o \ -bfin/vp3_bfin.o \ -bfin/vp3_idct_bfin.o\ OBJS-$(CONFIG_MPEGVIDEOENC) += bfin/mpegvideo_bfin.o +OBJS-$(CONFIG_VP3DSP) += bfin/vp3_bfin.o \ + bfin/vp3_idct_bfin.o diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index 5d60184..896a3c5 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -257,13 +257,7 @@ void ff_dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) if (avctx-dct_algo == FF_DCT_AUTO) c-fdct = ff_bfin_fdct; -// FIXME convert to VP3DSPContext -if (0) { // avctx-idct_algo == FF_IDCT_VP3) { -c-idct_permutation_type = FF_NO_IDCT_PERM; -c-idct = ff_bfin_vp3_idct; -c-idct_add = ff_bfin_vp3_idct_add; -c-idct_put = ff_bfin_vp3_idct_put; -} else if (avctx-idct_algo == FF_IDCT_AUTO) { +if (avctx-idct_algo == FF_IDCT_AUTO) { c-idct_permutation_type = FF_NO_IDCT_PERM; c-idct = ff_bfin_idct; c-idct_add = bfin_idct_add; diff --git a/libavcodec/bfin/vp3_bfin.c b/libavcodec/bfin/vp3_bfin.c index 962d383..f454f3a 100644 --- a/libavcodec/bfin/vp3_bfin.c +++ b/libavcodec/bfin/vp3_bfin.c @@ -19,8 +19,9 @@ */ #include libavcodec/avcodec.h -#include libavcodec/dsputil.h +#include libavcodec/vp3dsp.h #include dsputil_bfin.h +#include vp3_bfin.h /* Intra iDCT offset 128 */ void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block) @@ -33,6 +34,8 @@ void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block) for (i=0;i8;i++) for (j=0;j8;j++) dest[line_size*i+j]=cm[block[i*8+j]]; + +memset(block, 0, 128); } /* Inter iDCT */ @@ -40,4 +43,12 @@ void ff_bfin_vp3_idct_add (uint8_t *dest, int line_size, int16_t *block) { ff_bfin_vp3_idct (block); ff_bfin_add_pixels_clamped (block, dest, line_size); + +memset(block, 0, 128); +} + +void ff_vp3dsp_init_bfin(VP3DSPContext *c, int flags) +{ +c-idct_add = ff_bfin_vp3_idct_add; +c-idct_put = ff_bfin_vp3_idct_put; } diff --git a/libavcodec/vp3dsp.c b/libavcodec/vp3dsp.c index f6d2c2a..01649f0 100644 --- a/libavcodec/vp3dsp.c +++ b/libavcodec/vp3dsp.c @@ -310,6 +310,8 @@ av_cold void ff_vp3dsp_init(VP3DSPContext *c, int flags) if (ARCH_ARM) ff_vp3dsp_init_arm(c, flags); +if (ARCH_BFIN) +ff_vp3dsp_init_bfin(c, flags); if (ARCH_PPC) ff_vp3dsp_init_ppc(c, flags); if (ARCH_X86) diff --git a/libavcodec/vp3dsp.h b/libavcodec/vp3dsp.h index a5e25ec..755271d 100644 --- a/libavcodec/vp3dsp.h +++ b/libavcodec/vp3dsp.h @@ -49,6 +49,7 @@ typedef struct VP3DSPContext { void ff_vp3dsp_init(VP3DSPContext *c, int flags); void ff_vp3dsp_init_arm(VP3DSPContext *c, int flags); +void ff_vp3dsp_init_bfin(VP3DSPContext *c, int flags); void ff_vp3dsp_init_ppc(VP3DSPContext *c, int flags); void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags); -- 1.8.0.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [RFC][PATCH] probe for raw/mime MJPEG
Luca Barbato wrote: On 23/01/13 15:33, Vladimir Pantelic wrote: @@ -41,7 +43,10 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) pkt-pos= avio_tell(s-pb); pkt-stream_index = 0; + if( s1-gen_ts ) + pkt-pts = (av_gettime() - s1-starttime) / 1000; +av_log(NULL, AV_LOG_ERROR, pts %lld\n, pkt-pts); ret = ffio_read_partial(s-pb, pkt-data, size); if (ret 0) { av_free_packet(pkt); Unrelated hunk I think. oops yes, attached the wrong file, see attahed diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 5e95d10..f085b45 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -124,7 +135,43 @@ AVInputFormat ff_latm_demuxer = { #endif #if CONFIG_MJPEG_DEMUXER -FF_DEF_RAWVIDEO_DEMUXER(mjpeg, raw MJPEG video, NULL, mjpg,mjpeg, AV_CODEC_ID_MJPEG) + +static int mjpeg_probe(AVProbeData *p) +{ + int ofs = 0; + // possible attachment with mime type +if(!memcmp(p-buf , --, 2) || !memcmp(p-buf , \r\n--, 4)) { +if(av_strnstr(p-buf, image/jpeg, p-buf_size )) { +av_log(NULL, AV_LOG_ERROR, mjpeg_probe MIME\n); +return AVPROBE_SCORE_MAX; + } +} +if( p-buf[ofs] == 0xFF p-buf[ofs + 1] == 0xD8) { +av_log(NULL, AV_LOG_ERROR, mjpeg_probe FFD8\n); +return AVPROBE_SCORE_MAX; +} +return 0; +} + +static const AVClass mjpeg_demuxer_class = { +.class_name = mjpeg demuxer, +.item_name = av_default_item_name, +.option = ff_rawvideo_options, +.version= LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_mjpeg_demuxer = { +.name = mjpeg, +.long_name = NULL_IF_CONFIG_SMALL(raw MJPEG video), +.read_header= ff_raw_video_read_header, +.read_packet= ff_raw_read_partial_packet, +.read_probe = mjpeg_probe, +.flags = AVFMT_GENERIC_INDEX, +.extensions = mjpg,mjpeg, +.raw_codec_id = AV_CODEC_ID_MJPEG, +.priv_data_size = sizeof(FFRawVideoDemuxerContext), +.priv_class = mjpeg_demuxer_class, +}; #endif #if CONFIG_MLP_DEMUXER ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] lavu: Add av_strnstr()
From d09072fcdfdbf7d5aa860e60a7e8697a999de820 Mon Sep 17 00:00:00 2001 From: Vladimir Pantelic vlado...@gmail.com Date: Wed, 23 Jan 2013 16:56:16 +0100 Subject: [PATCH] lavu: Add av_strnstr() This is a length limited version of strstr() Signed-off-by: Vladimir Pantelic vlado...@gmail.com --- Changelog|1 + doc/APIchanges |3 +++ libavutil/avstring.c | 16 libavutil/avstring.h | 15 +++ libavutil/version.h |2 +- 5 files changed, 36 insertions(+), 1 deletions(-) diff --git a/Changelog b/Changelog index 24f0791..dd03e6e 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version 9: +- av_strnstr - av_basename and av_dirname - adobe and limelight publisher authentication in RTMP - VDPAU hardware acceleration through normal hwaccel diff --git a/doc/APIchanges b/doc/APIchanges index 3120f7e..79e3cb7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2013-01-xx - xxx - lavu 52.6.0 - avstring.h + Add av_strnstr() + 2013-01-xx - xxx - lavu 52.5.0 - hmac.h Add AVHMAC. diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 2c88bd3..db9eee2 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -64,6 +64,22 @@ char *av_stristr(const char *s1, const char *s2) return NULL; } +char *av_strnstr(const char *s1, const char *s2, size_t len) +{ +size_t l2; + +l2 = strlen(s2); +if (!l2) +return s1; +while (len = l2) { +len--; +if (!memcmp(s1, s2, l2)) +return s1; +s1++; +} +return NULL; +} + size_t av_strlcpy(char *dst, const char *src, size_t size) { size_t len = 0; diff --git a/libavutil/avstring.h b/libavutil/avstring.h index acd6610..da34105 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -67,6 +67,21 @@ int av_stristart(const char *str, const char *pfx, const char **ptr); char *av_stristr(const char *haystack, const char *needle); /** + * Locate the first occurrence in the string haystack of the string needle + * where not more than length characters are searched. A zero-length string + * needle is considered to match at the start of haystack. + * + * This function is a length limited version of the standard strstr(). + * + * @param haystack string to search in + * @param needle string to search for + * @param length length of string to search in + * @return pointer to the located match within haystack + * or a null pointer if no match + */ +char *av_strnstr(const char *haystack, const char *needle, size_t haystack_size); + +/** * Copy the string src to dst, but no more than size - 1 bytes, and * null-terminate dst. * diff --git a/libavutil/version.h b/libavutil/version.h index 68f5752..4c9651f 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -37,7 +37,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 52 -#define LIBAVUTIL_VERSION_MINOR 5 +#define LIBAVUTIL_VERSION_MINOR 6 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 1.7.6.rc1.1.g2c162b ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] lavu: Add av_strnstr()
On 23/01/2013 16:59, Vladimir Pantelic wrote: version 9: +- av_strnstr Shouldn't this be version 10? -- Diego Elio Pettenò — Flameeyes flamee...@flameeyes.eu — http://blog.flameeyes.eu/ ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] doc: update the reference for the title
The recent texi2html exports the title as 'fulltitle_no_texi'. --- doc/t2h.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/t2h.init b/doc/t2h.init index 78c5177..a42637a 100644 --- a/doc/t2h.init +++ b/doc/t2h.init @@ -185,7 +185,7 @@ $print_page_head = \Libav_print_page_head; sub Libav_print_page_head($$) { my $fh = shift; -my $longtitle = $Texi2HTML::THISDOC{'title_no_texi'}; +my $longtitle = $Texi2HTML::THISDOC{'fulltitle_no_texi'}; $longtitle .= : $Texi2HTML::NO_TEXI{'This'} if exists $Texi2HTML::NO_TEXI{'This'}; my $description = $DOCUMENT_DESCRIPTION; $description = $longtitle if (!defined($description)); -- 1.8.0.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [RFC][PATCH] probe for raw/mime MJPEG
On 01/23/2013 09:33 AM, Vladimir Pantelic wrote: +if( p-buf[ofs] == 0xFF p-buf[ofs + 1] == 0xD8) { +av_log(NULL, AV_LOG_ERROR, mjpeg_probe FFD8\n); +return AVPROBE_SCORE_MAX; +} +return 0; I have a feeling this part would lead to some false positives. The probing is very sensitive in this regard. Since it's just checking 2 bytes, maybe it would be ok if it returns a lower score. -Justin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] bfin: vp3: Separate VP3 initialization code
Hi, On Wed, Jan 23, 2013 at 7:45 AM, Luca Barbato lu_z...@gentoo.org wrote: From: Diego Biurrun di...@biurrun.de Signed-off-by: Luca Barbato lu_z...@gentoo.org --- Rebased after the move to int16_t. En passant, adding the missing memsets as pointed by Ronald. libavcodec/bfin/Makefile | 4 ++-- libavcodec/bfin/dsputil_bfin.c | 8 +--- libavcodec/bfin/vp3_bfin.c | 13 - libavcodec/vp3dsp.c| 2 ++ libavcodec/vp3dsp.h| 1 + 5 files changed, 18 insertions(+), 10 deletions(-) TY, should be good now. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [RFC][PATCH] probe for raw/mime MJPEG
Justin Ruggles wrote: On 01/23/2013 09:33 AM, Vladimir Pantelic wrote: +if( p-buf[ofs] == 0xFF p-buf[ofs + 1] == 0xD8) { +av_log(NULL, AV_LOG_ERROR, mjpeg_probe FFD8\n); +return AVPROBE_SCORE_MAX; +} +return 0; I have a feeling this part would lead to some false positives. The probing is very sensitive in this regard. Since it's just checking 2 bytes, maybe it would be ok if it returns a lower score. yeah, I have not done much testing so far, I was just surprised that there was no probing at all for images/mjpeg. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] lavu: Add av_strnstr()
From aaf7000b03161352075194be3300fe06320c80e3 Mon Sep 17 00:00:00 2001 From: Vladimir Pantelic vlado...@gmail.com Date: Wed, 23 Jan 2013 16:56:16 +0100 Subject: [PATCH] lavu: Add av_strnstr() This is a length limited version of strstr() Signed-off-by: Vladimir Pantelic vlado...@gmail.com --- Changelog|4 doc/APIchanges |3 +++ libavutil/avstring.c | 16 libavutil/avstring.h | 15 +++ libavutil/version.h |2 +- 5 files changed, 39 insertions(+), 1 deletions(-) diff --git a/Changelog b/Changelog index 24f0791..c235727 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,10 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 10: +- av_strnstr + + version 9: - av_basename and av_dirname - adobe and limelight publisher authentication in RTMP diff --git a/doc/APIchanges b/doc/APIchanges index 3120f7e..79e3cb7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2013-01-xx - xxx - lavu 52.6.0 - avstring.h + Add av_strnstr() + 2013-01-xx - xxx - lavu 52.5.0 - hmac.h Add AVHMAC. diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 2c88bd3..db9eee2 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -64,6 +64,22 @@ char *av_stristr(const char *s1, const char *s2) return NULL; } +char *av_strnstr(const char *s1, const char *s2, size_t len) +{ +size_t l2; + +l2 = strlen(s2); +if (!l2) +return s1; +while (len = l2) { +len--; +if (!memcmp(s1, s2, l2)) +return s1; +s1++; +} +return NULL; +} + size_t av_strlcpy(char *dst, const char *src, size_t size) { size_t len = 0; diff --git a/libavutil/avstring.h b/libavutil/avstring.h index acd6610..da34105 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -67,6 +67,21 @@ int av_stristart(const char *str, const char *pfx, const char **ptr); char *av_stristr(const char *haystack, const char *needle); /** + * Locate the first occurrence in the string haystack of the string needle + * where not more than length characters are searched. A zero-length string + * needle is considered to match at the start of haystack. + * + * This function is a length limited version of the standard strstr(). + * + * @param haystack string to search in + * @param needle string to search for + * @param length length of string to search in + * @return pointer to the located match within haystack + * or a null pointer if no match + */ +char *av_strnstr(const char *haystack, const char *needle, size_t haystack_size); + +/** * Copy the string src to dst, but no more than size - 1 bytes, and * null-terminate dst. * diff --git a/libavutil/version.h b/libavutil/version.h index 68f5752..4c9651f 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -37,7 +37,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 52 -#define LIBAVUTIL_VERSION_MINOR 5 +#define LIBAVUTIL_VERSION_MINOR 6 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 1.7.6.rc1.1.g2c162b ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v2] dsputil: x86: Convert mpeg4 qpel and dsputil avg to yasm
Hi Daniel, On Tue, Jan 22, 2013 at 11:19 PM, Daniel Kang daniel.d.k...@gmail.com wrote: @@ -1330,10 +1087,12 @@ static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src,\ { \ uint64_t half[8 + 9]; \ uint8_t * const halfH = ((uint8_t*)half); \ -put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ -stride, 9); \ -put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9); \ -OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8); \ +ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ + stride, 9); \ +ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, \ +8, stride, 9); \ +ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \ + stride, 8); \ } \ So, for all cases like this, does this actually affect speed? I mean, previously this could be inlined, now it no longer can be. I wonder if that has any effect on speed (i.e. was it ever inlined previously?). Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] lavu: Add av_strnstr()
On Wed, Jan 23, 2013 at 04:59:23PM +0100, Vladimir Pantelic wrote: From d09072fcdfdbf7d5aa860e60a7e8697a999de820 Mon Sep 17 00:00:00 2001 From: Vladimir Pantelic vlado...@gmail.com Date: Wed, 23 Jan 2013 16:56:16 +0100 Subject: [PATCH] lavu: Add av_strnstr() This is a length limited version of strstr() . --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version 9: +- av_strnstr - av_basename and av_dirname - adobe and limelight publisher authentication in RTMP - VDPAU hardware acceleration through normal hwaccel Quoting from directly above where you added this entry: Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. :-) --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2013-01-xx - xxx - lavu 52.6.0 - avstring.h + Add av_strnstr() . --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -64,6 +64,22 @@ char *av_stristr(const char *s1, const char *s2) +char *av_strnstr(const char *s1, const char *s2, size_t len) +{ +size_t l2; + +l2 = strlen(s2); +if (!l2) +return s1; +while (len = l2) { +len--; +if (!memcmp(s1, s2, l2)) +return s1; +s1++; +} +return NULL; +} Indentation level is twice what it should be. Doesn't this generate warnings when you return those const pointers? Also, all hail for non-descriptive variable names :) Here's my version, slightly more compact ;) char *av_strnstr(const char *haystack, const char *needle, size_t haystack_size); { size_t needle_len = strlen(needle); if (!needle_len) return haystack; for (; len = needle_len; len--, haystack++) if (!memcmp(haystack, needle, needle_len)) return haystack; return NULL; } --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -67,6 +67,21 @@ int av_stristart(const char *str, const char *pfx, const char **ptr); char *av_stristr(const char *haystack, const char *needle); /** + * Locate the first occurrence in the string haystack of the string needle + * where not more than length characters are searched. Locate the first occurrence of the string needle in the first length characters of the string haystack. There is some doxygen syntax to markup parameters that might help here. + * where not more than length characters are searched. A zero-length string + * This function is a length limited version of the standard strstr(). length-limited + * @param haystack string to search in + * @param needle string to search for + * @param length length of string to search in + * @return pointer to the located match within haystack pointer to the first match within the haystack + * or a null pointer if no match NULL + */ +char *av_strnstr(const char *haystack, const char *needle, size_t haystack_size); nit: break the line The parameter names of the declaration don't match the definition, nor the doxygen ... Diego ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] lavu: Add av_strnstr()
On 23/01/13 18:21, Vladimir Pantelic wrote: Subject: [PATCH] lavu: Add av_strnstr() Looks fine. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] rtp: Make sure priv_data is set before reading it
This fixes crashes with muxing H263 into RTSP. CC: libav-sta...@libav.org --- libavformat/rtp.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtp.c b/libavformat/rtp.c index dfe97de..d1c6ed0 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -104,7 +104,7 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, for (i = 0; rtp_payload_types[i].pt = 0; ++i) if (rtp_payload_types[i].codec_id == codec-codec_id) { if (codec-codec_id == AV_CODEC_ID_H263 (!fmt || -!fmt-oformat-priv_class || +!fmt-oformat-priv_class || !fmt-priv_data || !av_opt_flag_is_set(fmt-priv_data, rtpflags, rfc2190))) continue; /* G722 has 8000 as nominal rate even if the sample rate is 16000, -- 1.7.9.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] rtp: Make sure priv_data is set before reading it
On 23/01/13 20:39, Martin Storsjö wrote: This fixes crashes with muxing H263 into RTSP. CC: libav-sta...@libav.org --- libavformat/rtp.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) OK. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [libav-commits] wmv2: move IDCT to its own DSP context.
On Mon, 21 Jan 2013, Ronald S. Bultje wrote: Module: libav Branch: master Commit: e6bc38fd49c94726b45d5d5cc2b756ad8ec49ee0 Author:Ronald S. Bultje rsbul...@gmail.com Committer: Ronald S. Bultje rsbul...@gmail.com Date: Sun Jan 20 22:12:35 2013 -0800 wmv2: move IDCT to its own DSP context. This allows us to remove FF_IDCT_WMV2, which serves no practical purpose other than to be able to select the WMV2 IDCT for MPEG (or vice versa) and get corrupt output. Fate tests for all wmv2-related tests change, because (for some obscure reason) they forced use of the MPEG IDCT. You would get the same changes previously by not using -idct simple in the fate test (or replacing it with -idct auto). --- libavcodec/Makefile |4 +- libavcodec/dsputil.c | 89 - libavcodec/dsputil.h |1 - libavcodec/wmv2.c | 22 ++- libavcodec/wmv2.h |2 + libavcodec/wmv2dec.c |4 - libavcodec/wmv2dsp.c | 145 + libavcodec/wmv2dsp.h | 34 ++ tests/ref/seek/vsynth2-wmv2 | 28 tests/ref/vsynth/vsynth1-wmv2 |8 +- tests/ref/vsynth/vsynth2-wmv2 |6 +- 11 files changed, 223 insertions(+), 120 deletions(-) diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index a3dcbb3..595630f 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -28,8 +28,24 @@ av_cold void ff_wmv2_common_init(Wmv2Context * w){ MpegEncContext * const s= w-s; -ff_init_scantable(s-dsp.idct_permutation, w-abt_scantable[0], ff_wmv2_scantableA); -ff_init_scantable(s-dsp.idct_permutation, w-abt_scantable[1], ff_wmv2_scantableB); +ff_wmv2dsp_init(w-wdsp); +ff_init_scantable_permutation(s-dsp.idct_permutation, + w-wdsp.idct_perm); +ff_init_scantable(s-dsp.idct_permutation, w-abt_scantable[0], + ff_wmv2_scantableA); +ff_init_scantable(s-dsp.idct_permutation, w-abt_scantable[1], + ff_wmv2_scantableB); +ff_init_scantable(s-dsp.idct_permutation, s-intra_scantable, + ff_wmv1_scantable[1]); +ff_init_scantable(s-dsp.idct_permutation, s-intra_h_scantable, + ff_wmv1_scantable[2]); +ff_init_scantable(s-dsp.idct_permutation, s-intra_v_scantable, + ff_wmv1_scantable[3]); +ff_init_scantable(s-dsp.idct_permutation, s-inter_scantable, + ff_wmv1_scantable[0]); +s-dsp.idct_put = w-wdsp.idct_put; +s-dsp.idct_add = w-wdsp.idct_add; +s-dsp.idct = NULL; } This broke wmv2 encoding pretty severly. Try avconv -i foo -an -vcodec wmv2 foo.asf and play it back; before this it played back fine, now the pixels within macroblocks are pretty badly scrambled. // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v2] dsputil: x86: Convert mpeg4 qpel and dsputil avg to yasm
On Wed, Jan 23, 2013 at 12:36 PM, Ronald S. Bultje rsbul...@gmail.com wrote: Hi Daniel, On Tue, Jan 22, 2013 at 11:19 PM, Daniel Kang daniel.d.k...@gmail.com wrote: @@ -1330,10 +1087,12 @@ static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src,\ { \ uint64_t half[8 + 9]; \ uint8_t * const halfH = ((uint8_t*)half); \ -put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ -stride, 9); \ -put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9); \ -OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8); \ +ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ + stride, 9); \ +ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, \ +8, stride, 9); \ +ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \ + stride, 8); \ } \ So, for all cases like this, does this actually affect speed? I mean, previously this could be inlined, now it no longer can be. I wonder if that has any effect on speed (i.e. was it ever inlined previously?). Depending on the architecture (??) the functions are inlined, but are often not. I suspect GCC's insane method of reordering registers swallows any overhead from calling these functions, but due to macro hell, I'm not sure of the best way to test this. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] wmv2: Propagate the wmv2 idct permutation type to the dsputils context
This fixes encoding where the idct setting originally was set to FF_IDCT_AUTO and dsputil chose a default idct with a non-null permutation - even if the permutation tables were updated, dct_quantize in x86/mpegvideoenc_template.c also checked the value of this type variable. --- libavcodec/wmv2.c |1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index dea3b3b..4420f49 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -29,6 +29,7 @@ av_cold void ff_wmv2_common_init(Wmv2Context * w){ MpegEncContext * const s= w-s; ff_wmv2dsp_init(w-wdsp); +s-dsp.idct_permutation_type = w-wdsp.idct_perm; ff_init_scantable_permutation(s-dsp.idct_permutation, w-wdsp.idct_perm); ff_init_scantable(s-dsp.idct_permutation, w-abt_scantable[0], -- 1.7.9.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v2] dsputil: x86: Convert mpeg4 qpel and dsputil avg to yasm
On Wed, Jan 23, 2013 at 4:14 PM, Daniel Kang daniel.d.k...@gmail.com wrote: On Wed, Jan 23, 2013 at 12:36 PM, Ronald S. Bultje rsbul...@gmail.com wrote: Hi Daniel, On Tue, Jan 22, 2013 at 11:19 PM, Daniel Kang daniel.d.k...@gmail.com wrote: @@ -1330,10 +1087,12 @@ static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src,\ { \ uint64_t half[8 + 9]; \ uint8_t * const halfH = ((uint8_t*)half); \ -put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ -stride, 9); \ -put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9); \ -OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8); \ +ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ + stride, 9); \ +ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, \ +8, stride, 9); \ +ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \ + stride, 8); \ } \ So, for all cases like this, does this actually affect speed? I mean, previously this could be inlined, now it no longer can be. I wonder if that has any effect on speed (i.e. was it ever inlined previously?). Depending on the architecture (??) the functions are inlined, but are often not. I suspect GCC's insane method of reordering registers swallows any overhead from calling these functions, but due to macro hell, I'm not sure of the best way to test this. Sorry, this was not very clear. I think the yasm version is faster despite calling overhead, because GCC uses some ridiculous method of reordering registers for the inline assembly. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/2] rtp: Make sure the output format pointer is set
Not sure if this actually happens, but we do the same check when checking payload_type further above in the function, so it might be needed. --- libavformat/rtp.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtp.c b/libavformat/rtp.c index d1c6ed0..e827c2e 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -103,7 +103,7 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, /* static payload type */ for (i = 0; rtp_payload_types[i].pt = 0; ++i) if (rtp_payload_types[i].codec_id == codec-codec_id) { -if (codec-codec_id == AV_CODEC_ID_H263 (!fmt || +if (codec-codec_id == AV_CODEC_ID_H263 (!fmt || !fmt-oformat || !fmt-oformat-priv_class || !fmt-priv_data || !av_opt_flag_is_set(fmt-priv_data, rtpflags, rfc2190))) continue; -- 1.7.9.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/2] rtpenc_chain: Use the original AVFormatContext for getting payload type
In ff_rtp_get_payload_type, the AVFormatContext is used for checking whether the payload_type or rtpflags options are set. In rtpenc_chain, the rtpctx struct is a newly initialized struct where no options have been set yet, so no options can be fetched from there. All muxers that internally chain rtp muxers have the rtpflags field that allows passing such options on (which is how this worked before 8034130e06), so this works just as intended. This makes it possible to produce H263 in RFC2190 format with chained RTP muxers. CC: libav-sta...@libav.org --- libavformat/rtpenc_chain.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index 3c297eb..935dd6c 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -62,7 +62,7 @@ int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s, /* Get the payload type from the codec */ if (st-id RTP_PT_PRIVATE) rtpctx-streams[0]-id = -ff_rtp_get_payload_type(rtpctx, st-codec, idx); +ff_rtp_get_payload_type(s, st-codec, idx); else rtpctx-streams[0]-id = st-id; -- 1.7.9.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v2] dsputil: x86: Convert mpeg4 qpel and dsputil avg to yasm
Hi, On Wed, Jan 23, 2013 at 1:16 PM, Daniel Kang daniel.d.k...@gmail.com wrote: On Wed, Jan 23, 2013 at 4:14 PM, Daniel Kang daniel.d.k...@gmail.com wrote: On Wed, Jan 23, 2013 at 12:36 PM, Ronald S. Bultje rsbul...@gmail.com wrote: Hi Daniel, On Tue, Jan 22, 2013 at 11:19 PM, Daniel Kang daniel.d.k...@gmail.com wrote: @@ -1330,10 +1087,12 @@ static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src,\ { \ uint64_t half[8 + 9]; \ uint8_t * const halfH = ((uint8_t*)half); \ -put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ -stride, 9); \ -put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9); \ -OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8); \ +ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \ + stride, 9); \ +ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, \ +8, stride, 9); \ +ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \ + stride, 8); \ } \ So, for all cases like this, does this actually affect speed? I mean, previously this could be inlined, now it no longer can be. I wonder if that has any effect on speed (i.e. was it ever inlined previously?). Depending on the architecture (??) the functions are inlined, but are often not. I suspect GCC's insane method of reordering registers swallows any overhead from calling these functions, but due to macro hell, I'm not sure of the best way to test this. Sorry, this was not very clear. I think the yasm version is faster despite calling overhead, because GCC uses some ridiculous method of reordering registers for the inline assembly. Do you have numbers? Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] wmv2: Propagate the wmv2 idct permutation type to the dsputils context
On Wed, 23 Jan 2013, Martin Storsjö wrote: This fixes encoding where the idct setting originally was set to FF_IDCT_AUTO and dsputil chose a default idct with a non-null permutation - even if the permutation tables were updated, dct_quantize in x86/mpegvideoenc_template.c also checked the value of this type variable. --- libavcodec/wmv2.c |1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index dea3b3b..4420f49 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -29,6 +29,7 @@ av_cold void ff_wmv2_common_init(Wmv2Context * w){ MpegEncContext * const s= w-s; ff_wmv2dsp_init(w-wdsp); +s-dsp.idct_permutation_type = w-wdsp.idct_perm; ff_init_scantable_permutation(s-dsp.idct_permutation, w-wdsp.idct_perm); ff_init_scantable(s-dsp.idct_permutation, w-abt_scantable[0], -- 1.7.9.4 OK'd by Ronald on irc. // Martin___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/2] rtp: Make sure the output format pointer is set
On 23/01/13 22:30, Martin Storsjö wrote: Not sure if this actually happens, but we do the same check when checking payload_type further above in the function, so it might be needed. --- libavformat/rtp.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Better safe than sorry, commit this and the following one anytime. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Separate h264 qpel from dsputil
On 24/01/13 05:24, Ronald S. Bultje wrote: From: Mans Rullgard m...@mansr.com The sh4 optimizations are removed, because the code is 100% identical to the C code, so it is unlikely to provide any real practical benefit. Looks nice indeed. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel