Skip to content
Snippets Groups Projects
Commit 5e3e4706 authored by jrg@chromium.org's avatar jrg@chromium.org
Browse files

Revert 41386 - Removed custom FFmpegLock. Removed ffmpeg headers from third_party/ffmpeg/include.

Bot unhappy 

Automatic: "media_unittests" on "Vista Tests" from 41386: ... scherkus@chromium.org ...
http://chrome-buildbot:8010/builders/Vista%20Tests/builds/17009/steps/media_unittests/logs/stdio

Patch by sergeyu@chromium.org

BUG=23271
TEST=none

Review URL: http://codereview.chromium.org/909002

TBR=scherkus@chromium.org
Review URL: http://codereview.chromium.org/854006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41389 0039d316-1c4b-4281-b951-d872f2087c98
parent 58dd56d1
No related merge requests found
Showing
with 6005 additions and 69 deletions
......@@ -104,10 +104,6 @@ deps = {
"src/third_party/swig/Lib":
"/trunk/deps/third_party/swig/Lib@" + Var("swig_revision"),
"src/third_party/ffmpeg/source/patched-ffmpeg-mt":
"/trunk/deps/third_party/ffmpeg/patched-ffmpeg-mt@" +
Var("ffmpeg_revision"),
}
......@@ -169,6 +165,9 @@ deps_os = {
# TODO(ajwong): Move this into the OS-independent block.
"src/third_party/yasm/source/patched-yasm":
"/trunk/deps/third_party/yasm/patched-yasm@29937",
"src/third_party/ffmpeg/source/patched-ffmpeg-mt":
"/trunk/deps/third_party/ffmpeg/patched-ffmpeg-mt@" +
Var("ffmpeg_revision"),
"src/third_party/swig/mac":
"/trunk/deps/third_party/swig/mac@" + Var("swig_revision"),
......@@ -184,6 +183,9 @@ deps_os = {
# TODO(ajwong): Move this into the OS-independent block.
"src/third_party/yasm/source/patched-yasm":
"/trunk/deps/third_party/yasm/patched-yasm@29937",
"src/third_party/ffmpeg/source/patched-ffmpeg-mt":
"/trunk/deps/third_party/ffmpeg/patched-ffmpeg-mt@" +
Var("ffmpeg_revision"),
"src/third_party/swig/linux":
"/trunk/deps/third_party/swig/linux@" + Var("swig_revision"),
......
......@@ -92,16 +92,6 @@ void av_register_all() {
media::MockFFmpeg::get()->AVRegisterAll();
}
int av_lockmgr_register(int (*cb)(void**, enum AVLockOp)) {
media::MockFFmpeg* mock = media::MockFFmpeg::get();
// Here |mock| may be NULL when this function is called from ~FFmpegGlue().
if (mock != NULL) {
return media::MockFFmpeg::get()->AVRegisterLockManager(cb);
} else {
return 0;
}
}
AVCodec* avcodec_find_decoder(enum CodecID id) {
return media::MockFFmpeg::get()->AVCodecFindDecoder(id);
}
......
......@@ -21,7 +21,6 @@ class MockFFmpeg {
MOCK_METHOD0(AVCodecInit, void());
MOCK_METHOD1(AVRegisterProtocol, int(URLProtocol* protocol));
MOCK_METHOD0(AVRegisterAll, void());
MOCK_METHOD1(AVRegisterLockManager, int(int (*cb)(void**, enum AVLockOp)));
MOCK_METHOD1(AVCodecFindDecoder, AVCodec*(enum CodecID id));
MOCK_METHOD2(AVCodecOpen, int(AVCodecContext* avctx, AVCodec* codec));
......
......@@ -6,6 +6,16 @@
namespace media {
FFmpegLock::FFmpegLock() {
}
FFmpegLock::~FFmpegLock() {
}
Lock& FFmpegLock::lock() {
return lock_;
}
namespace mime_type {
const char kFFmpegAudio[] = "audio/x-ffmpeg";
......
......@@ -19,14 +19,34 @@ extern "C" {
// Temporarily disable possible loss of data warning.
// TODO(scherkus): fix and upstream the compiler warnings.
MSVC_PUSH_DISABLE_WARNING(4244);
#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavcodec/avcodec.h"
#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavformat/avformat.h"
#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavutil/log.h"
#include "third_party/ffmpeg/include/libavcodec/avcodec.h"
#include "third_party/ffmpeg/include/libavformat/avformat.h"
#include "third_party/ffmpeg/include/libavutil/log.h"
MSVC_POP_WARNING();
} // extern "C"
namespace media {
// FFmpegLock is used to serialize calls to avcodec_open(), avcodec_close(),
// and av_find_stream_info() for an entire process because for whatever reason
// it does Very Bad Things to other FFmpeg instances.
//
// TODO(scherkus): track down and upstream a fix to FFmpeg, if possible.
class FFmpegLock : public Singleton<FFmpegLock> {
public:
Lock& lock();
private:
// Only allow Singleton to create and delete FFmpegLock.
friend struct DefaultSingletonTraits<FFmpegLock>;
FFmpegLock();
virtual ~FFmpegLock();
Lock lock_;
DISALLOW_COPY_AND_ASSIGN(FFmpegLock);
};
// Wraps FFmpeg's av_free() in a class that can be passed as a template argument
// to scoped_ptr_malloc.
class ScopedPtrAVFree {
......
......@@ -61,8 +61,11 @@ void FFmpegAudioDecoder::DoInitialize(DemuxerStream* demuxer_stream,
// Serialize calls to avcodec_open().
AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (!codec || avcodec_open(codec_context_, codec) < 0) {
return;
{
AutoLock auto_lock(FFmpegLock::get()->lock());
if (!codec || avcodec_open(codec_context_, codec) < 0) {
return;
}
}
// When calling avcodec_find_decoder(), |codec_context_| might be altered by
......
......@@ -235,6 +235,7 @@ FFmpegDemuxer::~FFmpegDemuxer() {
// in the decoder filters. By reaching this point, all filters should have
// stopped, so this is the only safe place to do the global clean up.
// TODO(hclam): close the codecs in the corresponding decoders.
AutoLock auto_lock(FFmpegLock::get()->lock());
if (!format_context_)
return;
......@@ -396,12 +397,17 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source,
DCHECK(context);
format_context_ = context;
// Fully initialize AVFormatContext by parsing the stream a little.
result = av_find_stream_info(format_context_);
if (result < 0) {
host()->SetError(DEMUXER_ERROR_COULD_NOT_PARSE);
callback->Run();
return;
// Serialize calls to av_find_stream_info().
{
AutoLock auto_lock(FFmpegLock::get()->lock());
// Fully initialize AVFormatContext by parsing the stream a little.
result = av_find_stream_info(format_context_);
if (result < 0) {
host()->SetError(DEMUXER_ERROR_COULD_NOT_PARSE);
callback->Run();
return;
}
}
// Create demuxer streams for all supported streams.
......
......@@ -81,30 +81,6 @@ int CloseContext(URLContext* h) {
return 0;
}
int LockManagerOperation(void** lock, enum AVLockOp op) {
switch (op) {
case AV_LOCK_CREATE:
*lock = new Lock();
if (!*lock)
return 1;
return 0;
case AV_LOCK_OBTAIN:
static_cast<Lock*>(*lock)->Acquire();
return 0;
case AV_LOCK_RELEASE:
static_cast<Lock*>(*lock)->Release();
return 0;
case AV_LOCK_DESTROY:
delete static_cast<Lock*>(*lock);
*lock = NULL;
return 0;
}
return 1;
}
} // namespace
//------------------------------------------------------------------------------
......@@ -131,14 +107,12 @@ FFmpegGlue::FFmpegGlue() {
// Register our protocol glue code with FFmpeg.
avcodec_init();
av_register_protocol(&kFFmpegURLProtocol);
av_lockmgr_register(&LockManagerOperation);
// Now register the rest of FFmpeg.
av_register_all();
}
FFmpegGlue::~FFmpegGlue() {
av_lockmgr_register(NULL);
}
std::string FFmpegGlue::AddProtocol(FFmpegURLProtocol* protocol) {
......
......@@ -47,13 +47,17 @@ void FFmpegVideoDecodeEngine::Initialize(AVStream* stream, Task* done_cb) {
codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
codec_context_->error_recognition = FF_ER_CAREFUL;
// Serialize calls to avcodec_open().
AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (codec &&
avcodec_thread_init(codec_context_, kDecodeThreads) >= 0 &&
avcodec_open(codec_context_, codec) >= 0) {
state_ = kNormal;
} else {
state_ = kError;
{
AutoLock auto_lock(FFmpegLock::get()->lock());
if (codec &&
avcodec_thread_init(codec_context_, kDecodeThreads) >= 0 &&
avcodec_open(codec_context_, codec) >= 0) {
state_ = kNormal;
} else {
state_ = kError;
}
}
}
......
......@@ -22,4 +22,3 @@ AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe);
void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
void av_destruct_packet(AVPacket *pkt);
int av_lockmgr_register(AVLockMgrOperation cb);
......@@ -61,7 +61,7 @@
['(OS!="linux" and OS!="freebsd" and OS!="openbsd" and OS!="solaris" and OS!="mac") or use_system_ffmpeg!=0', {
'variables': {
'target_for_binaries': 'ffmpeg_binaries',
'ffmpeg_include_root': 'source/patched-ffmpeg-mt',
'ffmpeg_include_root': 'include',
},
},{ # else OS=="linux"
'variables': {
......@@ -136,7 +136,7 @@
'include_dirs': [
'source/config/<(ffmpeg_branding)/<(OS)/<(ffmpeg_config)',
'source/patched-ffmpeg-mt',
'source/config',
'source/config',
],
'defines': [
'HAVE_AV_CONFIG_H',
......@@ -642,8 +642,7 @@
'hard_dependency': 1,
'direct_dependent_settings': {
'include_dirs': [
'source/patched-ffmpeg-mt',
'source/config',
'include',
],
},
'conditions': [
......@@ -709,8 +708,7 @@
},
'type': '<(library)',
'include_dirs': [
'source/patched-ffmpeg-mt',
'source/config',
'include',
'<(output_root)',
'../..', # The chromium 'src' directory.
],
......
......@@ -3,9 +3,7 @@
extern "C" {
#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavcodec/avcodec.h"
#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavformat/avformat.h"
typedef int (*AVLockMgrOperation)(void**, enum AVLockOp);
#include "third_party/ffmpeg/include/libavcodec/avcodec.h"
#include "third_party/ffmpeg/include/libavformat/avformat.h"
}
This diff is collapsed.
/*
* AVOptions
* copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
*
* 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
*/
#ifndef AVCODEC_OPT_H
#define AVCODEC_OPT_H
/**
* @file libavcodec/opt.h
* AVOptions
*/
#include "libavutil/rational.h"
#include "avcodec.h"
enum AVOptionType{
FF_OPT_TYPE_FLAGS,
FF_OPT_TYPE_INT,
FF_OPT_TYPE_INT64,
FF_OPT_TYPE_DOUBLE,
FF_OPT_TYPE_FLOAT,
FF_OPT_TYPE_STRING,
FF_OPT_TYPE_RATIONAL,
FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
FF_OPT_TYPE_CONST=128,
};
/**
* AVOption
*/
typedef struct AVOption {
const char *name;
/**
* short English help text
* @todo What about other languages?
*/
const char *help;
/**
* The offset relative to the context structure where the option
* value is stored. It should be 0 for named constants.
*/
int offset;
enum AVOptionType type;
/**
* the default value for scalar options
*/
double default_val;
double min; ///< minimum valid value for the option
double max; ///< maximum valid value for the option
int flags;
#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ...
#define AV_OPT_FLAG_AUDIO_PARAM 8
#define AV_OPT_FLAG_VIDEO_PARAM 16
#define AV_OPT_FLAG_SUBTITLE_PARAM 32
//FIXME think about enc-audio, ... style flags
/**
* The logical unit to which the option belongs. Non-constant
* options and corresponding named constants share the same
* unit. May be NULL.
*/
const char *unit;
} AVOption;
/**
* Looks for an option in \p obj. Looks only for the options which
* have the flags set as specified in \p mask and \p flags (that is,
* for which it is the case that opt->flags & mask == flags).
*
* @param[in] obj a pointer to a struct whose first element is a
* pointer to an AVClass
* @param[in] name the name of the option to look for
* @param[in] unit the unit of the option to look for, or any if NULL
* @return a pointer to the option found, or NULL if no option
* has been found
*/
const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
#if LIBAVCODEC_VERSION_MAJOR < 53
/**
* @see av_set_string2()
*/
attribute_deprecated const AVOption *av_set_string(void *obj, const char *name, const char *val);
/**
* @return a pointer to the AVOption corresponding to the field set or
* NULL if no matching AVOption exists, or if the value \p val is not
* valid
* @see av_set_string3()
*/
attribute_deprecated const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc);
#endif
/**
* Sets the field of obj with the given name to value.
*
* @param[in] obj A struct whose first element is a pointer to an
* AVClass.
* @param[in] name the name of the field to set
* @param[in] val The value to set. If the field is not of a string
* type, then the given string is parsed.
* SI postfixes and some named scalars are supported.
* If the field is of a numeric type, it has to be a numeric or named
* scalar. Behavior with more than one scalar and +- infix operators
* is undefined.
* If the field is of a flags type, it has to be a sequence of numeric
* scalars or named flags separated by '+' or '-'. Prefixing a flag
* with '+' causes it to be set without affecting the other flags;
* similarly, '-' unsets a flag.
* @param[out] o_out if non-NULL put here a pointer to the AVOption
* found
* @param alloc when 1 then the old value will be av_freed() and the
* new av_strduped()
* when 0 then no av_free() nor av_strdup() will be used
* @return 0 if the value has been set, an AVERROR* error code if no
* matching option exists, or if the value \p val is not valid
*/
int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
const AVOption *av_set_double(void *obj, const char *name, double n);
const AVOption *av_set_q(void *obj, const char *name, AVRational n);
const AVOption *av_set_int(void *obj, const char *name, int64_t n);
double av_get_double(void *obj, const char *name, const AVOption **o_out);
AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
const AVOption *av_next_option(void *obj, const AVOption *last);
int av_opt_show(void *obj, void *av_log_obj);
void av_opt_set_defaults(void *s);
void av_opt_set_defaults2(void *s, int mask, int flags);
#endif /* AVCODEC_OPT_H */
/*
* The Video Decode and Presentation API for UNIX (VDPAU) is used for
* hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1.
*
* Copyright (C) 2008 NVIDIA
*
* 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
*/
#ifndef AVCODEC_VDPAU_H
#define AVCODEC_VDPAU_H
/**
* \defgroup Decoder VDPAU Decoder and Renderer
*
* VDPAU hardware acceleration has two modules
* - VDPAU decoding
* - VDPAU presentation
*
* The VDPAU decoding module parses all headers using FFmpeg
* parsing mechanisms and uses VDPAU for the actual decoding.
*
* As per the current implementation, the actual decoding
* and rendering (API calls) are done as part of the VDPAU
* presentation (vo_vdpau.c) module.
*
* @{
* \defgroup VDPAU_Decoding VDPAU Decoding
* \ingroup Decoder
* @{
*/
#include <vdpau/vdpau.h>
#include <vdpau/vdpau_x11.h>
/** \brief The videoSurface is used for rendering. */
#define FF_VDPAU_STATE_USED_FOR_RENDER 1
/**
* \brief The videoSurface is needed for reference/prediction.
* The codec manipulates this.
*/
#define FF_VDPAU_STATE_USED_FOR_REFERENCE 2
/**
* \brief This structure is used as a callback between the FFmpeg
* decoder (vd_) and presentation (vo_) module.
* This is used for defining a video frame containing surface,
* picture parameter, bitstream information etc which are passed
* between the FFmpeg decoder and its clients.
*/
struct vdpau_render_state {
VdpVideoSurface surface; ///< Used as rendered surface, never changed.
int state; ///< Holds FF_VDPAU_STATE_* values.
/** picture parameter information for all supported codecs */
union VdpPictureInfo {
VdpPictureInfoH264 h264;
VdpPictureInfoMPEG1Or2 mpeg;
VdpPictureInfoVC1 vc1;
} info;
/** Describe size/location of the compressed video data. */
int bitstream_buffers_allocated;
int bitstream_buffers_used;
VdpBitstreamBuffer *bitstream_buffers;
};
/* @}*/
#endif /* AVCODEC_VDPAU_H */
/*
* Copyright (C) 2003 Ivan Kalvachev
*
* 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
*/
#ifndef AVCODEC_XVMC_H
#define AVCODEC_XVMC_H
#include <X11/extensions/XvMC.h>
#include "avcodec.h"
#if LIBAVCODEC_VERSION_MAJOR < 53
#define AV_XVMC_STATE_DISPLAY_PENDING 1 /** the surface should be shown, the video driver manipulates this */
#define AV_XVMC_STATE_PREDICTION 2 /** the surface is needed for prediction, the codec manipulates this */
#define AV_XVMC_STATE_OSD_SOURCE 4 /** the surface is needed for subpicture rendering */
#endif
#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct
the number is 1337 speak for the letters IDCT MCo (motion compensation) */
struct xvmc_pix_fmt {
/** The field contains the special constant value AV_XVMC_ID.
It is used as a test that the application correctly uses the API,
and that there is no corruption caused by pixel routines.
- application - set during initialization
- libavcodec - unchanged
*/
int xvmc_id;
/** Pointer to the block array allocated by XvMCCreateBlocks().
The array has to be freed by XvMCDestroyBlocks().
Each group of 64 values represents one data block of differential
pixel information (in MoCo mode) or coefficients for IDCT.
- application - set the pointer during initialization
- libavcodec - fills coefficients/pixel data into the array
*/
short* data_blocks;
/** Pointer to the macroblock description array allocated by
XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks().
- application - set the pointer during initialization
- libavcodec - fills description data into the array
*/
XvMCMacroBlock* mv_blocks;
/** Number of macroblock descriptions that can be stored in the mv_blocks
array.
- application - set during initialization
- libavcodec - unchanged
*/
int allocated_mv_blocks;
/** Number of blocks that can be stored at once in the data_blocks array.
- application - set during initialization
- libavcodec - unchanged
*/
int allocated_data_blocks;
/** Indicates that the hardware would interpret data_blocks as IDCT
coefficients and perform IDCT on them.
- application - set during initialization
- libavcodec - unchanged
*/
int idct;
/** In MoCo mode it indicates that intra macroblocks are assumed to be in
unsigned format; same as the XVMC_INTRA_UNSIGNED flag.
- application - set during initialization
- libavcodec - unchanged
*/
int unsigned_intra;
/** Pointer to the surface allocated by XvMCCreateSurface().
It has to be freed by XvMCDestroySurface() on application exit.
It identifies the frame and its state on the video hardware.
- application - set during initialization
- libavcodec - unchanged
*/
XvMCSurface* p_surface;
/** Set by the decoder before calling ff_draw_horiz_band(),
needed by the XvMCRenderSurface function. */
//@{
/** Pointer to the surface used as past reference
- application - unchanged
- libavcodec - set
*/
XvMCSurface* p_past_surface;
/** Pointer to the surface used as future reference
- application - unchanged
- libavcodec - set
*/
XvMCSurface* p_future_surface;
/** top/bottom field or frame
- application - unchanged
- libavcodec - set
*/
unsigned int picture_structure;
/** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence
- application - unchanged
- libavcodec - set
*/
unsigned int flags;
//}@
/** Number of macroblock descriptions in the mv_blocks array
that have already been passed to the hardware.
- application - zeroes it on get_buffer().
A successful ff_draw_horiz_band() may increment it
with filled_mb_block_num or zero both.
- libavcodec - unchanged
*/
int start_mv_blocks_num;
/** Number of new macroblock descriptions in the mv_blocks array (after
start_mv_blocks_num) that are filled by libavcodec and have to be
passed to the hardware.
- application - zeroes it on get_buffer() or after successful
ff_draw_horiz_band().
- libavcodec - increment with one of each stored MB
*/
int filled_mv_blocks_num;
/** Number of the the next free data block; one data block consists of
64 short values in the data_blocks array.
All blocks before this one have already been claimed by placing their
position into the corresponding block description structure field,
that are part of the mv_blocks array.
- application - zeroes it on get_buffer().
A successful ff_draw_horiz_band() may zero it together
with start_mb_blocks_num.
- libavcodec - each decoded macroblock increases it by the number
of coded blocks it contains.
*/
int next_free_data_block_num;
/** extensions may be placed here */
#if LIBAVCODEC_VERSION_MAJOR < 53
//@{
/** State flags used to work around limitations in the MPlayer video system.
0 - Surface is not used.
1 - Surface is still held in application to be displayed or is
still visible.
2 - Surface is still held in libavcodec buffer for prediction.
*/
int state;
/** pointer to the surface where the subpicture is rendered */
void* p_osd_target_surface_render;
//}@
#endif
};
#endif /* AVCODEC_XVMC_H */
This diff is collapsed.
/*
* copyright (c) 2001 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
*/
#ifndef AVFORMAT_AVIO_H
#define AVFORMAT_AVIO_H
/**
* @file libavformat/avio.h
* unbuffered I/O operations
*
* @warning This file has to be considered an internal but installed
* header, so it should not be directly included in your projects.
*/
#include <stdint.h>
#include "libavutil/common.h"
/* unbuffered I/O */
/**
* URL Context.
* New fields can be added to the end with minor version bumps.
* Removal, reordering and changes to existing fields require a major
* version bump.
* sizeof(URLContext) must not be used outside libav*.
*/
struct URLContext {
#if LIBAVFORMAT_VERSION_MAJOR >= 53
const AVClass *av_class; ///< information for av_log(). Set by url_open().
#endif
struct URLProtocol *prot;
int flags;
int is_streamed; /**< true if streamed (no seek possible), default = false */
int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */
void *priv_data;
char *filename; /**< specified filename */
};
typedef struct URLContext URLContext;
typedef struct URLPollEntry {
URLContext *handle;
int events;
int revents;
} URLPollEntry;
#define URL_RDONLY 0
#define URL_WRONLY 1
#define URL_RDWR 2
typedef int URLInterruptCB(void);
int url_open_protocol (URLContext **puc, struct URLProtocol *up,
const char *filename, int flags);
int url_open(URLContext **h, const char *filename, int flags);
int url_read(URLContext *h, unsigned char *buf, int size);
int url_write(URLContext *h, unsigned char *buf, int size);
int64_t url_seek(URLContext *h, int64_t pos, int whence);
int url_close(URLContext *h);
int url_exist(const char *filename);
int64_t url_filesize(URLContext *h);
/**
* Return the file descriptor associated with this URL. For RTP, this
* will return only the RTP file descriptor, not the RTCP file descriptor.
* To get both, use rtp_get_file_handles().
*
* @return the file descriptor associated with this URL, or <0 on error.
*/
int url_get_file_handle(URLContext *h);
/**
* Return the maximum packet size associated to packetized file
* handle. If the file is not packetized (stream like HTTP or file on
* disk), then 0 is returned.
*
* @param h file handle
* @return maximum packet size in bytes
*/
int url_get_max_packet_size(URLContext *h);
void url_get_filename(URLContext *h, char *buf, int buf_size);
/**
* The callback is called in blocking functions to test regulary if
* asynchronous interruption is needed. AVERROR(EINTR) is returned
* in this case by the interrupted function. 'NULL' means no interrupt
* callback is given.
*/
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
/* not implemented */
int url_poll(URLPollEntry *poll_table, int n, int timeout);
/**
* Pause and resume playing - only meaningful if using a network streaming
* protocol (e.g. MMS).
* @param pause 1 for pause, 0 for resume
*/
int av_url_read_pause(URLContext *h, int pause);
/**
* Seek to a given timestamp relative to some component stream.
* Only meaningful if using a network streaming protocol (e.g. MMS.).
* @param stream_index The stream index that the timestamp is relative to.
* If stream_index is (-1) the timestamp should be in AV_TIME_BASE
* units from the beginning of the presentation.
* If a stream_index >= 0 is used and the protocol does not support
* seeking based on component streams, the call will fail with ENOTSUP.
* @param timestamp timestamp in AVStream.time_base units
* or if there is no stream specified then in AV_TIME_BASE units.
* @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
* and AVSEEK_FLAG_ANY. The protocol may silently ignore
* AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
* fail with ENOTSUP if used and not supported.
* @return >= 0 on success
* @see AVInputFormat::read_seek
*/
int64_t av_url_read_seek(URLContext *h, int stream_index,
int64_t timestamp, int flags);
/**
* Passing this as the "whence" parameter to a seek function causes it to
* return the filesize without seeking anywhere. Supporting this is optional.
* If it is not supported then the seek function will return <0.
*/
#define AVSEEK_SIZE 0x10000
typedef struct URLProtocol {
const char *name;
int (*url_open)(URLContext *h, const char *filename, int flags);
int (*url_read)(URLContext *h, unsigned char *buf, int size);
int (*url_write)(URLContext *h, unsigned char *buf, int size);
int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
int (*url_close)(URLContext *h);
struct URLProtocol *next;
int (*url_read_pause)(URLContext *h, int pause);
int64_t (*url_read_seek)(URLContext *h, int stream_index,
int64_t timestamp, int flags);
int (*url_get_file_handle)(URLContext *h);
} URLProtocol;
#if LIBAVFORMAT_VERSION_MAJOR < 53
extern URLProtocol *first_protocol;
#endif
extern URLInterruptCB *url_interrupt_cb;
/**
* If protocol is NULL, returns the first registered protocol,
* if protocol is non-NULL, returns the next registered protocol after protocol,
* or NULL if protocol is the last one.
*/
URLProtocol *av_protocol_next(URLProtocol *p);
#if LIBAVFORMAT_VERSION_MAJOR < 53
/**
* @deprecated Use av_register_protocol() instead.
*/
attribute_deprecated int register_protocol(URLProtocol *protocol);
#endif
int av_register_protocol(URLProtocol *protocol);
/**
* Bytestream IO Context.
* New fields can be added to the end with minor version bumps.
* Removal, reordering and changes to existing fields require a major
* version bump.
* sizeof(ByteIOContext) must not be used outside libav*.
*/
typedef struct {
unsigned char *buffer;
int buffer_size;
unsigned char *buf_ptr, *buf_end;
void *opaque;
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
int64_t (*seek)(void *opaque, int64_t offset, int whence);
int64_t pos; /**< position in the file of the current buffer */
int must_flush; /**< true if the next seek should flush */
int eof_reached; /**< true if eof reached */
int write_flag; /**< true if open for writing */
int is_streamed;
int max_packet_size;
unsigned long checksum;
unsigned char *checksum_ptr;
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
int error; ///< contains the error code or 0 if no error happened
int (*read_pause)(void *opaque, int pause);
int64_t (*read_seek)(void *opaque, int stream_index,
int64_t timestamp, int flags);
} ByteIOContext;
int init_put_byte(ByteIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
ByteIOContext *av_alloc_put_byte(
unsigned char *buffer,
int buffer_size,
int write_flag,
void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
void put_byte(ByteIOContext *s, int b);
void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
void put_le64(ByteIOContext *s, uint64_t val);
void put_be64(ByteIOContext *s, uint64_t val);
void put_le32(ByteIOContext *s, unsigned int val);
void put_be32(ByteIOContext *s, unsigned int val);
void put_le24(ByteIOContext *s, unsigned int val);
void put_be24(ByteIOContext *s, unsigned int val);
void put_le16(ByteIOContext *s, unsigned int val);
void put_be16(ByteIOContext *s, unsigned int val);
void put_tag(ByteIOContext *s, const char *tag);
void put_strz(ByteIOContext *s, const char *buf);
/**
* fseek() equivalent for ByteIOContext.
* @return new position or AVERROR.
*/
int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence);
/**
* Skip given number of bytes forward.
* @param offset number of bytes
*/
void url_fskip(ByteIOContext *s, int64_t offset);
/**
* ftell() equivalent for ByteIOContext.
* @return position or AVERROR.
*/
int64_t url_ftell(ByteIOContext *s);
/**
* Gets the filesize.
* @return filesize or AVERROR
*/
int64_t url_fsize(ByteIOContext *s);
/**
* feof() equivalent for ByteIOContext.
* @return non zero if and only if end of file
*/
int url_feof(ByteIOContext *s);
int url_ferror(ByteIOContext *s);
int av_url_read_fpause(ByteIOContext *h, int pause);
int64_t av_url_read_fseek(ByteIOContext *h, int stream_index,
int64_t timestamp, int flags);
#define URL_EOF (-1)
/** @note return URL_EOF (-1) if EOF */
int url_fgetc(ByteIOContext *s);
/** @warning currently size is limited */
#ifdef __GNUC__
int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
#else
int url_fprintf(ByteIOContext *s, const char *fmt, ...);
#endif
/** @note unlike fgets, the EOL character is not returned and a whole
line is parsed. return NULL if first char read was EOF */
char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
void put_flush_packet(ByteIOContext *s);
/**
* Reads size bytes from ByteIOContext into buf.
* @returns number of bytes read or AVERROR
*/
int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
/**
* Reads size bytes from ByteIOContext into buf.
* This reads at most 1 packet. If that is not enough fewer bytes will be
* returned.
* @returns number of bytes read or AVERROR
*/
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
/** @note return 0 if EOF, so you cannot use it if EOF handling is
necessary */
int get_byte(ByteIOContext *s);
unsigned int get_le24(ByteIOContext *s);
unsigned int get_le32(ByteIOContext *s);
uint64_t get_le64(ByteIOContext *s);
unsigned int get_le16(ByteIOContext *s);
char *get_strz(ByteIOContext *s, char *buf, int maxlen);
unsigned int get_be16(ByteIOContext *s);
unsigned int get_be24(ByteIOContext *s);
unsigned int get_be32(ByteIOContext *s);
uint64_t get_be64(ByteIOContext *s);
uint64_t ff_get_v(ByteIOContext *bc);
static inline int url_is_streamed(ByteIOContext *s)
{
return s->is_streamed;
}
/** @note when opened as read/write, the buffers are only used for
writing */
int url_fdopen(ByteIOContext **s, URLContext *h);
/** @warning must be called before any I/O */
int url_setbufsize(ByteIOContext *s, int buf_size);
/** Reset the buffer for reading or writing.
* @note Will drop any data currently in the buffer without transmitting it.
* @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY
* to set up the buffer for writing. */
int url_resetbuf(ByteIOContext *s, int flags);
/** @note when opened as read/write, the buffers are only used for
writing */
int url_fopen(ByteIOContext **s, const char *filename, int flags);
int url_fclose(ByteIOContext *s);
URLContext *url_fileno(ByteIOContext *s);
/**
* Return the maximum packet size associated to packetized buffered file
* handle. If the file is not packetized (stream like http or file on
* disk), then 0 is returned.
*
* @param s buffered file handle
* @return maximum packet size in bytes
*/
int url_fget_max_packet_size(ByteIOContext *s);
int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags);
/** return the written or read size */
int url_close_buf(ByteIOContext *s);
/**
* Open a write only memory stream.
*
* @param s new IO context
* @return zero if no error.
*/
int url_open_dyn_buf(ByteIOContext **s);
/**
* Open a write only packetized memory stream with a maximum packet
* size of 'max_packet_size'. The stream is stored in a memory buffer
* with a big endian 4 byte header giving the packet size in bytes.
*
* @param s new IO context
* @param max_packet_size maximum packet size (must be > 0)
* @return zero if no error.
*/
int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size);
/**
* Return the written size and a pointer to the buffer. The buffer
* must be freed with av_free().
* @param s IO context
* @param pbuffer pointer to a byte buffer
* @return the length of the byte buffer
*/
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
unsigned int len);
unsigned long get_checksum(ByteIOContext *s);
void init_checksum(ByteIOContext *s,
unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
unsigned long checksum);
/* udp.c */
int udp_set_remote_url(URLContext *h, const char *uri);
int udp_get_local_port(URLContext *h);
#if (LIBAVFORMAT_VERSION_MAJOR <= 52)
int udp_get_file_handle(URLContext *h);
#endif
#endif /* AVFORMAT_AVIO_H */
/*
* copyright (c) 2006 Mans Rullgard
*
* 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
*/
#ifndef AVUTIL_ADLER32_H
#define AVUTIL_ADLER32_H
#include <stdint.h>
#include "common.h"
unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
unsigned int len) av_pure;
#endif /* AVUTIL_ADLER32_H */
/*
* Copyright (c) 2007 Mans Rullgard
*
* 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
*/
#ifndef AVUTIL_AVSTRING_H
#define AVUTIL_AVSTRING_H
#include <stddef.h>
/**
* Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
* the address of the first character in str after the prefix.
*
* @param str input string
* @param pfx prefix to test
* @param ptr updated if the prefix is matched inside str
* @return non-zero if the prefix matches, zero otherwise
*/
int av_strstart(const char *str, const char *pfx, const char **ptr);
/**
* Return non-zero if pfx is a prefix of str independent of case. If
* it is, *ptr is set to the address of the first character in str
* after the prefix.
*
* @param str input string
* @param pfx prefix to test
* @param ptr updated if the prefix is matched inside str
* @return non-zero if the prefix matches, zero otherwise
*/
int av_stristart(const char *str, const char *pfx, const char **ptr);
/**
* Copy the string src to dst, but no more than size - 1 bytes, and
* null-terminate dst.
*
* This function is the same as BSD strlcpy().
*
* @param dst destination buffer
* @param src source string
* @param size size of destination buffer
* @return the length of src
*/
size_t av_strlcpy(char *dst, const char *src, size_t size);
/**
* Append the string src to the string dst, but to a total length of
* no more than size - 1 bytes, and null-terminate dst.
*
* This function is similar to BSD strlcat(), but differs when
* size <= strlen(dst).
*
* @param dst destination buffer
* @param src source string
* @param size size of destination buffer
* @return the total length of src and dst
*/
size_t av_strlcat(char *dst, const char *src, size_t size);
/**
* Append output to a string, according to a format. Never write out of
* the destination buffer, and and always put a terminating 0 within
* the buffer.
* @param dst destination buffer (string to which the output is
* appended)
* @param size total size of the destination buffer
* @param fmt printf-compatible format string, specifying how the
* following parameters are used
* @return the length of the string that would have been generated
* if enough space had been available
*/
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...);
#endif /* AVUTIL_AVSTRING_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment