diff options
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/Makefile | 4 | ||||
-rw-r--r-- | libavformat/framecrcenc.c | 5 | ||||
-rw-r--r-- | libavformat/framehash.c | 33 | ||||
-rw-r--r-- | libavformat/internal.h | 6 | ||||
-rw-r--r-- | libavformat/md5enc.c | 5 | ||||
-rw-r--r-- | libavformat/mov.c | 2 |
6 files changed, 51 insertions, 4 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile index bd2b17b..45d2aa3 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -97,8 +97,8 @@ OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o OBJS-$(CONFIG_FOURXM_DEMUXER) += 4xm.o -OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o -OBJS-$(CONFIG_FRAMEMD5_MUXER) += md5enc.o +OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o framehash.o +OBJS-$(CONFIG_FRAMEMD5_MUXER) += md5enc.o framehash.o OBJS-$(CONFIG_GIF_MUXER) += gif.o OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c index c389037..72eeba7 100644 --- a/libavformat/framecrcenc.c +++ b/libavformat/framecrcenc.c @@ -21,13 +21,15 @@ #include "libavutil/adler32.h" #include "avformat.h" +#include "internal.h" static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) { uint32_t crc = av_adler32_update(0, pkt->data, pkt->size); char buf[256]; - snprintf(buf, sizeof(buf), "%d, %"PRId64", %d, 0x%08x\n", pkt->stream_index, pkt->dts, pkt->size, crc); + snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08x\n", + pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc); avio_write(s->pb, buf, strlen(buf)); avio_flush(s->pb); return 0; @@ -38,6 +40,7 @@ AVOutputFormat ff_framecrc_muxer = { .long_name = NULL_IF_CONFIG_SMALL("framecrc testing format"), .audio_codec = CODEC_ID_PCM_S16LE, .video_codec = CODEC_ID_RAWVIDEO, + .write_header = ff_framehash_write_header, .write_packet = framecrc_write_packet, .flags = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT, }; diff --git a/libavformat/framehash.c b/libavformat/framehash.c new file mode 100644 index 0000000..28e9e84 --- /dev/null +++ b/libavformat/framehash.c @@ -0,0 +1,33 @@ +/* + * Common functions for the frame{crc,md5} muxers + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "internal.h" + +int ff_framehash_write_header(AVFormatContext *s) +{ + int i; + for (i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); + avio_printf(s->pb, "#tb %d: %d/%d\n", i, st->time_base.num, st->time_base.den); + avio_flush(s->pb); + } + return 0; +} diff --git a/libavformat/internal.h b/libavformat/internal.h index c8376f7..94c66b9 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -306,4 +306,10 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels, uint64_t channel_layout, int32_t sample_rate, int32_t width, int32_t height); +/** + * Set the timebase for each stream from the corresponding codec timebase and + * print it. + */ +int ff_framehash_write_header(AVFormatContext *s); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/md5enc.c b/libavformat/md5enc.c index 052061f..7077f47 100644 --- a/libavformat/md5enc.c +++ b/libavformat/md5enc.c @@ -21,6 +21,7 @@ #include "libavutil/md5.h" #include "avformat.h" +#include "internal.h" #define PRIVSIZE 512 @@ -89,7 +90,8 @@ static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt) av_md5_init(s->priv_data); av_md5_update(s->priv_data, pkt->data, pkt->size); - snprintf(buf, sizeof(buf) - 64, "%d, %"PRId64", %d, ", pkt->stream_index, pkt->dts, pkt->size); + snprintf(buf, sizeof(buf) - 64, "%d, %10"PRId64", %10"PRId64", %8d, %8d, ", + pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size); md5_finish(s, buf); return 0; } @@ -100,6 +102,7 @@ AVOutputFormat ff_framemd5_muxer = { .priv_data_size = PRIVSIZE, .audio_codec = CODEC_ID_PCM_S16LE, .video_codec = CODEC_ID_RAWVIDEO, + .write_header = ff_framehash_write_header, .write_packet = framemd5_write_packet, .flags = AVFMT_VARIABLE_FPS, }; diff --git a/libavformat/mov.c b/libavformat/mov.c index ddbe490..214463c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1593,6 +1593,8 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_dlog(c->fc, "keyframe_count = %d\n", entries); + if (!entries) + return 0; if (entries >= UINT_MAX / sizeof(int)) return AVERROR_INVALIDDATA; sc->keyframes = av_malloc(entries * sizeof(int)); |