FFmpeg: libavformat/dhav.c Source File
Go to the documentation of this file. 1 /*
2 * DHAV demuxer
3 *
4 * Copyright (c) 2018 Paul B Mahol
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
27
44
48
55
57 {
58 if (!memcmp(p->
buf,
"DAHUA", 5))
60
61 if (memcmp(p->
buf,
"DHAV", 4))
62 return 0;
63
64 if (p->
buf[4] == 0xf0 ||
69 return 0;
70 }
71
73 8000, 4000, 8000, 11025, 16000,
74 20000, 22050, 32000, 44100, 48000,
75 96000, 192000, 64000,
76 };
77
79 {
82
83 while (length > 0) {
86
88 case 0x80:
92 length -= 4;
93 break;
94 case 0x81:
98 length -= 4;
99 break;
100 case 0x82:
104 length -= 8;
105 break;
106 case 0x83:
112 } else {
114 }
115 length -= 4;
116 break;
117 case 0x88:
119 length -= 8;
120 break;
121 case 0x8c:
128 } else {
130 }
132 length -= 8;
133 break;
134 case 0x91:
135 case 0x92:
136 case 0x93:
137 case 0x95:
138 case 0x9a:
139 case 0x9b: // sample aspect ratio
140 case 0xb3:
142 length -= 8;
143 break;
144 case 0x84:
145 case 0x85:
146 case 0x8b:
147 case 0x94:
148 case 0x96:
149 case 0xa0:
150 case 0xb2:
151 case 0xb4:
153 length -= 4;
154 break;
155 default:
158 length = 0;
159 }
160
163 }
164
165 return 0;
166 }
167
169 {
171 int frame_length, ext_length;
172 int64_t start, end,
ret;
173
176
180 }
181
191
192 if (frame_length < 24)
194 if (dhav->
type == 0xf1) {
197 }
198
202
206
208
209 return frame_length - 8 - (end - start);
210 }
211
213 {
214 int year, month, day, hour,
min, sec;
215
216 sec = date & 0x3F;
217 min = (date >> 6) & 0x3F;
218 hour = (date >> 12) & 0x1F;
219 day = (date >> 17) & 0x1F;
220 month = (date >> 22) & 0x0F;
221 year = ((date >> 26) & 0x3F) + 2000;
222
223 timeinfo->tm_year = year - 1900;
224 timeinfo->tm_mon = month - 1;
225 timeinfo->tm_mday = day;
226 timeinfo->tm_hour = hour;
227 timeinfo->tm_min =
min;
228 timeinfo->tm_sec = sec;
229 }
230
232 {
235 int64_t start = 0, end = 0;
236 struct tm timeinfo;
237 int max_interations = 100000;
238
239 if (!
s->pb->seekable)
240 return 0;
241
243 while (
avio_tell(
s->pb) > 12 && max_interations--) {
246
251 break;
252 } else {
254 }
255 }
256
258
262
264
265 return end - start;
266 }
267
269 {
272
278 } else {
282 }
else if (
s->pb->seekable) {
286
289 break;
292 }
294 }
295 }
296
302
303 return 0;
304 }
305
307 {
308 DHAVStream *dst =
s->streams[stream_index]->priv_data;
310 struct tm timeinfo;
311 time_t t;
312
314
318
324 } else {
325 dst->
pts = t * 1000LL;
326 }
327
331
333 }
334
336 {
339
340 retry:
342 ;
343
346
350
351 if (!st)
353
358 case 0x2:
359 case 0x4:
363 }
374
379
380 if (!st)
382
396 }
405
407 }
408
410 if (stream_index < 0) {
414 goto retry;
415 }
416
422 if (dhav->
type != 0xfc)
430
432 }
433
435 int64_t timestamp,
int flags)
436 {
442
444 return -1;
449 return -1;
450
451 for (
int n = 0; n <
s->nb_streams; n++) {
454
457 }
459
460 return 0;
461 }
462
471 .extensions = "dav",
473 };
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
static int64_t get_pts(AVFormatContext *s, int stream_index)
#define AVERROR_EOF
End of file.
static int dhav_read_header(AVFormatContext *s)
static int dhav_probe(const AVProbeData *p)
AVRational avg_frame_rate
Average framerate.
static void get_timeinfo(unsigned date, struct tm *timeinfo)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int nb_channels
Number of channels in this layout.
int64_t avio_size(AVIOContext *s)
Get the filesize.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
static const char signature[]
#define FF_ARRAY_ELEMS(a)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int read_chunk(AVFormatContext *s)
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
static int dhav_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
static int parse_ext(AVFormatContext *s, int length)
This structure contains the data a format has to probe a file.
static void seek_back(AVFormatContext *s, AVIOContext *pb, int64_t pos)
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
static const uint32_t sample_rates[]
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int64_t get_duration(AVFormatContext *s)
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t last_frame_number
int avio_r8(AVIOContext *s)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int flags
A combination of AV_PKT_FLAG values.
#define AV_LOG_INFO
Standard information.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const AVInputFormat ff_dhav_demuxer
int index
stream index in AVFormatContext
static int dhav_read_packet(AVFormatContext *s, AVPacket *pkt)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
#define avpriv_request_sample(...)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int64_t pos
byte position in stream, -1 if unknown
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Wed Aug 24 2022 21:42:14 for FFmpeg by
doxygen
1.8.17