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 AVIOContext *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 avio_wl24(pb, 0);
00037 avio_w8(pb, 0xC5);
00038 avio_wl32(pb, 4);
00039 avio_write(pb, avc->extradata, 4);
00040 avio_wl32(pb, avc->height);
00041 avio_wl32(pb, avc->width);
00042 avio_wl32(pb, 0xC);
00043 avio_wl24(pb, 0);
00044 avio_w8(pb, 0x80);
00045 avio_wl32(pb, 0);
00046 if (s->streams[0]->r_frame_rate.den && s->streams[0]->r_frame_rate.num == 1)
00047 avio_wl32(pb, s->streams[0]->r_frame_rate.den);
00048 else
00049 avio_wl32(pb, 0xFFFFFFFF);
00050 av_set_pts_info(s->streams[0], 32, 1, 1000);
00051
00052 return 0;
00053 }
00054
00055 static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
00056 {
00057 RCVContext *ctx = s->priv_data;
00058 AVIOContext *pb = s->pb;
00059
00060 if (!pkt->size)
00061 return 0;
00062 avio_wl32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
00063 avio_wl32(pb, pkt->pts);
00064 avio_write(pb, pkt->data, pkt->size);
00065 avio_flush(pb);
00066 ctx->frames++;
00067
00068 return 0;
00069 }
00070
00071 static int vc1test_write_trailer(AVFormatContext *s)
00072 {
00073 RCVContext *ctx = s->priv_data;
00074 AVIOContext *pb = s->pb;
00075
00076 if (s->pb->seekable) {
00077 avio_seek(pb, 0, SEEK_SET);
00078 avio_wl24(pb, ctx->frames);
00079 avio_flush(pb);
00080 }
00081 return 0;
00082 }
00083
00084 AVOutputFormat ff_vc1t_muxer = {
00085 "rcv",
00086 NULL_IF_CONFIG_SMALL("VC-1 test bitstream"),
00087 "",
00088 "rcv",
00089 sizeof(RCVContext),
00090 CODEC_ID_NONE,
00091 CODEC_ID_WMV3,
00092 vc1test_write_header,
00093 vc1test_write_packet,
00094 vc1test_write_trailer,
00095 };