internal.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. /*
  2. * copyright (c) 2001 Fabrice Bellard
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVFORMAT_INTERNAL_H
  21. #define AVFORMAT_INTERNAL_H
  22. #include <stdint.h>
  23. #include "libavutil/bprint.h"
  24. #include "avformat.h"
  25. #include "os_support.h"
  26. #define MAX_URL_SIZE 4096
  27. /** size of probe buffer, for guessing file type from file contents */
  28. #define PROBE_BUF_MIN 2048
  29. #define PROBE_BUF_MAX (1 << 20)
  30. #define MAX_PROBE_PACKETS 2500
  31. #ifdef DEBUG
  32. # define hex_dump_debug(class, buf, size) av_hex_dump_log(class, AV_LOG_DEBUG, buf, size)
  33. #else
  34. # define hex_dump_debug(class, buf, size) do { if (0) av_hex_dump_log(class, AV_LOG_DEBUG, buf, size); } while(0)
  35. #endif
  36. typedef struct AVCodecTag {
  37. enum AVCodecID id;
  38. unsigned int tag;
  39. } AVCodecTag;
  40. typedef struct CodecMime{
  41. char str[32];
  42. enum AVCodecID id;
  43. } CodecMime;
  44. /*************************************************/
  45. /* fractional numbers for exact pts handling */
  46. /**
  47. * The exact value of the fractional number is: 'val + num / den'.
  48. * num is assumed to be 0 <= num < den.
  49. */
  50. typedef struct FFFrac {
  51. int64_t val, num, den;
  52. } FFFrac;
  53. struct AVFormatInternal {
  54. /**
  55. * Number of streams relevant for interleaving.
  56. * Muxing only.
  57. */
  58. int nb_interleaved_streams;
  59. /**
  60. * This buffer is only needed when packets were already buffered but
  61. * not decoded, for example to get the codec parameters in MPEG
  62. * streams.
  63. */
  64. struct AVPacketList *packet_buffer;
  65. struct AVPacketList *packet_buffer_end;
  66. /* av_seek_frame() support */
  67. int64_t data_offset; /**< offset of the first packet */
  68. /**
  69. * Raw packets from the demuxer, prior to parsing and decoding.
  70. * This buffer is used for buffering packets until the codec can
  71. * be identified, as parsing cannot be done without knowing the
  72. * codec.
  73. */
  74. struct AVPacketList *raw_packet_buffer;
  75. struct AVPacketList *raw_packet_buffer_end;
  76. /**
  77. * Packets split by the parser get queued here.
  78. */
  79. struct AVPacketList *parse_queue;
  80. struct AVPacketList *parse_queue_end;
  81. /**
  82. * Remaining size available for raw_packet_buffer, in bytes.
  83. */
  84. #define RAW_PACKET_BUFFER_SIZE 2500000
  85. int raw_packet_buffer_remaining_size;
  86. /**
  87. * Offset to remap timestamps to be non-negative.
  88. * Expressed in timebase units.
  89. * @see AVStream.mux_ts_offset
  90. */
  91. int64_t offset;
  92. /**
  93. * Timebase for the timestamp offset.
  94. */
  95. AVRational offset_timebase;
  96. #if FF_API_COMPUTE_PKT_FIELDS2
  97. int missing_ts_warning;
  98. #endif
  99. int inject_global_side_data;
  100. int avoid_negative_ts_use_pts;
  101. /**
  102. * Whether or not a header has already been written
  103. */
  104. int header_written;
  105. int write_header_ret;
  106. /**
  107. * Timestamp of the end of the shortest stream.
  108. */
  109. int64_t shortest_end;
  110. /**
  111. * Whether or not avformat_init_output has already been called
  112. */
  113. int initialized;
  114. /**
  115. * Whether or not avformat_init_output fully initialized streams
  116. */
  117. int streams_initialized;
  118. /**
  119. * ID3v2 tag useful for MP3 demuxing
  120. */
  121. AVDictionary *id3v2_meta;
  122. /*
  123. * Prefer the codec framerate for avg_frame_rate computation.
  124. */
  125. int prefer_codec_framerate;
  126. };
  127. struct AVStreamInternal {
  128. /**
  129. * Set to 1 if the codec allows reordering, so pts can be different
  130. * from dts.
  131. */
  132. int reorder;
  133. /**
  134. * bitstream filters to run on stream
  135. * - encoding: Set by muxer using ff_stream_add_bitstream_filter
  136. * - decoding: unused
  137. */
  138. AVBSFContext **bsfcs;
  139. int nb_bsfcs;
  140. /**
  141. * Whether or not check_bitstream should still be run on each packet
  142. */
  143. int bitstream_checked;
  144. /**
  145. * The codec context used by avformat_find_stream_info, the parser, etc.
  146. */
  147. AVCodecContext *avctx;
  148. /**
  149. * 1 if avctx has been initialized with the values from the codec parameters
  150. */
  151. int avctx_inited;
  152. enum AVCodecID orig_codec_id;
  153. /* the context for extracting extradata in find_stream_info()
  154. * inited=1/bsf=NULL signals that extracting is not possible (codec not
  155. * supported) */
  156. struct {
  157. AVBSFContext *bsf;
  158. AVPacket *pkt;
  159. int inited;
  160. } extract_extradata;
  161. /**
  162. * Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
  163. */
  164. int need_context_update;
  165. };
  166. #ifdef __GNUC__
  167. #define dynarray_add(tab, nb_ptr, elem)\
  168. do {\
  169. __typeof__(tab) _tab = (tab);\
  170. __typeof__(elem) _elem = (elem);\
  171. (void)sizeof(**_tab == _elem); /* check that types are compatible */\
  172. av_dynarray_add(_tab, nb_ptr, _elem);\
  173. } while(0)
  174. #else
  175. #define dynarray_add(tab, nb_ptr, elem)\
  176. do {\
  177. av_dynarray_add((tab), nb_ptr, (elem));\
  178. } while(0)
  179. #endif
  180. struct tm *ff_brktimegm(time_t secs, struct tm *tm);
  181. char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase);
  182. /**
  183. * Parse a string of hexadecimal strings. Any space between the hexadecimal
  184. * digits is ignored.
  185. *
  186. * @param data if non-null, the parsed data is written to this pointer
  187. * @param p the string to parse
  188. * @return the number of bytes written (or to be written, if data is null)
  189. */
  190. int ff_hex_to_data(uint8_t *data, const char *p);
  191. /**
  192. * Add packet to AVFormatContext->packet_buffer list, determining its
  193. * interleaved position using compare() function argument.
  194. * @return 0, or < 0 on error
  195. */
  196. int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
  197. int (*compare)(AVFormatContext *, AVPacket *, AVPacket *));
  198. void ff_read_frame_flush(AVFormatContext *s);
  199. #define NTP_OFFSET 2208988800ULL
  200. #define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL)
  201. /** Get the current time since NTP epoch in microseconds. */
  202. uint64_t ff_ntp_time(void);
  203. /**
  204. * Append the media-specific SDP fragment for the media stream c
  205. * to the buffer buff.
  206. *
  207. * Note, the buffer needs to be initialized, since it is appended to
  208. * existing content.
  209. *
  210. * @param buff the buffer to append the SDP fragment to
  211. * @param size the size of the buff buffer
  212. * @param st the AVStream of the media to describe
  213. * @param idx the global stream index
  214. * @param dest_addr the destination address of the media stream, may be NULL
  215. * @param dest_type the destination address type, may be NULL
  216. * @param port the destination port of the media stream, 0 if unknown
  217. * @param ttl the time to live of the stream, 0 if not multicast
  218. * @param fmt the AVFormatContext, which might contain options modifying
  219. * the generated SDP
  220. */
  221. void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx,
  222. const char *dest_addr, const char *dest_type,
  223. int port, int ttl, AVFormatContext *fmt);
  224. /**
  225. * Write a packet to another muxer than the one the user originally
  226. * intended. Useful when chaining muxers, where one muxer internally
  227. * writes a received packet to another muxer.
  228. *
  229. * @param dst the muxer to write the packet to
  230. * @param dst_stream the stream index within dst to write the packet to
  231. * @param pkt the packet to be written
  232. * @param src the muxer the packet originally was intended for
  233. * @param interleave 0->use av_write_frame, 1->av_interleaved_write_frame
  234. * @return the value av_write_frame returned
  235. */
  236. int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
  237. AVFormatContext *src, int interleave);
  238. /**
  239. * Get the length in bytes which is needed to store val as v.
  240. */
  241. int ff_get_v_length(uint64_t val);
  242. /**
  243. * Put val using a variable number of bytes.
  244. */
  245. void ff_put_v(AVIOContext *bc, uint64_t val);
  246. /**
  247. * Read a whole line of text from AVIOContext. Stop reading after reaching
  248. * either a \\n, a \\0 or EOF. The returned string is always \\0-terminated,
  249. * and may be truncated if the buffer is too small.
  250. *
  251. * @param s the read-only AVIOContext
  252. * @param buf buffer to store the read line
  253. * @param maxlen size of the buffer
  254. * @return the length of the string written in the buffer, not including the
  255. * final \\0
  256. */
  257. int ff_get_line(AVIOContext *s, char *buf, int maxlen);
  258. #define SPACE_CHARS " \t\r\n"
  259. /**
  260. * Callback function type for ff_parse_key_value.
  261. *
  262. * @param key a pointer to the key
  263. * @param key_len the number of bytes that belong to the key, including the '='
  264. * char
  265. * @param dest return the destination pointer for the value in *dest, may
  266. * be null to ignore the value
  267. * @param dest_len the length of the *dest buffer
  268. */
  269. typedef void (*ff_parse_key_val_cb)(void *context, const char *key,
  270. int key_len, char **dest, int *dest_len);
  271. /**
  272. * Parse a string with comma-separated key=value pairs. The value strings
  273. * may be quoted and may contain escaped characters within quoted strings.
  274. *
  275. * @param str the string to parse
  276. * @param callback_get_buf function that returns where to store the
  277. * unescaped value string.
  278. * @param context the opaque context pointer to pass to callback_get_buf
  279. */
  280. void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
  281. void *context);
  282. /**
  283. * Find stream index based on format-specific stream ID
  284. * @return stream index, or < 0 on error
  285. */
  286. int ff_find_stream_index(AVFormatContext *s, int id);
  287. /**
  288. * Internal version of av_index_search_timestamp
  289. */
  290. int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,
  291. int64_t wanted_timestamp, int flags);
  292. /**
  293. * Internal version of av_add_index_entry
  294. */
  295. int ff_add_index_entry(AVIndexEntry **index_entries,
  296. int *nb_index_entries,
  297. unsigned int *index_entries_allocated_size,
  298. int64_t pos, int64_t timestamp, int size, int distance, int flags);
  299. void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance);
  300. /**
  301. * Add a new chapter.
  302. *
  303. * @param s media file handle
  304. * @param id unique ID for this chapter
  305. * @param start chapter start time in time_base units
  306. * @param end chapter end time in time_base units
  307. * @param title chapter title
  308. *
  309. * @return AVChapter or NULL on error
  310. */
  311. AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base,
  312. int64_t start, int64_t end, const char *title);
  313. /**
  314. * Ensure the index uses less memory than the maximum specified in
  315. * AVFormatContext.max_index_size by discarding entries if it grows
  316. * too large.
  317. */
  318. void ff_reduce_index(AVFormatContext *s, int stream_index);
  319. enum AVCodecID ff_guess_image2_codec(const char *filename);
  320. /**
  321. * Perform a binary search using av_index_search_timestamp() and
  322. * AVInputFormat.read_timestamp().
  323. *
  324. * @param target_ts target timestamp in the time base of the given stream
  325. * @param stream_index stream number
  326. */
  327. int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
  328. int64_t target_ts, int flags);
  329. /**
  330. * Update cur_dts of all streams based on the given timestamp and AVStream.
  331. *
  332. * Stream ref_st unchanged, others set cur_dts in their native time base.
  333. * Only needed for timestamp wrapping or if (dts not set and pts!=dts).
  334. * @param timestamp new dts expressed in time_base of param ref_st
  335. * @param ref_st reference stream giving time_base of param timestamp
  336. */
  337. void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
  338. int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos,
  339. int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
  340. /**
  341. * Perform a binary search using read_timestamp().
  342. *
  343. * @param target_ts target timestamp in the time base of the given stream
  344. * @param stream_index stream number
  345. */
  346. int64_t ff_gen_search(AVFormatContext *s, int stream_index,
  347. int64_t target_ts, int64_t pos_min,
  348. int64_t pos_max, int64_t pos_limit,
  349. int64_t ts_min, int64_t ts_max,
  350. int flags, int64_t *ts_ret,
  351. int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
  352. /**
  353. * Set the time base and wrapping info for a given stream. This will be used
  354. * to interpret the stream's timestamps. If the new time base is invalid
  355. * (numerator or denominator are non-positive), it leaves the stream
  356. * unchanged.
  357. *
  358. * @param s stream
  359. * @param pts_wrap_bits number of bits effectively used by the pts
  360. * (used for wrap control)
  361. * @param pts_num time base numerator
  362. * @param pts_den time base denominator
  363. */
  364. void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits,
  365. unsigned int pts_num, unsigned int pts_den);
  366. /**
  367. * Add side data to a packet for changing parameters to the given values.
  368. * Parameters set to 0 aren't included in the change.
  369. */
  370. int ff_add_param_change(AVPacket *pkt, int32_t channels,
  371. uint64_t channel_layout, int32_t sample_rate,
  372. int32_t width, int32_t height);
  373. /**
  374. * Set the timebase for each stream from the corresponding codec timebase and
  375. * print it.
  376. */
  377. int ff_framehash_write_header(AVFormatContext *s);
  378. /**
  379. * Read a transport packet from a media file.
  380. *
  381. * @param s media file handle
  382. * @param pkt is filled
  383. * @return 0 if OK, AVERROR_xxx on error
  384. */
  385. int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
  386. /**
  387. * Interleave a packet per dts in an output media file.
  388. *
  389. * Packets with pkt->destruct == av_destruct_packet will be freed inside this
  390. * function, so they cannot be used after it. Note that calling av_packet_unref()
  391. * on them is still safe.
  392. *
  393. * @param s media file handle
  394. * @param out the interleaved packet will be output here
  395. * @param pkt the input packet
  396. * @param flush 1 if no further packets are available as input and all
  397. * remaining packets should be output
  398. * @return 1 if a packet was output, 0 if no packet could be output,
  399. * < 0 if an error occurred
  400. */
  401. int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
  402. AVPacket *pkt, int flush);
  403. void ff_free_stream(AVFormatContext *s, AVStream *st);
  404. /**
  405. * Return the frame duration in seconds. Return 0 if not available.
  406. */
  407. void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st,
  408. AVCodecParserContext *pc, AVPacket *pkt);
  409. unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id);
  410. enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag);
  411. /**
  412. * Select a PCM codec based on the given parameters.
  413. *
  414. * @param bps bits-per-sample
  415. * @param flt floating-point
  416. * @param be big-endian
  417. * @param sflags signed flags. each bit corresponds to one byte of bit depth.
  418. * e.g. the 1st bit indicates if 8-bit should be signed or
  419. * unsigned, the 2nd bit indicates if 16-bit should be signed or
  420. * unsigned, etc... This is useful for formats such as WAVE where
  421. * only 8-bit is unsigned and all other bit depths are signed.
  422. * @return a PCM codec id or AV_CODEC_ID_NONE
  423. */
  424. enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
  425. /**
  426. * Chooses a timebase for muxing the specified stream.
  427. *
  428. * The chosen timebase allows sample accurate timestamps based
  429. * on the framerate or sample rate for audio streams. It also is
  430. * at least as precise as 1/min_precision would be.
  431. */
  432. AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precision);
  433. /**
  434. * Chooses a timebase for muxing the specified stream.
  435. */
  436. enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st);
  437. /**
  438. * Generate standard extradata for AVC-Intra based on width/height and field
  439. * order.
  440. */
  441. int ff_generate_avci_extradata(AVStream *st);
  442. /**
  443. * Add a bitstream filter to a stream.
  444. *
  445. * @param st output stream to add a filter to
  446. * @param name the name of the filter to add
  447. * @param args filter-specific argument string
  448. * @return >0 on success;
  449. * AVERROR code on failure
  450. */
  451. int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args);
  452. /**
  453. * Copy encoding parameters from source to destination stream
  454. *
  455. * @param dst pointer to destination AVStream
  456. * @param src pointer to source AVStream
  457. * @return >=0 on success, AVERROR code on error
  458. */
  459. int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
  460. /**
  461. * Wrap errno on rename() error.
  462. *
  463. * @param oldpath source path
  464. * @param newpath destination path
  465. * @return 0 or AVERROR on failure
  466. */
  467. static inline int ff_rename(const char *oldpath, const char *newpath, void *logctx)
  468. {
  469. int ret = 0;
  470. if (rename(oldpath, newpath) == -1) {
  471. ret = AVERROR(errno);
  472. if (logctx)
  473. av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s\n", oldpath, newpath);
  474. }
  475. return ret;
  476. }
  477. /**
  478. * Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end
  479. * which is always set to 0.
  480. *
  481. * @param size size of extradata
  482. * @return 0 if OK, AVERROR_xxx on error
  483. */
  484. int ff_alloc_extradata(AVCodecParameters *par, int size);
  485. /**
  486. * Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end
  487. * which is always set to 0 and fill it from pb.
  488. *
  489. * @param size size of extradata
  490. * @return >= 0 if OK, AVERROR_xxx on error
  491. */
  492. int ff_get_extradata(AVFormatContext *s, AVCodecParameters *par, AVIOContext *pb, int size);
  493. /**
  494. * add frame for rfps calculation.
  495. *
  496. * @param dts timestamp of the i-th frame
  497. * @return 0 if OK, AVERROR_xxx on error
  498. */
  499. int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t dts);
  500. void ff_rfps_calculate(AVFormatContext *ic);
  501. /**
  502. * Flags for AVFormatContext.write_uncoded_frame()
  503. */
  504. enum AVWriteUncodedFrameFlags {
  505. /**
  506. * Query whether the feature is possible on this stream.
  507. * The frame argument is ignored.
  508. */
  509. AV_WRITE_UNCODED_FRAME_QUERY = 0x0001,
  510. };
  511. /**
  512. * Copies the whilelists from one context to the other
  513. */
  514. int ff_copy_whiteblacklists(AVFormatContext *dst, const AVFormatContext *src);
  515. int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
  516. const AVIOInterruptCB *int_cb, AVDictionary **options);
  517. /**
  518. * Returned by demuxers to indicate that data was consumed but discarded
  519. * (ignored streams or junk data). The framework will re-call the demuxer.
  520. */
  521. #define FFERROR_REDO FFERRTAG('R','E','D','O')
  522. /**
  523. * Utility function to open IO stream of output format.
  524. *
  525. * @param s AVFormatContext
  526. * @param url URL or file name to open for writing
  527. * @options optional options which will be passed to io_open callback
  528. * @return >=0 on success, negative AVERROR in case of failure
  529. */
  530. int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options);
  531. /*
  532. * A wrapper around AVFormatContext.io_close that should be used
  533. * instead of calling the pointer directly.
  534. */
  535. void ff_format_io_close(AVFormatContext *s, AVIOContext **pb);
  536. /**
  537. * Parse creation_time in AVFormatContext metadata if exists and warn if the
  538. * parsing fails.
  539. *
  540. * @param s AVFormatContext
  541. * @param timestamp parsed timestamp in microseconds, only set on successful parsing
  542. * @param return_seconds set this to get the number of seconds in timestamp instead of microseconds
  543. * @return 1 if OK, 0 if the metadata was not present, AVERROR(EINVAL) on parse error
  544. */
  545. int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds);
  546. /**
  547. * Standardize creation_time metadata in AVFormatContext to an ISO-8601
  548. * timestamp string.
  549. *
  550. * @param s AVFormatContext
  551. * @return <0 on error
  552. */
  553. int ff_standardize_creation_time(AVFormatContext *s);
  554. #define CONTAINS_PAL 2
  555. /**
  556. * Reshuffles the lines to use the user specified stride.
  557. *
  558. * @param ppkt input and output packet
  559. * @return negative error code or
  560. * 0 if no new packet was allocated
  561. * non-zero if a new packet was allocated and ppkt has to be freed
  562. * CONTAINS_PAL if in addition to a new packet the old contained a palette
  563. */
  564. int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride);
  565. /**
  566. * Retrieves the palette from a packet, either from side data, or
  567. * appended to the video data in the packet itself (raw video only).
  568. * It is commonly used after a call to ff_reshuffle_raw_rgb().
  569. *
  570. * Use 0 for the ret parameter to check for side data only.
  571. *
  572. * @param pkt pointer to packet before calling ff_reshuffle_raw_rgb()
  573. * @param ret return value from ff_reshuffle_raw_rgb(), or 0
  574. * @param palette pointer to palette buffer
  575. * @return negative error code or
  576. * 1 if the packet has a palette, else 0
  577. */
  578. int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette);
  579. /**
  580. * Finalize buf into extradata and set its size appropriately.
  581. */
  582. int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf);
  583. /**
  584. * Find the next packet in the interleaving queue for the given stream.
  585. * The pkt parameter is filled in with the queued packet, including
  586. * references to the data (which the caller is not allowed to keep or
  587. * modify).
  588. *
  589. * @return 0 if a packet was found, a negative value if no packet was found
  590. */
  591. int ff_interleaved_peek(AVFormatContext *s, int stream,
  592. AVPacket *pkt, int add_offset);
  593. #endif /* AVFORMAT_INTERNAL_H */