Merge pull request #1585 from ZoneMinder/copy_av_dict_parse_string_from_ffmpeg
Fixes #1584. I've just copied the relevant functions from ffmpeg sour…
This commit is contained in:
commit
cd55c8b2fb
|
@ -69,6 +69,55 @@ enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subp
|
|||
|
||||
return pf;
|
||||
}
|
||||
/* The following is copied directly from newer ffmpeg. */
|
||||
#if LIBAVUTIL_VERSION_CHECK(52, 7, 0, 17, 100)
|
||||
#else
|
||||
static int parse_key_value_pair(AVDictionary **pm, const char **buf,
|
||||
const char *key_val_sep, const char *pairs_sep,
|
||||
int flags)
|
||||
{
|
||||
char *key = av_get_token(buf, key_val_sep);
|
||||
char *val = NULL;
|
||||
int ret;
|
||||
|
||||
if (key && *key && strspn(*buf, key_val_sep)) {
|
||||
(*buf)++;
|
||||
val = av_get_token(buf, pairs_sep);
|
||||
}
|
||||
|
||||
if (key && *key && val && *val)
|
||||
ret = av_dict_set(pm, key, val, flags);
|
||||
else
|
||||
ret = AVERROR(EINVAL);
|
||||
|
||||
av_freep(&key);
|
||||
av_freep(&val);
|
||||
|
||||
return ret;
|
||||
}
|
||||
int av_dict_parse_string(AVDictionary **pm, const char *str,
|
||||
const char *key_val_sep, const char *pairs_sep,
|
||||
int flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
/* ignore STRDUP flags */
|
||||
flags &= ~(AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
||||
|
||||
while (*str) {
|
||||
if ((ret = parse_key_value_pair(pm, &str, key_val_sep, pairs_sep, flags)) < 0)
|
||||
return ret;
|
||||
|
||||
if (*str)
|
||||
str++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif // HAVE_LIBAVUTIL
|
||||
|
||||
#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
|
@ -240,4 +289,5 @@ int SWScale::ConvertDefaults(const uint8_t* in_buffer, const size_t in_buffer_si
|
|||
}
|
||||
#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
|
||||
|
||||
#endif // HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE
|
||||
|
|
|
@ -32,6 +32,7 @@ extern "C" {
|
|||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/base64.h>
|
||||
#include <libavutil/mathematics.h>
|
||||
#include <libavutil/avstring.h>
|
||||
|
||||
/* LIBAVUTIL_VERSION_CHECK checks for the right version of libav and FFmpeg
|
||||
* The original source is vlc (in modules/codec/avcodec/avcommon_compat.h)
|
||||
|
@ -274,7 +275,15 @@ protected:
|
|||
#undef av_err2str
|
||||
#define av_err2str(errnum) av_make_error_string(errnum).c_str()
|
||||
|
||||
#endif // __cplusplus
|
||||
/* The following is copied directly from newer ffmpeg */
|
||||
#if LIBAVUTIL_VERSION_CHECK(52, 7, 0, 17, 100)
|
||||
#else
|
||||
int av_dict_parse_string(AVDictionary **pm, const char *str,
|
||||
const char *key_val_sep, const char *pairs_sep,
|
||||
int flags);
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#endif // ( HAVE_LIBAVUTIL_AVUTIL_H || HAVE_LIBAVCODEC_AVCODEC_H || HAVE_LIBAVFORMAT_AVFORMAT_H || HAVE_LIBAVDEVICE_AVDEVICE_H )
|
||||
|
|
Loading…
Reference in New Issue