summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Conrad <lessen42@gmail.com>2007-09-05 00:23:47 +0000
committerDavid Conrad <lessen42@gmail.com>2007-09-05 00:23:47 +0000
commit95527e066938e4d342b1c59a79a23487bba36efb (patch)
treef6d9cb50a050b655ed3f485ca9885953c275b7ab
parent8bea4aee4fc8d2169b8bebc3dd49dc8e989ba936 (diff)
Move writing a block to its own function
Originally committed as revision 10329 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/matroskaenc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 0f59fc3359..51913a3bb2 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -551,6 +551,19 @@ static int mkv_write_header(AVFormatContext *s)
return 0;
}
+static void mkv_write_block(AVFormatContext *s, unsigned int blockid, AVPacket *pkt, int flags)
+{
+ MatroskaMuxContext *mkv = s->priv_data;
+ ByteIOContext *pb = &s->pb;
+
+ put_ebml_id(pb, blockid);
+ put_ebml_size(pb, pkt->size + 4, 0);
+ put_byte(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
+ put_be16(pb, pkt->pts - mkv->cluster_pts);
+ put_byte(pb, flags);
+ put_buffer(pb, pkt->data, pkt->size);
+}
+
static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MatroskaMuxContext *mkv = s->priv_data;
@@ -570,12 +583,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
mkv->cluster_pts = pkt->pts;
}
- put_ebml_id(pb, MATROSKA_ID_SIMPLEBLOCK);
- put_ebml_size(pb, pkt->size + 4, 0);
- put_byte(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
- put_be16(pb, pkt->pts - mkv->cluster_pts);
- put_byte(pb, keyframe << 7);
- put_buffer(pb, pkt->data, pkt->size);
+ mkv_write_block(s, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe << 7);
if (s->streams[pkt->stream_index]->codec->codec_type == CODEC_TYPE_VIDEO && keyframe) {
if (mkv_add_cuepoint(mkv->cues, pkt, mkv->cluster_pos) < 0)