From a84fb6e06f7f13e61b5dad0224fa392ebe65e294 Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Wed, 23 Jan 2013 12:26:59 +0100 Subject: [PATCH 1/2] h264: Allow discarding the cropping information from SPS Some 3D systems overload the meaning of the field for other purposes. Signed-off-by: Luca Barbato --- libavcodec/avcodec.h | 2 ++ libavcodec/h264_ps.c | 14 ++++++++++++++ libavcodec/options_table.h | 1 + libavcodec/version.h | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e60119e8db..7a2477516d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -657,6 +657,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. +#define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS. + #if FF_API_MPV_GLOBAL_OPTS #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp. #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index ff6c077ed3..63f371c80c 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -425,6 +425,20 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ sps->crop_right = get_ue_golomb(&s->gb); sps->crop_top = get_ue_golomb(&s->gb); sps->crop_bottom= get_ue_golomb(&s->gb); + if (h->s.avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { + av_log(h->s.avctx, AV_LOG_DEBUG, + "discarding sps cropping, " + "original values are l:%u r:%u t:%u b:%u\n", + sps->crop_left, + sps->crop_right, + sps->crop_top, + sps->crop_bottom); + + sps->crop_left = + sps->crop_right = + sps->crop_top = + sps->crop_bottom = 0; + } if(sps->crop_left || sps->crop_top){ av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n"); } diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index f2e83121a1..7d0795a580 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -76,6 +76,7 @@ static const AVOption options[]={ {"sgop", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"}, #endif {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"ignorecrop", "ignore cropping information from sps", 1, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"}, {"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"}, #if FF_API_SUB_ID {"sub_id", NULL, OFFSET(sub_id), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 62f2bcd842..80da6e2133 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,7 +27,7 @@ */ #define LIBAVCODEC_VERSION_MAJOR 54 -#define LIBAVCODEC_VERSION_MINOR 40 +#define LIBAVCODEC_VERSION_MINOR 41 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From b85a5e87af4254b80913fe33591d96361f30832b Mon Sep 17 00:00:00 2001 From: Vladimir Pantelic Date: Thu, 24 Jan 2013 14:09:48 +0000 Subject: [PATCH 2/2] lavu: Add av_strnstr() This is a length limited version of strstr() Signed-off-by: Vladimir Pantelic Signed-off-by: Luca Barbato --- Changelog | 4 ++++ doc/APIchanges | 3 +++ libavutil/avstring.c | 14 ++++++++++++++ libavutil/avstring.h | 15 +++++++++++++++ libavutil/version.h | 2 +- 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 24f079192d..c235727e42 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 3120f7ee6a..79e3cb79a0 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2013-01-xx - xxxxxxx - lavu 52.6.0 - avstring.h + Add av_strnstr() + 2013-01-xx - xxxxxxx - lavu 52.5.0 - hmac.h Add AVHMAC. diff --git a/libavutil/avstring.c b/libavutil/avstring.c index a16adcb3fe..625f723686 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -65,6 +65,20 @@ char *av_stristr(const char *s1, const char *s2) return NULL; } +char *av_strnstr(const char *haystack, const char *needle, size_t hay_length) +{ + size_t needle_len = strlen(needle); + if (!needle_len) + return haystack; + while (hay_length >= needle_len) { + hay_length--; + if (!memcmp(haystack, needle, needle_len)) + return haystack; + haystack++; + } + 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 acd6610d38..e0e6ed26f5 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -66,6 +66,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 of the string needle in the string haystack + * where not more than hay_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 hay_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 hay_length); + /** * 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 68f5752f05..4c9651fae2 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, \