FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
r3d.c
Go to the documentation of this file.
1 /*
2  * R3D REDCODE demuxer
3  * Copyright (c) 2008 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/intreadwrite.h"
23 #include "libavutil/dict.h"
24 #include "libavutil/mathematics.h"
25 #include "avformat.h"
26 #include "internal.h"
27 
28 typedef struct R3DContext {
30  unsigned *video_offsets;
31  unsigned rdvo_offset;
32 } R3DContext;
33 
34 typedef struct Atom {
35  unsigned size;
36  uint32_t tag;
37  uint64_t offset;
38 } Atom;
39 
40 static int read_atom(AVFormatContext *s, Atom *atom)
41 {
42  atom->offset = avio_tell(s->pb);
43  atom->size = avio_rb32(s->pb);
44  if (atom->size < 8)
45  return -1;
46  atom->tag = avio_rl32(s->pb);
47  av_log(s, AV_LOG_TRACE, "atom %u %.4s offset %#"PRIx64"\n",
48  atom->size, (char*)&atom->tag, atom->offset);
49  return atom->size;
50 }
51 
53 {
55  char filename[258];
56  int tmp;
57  int av_unused tmp2;
58  AVRational framerate;
59 
60  if (!st)
61  return AVERROR(ENOMEM);
64 
65  tmp = avio_r8(s->pb); // major version
66  tmp2 = avio_r8(s->pb); // minor version
67  av_log(s, AV_LOG_TRACE, "version %d.%d\n", tmp, tmp2);
68 
69  tmp = avio_rb16(s->pb); // unknown
70  av_log(s, AV_LOG_TRACE, "unknown1 %d\n", tmp);
71 
72  tmp = avio_rb32(s->pb);
73  avpriv_set_pts_info(st, 32, 1, tmp);
74 
75  tmp = avio_rb32(s->pb); // filenum
76  av_log(s, AV_LOG_TRACE, "filenum %d\n", tmp);
77 
78  avio_skip(s->pb, 32); // unknown
79 
80  st->codec->width = avio_rb32(s->pb);
81  st->codec->height = avio_rb32(s->pb);
82 
83  tmp = avio_rb16(s->pb); // unknown
84  av_log(s, AV_LOG_TRACE, "unknown2 %d\n", tmp);
85 
86  framerate.num = avio_rb16(s->pb);
87  framerate.den = avio_rb16(s->pb);
88  if (framerate.num > 0 && framerate.den > 0) {
89 #if FF_API_R_FRAME_RATE
90  st->r_frame_rate =
91 #endif
92  st->avg_frame_rate = framerate;
93  }
94 
95  tmp = avio_r8(s->pb); // audio channels
96  av_log(s, AV_LOG_TRACE, "audio channels %d\n", tmp);
97  if (tmp > 0) {
99  if (!ast)
100  return AVERROR(ENOMEM);
103  ast->codec->channels = tmp;
104  avpriv_set_pts_info(ast, 32, 1, st->time_base.den);
105  }
106 
107  avio_read(s->pb, filename, 257);
108  filename[sizeof(filename)-1] = 0;
109  av_dict_set(&st->metadata, "filename", filename, 0);
110 
111  av_log(s, AV_LOG_TRACE, "filename %s\n", filename);
112  av_log(s, AV_LOG_TRACE, "resolution %dx%d\n", st->codec->width, st->codec->height);
113  av_log(s, AV_LOG_TRACE, "timescale %d\n", st->time_base.den);
114  av_log(s, AV_LOG_TRACE, "frame rate %d/%d\n",
115  framerate.num, framerate.den);
116 
117  return 0;
118 }
119 
120 static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
121 {
122  R3DContext *r3d = s->priv_data;
123  AVStream *st = s->streams[0];
124  int i;
125 
126  r3d->video_offsets_count = (atom->size - 8) / 4;
127  r3d->video_offsets = av_malloc(atom->size);
128  if (!r3d->video_offsets)
129  return AVERROR(ENOMEM);
130 
131  for (i = 0; i < r3d->video_offsets_count; i++) {
132  r3d->video_offsets[i] = avio_rb32(s->pb);
133  if (!r3d->video_offsets[i]) {
134  r3d->video_offsets_count = i;
135  break;
136  }
137  av_log(s, AV_LOG_TRACE, "video offset %d: %#x\n", i, r3d->video_offsets[i]);
138  }
139 
140  if (st->avg_frame_rate.num)
143  st->time_base);
144  av_log(s, AV_LOG_TRACE, "duration %"PRId64"\n", st->duration);
145 
146  return 0;
147 }
148 
150 {
151  R3DContext *r3d = s->priv_data;
152  int av_unused tmp;
153 
154  r3d->rdvo_offset = avio_rb32(s->pb);
155  avio_rb32(s->pb); // rdvs offset
156  avio_rb32(s->pb); // rdao offset
157  avio_rb32(s->pb); // rdas offset
158 
159  tmp = avio_rb32(s->pb);
160  av_log(s, AV_LOG_TRACE, "num video chunks %d\n", tmp);
161 
162  tmp = avio_rb32(s->pb);
163  av_log(s, AV_LOG_TRACE, "num audio chunks %d\n", tmp);
164 
165  avio_skip(s->pb, 6*4);
166 }
167 
169 {
170  R3DContext *r3d = s->priv_data;
171  Atom atom;
172  int ret;
173 
174  if (read_atom(s, &atom) < 0) {
175  av_log(s, AV_LOG_ERROR, "error reading atom\n");
176  return -1;
177  }
178  if (atom.tag == MKTAG('R','E','D','1')) {
179  if ((ret = r3d_read_red1(s)) < 0) {
180  av_log(s, AV_LOG_ERROR, "error parsing 'red1' atom\n");
181  return ret;
182  }
183  } else {
184  av_log(s, AV_LOG_ERROR, "could not find 'red1' atom\n");
185  return -1;
186  }
187 
188  s->internal->data_offset = avio_tell(s->pb);
189  av_log(s, AV_LOG_TRACE, "data offset %#"PRIx64"\n", s->internal->data_offset);
190  if (!s->pb->seekable)
191  return 0;
192  // find REOB/REOF/REOS to load index
193  avio_seek(s->pb, avio_size(s->pb)-48-8, SEEK_SET);
194  if (read_atom(s, &atom) < 0)
195  av_log(s, AV_LOG_ERROR, "error reading end atom\n");
196 
197  if (atom.tag != MKTAG('R','E','O','B') &&
198  atom.tag != MKTAG('R','E','O','F') &&
199  atom.tag != MKTAG('R','E','O','S'))
200  goto out;
201 
202  r3d_read_reos(s);
203 
204  if (r3d->rdvo_offset) {
205  avio_seek(s->pb, r3d->rdvo_offset, SEEK_SET);
206  if (read_atom(s, &atom) < 0)
207  av_log(s, AV_LOG_ERROR, "error reading 'rdvo' atom\n");
208  if (atom.tag == MKTAG('R','D','V','O')) {
209  if (r3d_read_rdvo(s, &atom) < 0)
210  av_log(s, AV_LOG_ERROR, "error parsing 'rdvo' atom\n");
211  }
212  }
213 
214  out:
215  avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
216  return 0;
217 }
218 
220 {
221  AVStream *st = s->streams[0];
222  int tmp;
223  int av_unused tmp2;
224  int64_t pos = avio_tell(s->pb);
225  unsigned dts;
226  int ret;
227 
228  dts = avio_rb32(s->pb);
229 
230  tmp = avio_rb32(s->pb);
231  av_log(s, AV_LOG_TRACE, "frame num %d\n", tmp);
232 
233  tmp = avio_r8(s->pb); // major version
234  tmp2 = avio_r8(s->pb); // minor version
235  av_log(s, AV_LOG_TRACE, "version %d.%d\n", tmp, tmp2);
236 
237  tmp = avio_rb16(s->pb); // unknown
238  av_log(s, AV_LOG_TRACE, "unknown %d\n", tmp);
239 
240  if (tmp > 4) {
241  tmp = avio_rb16(s->pb); // unknown
242  av_log(s, AV_LOG_TRACE, "unknown %d\n", tmp);
243 
244  tmp = avio_rb16(s->pb); // unknown
245  av_log(s, AV_LOG_TRACE, "unknown %d\n", tmp);
246 
247  tmp = avio_rb32(s->pb);
248  av_log(s, AV_LOG_TRACE, "width %d\n", tmp);
249  tmp = avio_rb32(s->pb);
250  av_log(s, AV_LOG_TRACE, "height %d\n", tmp);
251 
252  tmp = avio_rb32(s->pb);
253  av_log(s, AV_LOG_TRACE, "metadata len %d\n", tmp);
254  }
255  tmp = atom->size - 8 - (avio_tell(s->pb) - pos);
256  if (tmp < 0)
257  return -1;
258  ret = av_get_packet(s->pb, pkt, tmp);
259  if (ret < 0) {
260  av_log(s, AV_LOG_ERROR, "error reading video packet\n");
261  return -1;
262  }
263 
264  pkt->stream_index = 0;
265  pkt->dts = dts;
266  if (st->avg_frame_rate.num)
267  pkt->duration = (uint64_t)st->time_base.den*
269  av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %d\n", pkt->dts, pkt->duration);
270 
271  return 0;
272 }
273 
275 {
276  AVStream *st = s->streams[1];
277  int av_unused tmp, tmp2;
278  int samples, size;
279  int64_t pos = avio_tell(s->pb);
280  unsigned dts;
281  int ret;
282 
283  dts = avio_rb32(s->pb);
284 
285  st->codec->sample_rate = avio_rb32(s->pb);
286  if (st->codec->sample_rate <= 0) {
287  av_log(s, AV_LOG_ERROR, "Bad sample rate\n");
288  return AVERROR_INVALIDDATA;
289  }
290 
291  samples = avio_rb32(s->pb);
292 
293  tmp = avio_rb32(s->pb);
294  av_log(s, AV_LOG_TRACE, "packet num %d\n", tmp);
295 
296  tmp = avio_rb16(s->pb); // unknown
297  av_log(s, AV_LOG_TRACE, "unknown %d\n", tmp);
298 
299  tmp = avio_r8(s->pb); // major version
300  tmp2 = avio_r8(s->pb); // minor version
301  av_log(s, AV_LOG_TRACE, "version %d.%d\n", tmp, tmp2);
302 
303  tmp = avio_rb32(s->pb); // unknown
304  av_log(s, AV_LOG_TRACE, "unknown %d\n", tmp);
305 
306  size = atom->size - 8 - (avio_tell(s->pb) - pos);
307  if (size < 0)
308  return -1;
309  ret = av_get_packet(s->pb, pkt, size);
310  if (ret < 0) {
311  av_log(s, AV_LOG_ERROR, "error reading audio packet\n");
312  return ret;
313  }
314 
315  pkt->stream_index = 1;
316  pkt->dts = dts;
317  if (st->codec->sample_rate)
318  pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
319  av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %d samples %d sample rate %d\n",
320  pkt->dts, pkt->duration, samples, st->codec->sample_rate);
321 
322  return 0;
323 }
324 
326 {
327  Atom atom;
328  int err = 0;
329 
330  while (!err) {
331  if (read_atom(s, &atom) < 0) {
332  err = -1;
333  break;
334  }
335  switch (atom.tag) {
336  case MKTAG('R','E','D','V'):
337  if (s->streams[0]->discard == AVDISCARD_ALL)
338  goto skip;
339  if (!(err = r3d_read_redv(s, pkt, &atom)))
340  return 0;
341  break;
342  case MKTAG('R','E','D','A'):
343  if (s->nb_streams < 2)
344  return -1;
345  if (s->streams[1]->discard == AVDISCARD_ALL)
346  goto skip;
347  if (!(err = r3d_read_reda(s, pkt, &atom)))
348  return 0;
349  break;
350  default:
351  skip:
352  avio_skip(s->pb, atom.size-8);
353  }
354  }
355  return err;
356 }
357 
358 static int r3d_probe(AVProbeData *p)
359 {
360  if (AV_RL32(p->buf + 4) == MKTAG('R','E','D','1'))
361  return AVPROBE_SCORE_MAX;
362  return 0;
363 }
364 
365 static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
366 {
367  AVStream *st = s->streams[0]; // video stream
368  R3DContext *r3d = s->priv_data;
369  int frame_num;
370 
371  if (!st->avg_frame_rate.num)
372  return -1;
373 
374  frame_num = av_rescale_q(sample_time, st->time_base,
375  av_inv_q(st->avg_frame_rate));
376  av_log(s, AV_LOG_TRACE, "seek frame num %d timestamp %"PRId64"\n",
377  frame_num, sample_time);
378 
379  if (frame_num < r3d->video_offsets_count) {
380  if (avio_seek(s->pb, r3d->video_offsets_count, SEEK_SET) < 0)
381  return -1;
382  } else {
383  av_log(s, AV_LOG_ERROR, "could not seek to frame %d\n", frame_num);
384  return -1;
385  }
386 
387  return 0;
388 }
389 
391 {
392  R3DContext *r3d = s->priv_data;
393 
394  av_freep(&r3d->video_offsets);
395 
396  return 0;
397 }
398 
400  .name = "r3d",
401  .long_name = NULL_IF_CONFIG_SMALL("REDCODE R3D"),
402  .priv_data_size = sizeof(R3DContext),
407  .read_seek = r3d_seek,
408 };
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:631
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
uint64_t offset
Definition: r3d.c:37
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:282
uint32_t tag
Definition: r3d.c:36
unsigned video_offsets_count
Definition: r3d.c:29
static int read_atom(AVFormatContext *s, Atom *atom)
Definition: r3d.c:40
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4075
int64_t data_offset
offset of the first packet
Definition: internal.h:80
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
static int r3d_close(AVFormatContext *s)
Definition: r3d.c:390
int num
numerator
Definition: rational.h:44
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:204
unsigned size
Definition: r3d.c:35
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1696
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:277
discard all
Definition: avcodec.h:688
static AVPacket pkt
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:675
Format I/O context.
Definition: avformat.h:1273
Public dictionary API.
#define av_malloc(s)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:202
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:690
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:3741
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1341
static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
Definition: r3d.c:274
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:244
ptrdiff_t size
Definition: opengl_enc.c:101
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:390
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1440
#define av_log(a,...)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:538
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:140
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:659
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
static void r3d_read_reos(AVFormatContext *s)
Definition: r3d.c:149
Definition: r3d.c:34
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:925
Definition: r3d.c:28
unsigned rdvo_offset
Definition: r3d.c:31
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:529
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:861
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:450
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1329
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:160
AVInputFormat ff_r3d_demuxer
Definition: r3d.c:399
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:127
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
int width
picture width / height.
Definition: avcodec.h:1680
AVDictionary * metadata
Definition: avformat.h:916
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:620
Stream structure.
Definition: avformat.h:842
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
enum AVMediaType codec_type
Definition: avcodec.h:1509
enum AVCodecID codec_id
Definition: avcodec.h:1518
int sample_rate
samples per second
Definition: avcodec.h:2261
AVIOContext * pb
I/O context.
Definition: avformat.h:1315
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:69
static int r3d_probe(AVProbeData *p)
Definition: r3d.c:358
rational number numerator/denominator
Definition: rational.h:43
static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
Definition: r3d.c:120
This structure contains the data a format has to probe a file.
Definition: avformat.h:448
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:133
unsigned * video_offsets
Definition: r3d.c:30
static int flags
Definition: cpu.c:47
static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
Definition: r3d.c:365
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:901
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:460
Main libavformat public API header.
static int r3d_read_header(AVFormatContext *s)
Definition: r3d.c:168
static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: r3d.c:325
int den
denominator
Definition: rational.h:45
int channels
number of audio channels
Definition: avcodec.h:2262
void * priv_data
Format private data.
Definition: avformat.h:1301
static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
Definition: r3d.c:219
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1421
static int r3d_read_red1(AVFormatContext *s)
Definition: r3d.c:52
#define av_freep(p)
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:628
int stream_index
Definition: avcodec.h:1424
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:884
#define MKTAG(a, b, c, d)
Definition: common.h:315
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:907
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:1061
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:87
This structure stores compressed data.
Definition: avcodec.h:1399
#define av_unused
Definition: attributes.h:118