[FFmpeg-devel] avformat option strange behaviour
Clément Bœsch
ubitux at gmail.com
Mon Jul 25 18:05:36 CEST 2011
Hi,
It seems the format option parsing is broken in FFmpeg, but I can't figure
out why. I still didn't do a git bisect to track down the issue, but
someone may have a hint about this.
I attached a dummy patch to add an option to a random format, and tried to
use it. Unfortunately, the -foobar bla never set the option in the context
struct; the option is well recognized and parsed (it fills the options
dict), but that dict may not be used. I'm almost certain it's a bug since
applying the exact same patch works with libav HEAD.
--
Clément B.
-------------- next part --------------
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index b84504c..913a605 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -35,6 +35,7 @@
#include <math.h>
#include <time.h>
+#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "libavcodec/bytestream.h"
#include "audiointerleave.h"
@@ -171,6 +172,7 @@ static const MXFContainerEssenceEntry mxf_essence_container_uls[] = {
};
typedef struct MXFContext {
+ AVClass *av_class;
int64_t footer_partition_offset;
int essence_container_count;
AVRational time_base;
@@ -192,6 +194,7 @@ typedef struct MXFContext {
uint64_t body_offset;
uint32_t instance_number;
uint8_t umid[16]; ///< unique material identifier
+ char *foobar;
} MXFContext;
static const uint8_t uuid_base[] = { 0xAD,0xAB,0x44,0x24,0x2f,0x25,0x4d,0xc7,0x92,0xff,0x29,0xbd };
@@ -1411,6 +1414,8 @@ static int mxf_write_header(AVFormatContext *s)
AVDictionaryEntry *t;
int64_t timestamp = 0;
+ av_log(0,0,"foobar=%s\n", mxf->foobar);
+
if (!s->nb_streams)
return -1;
@@ -1889,6 +1894,16 @@ static int mxf_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int
mxf_interleave_get_packet, mxf_compare_timestamps);
}
+static const AVClass class = {
+ .class_name = "mxf",
+ .item_name = av_default_item_name,
+ .version = LIBAVUTIL_VERSION_INT,
+ .option = (const AVOption[]){
+ {"foobar", "", offsetof(MXFContext, foobar), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, AV_OPT_FLAG_ENCODING_PARAM},
+ {NULL}
+ },
+};
+
AVOutputFormat ff_mxf_muxer = {
.name = "mxf",
.long_name = NULL_IF_CONFIG_SMALL("Material eXchange Format"),
@@ -1902,6 +1917,7 @@ AVOutputFormat ff_mxf_muxer = {
.write_trailer = mxf_write_footer,
.flags = AVFMT_NOTIMESTAMPS,
.interleave_packet = mxf_interleave,
+ .priv_class = &class,
};
AVOutputFormat ff_mxf_d10_muxer = {
@@ -1916,4 +1932,5 @@ AVOutputFormat ff_mxf_d10_muxer = {
.write_trailer = mxf_write_footer,
.flags = AVFMT_NOTIMESTAMPS,
.interleave_packet = mxf_interleave,
+ .priv_class = &class,
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110725/3249b360/attachment.asc>
More information about the ffmpeg-devel
mailing list