00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "avformat.h"
00022
00023 typedef struct RCVContext {
00024 int frames;
00025 } RCVContext;
00026
00027 static int vc1test_write_header(AVFormatContext *s)
00028 {
00029 AVCodecContext *avc = s->streams[0]->codec;
00030 ByteIOContext *pb = s->pb;
00031
00032 if (avc->codec_id != CODEC_ID_WMV3) {
00033 av_log(s, AV_LOG_ERROR, "Only WMV3 is accepted!\n");
00034 return -1;
00035 }
00036 put_le24(pb, 0);
00037 put_byte(pb, 0xC5);
00038 put_le32(pb, 4);
00039 put_buffer(pb, avc->extradata, 4);
00040 put_le32(pb, avc->height);
00041 put_le32(pb, avc->width);
00042 put_le32(pb, 0xC);
00043 put_le24(pb, 0);
00044 put_byte(pb, 0x80);
00045 put_le32(pb, 0);
00046 if (s->streams[0]->r_frame_rate.den && s->streams[0]->r_frame_rate.num == 1)
00047 put_le32(pb, s->streams[0]->r_frame_rate.den);
00048 else
00049 put_le32(pb, 0xFFFFFFFF);
00050
00051 return 0;
00052 }
00053
00054 static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
00055 {
00056 RCVContext *ctx = s->priv_data;
00057 ByteIOContext *pb = s->pb;
00058
00059 if (!pkt->size)
00060 return 0;
00061 put_le32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
00062 put_le32(pb, pkt->pts);
00063 put_buffer(pb, pkt->data, pkt->size);
00064 put_flush_packet(pb);
00065 ctx->frames++;
00066
00067 return 0;
00068 }
00069
00070 static int vc1test_write_trailer(AVFormatContext *s)
00071 {
00072 RCVContext *ctx = s->priv_data;
00073 ByteIOContext *pb = s->pb;
00074
00075 if (!url_is_streamed(s->pb)) {
00076 url_fseek(pb, 0, SEEK_SET);
00077 put_le24(pb, ctx->frames);
00078 put_flush_packet(pb);
00079 }
00080 return 0;
00081 }
00082
00083 AVOutputFormat vc1t_muxer = {
00084 "rcv",
00085 NULL_IF_CONFIG_SMALL("VC-1 test bitstream"),
00086 "",
00087 "rcv",
00088 sizeof(RCVContext),
00089 CODEC_ID_NONE,
00090 CODEC_ID_WMV3,
00091 vc1test_write_header,
00092 vc1test_write_packet,
00093 vc1test_write_trailer,
00094 };