Message ID | 1327082572-67935-2-git-send-email-martin@martin.st |
---|---|
State | Superseded |
Headers | show |
On 01/20/2012 01:02 PM, Martin Storsjö wrote: > --- > libavformat/avformat.h | 1 + > libavformat/utils.c | 10 +++++++++- > libavformat/version.h | 2 +- > 3 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 71aed80..54d7407 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -380,6 +380,7 @@ typedef struct AVFormatParameters { > #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */ > #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ > #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ > +#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing */ I would be more clear here. Saying that unless a muxer sets this flag, it will be guarenteed to not receive a NULL packet in write_packet(). Also please mention specifics in the public packet writing functions about being able to pass NULL packets to flush a muxer. > > /** > * @addtogroup lavf_encoding > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 22ee13b..20a0d80 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -3135,7 +3135,15 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ > > int av_write_frame(AVFormatContext *s, AVPacket *pkt) > { > - int ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt); > + int ret; > + > + if (!pkt) { > + if (s->oformat->flags & AVFMT_ALLOW_FLUSH) > + return s->oformat->write_packet(s, pkt); > + return AVERROR(ENOSYS); Why an error? We should allow this so the user does not have to check. hmm... maybe that's what the "1 if end of stream wanted" was originally intended for? -Justin
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 71aed80..54d7407 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -380,6 +380,7 @@ typedef struct AVFormatParameters { #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */ #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ +#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing */ /** * @addtogroup lavf_encoding diff --git a/libavformat/utils.c b/libavformat/utils.c index 22ee13b..20a0d80 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3135,7 +3135,15 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ int av_write_frame(AVFormatContext *s, AVPacket *pkt) { - int ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt); + int ret; + + if (!pkt) { + if (s->oformat->flags & AVFMT_ALLOW_FLUSH) + return s->oformat->write_packet(s, pkt); + return AVERROR(ENOSYS); + } + + ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt); if(ret<0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) return ret; diff --git a/libavformat/version.h b/libavformat/version.h index 009a60b..898f4b1 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -30,7 +30,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 53 -#define LIBAVFORMAT_VERSION_MINOR 21 +#define LIBAVFORMAT_VERSION_MINOR 22 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \