[FFmpeg-devel] [PATCH] astenc: Add an option to set the loop flag
James Almer
jamrial at gmail.com
Sun Dec 23 01:10:24 CET 2012
>> On 22/12/12 2:46 PM, Michael Niedermayer wrote:
> Consider a user who wants to use the features and doesnt know the ast
> internal details nor does he have the time to read the whole manual
>
> he tries -loop, -loop 1, probably not -astflags loop
> he might try -loopstart & end after finding them in the help text but
> the error on a not set loop flag will again send him searching while
> the muxer actually knows what the user wants quite well and could
> have done that
>
> Reminds me a bit of git telling me that i put an option after the
> filename. Its this kind of yeah git if you know that is an option
> and that is a filename why do you not reorder them yourself ...
./ffmpeg -help muxer=NAME is enough to get the list of AVOptions of a given muxer. No need to check the entire documentation.
Here's an updated patch. Using "loop 1" and/or providing a value for loopstart/loopend will enable the flag.
Regards.
-------------- next part --------------
>From beb9fa901e42767c933df6c65cb71db267e53e17 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial at gmail.com>
Date: Sat, 22 Dec 2012 21:05:06 -0300
Subject: [PATCH] astenc: Enable the loop flag only when requested or needed
The loop flag will be set only if values for loopstart/loopend
are provided, or if the user explicitly enables it.
For the latter case, a new AVOption "loop" is introduced.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/astenc.c | 5 ++++-
libavformat/version.h | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index 10001c7..59537c5 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -33,6 +33,7 @@ typedef struct ASTMuxContext {
int64_t loopstart;
int64_t loopend;
int fbs;
+ int loop;
} ASTMuxContext;
#define CHECK_LOOP(type) \
@@ -42,6 +43,7 @@ typedef struct ASTMuxContext {
av_log(s, AV_LOG_ERROR, "Invalid loop" #type " value\n"); \
return AVERROR(EINVAL); \
} \
+ ast->loop = 1; \
}
static int ast_write_header(AVFormatContext *s)
@@ -85,7 +87,7 @@ static int ast_write_header(AVFormatContext *s)
avio_wb16(pb, codec_tag);
avio_wb16(pb, 16); /* Bit depth */
avio_wb16(pb, enc->channels);
- avio_wb16(pb, 0xFFFF);
+ avio_wb16(pb, ast->loop ? 0xFFFF: 0);
avio_wb32(pb, enc->sample_rate);
ast->samples = avio_tell(pb);
@@ -175,6 +177,7 @@ static int ast_write_trailer(AVFormatContext *s)
#define OFFSET(obj) offsetof(ASTMuxContext, obj)
static const AVOption options[] = {
+ { "loop", "Enable loop flag", OFFSET(loop), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
{ "loopstart", "Loopstart position in milliseconds.", OFFSET(loopstart), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ "loopend", "Loopend position in milliseconds.", OFFSET(loopend), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
diff --git a/libavformat/version.h b/libavformat/version.h
index f2c0c11..08eb6ee 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 54
#define LIBAVFORMAT_VERSION_MINOR 49
-#define LIBAVFORMAT_VERSION_MICRO 102
+#define LIBAVFORMAT_VERSION_MICRO 103
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
--
1.8.0.msysgit.0
More information about the ffmpeg-devel
mailing list