On 14.09.2014 01:01, Luca Barbato wrote:
On 14/09/14 00:45, Andreas Cadhalpun wrote:
On 14.09.2014 00:43, Luca Barbato wrote:
On 14/09/14 00:41, Andreas Cadhalpun wrote:
Hi,
in commit 3a19405d574a467c68b48e4b824c76617fd59de0 the
AVProbeData.mime_type and AVInputFormat.mime_type fields were added, but
they have different types: AVProbeData.mime_type is uint8_t*, while
AVInputFormat.mime_type is const char*. The latter seems to be more
correct, since both are used as arguments for av_match_name, which takes
const char*.
Attached patch changes AVProbeData.mime_type to const char* to make this
consistent.
It isn't enough since just doing that would generate a warning, I'm not
against the change all in all.
What else needs to be changed?
check the generated warning, the whole stuff generated by getting the
data from avoption and that means that the data is recovered as uint8_t
*. (you should notice since the warning generated is quite wordy).
OK, fixed.
Best regards,
Andreas
>From d25885a51673053363ad252819cf5432be94cdce Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <[email protected]>
Date: Sun, 14 Sep 2014 01:26:49 +0200
Subject: [PATCH] lavf/avformat.h: use const char* instead of uint8_t* for
AVProbeData.mime_type
This makes the field consistent with AVInputFormat.mime_type and the argument type of av_match_name.
Signed-off-by: Andreas Cadhalpun <[email protected]>
---
libavformat/avformat.h | 2 +-
libavformat/format.c | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 923b282..f28186f 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -396,7 +396,7 @@ typedef struct AVProbeData {
const char *filename;
unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
int buf_size; /**< Size of buf except extra allocated bytes */
- uint8_t *mime_type; /**< mime_type, when known. */
+ const char *mime_type; /**< mime_type, when known. */
} AVProbeData;
#define AVPROBE_SCORE_EXTENSION 50 ///< score for file extension
diff --git a/libavformat/format.c b/libavformat/format.c
index c5a57d5..e001311 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -242,6 +242,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
AVProbeData pd = { filename ? filename : "" };
uint8_t *buf = NULL;
int ret = 0, probe_size;
+ uint8_t *mime_type_opt = NULL;
if (!max_probe_size)
max_probe_size = PROBE_BUF_MAX;
@@ -255,7 +256,9 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
avio_skip(pb, offset);
max_probe_size -= offset;
if (pb->av_class)
- av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &pd.mime_type);
+ av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type_opt);
+ pd.mime_type = (const char*) mime_type_opt;
+ mime_type_opt = NULL;
for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt;
probe_size = FFMIN(probe_size << 1,
FFMAX(max_probe_size, probe_size + 1))) {
@@ -301,6 +304,6 @@ fail:
(ret = ffio_rewind_with_probe_data(pb, buf, pd.buf_size)) < 0) {
av_free(buf);
}
- av_free(pd.mime_type);
+ av_freep(&pd.mime_type);
return ret;
}
--
2.1.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel