55 uint16_t shift, result;
57 sample = (sample < 0x800) ? sample : sample | 0xf000;
58 shift = (sample & 0xf00) >> 8;
60 if (shift < 0x2 || shift > 0xd) {
62 }
else if (shift < 0x8) {
64 result = (sample - (256 * shift)) << shift;
67 result = ((sample + ((256 * shift) + 1)) << shift) - 1;
84 offs = (80 * 6 + 80 * 16 * 3 + 3);
87 offs = (80 * 6 + 80 * 16 * 4 + 3);
90 offs = (80 * 5 + 48 + 5);
96 return frame[offs] == t ? &frame[offs] :
NULL;
114 int size, chan, i, j, d, of, smpls, freq,
quant, half_ch;
123 smpls = as_pack[1] & 0x3f;
124 freq = as_pack[4] >> 3 & 0x07;
125 quant = as_pack[4] & 0x07;
138 ipcm = (sys->
height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
141 for (chan = 0; chan < sys->
n_difchan; chan++) {
150 if (quant == 1 && i == half_ch) {
158 for (j = 0; j < 9; j++) {
159 for (d = 8; d < 80; d += 2) {
168 pcm[of * 2] = frame[d + 1];
169 pcm[of * 2 + 1] = frame[d];
171 if (pcm[of * 2 + 1] == 0x80 && pcm[of * 2] == 0x00)
174 lc = ((uint16_t)frame[d] << 4) |
175 ((uint16_t)frame[d + 2] >> 4);
176 rc = ((uint16_t)frame[d + 1] << 4) |
177 ((uint16_t)frame[d + 2] & 0x0f);
188 pcm[of * 2] = lc & 0xff;
189 pcm[of * 2 + 1] = lc >> 8;
194 pcm[of * 2] = rc & 0xff;
195 pcm[of * 2 + 1] = rc >> 8;
211 int freq, stype, smpls,
quant, i,
ach;
214 if (!as_pack || !c->
sys) {
219 smpls = as_pack[1] & 0x3f;
220 freq = as_pack[4] >> 3 & 0x07;
221 stype = as_pack[3] & 0x1f;
222 quant = as_pack[4] & 0x07;
226 "Unrecognized audio sample rate index (%d)\n", freq);
237 ach = ((
int[4]) { 1, 0, 2, 4 })[stype];
238 if (ach == 1 && quant && freq == 2)
242 for (i = 0; i <
ach; i++) {
289 apt = frame[4] & 0x07;
290 is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
291 (!apt && (vsc_pack[2] & 0x07) == 0x07)));
331 for (i = 0; i < c->
ach; i++) {
358 for (i = 0; i < c->
ach; i++) {
395 int64_t timestamp,
int flags)
406 if (size >= 0 && offset > max_offset)
419 (
AVRational) { 8, c->ast[0]->codec->bit_rate });
436 unsigned state, marker_pos = 0;
444 while ((state & 0xffffff7f) != 0x1f07003f) {
449 if (state == 0x003f0700 || state == 0xff3f0700)
451 if (state == 0xff3f0701 &&
avio_tell(s->
pb) - marker_pos == 80) {
469 "Can't determine profile of DV input stream.\n");
501 int64_t timestamp,
int flags)
523 unsigned state, marker_pos = 0;
526 int secondary_matches = 0;
533 if ((state & 0xffffff7f) == 0x1f07003f)
537 if ((state & 0xff07ff7f) == 0x1f07003f)
539 if (state == 0x003f0700 || state == 0xff3f0700)
541 if (state == 0xff3f0701 && i - marker_pos == 80)
543 state = (state << 8) | p->
buf[i];
546 if (matches && p->
buf_size / matches < 1024 * 1024) {
548 (secondary_matches >= 10 &&
549 p->
buf_size / secondary_matches < 24000))
566 .extensions =
"dv,dif",
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define FF_ARRAY_ELEMS(a)
int64_t data_offset
offset of the first packet
#define AV_CH_LAYOUT_STEREO
uint8_t audio_buf[4][8192]
unsigned int avio_rb32(AVIOContext *s)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static av_cold int read_close(AVFormatContext *ctx)
enum AVPixelFormat pix_fmt
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
const uint8_t(* audio_shuffle)[9]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const AVDVProfile * av_dv_frame_profile(const AVDVProfile *sys, const uint8_t *frame, unsigned buf_size)
Get a DV profile for the provided compressed frame.
void av_log(void *avcl, int level, const char *fmt,...)
AVRational avg_frame_rate
Average framerate.
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int bit_rate
the average bitrate
audio channel layout utility functions
int width
picture width / height.
const AVDVProfile * av_dv_codec_profile(int width, int height, enum AVPixelFormat pix_fmt)
Get a DV profile for the provided stream parameters.
DVDemuxContext * dv_demux
static int read_header(FFV1Context *f)
if(ac->has_optimized_func)
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
main external API structure.
#define DV_MAX_FRAME_SIZE
largest possible DV frame, in bytes (1080i50)
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
rational number numerator/denominator
This structure contains the data a format has to probe a file.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
uint8_t buf[DV_MAX_FRAME_SIZE]
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int eof_reached
true if eof reached
int channels
number of audio channels
void * priv_data
Format private data.
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...