diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-09-15 23:52:42 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-09-18 00:18:11 +0200 |
commit | e1ab851da65d2ca01823a8d2e4da964bc243c1f2 (patch) | |
tree | 42da38ba6b7c7d5a9123921793249dea45725387 | |
parent | 0bdfdd6d2f57afef1ca1db1137c03809125a58b1 (diff) | |
download | ffmpeg-e1ab851da65d2ca01823a8d2e4da964bc243c1f2.tar.gz |
avformat/movenc: Factor check_pkt() out
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit deabcd2c05b2b01689d91394bbf3908da17234ed)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/movenc.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 08d0c2a772..4c93872c71 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4296,15 +4296,10 @@ static int mov_auto_flush_fragment(AVFormatContext *s) return ret; } -int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) +static int check_pkt(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; - AVIOContext *pb = s->pb; MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; - unsigned int samples_in_chunk = 0; - int size = pkt->size, ret = 0; - uint8_t *reformatted_data = NULL; if (trk->entry) { int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts; @@ -4321,6 +4316,23 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EINVAL); } } + return 0; +} + +int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + MOVMuxContext *mov = s->priv_data; + AVIOContext *pb = s->pb; + MOVTrack *trk = &mov->tracks[pkt->stream_index]; + AVCodecContext *enc = trk->enc; + unsigned int samples_in_chunk = 0; + int size = pkt->size, ret = 0; + uint8_t *reformatted_data = NULL; + + ret = check_pkt(s, pkt); + if (ret < 0) + return ret; + if (mov->flags & FF_MOV_FLAG_FRAGMENT) { int ret; if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) { |