Discussion:
[PATCH 2/2] ffmpeg: avoid deprecated functions
Johannes Weißl
2011-07-28 15:19:04 UTC
Permalink
---
ffmpeg.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 365c340..c1ad380 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -52,6 +52,12 @@
#endif
#endif

+#if (LIBAVUTIL_VERSION_INT < ((51<<16)+(5<<8)+0))
+#define AV_DICT_IGNORE_SUFFIX AV_METADATA_IGNORE_SUFFIX
+#define av_dict_get av_metadata_get
+#define AVDictionaryEntry AVMetadataTag
+#endif
+
struct ffmpeg_input {
AVPacket pkt;
int curr_pkt_size;
@@ -174,7 +180,11 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)

ffmpeg_init();

+#if (LIBAVFORMAT_VERSION_INT < ((53<<16)+(2<<8)+0))
err = av_open_input_file(&ic, ip_data->filename, NULL, 0, NULL);
+#else
+ err = avformat_open_input(&ic, ip_data->filename, NULL, NULL);
+#endif
if (err < 0) {
d_print("av_open failed: %d\n", err);
return -IP_ERROR_FILE_FORMAT;
@@ -437,9 +447,9 @@ static int ffmpeg_read_comments(struct input_plugin_data *ip_data, struct keyval
}
#else
GROWING_KEYVALS(c);
- AVMetadataTag *tag = NULL;
+ AVDictionaryEntry *tag = NULL;

- while ((tag = av_metadata_get(ic->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
+ while ((tag = av_dict_get(ic->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
if (tag && tag->value[0])
comments_add_const(&c, tag->key, tag->value);
}
--
1.7.6
Johannes Weißl
2011-07-28 16:32:16 UTC
Permalink
API versions are different in libav and ffmpeg, just choose the safest
one that works...
---
ffmpeg.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index c1ad380..d6f95fa 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -191,7 +191,11 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
}

do {
+#if (LIBAVFORMAT_VERSION_INT < ((53<<16)+(6<<8)+0))
err = av_find_stream_info(ic);
+#else
+ err = avformat_find_stream_info(ic, NULL);
+#endif
if (err < 0) {
d_print("unable to find stream info: %d\n", err);
err = -IP_ERROR_FILE_FORMAT;
@@ -222,7 +226,11 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
if (codec->capabilities & CODEC_CAP_TRUNCATED)
cc->flags |= CODEC_FLAG_TRUNCATED;

+#if (LIBAVCODEC_VERSION_INT < ((53<<16)+(9<<8)+0))
if (avcodec_open(cc, codec) < 0) {
+#else
+ if (avcodec_open2(cc, codec, NULL) < 0) {
+#endif
d_print("could not open codec: %d, %s\n", cc->codec_id, cc->codec_name);
err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
break;
--
1.7.6
Johannes Weißl
2011-07-28 16:32:17 UTC
Permalink
The libav project is not including the header in libavutil/avutil.h
anymore (commit 0ebcdf5cdad6bf20a5170735a7f77b23ecc081ac).

ffmpeg.c:406:2: error: implicit declaration of function 'av_rescale_q' [-Werror=implicit-function-declaration]
---
ffmpeg.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index d6f95fa..60b9758 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -32,6 +32,9 @@
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
+#ifndef AVUTIL_MATHEMATICS_H
+#include <libavutil/mathematics.h>
+#endif
#endif

#if (LIBAVFORMAT_VERSION_INT < ((52<<16)+(31<<8)+0))
--
1.7.6
Johannes Weißl
2011-07-30 16:54:46 UTC
Permalink
AVCodecContext needs to be a pointer to NULL, otherwise newer versions
of ffmpeg segfault!
---
ffmpeg.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 60b9758..43ab696 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -179,7 +179,7 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
int64_t channel_layout = 0;
AVCodec *codec;
AVCodecContext *cc = NULL;
- AVFormatContext *ic;
+ AVFormatContext *ic = NULL;

ffmpeg_init();
--
1.7.6
Gregory Petrosyan
2011-08-01 07:44:34 UTC
Permalink
Hello!

Sorry for the delay :-(
static void decode_comment(struct id3tag *id3, const char *buf, int len, int encoding)
{
int slen;
- char out0;
char *out;
+ int valid_description;
if (len <= 3)
return;
@@ -802,11 +802,10 @@ static void decode_comment(struct id3tag *id3, const char *buf, int len, int enc
if (!out)
return;
- out0 = *out;
+ valid_description = strcmp(out, "") || strcmp(out, "description");
free(out);
- /* we are interested only in comments with empty description */
- if (out0 != '\0')
+ if (!valid_description)
return;
'out0 != 0' <=> 'strcmp(out, "") != 0'
'strcmp(out, "") != 0' => 'valid_description != 0'
'valid_description != 0' => 'return' will not work.

I may be a little rusty after a couple of days outside the city, but it seems
that
+ valid_description = strcmp(out, "") || strcmp(out, "description");
should instead be
+ valid_description = strcmp(out, "") == 0 || !strcmp(out, "description") == 0;
?

Gregory
Johannes Weißl
2011-08-01 09:44:30 UTC
Permalink
Hi Gregory,
Post by Gregory Petrosyan
I may be a little rusty after a couple of days outside the city, but it seems
that
+ valid_description = strcmp(out, "") || strcmp(out, "description");
should instead be
+ valid_description = strcmp(out, "") == 0 || !strcmp(out, "description") == 0;
Argh, of course! Thanks a lot! My patch reads comments with arbitrary
description, that is the reason why my test was successful...

Johannes
Gregory Petrosyan
2011-08-01 10:04:36 UTC
Permalink
Post by Johannes Weißl
Post by Gregory Petrosyan
I may be a little rusty after a couple of days outside the city, but it seems
that
+ valid_description = strcmp(out, "") || strcmp(out, "description");
should instead be
+ valid_description = strcmp(out, "") == 0 || !strcmp(out, "description") == 0;
Argh, of course! Thanks a lot! My patch reads comments with arbitrary
description, that is the reason why my test was successful...
OK, cool -- merged all 5 now to both maint and master, thanks a lot!

Gregory
Johannes Weißl
2011-08-01 10:27:21 UTC
Permalink
Compilation for (even slightly) older versions fails, so we need
pkg-config to check for the right version!
---
configure | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 21f1050..327654d 100755
--- a/configure
+++ b/configure
@@ -312,7 +312,7 @@ check_waveout()

check_roar()
{
- pkg_config ROAR "libroar >= 0.4.5" "" "-lroar"
+ pkg_config ROAR "libroar >= 0.4.5"
return $?
}
--
1.7.6
Gregory Petrosyan
2011-08-01 12:50:15 UTC
Permalink
Post by Johannes Weißl
Compilation for (even slightly) older versions fails, so we need
pkg-config to check for the right version!
Thanks, merged!

Gregory

Loading...