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 #include "internal.h"
00023
00024 typedef struct RCVContext {
00025 int frames;
00026 } RCVContext;
00027
00028 static int vc1test_write_header(AVFormatContext *s)
00029 {
00030 AVCodecContext *avc = s->streams[0]->codec;
00031 AVIOContext *pb = s->pb;
00032
00033 if (avc->codec_id != CODEC_ID_WMV3) {
00034 av_log(s, AV_LOG_ERROR, "Only WMV3 is accepted!\n");
00035 return -1;
00036 }
00037 avio_wl24(pb, 0);
00038 avio_w8(pb, 0xC5);
00039 avio_wl32(pb, 4);
00040 avio_write(pb, avc->extradata, 4);
00041 avio_wl32(pb, avc->height);
00042 avio_wl32(pb, avc->width);
00043 avio_wl32(pb, 0xC);
00044 avio_wl24(pb, 0);
00045 avio_w8(pb, 0x80);
00046 avio_wl32(pb, 0);
00047 if (s->streams[0]->r_frame_rate.den && s->streams[0]->r_frame_rate.num == 1)
00048 avio_wl32(pb, s->streams[0]->r_frame_rate.den);
00049 else
00050 avio_wl32(pb, 0xFFFFFFFF);
00051 avpriv_set_pts_info(s->streams[0], 32, 1, 1000);
00052
00053 return 0;
00054 }
00055
00056 static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
00057 {
00058 RCVContext *ctx = s->priv_data;
00059 AVIOContext *pb = s->pb;
00060
00061 if (!pkt->size)
00062 return 0;
00063 avio_wl32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
00064 avio_wl32(pb, pkt->pts);
00065 avio_write(pb, pkt->data, pkt->size);
00066 avio_flush(pb);
00067 ctx->frames++;
00068
00069 return 0;
00070 }
00071
00072 static int vc1test_write_trailer(AVFormatContext *s)
00073 {
00074 RCVContext *ctx = s->priv_data;
00075 AVIOContext *pb = s->pb;
00076
00077 if (s->pb->seekable) {
00078 avio_seek(pb, 0, SEEK_SET);
00079 avio_wl24(pb, ctx->frames);
00080 avio_flush(pb);
00081 }
00082 return 0;
00083 }
00084
00085 AVOutputFormat ff_vc1t_muxer = {
00086 .name = "rcv",
00087 .long_name = NULL_IF_CONFIG_SMALL("VC-1 test bitstream"),
00088 .extensions = "rcv",
00089 .priv_data_size = sizeof(RCVContext),
00090 .audio_codec = CODEC_ID_NONE,
00091 .video_codec = CODEC_ID_WMV3,
00092 .write_header = vc1test_write_header,
00093 .write_packet = vc1test_write_packet,
00094 .write_trailer = vc1test_write_trailer,
00095 };