Mercurial > libavformat.hg
annotate dv.c @ 1960:c0289552590f libavformat
Change the vhook code to send real timestamps to the filters instead of the
current time of day, which is useless, and which the filters could just as
easily query for themselves.
patch by Bobby Bingham, uhmmmm gmail com
author | diego |
---|---|
date | Thu, 29 Mar 2007 05:24:35 +0000 |
parents | aedce96c28ff |
children | a81bd08b5ff2 |
rev | line source |
---|---|
885 | 1 /* |
2 * General DV muxer/demuxer | |
933 | 3 * Copyright (c) 2003 Roman Shaposhnik |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
4 * |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
5 * Many thanks to Dan Dennedy <dan@dennedy.org> for providing wealth |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
6 * of DV technical info. |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
7 * |
0 | 8 * Raw DV format |
9 * Copyright (c) 2002 Fabrice Bellard. | |
10 * | |
995 | 11 * 50 Mbps (DVCPRO50) support |
12 * Copyright (c) 2006 Daniel Maas <dmaas@maasdigital.com> | |
13 * | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1317
diff
changeset
|
14 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1317
diff
changeset
|
15 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1317
diff
changeset
|
16 * FFmpeg is free software; you can redistribute it and/or |
0 | 17 * modify it under the terms of the GNU Lesser General Public |
18 * License as published by the Free Software Foundation; either | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1317
diff
changeset
|
19 * version 2.1 of the License, or (at your option) any later version. |
0 | 20 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1317
diff
changeset
|
21 * FFmpeg is distributed in the hope that it will be useful, |
0 | 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
24 * Lesser General Public License for more details. | |
25 * | |
26 * You should have received a copy of the GNU Lesser General Public | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1317
diff
changeset
|
27 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 29 */ |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
30 #include <time.h> |
0 | 31 #include "avformat.h" |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
32 #include "dvdata.h" |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
33 #include "dv.h" |
0 | 34 |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
35 struct DVDemuxContext { |
995 | 36 const DVprofile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */ |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
37 AVFormatContext* fctx; |
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
38 AVStream* vst; |
885 | 39 AVStream* ast[2]; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
40 AVPacket audio_pkt[2]; |
562
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
41 uint8_t audio_buf[2][8192]; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
42 int ach; |
392 | 43 int frames; |
44 uint64_t abytes; | |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
45 }; |
0 | 46 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
47 static inline uint16_t dv_audio_12to16(uint16_t sample) |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
48 { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
49 uint16_t shift, result; |
885 | 50 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
51 sample = (sample < 0x800) ? sample : sample | 0xf000; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
52 shift = (sample & 0xf00) >> 8; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
53 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
54 if (shift < 0x2 || shift > 0xd) { |
887 | 55 result = sample; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
56 } else if (shift < 0x8) { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
57 shift--; |
887 | 58 result = (sample - (256 * shift)) << shift; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
59 } else { |
887 | 60 shift = 0xe - shift; |
61 result = ((sample + ((256 * shift) + 1)) << shift) - 1; | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
62 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
63 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
64 return result; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
65 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
66 |
885 | 67 /* |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
68 * This is the dumbest implementation of all -- it simply looks at |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
69 * a fixed offset and if pack isn't there -- fails. We might want |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
70 * to have a fallback mechanism for complete search of missing packs. |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
71 */ |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
72 static const uint8_t* dv_extract_pack(uint8_t* frame, enum dv_pack_type t) |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
73 { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
74 int offs; |
885 | 75 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
76 switch (t) { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
77 case dv_audio_source: |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
78 offs = (80*6 + 80*16*3 + 3); |
887 | 79 break; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
80 case dv_audio_control: |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
81 offs = (80*6 + 80*16*4 + 3); |
887 | 82 break; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
83 case dv_video_control: |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
84 offs = (80*5 + 48 + 5); |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
85 break; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
86 default: |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
87 return NULL; |
885 | 88 } |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
89 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
90 return (frame[offs] == t ? &frame[offs] : NULL); |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
91 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
92 |
885 | 93 /* |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
94 * There's a couple of assumptions being made here: |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
95 * 1. By default we silence erroneous (0x8000/16bit 0x800/12bit) audio samples. |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
96 * We can pass them upwards when ffmpeg will be ready to deal with them. |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
97 * 2. We don't do software emphasis. |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
98 * 3. Audio is always returned as 16bit linear samples: 12bit nonlinear samples |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
99 * are converted into 16bit linear ones. |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
100 */ |
995 | 101 static int dv_extract_audio(uint8_t* frame, uint8_t* pcm, uint8_t* pcm2, |
102 const DVprofile *sys) | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
103 { |
995 | 104 int size, chan, i, j, d, of, smpls, freq, quant, half_ch; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
105 uint16_t lc, rc; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
106 const uint8_t* as_pack; |
885 | 107 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
108 as_pack = dv_extract_pack(frame, dv_audio_source); |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
109 if (!as_pack) /* No audio ? */ |
887 | 110 return 0; |
885 | 111 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
112 smpls = as_pack[1] & 0x3f; /* samples in this frame - min. samples */ |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
113 freq = (as_pack[4] >> 3) & 0x07; /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */ |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
114 quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */ |
885 | 115 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
116 if (quant > 1) |
887 | 117 return -1; /* Unsupported quantization */ |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
118 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
119 size = (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */ |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
120 half_ch = sys->difseg_size/2; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
121 |
995 | 122 /* for each DIF channel */ |
123 for (chan = 0; chan < sys->n_difchan; chan++) { | |
124 /* for each DIF segment */ | |
125 for (i = 0; i < sys->difseg_size; i++) { | |
126 frame += 6 * 80; /* skip DIF segment header */ | |
127 if (quant == 1 && i == half_ch) { | |
128 /* next stereo channel (12bit mode only) */ | |
129 if (!pcm2) | |
130 break; | |
131 else | |
132 pcm = pcm2; | |
133 } | |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
134 |
995 | 135 /* for each AV sequence */ |
136 for (j = 0; j < 9; j++) { | |
137 for (d = 8; d < 80; d += 2) { | |
138 if (quant == 0) { /* 16bit quantization */ | |
139 of = sys->audio_shuffle[i][j] + (d - 8)/2 * sys->audio_stride; | |
140 if (of*2 >= size) | |
141 continue; | |
885 | 142 |
995 | 143 pcm[of*2] = frame[d+1]; // FIXME: may be we have to admit |
144 pcm[of*2+1] = frame[d]; // that DV is a big endian PCM | |
145 if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00) | |
146 pcm[of*2+1] = 0; | |
147 } else { /* 12bit quantization */ | |
148 lc = ((uint16_t)frame[d] << 4) | | |
149 ((uint16_t)frame[d+2] >> 4); | |
150 rc = ((uint16_t)frame[d+1] << 4) | | |
151 ((uint16_t)frame[d+2] & 0x0f); | |
152 lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); | |
153 rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc)); | |
154 | |
155 of = sys->audio_shuffle[i%half_ch][j] + (d - 8)/3 * sys->audio_stride; | |
156 if (of*2 >= size) | |
157 continue; | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
158 |
995 | 159 pcm[of*2] = lc & 0xff; // FIXME: may be we have to admit |
160 pcm[of*2+1] = lc >> 8; // that DV is a big endian PCM | |
161 of = sys->audio_shuffle[i%half_ch+half_ch][j] + | |
162 (d - 8)/3 * sys->audio_stride; | |
163 pcm[of*2] = rc & 0xff; // FIXME: may be we have to admit | |
164 pcm[of*2+1] = rc >> 8; // that DV is a big endian PCM | |
165 ++d; | |
166 } | |
167 } | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
168 |
995 | 169 frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ |
170 } | |
171 } | |
885 | 172 |
995 | 173 /* next stereo channel (50Mbps only) */ |
174 if(!pcm2) | |
175 break; | |
176 pcm = pcm2; | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
177 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
178 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
179 return size; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
180 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
181 |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
182 static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
183 { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
184 const uint8_t* as_pack; |
995 | 185 int freq, stype, smpls, quant, i, ach; |
37 | 186 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
187 as_pack = dv_extract_pack(frame, dv_audio_source); |
995 | 188 if (!as_pack || !c->sys) { /* No audio ? */ |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
189 c->ach = 0; |
887 | 190 return 0; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
191 } |
885 | 192 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
193 smpls = as_pack[1] & 0x3f; /* samples in this frame - min. samples */ |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
194 freq = (as_pack[4] >> 3) & 0x07; /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */ |
995 | 195 stype = (as_pack[3] & 0x1f); /* 0 - 2CH, 2 - 4CH */ |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
196 quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */ |
995 | 197 |
198 /* note: ach counts PAIRS of channels (i.e. stereo channels) */ | |
199 ach = (stype == 2 || (quant && (freq == 2))) ? 2 : 1; | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
200 |
532
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
201 /* Dynamic handling of the audio streams in DV */ |
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
202 for (i=0; i<ach; i++) { |
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
203 if (!c->ast[i]) { |
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
204 c->ast[i] = av_new_stream(c->fctx, 0); |
887 | 205 if (!c->ast[i]) |
206 break; | |
207 av_set_pts_info(c->ast[i], 64, 1, 30000); | |
208 c->ast[i]->codec->codec_type = CODEC_TYPE_AUDIO; | |
209 c->ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; | |
562
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
210 |
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
211 av_init_packet(&c->audio_pkt[i]); |
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
212 c->audio_pkt[i].size = 0; |
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
213 c->audio_pkt[i].data = c->audio_buf[i]; |
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
214 c->audio_pkt[i].stream_index = c->ast[i]->index; |
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
215 c->audio_pkt[i].flags |= PKT_FLAG_KEY; |
532
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
216 } |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
217 c->ast[i]->codec->sample_rate = dv_audio_frequency[freq]; |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
218 c->ast[i]->codec->channels = 2; |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
219 c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16; |
532
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
220 c->ast[i]->start_time = 0; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
221 } |
532
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
222 c->ach = i; |
885 | 223 |
995 | 224 return (c->sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
225 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
226 |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
227 static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
228 { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
229 const uint8_t* vsc_pack; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
230 AVCodecContext* avctx; |
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
231 int apt, is16_9; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
232 int size = 0; |
885 | 233 |
995 | 234 if (c->sys) { |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
235 avctx = c->vst->codec; |
885 | 236 |
995 | 237 av_set_pts_info(c->vst, 64, c->sys->frame_rate_base, c->sys->frame_rate); |
238 avctx->time_base= (AVRational){c->sys->frame_rate_base, c->sys->frame_rate}; | |
845 | 239 if(!avctx->width){ |
995 | 240 avctx->width = c->sys->width; |
241 avctx->height = c->sys->height; | |
845 | 242 } |
995 | 243 avctx->pix_fmt = c->sys->pix_fmt; |
885 | 244 |
887 | 245 /* finding out SAR is a little bit messy */ |
246 vsc_pack = dv_extract_pack(frame, dv_video_control); | |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
247 apt = frame[4] & 0x07; |
887 | 248 is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || |
249 (!apt && (vsc_pack[2] & 0x07) == 0x07))); | |
995 | 250 avctx->sample_aspect_ratio = c->sys->sar[is16_9]; |
251 avctx->bit_rate = av_rescale(c->sys->frame_size * 8, | |
252 c->sys->frame_rate, | |
253 c->sys->frame_rate_base); | |
254 size = c->sys->frame_size; | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
255 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
256 return size; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
257 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
258 |
885 | 259 /* |
1317
132206560fe6
Split the DV demuxer and muxer into separate files (as suggested by Diego
takis
parents:
1289
diff
changeset
|
260 * The following 3 functions constitute our interface to the world |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
261 */ |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
262 |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
263 DVDemuxContext* dv_init_demux(AVFormatContext *s) |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
264 { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
265 DVDemuxContext *c; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
266 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
267 c = av_mallocz(sizeof(DVDemuxContext)); |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
268 if (!c) |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
269 return NULL; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
270 |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
271 c->vst = av_new_stream(s, 0); |
532
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
272 if (!c->vst) { |
885 | 273 av_free(c); |
532
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
274 return NULL; |
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
275 } |
462
b69898ffc92a
move time_base (pts_num/pts_den) from AVFormatContext -> AVStream
michael
parents:
460
diff
changeset
|
276 |
995 | 277 c->sys = NULL; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
278 c->fctx = s; |
532
772247018ade
* experimental dynamic audio stream allocation for DV demuxer. This
romansh
parents:
531
diff
changeset
|
279 c->ast[0] = c->ast[1] = NULL; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
280 c->ach = 0; |
392 | 281 c->frames = 0; |
282 c->abytes = 0; | |
562
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
283 |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
284 c->vst->codec->codec_type = CODEC_TYPE_VIDEO; |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
285 c->vst->codec->codec_id = CODEC_ID_DVVIDEO; |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
286 c->vst->codec->bit_rate = 25000000; |
524
0b9dfb0cddc8
* misc. fixes and hacks to improve timing detection in raw DV
romansh
parents:
523
diff
changeset
|
287 c->vst->start_time = 0; |
885 | 288 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
289 return c; |
0 | 290 } |
291 | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
292 int dv_get_packet(DVDemuxContext *c, AVPacket *pkt) |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
293 { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
294 int size = -1; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
295 int i; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
296 |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
297 for (i=0; i<c->ach; i++) { |
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
298 if (c->ast[i] && c->audio_pkt[i].size) { |
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
299 *pkt = c->audio_pkt[i]; |
887 | 300 c->audio_pkt[i].size = 0; |
301 size = pkt->size; | |
302 break; | |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
303 } |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
304 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
305 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
306 return size; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
307 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
308 |
885 | 309 int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
310 uint8_t* buf, int buf_size) |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
311 { |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
312 int size, i; |
885 | 313 |
1048 | 314 if (buf_size < DV_PROFILE_BYTES || |
315 !(c->sys = dv_frame_profile(buf)) || | |
316 buf_size < c->sys->frame_size) { | |
317 return -1; /* Broken frame, or not enough data */ | |
318 } | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
319 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
320 /* Queueing audio packet */ |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
321 /* FIXME: in case of no audio/bad audio we have to do something */ |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
322 size = dv_extract_audio_info(c, buf); |
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
323 for (i=0; i<c->ach; i++) { |
562
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
324 c->audio_pkt[i].size = size; |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
325 c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
326 } |
995 | 327 dv_extract_audio(buf, c->audio_buf[0], c->audio_buf[1], c->sys); |
392 | 328 c->abytes += size; |
885 | 329 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
330 /* Now it's time to return video packet */ |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
331 size = dv_extract_video_info(c, buf); |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
332 av_init_packet(pkt); |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
333 pkt->data = buf; |
885 | 334 pkt->size = size; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
335 pkt->flags |= PKT_FLAG_KEY; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
336 pkt->stream_index = c->vst->id; |
741 | 337 pkt->pts = c->frames; |
885 | 338 |
392 | 339 c->frames++; |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
340 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
341 return size; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
342 } |
885 | 343 |
559
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
344 static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, |
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
345 int64_t timestamp, int flags) |
392 | 346 { |
523
d788959a01e2
* seek in raw DV patch by Nathan Kurz (nate at verse dot com)
romansh
parents:
515
diff
changeset
|
347 // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
764
diff
changeset
|
348 const DVprofile* sys = dv_codec_profile(c->vst->codec); |
741 | 349 int64_t offset; |
764
cdb845a57ae4
drop most url_fileno() calls (allows to use ByteIOContext directly in caller apps instead of URLProtocol)
aurel
parents:
743
diff
changeset
|
350 int64_t size = url_fsize(&s->pb); |
559
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
351 int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; |
392 | 352 |
741 | 353 offset = sys->frame_size * timestamp; |
885 | 354 |
559
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
355 if (offset > max_offset) offset = max_offset; |
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
356 else if (offset < 0) offset = 0; |
523
d788959a01e2
* seek in raw DV patch by Nathan Kurz (nate at verse dot com)
romansh
parents:
515
diff
changeset
|
357 |
d788959a01e2
* seek in raw DV patch by Nathan Kurz (nate at verse dot com)
romansh
parents:
515
diff
changeset
|
358 return offset; |
392 | 359 } |
360 | |
1629
aedce96c28ff
* Fixing seeking with DV-AVI (by Jeff Downs <heydowns at borg dot com>)
romansh
parents:
1358
diff
changeset
|
361 void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset) |
562
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
362 { |
1629
aedce96c28ff
* Fixing seeking with DV-AVI (by Jeff Downs <heydowns at borg dot com>)
romansh
parents:
1358
diff
changeset
|
363 c->frames= frame_offset; |
aedce96c28ff
* Fixing seeking with DV-AVI (by Jeff Downs <heydowns at borg dot com>)
romansh
parents:
1358
diff
changeset
|
364 if (c->ach) |
aedce96c28ff
* Fixing seeking with DV-AVI (by Jeff Downs <heydowns at borg dot com>)
romansh
parents:
1358
diff
changeset
|
365 c->abytes= av_rescale(c->frames, |
aedce96c28ff
* Fixing seeking with DV-AVI (by Jeff Downs <heydowns at borg dot com>)
romansh
parents:
1358
diff
changeset
|
366 c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base, |
aedce96c28ff
* Fixing seeking with DV-AVI (by Jeff Downs <heydowns at borg dot com>)
romansh
parents:
1358
diff
changeset
|
367 8*c->sys->frame_rate); |
562
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
368 c->audio_pkt[0].size = c->audio_pkt[1].size = 0; |
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
369 } |
bf3231dd1d7c
* static allocation for audio packets. This will make it a little bit
romansh
parents:
560
diff
changeset
|
370 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
371 /************************************************************ |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
372 * Implementation of the easiest DV storage of all -- raw DV. |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
373 ************************************************************/ |
885 | 374 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
375 typedef struct RawDVContext { |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
376 DVDemuxContext* dv_demux; |
995 | 377 uint8_t buf[DV_MAX_FRAME_SIZE]; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
378 } RawDVContext; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
379 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
380 static int dv_read_header(AVFormatContext *s, |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
381 AVFormatParameters *ap) |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
382 { |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
383 RawDVContext *c = s->priv_data; |
995 | 384 |
296
252946de6d3f
* DV demuxer is now capable of decoding auxilary audio stream. So,
romansh
parents:
288
diff
changeset
|
385 c->dv_demux = dv_init_demux(s); |
524
0b9dfb0cddc8
* misc. fixes and hacks to improve timing detection in raw DV
romansh
parents:
523
diff
changeset
|
386 if (!c->dv_demux) |
0b9dfb0cddc8
* misc. fixes and hacks to improve timing detection in raw DV
romansh
parents:
523
diff
changeset
|
387 return -1; |
885 | 388 |
995 | 389 if (get_buffer(&s->pb, c->buf, DV_PROFILE_BYTES) <= 0 || |
390 url_fseek(&s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) | |
524
0b9dfb0cddc8
* misc. fixes and hacks to improve timing detection in raw DV
romansh
parents:
523
diff
changeset
|
391 return AVERROR_IO; |
0b9dfb0cddc8
* misc. fixes and hacks to improve timing detection in raw DV
romansh
parents:
523
diff
changeset
|
392 |
995 | 393 c->dv_demux->sys = dv_frame_profile(c->buf); |
394 s->bit_rate = av_rescale(c->dv_demux->sys->frame_size * 8, | |
395 c->dv_demux->sys->frame_rate, | |
396 c->dv_demux->sys->frame_rate_base); | |
885 | 397 |
524
0b9dfb0cddc8
* misc. fixes and hacks to improve timing detection in raw DV
romansh
parents:
523
diff
changeset
|
398 return 0; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
399 } |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
400 |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
401 |
0 | 402 static int dv_read_packet(AVFormatContext *s, AVPacket *pkt) |
403 { | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
404 int size; |
885 | 405 RawDVContext *c = s->priv_data; |
406 | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
407 size = dv_get_packet(c->dv_demux, pkt); |
885 | 408 |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
409 if (size < 0) { |
995 | 410 size = c->dv_demux->sys->frame_size; |
411 if (get_buffer(&s->pb, c->buf, size) <= 0) | |
887 | 412 return AVERROR_IO; |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
413 |
887 | 414 size = dv_produce_packet(c->dv_demux, pkt, c->buf, size); |
885 | 415 } |
416 | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
417 return size; |
0 | 418 } |
419 | |
885 | 420 static int dv_read_seek(AVFormatContext *s, int stream_index, |
559
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
421 int64_t timestamp, int flags) |
392 | 422 { |
559
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
423 RawDVContext *r = s->priv_data; |
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
424 DVDemuxContext *c = r->dv_demux; |
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
425 int64_t offset= dv_frame_offset(s, c, timestamp, flags); |
392 | 426 |
1629
aedce96c28ff
* Fixing seeking with DV-AVI (by Jeff Downs <heydowns at borg dot com>)
romansh
parents:
1358
diff
changeset
|
427 dv_offset_reset(c, offset / c->sys->frame_size); |
885 | 428 |
559
f5f85a07fafe
flags, rounding and cliping fix by (Nathan Kurz <nate at verse dot com>)
michael
parents:
532
diff
changeset
|
429 return url_fseek(&s->pb, offset, SEEK_SET); |
392 | 430 } |
431 | |
0 | 432 static int dv_read_close(AVFormatContext *s) |
433 { | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
434 RawDVContext *c = s->priv_data; |
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
435 av_free(c->dv_demux); |
0 | 436 return 0; |
437 } | |
438 | |
1169 | 439 #ifdef CONFIG_DV_DEMUXER |
440 AVInputFormat dv_demuxer = { | |
0 | 441 "dv", |
442 "DV video format", | |
262
f174d9c00bce
* DV handling was streamlined for both muxing/demuxing and
romansh
parents:
241
diff
changeset
|
443 sizeof(RawDVContext), |
0 | 444 NULL, |
445 dv_read_header, | |
446 dv_read_packet, | |
447 dv_read_close, | |
392 | 448 dv_read_seek, |
393 | 449 .extensions = "dv,dif", |
0 | 450 }; |
1169 | 451 #endif |