3 * Copyright (c) 2002 Fabrice Bellard.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define NTSC_FRAME_SIZE 120000
22 #define PAL_FRAME_SIZE 144000
24 typedef struct DVDemuxContext {
29 static int dv_read_header(AVFormatContext *s,
30 AVFormatParameters *ap)
34 vst = av_new_stream(s, 0);
37 vst->codec.codec_type = CODEC_TYPE_VIDEO;
38 vst->codec.codec_id = CODEC_ID_DVVIDEO;
41 ast = av_new_stream(s, 1);
45 ast->codec.codec_type = CODEC_TYPE_AUDIO;
46 ast->codec.codec_id = CODEC_ID_DVAUDIO;
51 /* XXX: build fake audio stream when DV audio decoder will be finished */
52 static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
57 ret = get_buffer(&s->pb, buf, 4);
62 size = NTSC_FRAME_SIZE;
64 size = PAL_FRAME_SIZE;
66 if (av_new_packet(pkt, size) < 0)
69 pkt->stream_index = 0;
70 memcpy(pkt->data, buf, 4);
71 ret = get_buffer(&s->pb, pkt->data + 4, size - 4);
79 static int dv_read_close(AVFormatContext *s)
84 static AVInputFormat dv_iformat = {
87 sizeof(DVDemuxContext),
96 int dv_write_header(struct AVFormatContext *s)
101 int dv_write_packet(struct AVFormatContext *s,
103 unsigned char *buf, int size, int force_pts)
105 put_buffer(&s->pb, buf, size);
106 put_flush_packet(&s->pb);
110 int dv_write_trailer(struct AVFormatContext *s)
115 AVOutputFormat dv_oformat = {
131 av_register_input_format(&dv_iformat);
132 // av_register_output_format(&dv_oformat);