chromium/third_party/ffmpeg/libavformat/demux.c

/*
 * Core demuxing component
 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include <stdint.h>

#include "config_components.h"

#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "libavutil/time.h"
#include "libavutil/timestamp.h"

#include "libavcodec/avcodec.h"
#include "libavcodec/bsf.h"
#include "libavcodec/codec_desc.h"
#include "libavcodec/internal.h"
#include "libavcodec/packet_internal.h"
#include "libavcodec/raw.h"

#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "id3v2.h"
#include "internal.h"
#include "url.h"

static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp)
{}

int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp)
{}

static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id)
{}

static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st,
                                     AVProbeData *pd)
{}

static int init_input(AVFormatContext *s, const char *filename,
                      AVDictionary **options)
{}

static int update_stream_avctx(AVFormatContext *s)
{}

int avformat_open_input(AVFormatContext **ps, const char *filename,
                        const AVInputFormat *fmt, AVDictionary **options)
{}

void avformat_close_input(AVFormatContext **ps)
{}

static void force_codec_ids(AVFormatContext *s, AVStream *st)
{}

static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
{}

static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index, AVPacket *pkt)
{}

static void update_timestamps(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{}

/**
 * Handle a new packet and either return it directly if possible and
 * allow_passthrough is true or queue the packet (or drop the packet
 * if corrupt).
 *
 * @return < 0 on error, 0 if the packet was passed through,
 *         1 if it was queued or dropped
 */
static int handle_new_packet(AVFormatContext *s, AVPacket *pkt, int allow_passthrough)
{}

int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
{}

int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
{}

/**
 * Return the frame duration in seconds. Return 0 if not available.
 */
static void compute_frame_duration(AVFormatContext *s, int *pnum, int *pden,
                                   AVStream *st, AVCodecParserContext *pc,
                                   AVPacket *pkt)
{}

static int has_decode_delay_been_guessed(AVStream *st)
{}

static PacketListEntry *get_next_pkt(AVFormatContext *s, AVStream *st,
                                     PacketListEntry *pktl)
{}

static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t dts)
{}

/**
 * Updates the dts of packets of a stream in pkt_buffer, by re-ordering the pts
 * of the packets in a window.
 */
static void update_dts_from_pts(AVFormatContext *s, int stream_index,
                                PacketListEntry *pkt_buffer)
{}

static void update_initial_timestamps(AVFormatContext *s, int stream_index,
                                      int64_t dts, int64_t pts, AVPacket *pkt)
{}

static void update_initial_durations(AVFormatContext *s, AVStream *st,
                                     int stream_index, int64_t duration)
{}

static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
                               AVCodecParserContext *pc, AVPacket *pkt,
                               int64_t next_dts, int64_t next_pts)
{}

/**
 * Parse a packet, add all split parts to parse_queue.
 *
 * @param pkt   Packet to parse; must not be NULL.
 * @param flush Indicates whether to flush. If set, pkt must be blank.
 */
static int parse_packet(AVFormatContext *s, AVPacket *pkt,
                        int stream_index, int flush)
{}

static int64_t ts_to_samples(AVStream *st, int64_t ts)
{}

static int codec_close(FFStream *sti)
{}

static int extract_extradata(FFFormatContext *si, AVStream *st, const AVPacket *pkt);

static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{}

int av_read_frame(AVFormatContext *s, AVPacket *pkt)
{}

/**
 * Return TRUE if the stream has accurate duration in any stream.
 *
 * @return TRUE if the stream has accurate duration for at least one component.
 */
static int has_duration(AVFormatContext *ic)
{}

/**
 * Estimate the stream timings from the one of each components.
 *
 * Also computes the global bitrate if possible.
 */
static void update_stream_timings(AVFormatContext *ic)
{}

static void fill_all_stream_timings(AVFormatContext *ic)
{}

static void estimate_timings_from_bit_rate(AVFormatContext *ic)
{}

#define DURATION_DEFAULT_MAX_READ_SIZE
#define DURATION_DEFAULT_MAX_RETRY
#define DURATION_MAX_RETRY

/* only usable for MPEG-PS streams */
static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
{}

/* 1:1 map to AVDurationEstimationMethod */
static const char *const duration_name[] =;

static const char *duration_estimate_name(enum AVDurationEstimationMethod method)
{}

static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
{}

static int determinable_frame_size(const AVCodecContext *avctx)
{}

static int has_codec_parameters(const AVStream *st, const char **errmsg_ptr)
{}

/* returns 1 or 0 if or if not decoded data was returned, or a negative error */
static int try_decode_frame(AVFormatContext *s, AVStream *st,
                            const AVPacket *pkt, AVDictionary **options)
{}

static int chapter_start_cmp(const void *p1, const void *p2)
{}

static int compute_chapters_end(AVFormatContext *s)
{}

static int get_std_framerate(int i)
{}

/* Is the time base unreliable?
 * This is a heuristic to balance between quick acceptance of the values in
 * the headers vs. some extra checks.
 * Old DivX and Xvid often have nonsense timebases like 1fps or 2fps.
 * MPEG-2 commonly misuses field repeat flags to store different framerates.
 * And there are "variable" fps files this needs to detect as well. */
static int tb_unreliable(AVFormatContext *ic, AVStream *st)
{}

int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts)
{}

void ff_rfps_calculate(AVFormatContext *ic)
{}

static int extract_extradata_check(AVStream *st)
{}

static int extract_extradata_init(AVStream *st)
{}

static int extract_extradata(FFFormatContext *si, AVStream *st, const AVPacket *pkt)
{}

int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
{}