diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-02-02 14:20:43 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-02-03 09:29:02 +0100 |
commit | d2afbd9a56e4e863bad01923006dd9b77f747035 (patch) | |
tree | 09593d24781bd903c2a3826ae45c372da1d61ab1 /libavformat | |
parent | 22c0babbb2ac37724c2462d9cda01e3b7229df56 (diff) | |
download | ffmpeg-d2afbd9a56e4e863bad01923006dd9b77f747035.tar.gz |
frame{crc/md5}: set the stream timebase from codec timebase.
Right now those muxers use the default timebase in all cases(1/90000).
This patch avoid unnecessary rescaling and makes the printed timestamps
more readable.
Also, extend the printed information to include the timebases and packet
pts/duration and align the columns.
Obviously changes the results of all fate tests which use those two
muxers.
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 |
5 files changed, 49 insertions, 4 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile index 06718d2485..0d6cb91e49 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -89,8 +89,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 d845e79c41..d1148f9190 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; @@ -39,6 +41,7 @@ AVOutputFormat ff_framecrc_muxer = { .extensions = "", .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, }; diff --git a/libavformat/framehash.c b/libavformat/framehash.c new file mode 100644 index 0000000000..28e9e8407d --- /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 559e710014..322dff94af 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -307,4 +307,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 4509c18e84..3fd54506b3 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 @@ -90,7 +91,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; } @@ -102,6 +104,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, }; |