From db8cdc73e38c3490389212d94ae9b92dfddd5975 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 28 Jan 2012 13:41:36 +0200 Subject: Update Libav API uses Change various code to use the latest Libav API. The libavcodec error_recognition setting has been removed and replaced with different semantics. I removed the "--lavdopts=er=" option accordingly, as I don't think it's widely enough used to be worth attempting to emulate the old option semantics using the new API. A new option with the new semantics can be added later if needed. Libav dropped APIs that were necessary with all Libav versions until quite recently (like setting avctx->age), and it would thus not be possible to keep compatibility with previous Libav versions without adding workarounds. The new APIs also had some bugs/limitations in the recent Libav release 0.8, and it would not work fully (at least some avcodec options would not be set correctly). Because of those issues, this commit makes no attempt to maintain compatibility with anything but the latest Libav git head. Hopefully the required fixes and improvements will be included in a following Libav point release. --- av_log.c | 3 --- av_opts.c | 6 ++++-- configure | 4 +++- defaultopts.c | 1 - ffmpeg_files/taglists.c | 2 -- libaf/af_lavcac3enc.c | 21 +++++++++------------ libmpcodecs/ad_ffmpeg.c | 27 +++++++++++++++------------ libmpcodecs/vd_ffmpeg.c | 36 ++++++++++-------------------------- libmpcodecs/vf_lavc.c | 4 ++-- libmpcodecs/vf_uspp.c | 7 +++---- libmpdemux/demux_lavf.c | 31 ++++++++++++++----------------- libmpdemux/demux_rtp_codec.cpp | 2 +- libmpdemux/demuxer.c | 2 +- libmpdemux/ebml.c | 10 +++++----- libvo/vo_png.c | 17 ++++++++++++----- screenshot.c | 12 ++++++++---- stream/stream_ffmpeg.c | 4 ++-- sub/av_sub.c | 9 +++++++-- 18 files changed, 96 insertions(+), 102 deletions(-) diff --git a/av_log.c b/av_log.c index bccbff54de..b804cd18d0 100644 --- a/av_log.c +++ b/av_log.c @@ -111,10 +111,7 @@ static void mp_msg_av_log_callback(void *ptr, int level, const char *fmt, void init_libav(void) { av_log_set_callback(mp_msg_av_log_callback); - - avcodec_init(); avcodec_register_all(); - av_register_all(); } diff --git a/av_opts.c b/av_opts.c index 59f47edf52..bc2e392c5f 100644 --- a/av_opts.c +++ b/av_opts.c @@ -21,8 +21,10 @@ #include #include + +#include + #include "av_opts.h" -#include "libavcodec/opt.h" int parse_avopts(void *v, char *str){ char *start; @@ -37,7 +39,7 @@ int parse_avopts(void *v, char *str){ arg = strchr(str, '='); if(arg) *arg++= 0; - if (av_set_string3(v, str, arg, 0, NULL) < 0) { + if (av_opt_set(v, str, arg, AV_OPT_SEARCH_CHILDREN) < 0) { free(start); return -1; } diff --git a/configure b/configure index 83782c9349..ee2ea4cf14 100755 --- a/configure +++ b/configure @@ -6003,7 +6003,9 @@ echores "$_live" -all_libav_libs="libavutil >= 51.7.0:libavcodec >= 53.5.0:libavformat >= 53.2.0:libswscale >= 2.0.0:libpostproc >= 52.0.0" +# Test with > against Libav 0.8 versions which will NOT work rather than +# specify minimum version, to allow (future) point releases to possibly work. +all_libav_libs="libavutil > 51.21.0:libavcodec > 53.34.0:libavformat > 53.20.0:libswscale >= 2.0.0:libpostproc >= 52.0.0" echocheck "Libav ($all_libav_libs)" if test "$ffmpeg" = auto ; then IFS=":" # shell should not be used for programming diff --git a/defaultopts.c b/defaultopts.c index a398c32417..52e63cc489 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -55,7 +55,6 @@ void set_default_mplayer_options(struct MPOpts *opts) .lavc_param = { .workaround_bugs = 1, // autodetect - .error_resilience = 2, .error_concealment = 3, }, .input = { diff --git a/ffmpeg_files/taglists.c b/ffmpeg_files/taglists.c index ec414a35c1..ee2ac94427 100644 --- a/ffmpeg_files/taglists.c +++ b/ffmpeg_files/taglists.c @@ -302,8 +302,6 @@ const struct mp_AVCodecTag mp_ff_codec_wav_tags[] = { { CODEC_ID_AAC_LATM, 0x1602 }, { CODEC_ID_AC3, 0x2000 }, { CODEC_ID_DTS, 0x2001 }, - { CODEC_ID_SONIC, 0x2048 }, - { CODEC_ID_SONIC_LS, 0x2048 }, { CODEC_ID_PCM_MULAW, 0x6c75 }, { CODEC_ID_AAC, 0x706d }, { CODEC_ID_AAC, 0x4143 }, diff --git a/libaf/af_lavcac3enc.c b/libaf/af_lavcac3enc.c index db6dc52163..ebb1c6ebea 100644 --- a/libaf/af_lavcac3enc.c +++ b/libaf/af_lavcac3enc.c @@ -98,15 +98,14 @@ static int control(struct af_instance_s *af, int cmd, void *arg) s->lavc_actx->sample_rate != af->data->rate || s->lavc_actx->bit_rate != bit_rate) { - if (s->lavc_actx->codec) - avcodec_close(s->lavc_actx); + avcodec_close(s->lavc_actx); // Put sample parameters s->lavc_actx->channels = af->data->nch; s->lavc_actx->sample_rate = af->data->rate; s->lavc_actx->bit_rate = bit_rate; - if(avcodec_open(s->lavc_actx, s->lavc_acodec) < 0) { + if (avcodec_open2(s->lavc_actx, s->lavc_acodec, NULL) < 0) { mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Couldn't open codec %s, br=%d.\n", "ac3", bit_rate); return AF_ERROR; } @@ -160,9 +159,8 @@ static void uninit(struct af_instance_s* af) af_ac3enc_t *s = af->setup; af->setup = NULL; if(s->lavc_actx) { - if (s->lavc_actx->codec) - avcodec_close(s->lavc_actx); - free(s->lavc_actx); + avcodec_close(s->lavc_actx); + av_free(s->lavc_actx); } free(s->pending_data); free(s); @@ -291,23 +289,22 @@ static int af_open(af_instance_t* af){ return AF_ERROR; } - s->lavc_actx = avcodec_alloc_context(); + s->lavc_actx = avcodec_alloc_context3(s->lavc_acodec); if (!s->lavc_actx) { mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, couldn't allocate context!\n"); return AF_ERROR; } - // using deprecated SampleFormat/FMT, AV* versions only added in 2010-11 - const enum SampleFormat *fmts = s->lavc_acodec->sample_fmts; + const enum AVSampleFormat *fmts = s->lavc_acodec->sample_fmts; for (int i = 0; ; i++) { - if (fmts[i] == SAMPLE_FMT_NONE) { + if (fmts[i] == AV_SAMPLE_FMT_NONE) { mp_msg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, encoder doesn't " "support expected sample formats!\n"); return AF_ERROR; - } else if (fmts[i] == SAMPLE_FMT_S16) { + } else if (fmts[i] == AV_SAMPLE_FMT_S16) { s->in_sampleformat = AF_FORMAT_S16_NE; s->lavc_actx->sample_fmt = fmts[i]; break; - } else if (fmts[i] == SAMPLE_FMT_FLT) { + } else if (fmts[i] == AV_SAMPLE_FMT_FLT) { s->in_sampleformat = AF_FORMAT_FLOAT_NE; s->lavc_actx->sample_fmt = fmts[i]; break; diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index cd742cf8f8..4a5062ba00 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -23,6 +23,7 @@ #include #include +#include #include "talloc.h" @@ -67,10 +68,10 @@ static int setup_format(sh_audio_t *sh_audio, { int sample_format = sh_audio->sample_format; switch (lavc_context->sample_fmt) { - case SAMPLE_FMT_U8: sample_format = AF_FORMAT_U8; break; - case SAMPLE_FMT_S16: sample_format = AF_FORMAT_S16_NE; break; - case SAMPLE_FMT_S32: sample_format = AF_FORMAT_S32_NE; break; - case SAMPLE_FMT_FLT: sample_format = AF_FORMAT_FLOAT_NE; break; + case AV_SAMPLE_FMT_U8: sample_format = AF_FORMAT_U8; break; + case AV_SAMPLE_FMT_S16: sample_format = AF_FORMAT_S16_NE; break; + case AV_SAMPLE_FMT_S32: sample_format = AF_FORMAT_S32_NE; break; + case AV_SAMPLE_FMT_FLT: sample_format = AF_FORMAT_FLOAT_NE; break; default: mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Unsupported sample format\n"); } @@ -119,10 +120,12 @@ static int init(sh_audio_t *sh_audio) struct priv *ctx = talloc_zero(NULL, struct priv); sh_audio->context = ctx; - lavc_context = avcodec_alloc_context(); + lavc_context = avcodec_alloc_context3(lavc_codec); ctx->avctx = lavc_context; - lavc_context->drc_scale = opts->drc_level; + // Always try to set - option only exists for AC3 at the moment + av_opt_set_double(lavc_context, "drc_scale", opts->drc_level, + AV_OPT_SEARCH_CHILDREN); lavc_context->sample_rate = sh_audio->samplerate; lavc_context->bit_rate = sh_audio->i_bps * 8; if (sh_audio->wf) { @@ -156,7 +159,7 @@ static int init(sh_audio_t *sh_audio) } /* open it */ - if (avcodec_open(lavc_context, lavc_codec) < 0) { + if (avcodec_open2(lavc_context, lavc_codec, NULL) < 0) { mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Could not open codec.\n"); uninit(sh_audio); return 0; @@ -195,10 +198,10 @@ static int init(sh_audio_t *sh_audio) sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; switch (lavc_context->sample_fmt) { - case SAMPLE_FMT_U8: - case SAMPLE_FMT_S16: - case SAMPLE_FMT_S32: - case SAMPLE_FMT_FLT: + case AV_SAMPLE_FMT_U8: + case AV_SAMPLE_FMT_S16: + case AV_SAMPLE_FMT_S32: + case AV_SAMPLE_FMT_FLT: break; default: uninit(sh_audio); @@ -215,7 +218,7 @@ static void uninit(sh_audio_t *sh) AVCodecContext *lavc_context = ctx->avctx; if (lavc_context) { - if (lavc_context->codec && avcodec_close(lavc_context) < 0) + if (avcodec_close(lavc_context) < 0) mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n"); av_freep(&lavc_context->extradata); av_freep(&lavc_context); diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index 0688aae7cc..cd59b05e79 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -22,13 +22,15 @@ #include #include +#include +#include + #include "talloc.h" #include "config.h" #include "mp_msg.h" #include "options.h" #include "av_opts.h" -#include "libavutil/common.h" #include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "fmt-conversion.h" @@ -62,8 +64,6 @@ typedef struct { int do_dr1; int vo_initialized; int best_csp; - int b_age; - int ip_age[2]; int qp_stat[32]; double qp_sum; double inv_qp_sum; @@ -86,7 +86,6 @@ static void uninit(struct sh_video *sh); const m_option_t lavc_decode_opts_conf[] = { OPT_INTRANGE("bug", lavc_param.workaround_bugs, 0, -1, 999999), - OPT_INTRANGE("er", lavc_param.error_resilience, 0, 0, 99), OPT_FLAG_ON("gray", lavc_param.gray, 0), OPT_INTRANGE("idct", lavc_param.idct_algo, 0, 0, 99), OPT_INTRANGE("ec", lavc_param.error_concealment, 0, 0, 99), @@ -149,11 +148,10 @@ static int init(sh_video_t *sh) && lavc_codec->id != CODEC_ID_ROQ && lavc_codec->id != CODEC_ID_VP8 && lavc_codec->id != CODEC_ID_LAGARITH) ctx->do_dr1 = 1; - ctx->b_age = ctx->ip_age[0] = ctx->ip_age[1] = 256 * 256 * 256 * 64; ctx->ip_count = ctx->b_count = 0; ctx->pic = avcodec_alloc_frame(); - ctx->avctx = avcodec_alloc_context(); + ctx->avctx = avcodec_alloc_context3(lavc_codec); avctx = ctx->avctx; avctx->opaque = sh; avctx->codec_type = AVMEDIA_TYPE_VIDEO; @@ -209,7 +207,6 @@ static int init(sh_video_t *sh) avctx->coded_width = sh->disp_w; avctx->coded_height = sh->disp_h; avctx->workaround_bugs = lavc_param->workaround_bugs; - avctx->error_recognition = lavc_param->error_resilience; if (lavc_param->gray) avctx->flags |= CODEC_FLAG_GRAY; avctx->flags2 |= lavc_param->fast; @@ -272,7 +269,7 @@ static int init(sh_video_t *sh) * MJPG fourcc :( */ if (!sh->bih || sh->bih->biSize <= sizeof(*sh->bih)) break; - avctx->flags |= CODEC_FLAG_EXTERN_HUFF; + av_opt_set_int(avctx, "extern_huff", 1, AV_OPT_SEARCH_CHILDREN); avctx->extradata_size = sh->bih->biSize - sizeof(*sh->bih); avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); @@ -318,7 +315,7 @@ static int init(sh_video_t *sh) avctx->thread_count = lavc_param->threads; /* open it */ - if (avcodec_open(avctx, lavc_codec) < 0) { + if (avcodec_open2(avctx, lavc_codec, NULL) < 0) { mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n"); uninit(sh); return 0; @@ -550,19 +547,6 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic) pic->opaque = mpi; - if (pic->reference) { - pic->age = ctx->ip_age[0]; - - ctx->ip_age[0] = ctx->ip_age[1] + 1; - ctx->ip_age[1] = 1; - ctx->b_age++; - } else { - pic->age = ctx->b_age; - - ctx->ip_age[0]++; - ctx->ip_age[1]++; - ctx->b_age = 1; - } pic->type = FF_BUFFER_TYPE_USER; /* The libavcodec reordered_opaque functionality is implemented by @@ -708,16 +692,16 @@ static struct mp_image *decode(struct sh_video *sh, struct demux_packet *packet, all_frametime, (double)(len * 8) / sh->frametime / 1000.0, (double)(all_len * 8) / all_frametime / 1000.0); switch (pic->pict_type) { - case FF_I_TYPE: + case AV_PICTURE_TYPE_I: fprintf(fvstats, "type= I\n"); break; - case FF_P_TYPE: + case AV_PICTURE_TYPE_P: fprintf(fvstats, "type= P\n"); break; - case FF_S_TYPE: + case AV_PICTURE_TYPE_S: fprintf(fvstats, "type= S\n"); break; - case FF_B_TYPE: + case AV_PICTURE_TYPE_B: fprintf(fvstats, "type= B\n"); break; default: diff --git a/libmpcodecs/vf_lavc.c b/libmpcodecs/vf_lavc.c index ba870a8b85..b2c1dd756d 100644 --- a/libmpcodecs/vf_lavc.c +++ b/libmpcodecs/vf_lavc.c @@ -71,7 +71,7 @@ static int config(struct vf_instance *vf, vf->priv->outbuf_size=10000+width*height; // must be enough! vf->priv->outbuf = malloc(vf->priv->outbuf_size); - if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) { + if (avcodec_open2(&lavc_venc_context, vf->priv->codec, NULL) != 0) { mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Could not open codec.\n"); return 0; } @@ -143,7 +143,7 @@ static int vf_open(vf_instance_t *vf, char *args){ return 0; } - vf->priv->context=avcodec_alloc_context(); + vf->priv->context=avcodec_alloc_context3(vf->priv->codec); vf->priv->pic = avcodec_alloc_frame(); // TODO: parse args -> diff --git a/libmpcodecs/vf_uspp.c b/libmpcodecs/vf_uspp.c index 332d59ee22..ae044b19a6 100644 --- a/libmpcodecs/vf_uspp.c +++ b/libmpcodecs/vf_uspp.c @@ -222,8 +222,7 @@ static int config(struct vf_instance *vf, for(i=0; i< (1<priv->log2_count); i++){ AVCodecContext *avctx_enc; - avctx_enc= - vf->priv->avctx_enc[i]= avcodec_alloc_context(); + avctx_enc = vf->priv->avctx_enc[i] = avcodec_alloc_context3(enc); avctx_enc->width = width + BLOCK; avctx_enc->height = height + BLOCK; avctx_enc->time_base= (AVRational){1,25}; // meaningless @@ -233,8 +232,8 @@ static int config(struct vf_instance *vf, avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality= 123; - avcodec_open(avctx_enc, enc); - assert(avctx_enc->codec); + int res = avcodec_open2(avctx_enc, enc, NULL); + assert(res >= 0); } vf->priv->frame= avcodec_alloc_frame(); vf->priv->frame_dec= avcodec_alloc_frame(); diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 4314a96c02..cf17664aab 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -25,6 +25,13 @@ #include #include +#include +#include +#include +#include +#include +#include + #include "config.h" #include "options.h" #include "mp_msg.h" @@ -38,13 +45,6 @@ #include "m_option.h" #include "sub/sub.h" -#include "libavformat/avformat.h" -#include "libavformat/avio.h" -#include "libavutil/avutil.h" -#include "libavutil/avstring.h" -#include -#include "libavcodec/opt.h" - #include "mp_taglists.h" #define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE @@ -534,7 +534,6 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) struct MPOpts *opts = demuxer->opts; struct lavfdopts *lavfdopts = &opts->lavfdopts; AVFormatContext *avfc; - const AVOption *opt; AVDictionaryEntry *t = NULL; lavf_priv_t *priv = demuxer->priv; int i; @@ -559,16 +558,14 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) avfc->flags |= AVFMT_FLAG_IGNIDX; if (lavfdopts->probesize) { - opt = av_set_int(avfc, "probesize", lavfdopts->probesize); - if (!opt) + if (av_opt_set_int(avfc, "probesize", lavfdopts->probesize, 0) < 0) mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option probesize to %u\n", lavfdopts->probesize); } if (lavfdopts->analyzeduration) { - opt = av_set_int(avfc, "analyzeduration", - lavfdopts->analyzeduration * AV_TIME_BASE); - if (!opt) + if (av_opt_set_int(avfc, "analyzeduration", + lavfdopts->analyzeduration * AV_TIME_BASE, 0) < 0) mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option " "analyzeduration to %u\n", lavfdopts->analyzeduration); } @@ -609,7 +606,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) priv->avfc = avfc; - if (av_find_stream_info(avfc) < 0) { + if (avformat_find_stream_info(avfc, NULL) < 0) { mp_msg(MSGT_HEADER, MSGL_ERR, "LAVF_header: av_find_stream_info() failed\n"); return NULL; @@ -617,7 +614,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) /* Add metadata. */ while ((t = av_dict_get(avfc->metadata, "", t, - AV_METADATA_IGNORE_SUFFIX))) + AV_DICT_IGNORE_SUFFIX))) demux_info_add(demuxer, t->key, t->value); for (i = 0; i < avfc->nb_chapters; i++) { @@ -708,7 +705,7 @@ static void check_internet_radio_hack(struct demuxer *demuxer) AVDictionaryEntry *t = NULL; AVStream *stream = avfc->streams[avfc->nb_streams - 1]; while ((t = av_dict_get(stream->metadata, "", t, - AV_METADATA_IGNORE_SUFFIX))) + AV_DICT_IGNORE_SUFFIX))) demux_info_add(demuxer, t->key, t->value); } else { if (priv->internet_radio_hack) @@ -995,7 +992,7 @@ static void demux_close_lavf(demuxer_t *demuxer) if (priv) { if (priv->avfc) { av_freep(&priv->avfc->key); - av_close_input_file(priv->avfc); + avformat_close_input(&priv->avfc); } av_freep(&priv->pb); free(priv); diff --git a/libmpdemux/demux_rtp_codec.cpp b/libmpdemux/demux_rtp_codec.cpp index 28fb51e96e..cb21e6b633 100644 --- a/libmpdemux/demux_rtp_codec.cpp +++ b/libmpdemux/demux_rtp_codec.cpp @@ -135,7 +135,7 @@ void rtpCodecInitialize_video(demuxer_t* demuxer, int fooLen; const uint8_t* fooData; h264parserctx = av_parser_init(CODEC_ID_H264); - avcctx = avcodec_alloc_context(); + avcctx = avcodec_alloc_context3(NULL); // Pass the config to the parser h264parserctx->parser->parser_parse(h264parserctx, avcctx, &fooData, &fooLen, configData, configLen); diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index b3a1998d0c..0ff734b074 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -547,7 +547,7 @@ static void allocate_parser(AVCodecContext **avctx, AVCodecParserContext **parse break; } if (codec_id != CODEC_ID_NONE) { - *avctx = avcodec_alloc_context(); + *avctx = avcodec_alloc_context3(NULL); if (!*avctx) return; *parser = av_parser_init(codec_id); diff --git a/libmpdemux/ebml.c b/libmpdemux/ebml.c index 28b4a4643a..9bce3b5182 100644 --- a/libmpdemux/ebml.c +++ b/libmpdemux/ebml.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include "talloc.h" #include "ebml.h" @@ -191,11 +191,11 @@ double ebml_read_float(stream_t *s, uint64_t *length) len = ebml_read_length(s, &l); switch (len) { case 4: - value = av_int2flt(stream_read_dword(s)); + value = av_int2float(stream_read_dword(s)); break; case 8: - value = av_int2dbl(stream_read_qword(s)); + value = av_int2double(stream_read_qword(s)); break; default: @@ -382,9 +382,9 @@ static double ebml_parse_float(uint8_t *data, int length) assert(length == 4 || length == 8); uint64_t i = ebml_parse_uint(data, length); if (length == 4) - return av_int2flt(i); + return av_int2float(i); else - return av_int2dbl(i); + return av_int2double(i); } diff --git a/libvo/vo_png.c b/libvo/vo_png.c index 5ad683ad22..da08bb379e 100644 --- a/libvo/vo_png.c +++ b/libvo/vo_png.c @@ -165,13 +165,20 @@ static int preinit(const char *arg) if (subopt_parse(arg, subopts) != 0) { return -1; } - avctx = avcodec_alloc_context(); - if (avcodec_open(avctx, avcodec_find_encoder(CODEC_ID_PNG)) < 0) { - uninit(); - return -1; - } + struct AVCodec *png_codec = avcodec_find_encoder(CODEC_ID_PNG); + if (!png_codec) + goto error; + avctx = avcodec_alloc_context3(png_codec); + if (!avctx) + goto error; + if (avcodec_open2(avctx, png_codec, NULL) < 0) + goto error; avctx->compression_level = z_compression; return 0; + + error: + uninit(); + return -1; } static int control(uint32_t request, void *data) diff --git a/screenshot.c b/screenshot.c index 9b8c67a89a..55107bf930 100644 --- a/screenshot.c +++ b/screenshot.c @@ -68,11 +68,15 @@ static int write_png(screenshot_ctx *ctx, struct mp_image *image) void *outbuffer = NULL; int success = 0; - AVCodecContext *avctx = avcodec_alloc_context(); + struct AVCodec *png_codec = avcodec_find_encoder(CODEC_ID_PNG); + AVCodecContext *avctx = NULL; + if (!png_codec) + goto print_open_fail; + avctx = avcodec_alloc_context3(png_codec); if (!avctx) - goto error_exit; - - if (avcodec_open(avctx, avcodec_find_encoder(CODEC_ID_PNG))) { + goto print_open_fail; + if (avcodec_open2(avctx, png_codec, NULL) < 0) { + print_open_fail: mp_msg(MSGT_CPLAYER, MSGL_INFO, "Could not open libavcodec PNG encoder" " for saving screenshot\n"); goto error_exit; diff --git a/stream/stream_ffmpeg.c b/stream/stream_ffmpeg.c index 74e9db791c..a76b9e5f3b 100644 --- a/stream/stream_ffmpeg.c +++ b/stream/stream_ffmpeg.c @@ -101,9 +101,9 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format) int dummy; if (mode == STREAM_READ) - flags = URL_RDONLY; + flags = AVIO_FLAG_READ; else if (mode == STREAM_WRITE) - flags = URL_WRONLY; + flags = AVIO_FLAG_WRITE; else { mp_msg(MSGT_OPEN, MSGL_ERR, "[ffmpeg] Unknown open mode %d\n", mode); res = STREAM_UNSUPPORTED; diff --git a/sub/av_sub.c b/sub/av_sub.c index 0d8c14db60..3a9e1b4f26 100644 --- a/sub/av_sub.c +++ b/sub/av_sub.c @@ -63,9 +63,14 @@ int decode_avsub(struct sh_sub *sh, uint8_t *data, int size, pkt.convergence_duration = duration * 1000; if (!ctx) { AVCodec *sub_codec; - ctx = avcodec_alloc_context(); sub_codec = avcodec_find_decoder(cid); - if (!ctx || !sub_codec || avcodec_open(ctx, sub_codec) < 0) { + if (!sub_codec) + goto error; + ctx = avcodec_alloc_context3(sub_codec); + if (!ctx) + goto error; + if (avcodec_open2(ctx, sub_codec, NULL) < 0) { + error: mp_msg(MSGT_SUBREADER, MSGL_FATAL, "Could not open subtitle decoder\n"); av_freep(&ctx); -- cgit v1.2.3 From cdb6d157ccb2d311afb72b7cbf128c3866e85ec6 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 1 Feb 2012 18:34:51 +0200 Subject: demux_lavf: use Libav RIFF tag lists directly Change demux_lavf to use CodecID -> RIFF tag mappings that are now available through the public Libav API. Previously it used a copy in ffmpeg_files/taglists.c. That can now be deleted. --- ffmpeg_files/taglists.c | 365 ----------------------------------------------- ffmpeg_files/taglists.h | 9 -- libmpdemux/demux_lavf.c | 9 +- libmpdemux/mp_taglists.c | 54 +++++-- libmpdemux/mp_taglists.h | 10 +- 5 files changed, 47 insertions(+), 400 deletions(-) delete mode 100644 ffmpeg_files/taglists.c delete mode 100644 ffmpeg_files/taglists.h diff --git a/ffmpeg_files/taglists.c b/ffmpeg_files/taglists.c deleted file mode 100644 index ee2ac94427..0000000000 --- a/ffmpeg_files/taglists.c +++ /dev/null @@ -1,365 +0,0 @@ -/* - * 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 - */ - - -/* This file contains: - * - the tables ff_codec_bmp_tags and ff_codec_wav_tags from FFmpeg's - * libavformat/riff.c, renamed to have an extra mp_ prefix, and with - * libavcodec version check added around CODEC_ID_ macros only available - * in latest libavcodec versions - * - an implementation of av_codec_get_tag and av_codec_get_id from - * libavformat/utils.c, renamed to have an extra mp_ prefix - */ - - -const struct mp_AVCodecTag mp_ff_codec_bmp_tags[] = { - { CODEC_ID_H264, MKTAG('H', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('h', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('X', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('x', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, - { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') }, - { CODEC_ID_H263, MKTAG('H', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('X', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('T', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('L', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') }, - { CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') }, - { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') }, - { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */ - { CODEC_ID_H261, MKTAG('H', '2', '6', '1') }, - { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') }, - { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') }, - { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, - { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') }, - { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') }, - { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') }, - { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') }, - { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 0 ) }, /* some broken avi use this */ - { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') }, - { CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') }, - { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') }, - { CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') }, - { CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') }, - { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') }, - { CODEC_ID_MPEG4, MKTAG('W', 'A', 'W', 'V') }, /* WaWv MPEG-4 Video Codec */ - { CODEC_ID_MPEG4, MKTAG('F', 'F', 'D', 'S') }, - { CODEC_ID_MPEG4, MKTAG('F', 'V', 'F', 'W') }, - { CODEC_ID_MPEG4, MKTAG('D', 'C', 'O', 'D') }, - { CODEC_ID_MPEG4, MKTAG('M', 'V', 'X', 'M') }, - { CODEC_ID_MPEG4, MKTAG('P', 'M', '4', 'V') }, - { CODEC_ID_MPEG4, MKTAG('S', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('D', 'X', 'G', 'M') }, - { CODEC_ID_MPEG4, MKTAG('V', 'I', 'D', 'M') }, - { CODEC_ID_MPEG4, MKTAG('M', '4', 'T', '3') }, - { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'X') }, - { CODEC_ID_MPEG4, MKTAG('H', 'D', 'X', '4') }, /* flipped video */ - { CODEC_ID_MPEG4, MKTAG('D', 'M', 'K', '2') }, - { CODEC_ID_MPEG4, MKTAG('D', 'I', 'G', 'I') }, - { CODEC_ID_MPEG4, MKTAG('I', 'N', 'M', 'C') }, - { CODEC_ID_MPEG4, MKTAG('E', 'P', 'H', 'V') }, /* Ephv MPEG-4 */ - { CODEC_ID_MPEG4, MKTAG('E', 'M', '4', 'A') }, - { CODEC_ID_MPEG4, MKTAG('M', '4', 'C', 'C') }, /* Divio MPEG-4 */ - { CODEC_ID_MPEG4, MKTAG('S', 'N', '4', '0') }, - { CODEC_ID_MPEG4, MKTAG('V', 'S', 'P', 'X') }, - { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') }, - { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') }, - { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */ - { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'V', 'X', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') }, - { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') }, - { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') }, - { CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') }, - { CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') }, - { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') }, - { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', '4', '1') }, - { CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') }, - { CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') }, - { CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') }, /* Canopus DV */ - { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') }, /* Canopus DV */ - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('P', 'I', 'M', '2') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') }, - { CODEC_ID_MPEG1VIDEO, MKTAG( 1 , 0 , 0 , 16) }, - { CODEC_ID_MPEG2VIDEO, MKTAG( 2 , 0 , 0 , 16) }, - { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 16) }, - { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('L', 'M', 'P', '2') }, /* Lead MPEG2 in avi */ - { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') }, /* Matrox MPEG2 intra-only */ - { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') }, - { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, - { CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */ - { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - encoder */ - { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - decoder */ - { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, - { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') }, - { CODEC_ID_MJPEG, MKTAG('A', 'C', 'D', 'V') }, - { CODEC_ID_MJPEG, MKTAG('Q', 'I', 'V', 'G') }, - { CODEC_ID_MJPEG, MKTAG('S', 'L', 'M', 'J') }, /* SL M-JPEG */ - { CODEC_ID_MJPEG, MKTAG('C', 'J', 'P', 'G') }, /* Creative Webcam JPEG */ - { CODEC_ID_MJPEG, MKTAG('I', 'J', 'L', 'V') }, /* Intel JPEG Library Video Codec */ - { CODEC_ID_MJPEG, MKTAG('M', 'V', 'J', 'P') }, /* Midvid JPEG Video Codec */ - { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '1') }, - { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') }, - { CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') }, - { CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') }, /* Paradigm Matrix M-JPEG Codec */ - { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') }, - { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') }, - { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG( 0 , 0 , 0 , 0 ) }, - { CODEC_ID_RAWVIDEO, MKTAG( 3 , 0 , 0 , 0 ) }, - { CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('V', '4', '2', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'N', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'Y') }, - { CODEC_ID_RAWVIDEO, MKTAG('u', 'y', 'v', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('2', 'V', 'u', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, - { CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') }, - { CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') }, - { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') }, - { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') }, - { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, - { CODEC_ID_RAWVIDEO, MKTAG('V', 'D', 'T', 'Z') }, /* SoftLab-NSK VideoTizer */ - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '1', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '2', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', 'B') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', 'B') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'V', '9') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, - { CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') }, - { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') }, - { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, - { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, - { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') }, - { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') }, - { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') }, - { CODEC_ID_INDEO5, MKTAG('I', 'V', '5', '0') }, - { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, - { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') }, - { CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') }, - { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') }, - { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') }, - { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') }, - { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') }, - { CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') }, - { CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') }, - { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') }, - { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') }, - { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') }, - { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') }, - { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') }, - { CODEC_ID_MIMIC, MKTAG('L', 'M', '2', '0') }, - { CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') }, - { CODEC_ID_MSRLE, MKTAG( 1 , 0 , 0 , 0 ) }, - { CODEC_ID_MSRLE, MKTAG( 2 , 0 , 0 , 0 ) }, - { CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') }, - { CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') }, - { CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') }, - { CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') }, - { CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') }, - { CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') }, - { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, - { CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') }, - { CODEC_ID_TRUEMOTION1, MKTAG('P', 'V', 'E', 'Z') }, - { CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') }, - { CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') }, - { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') }, - { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') }, - { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') }, - { CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') }, - { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, - { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') }, - { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') }, - { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') }, - { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') }, - { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') }, - { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') }, - { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') }, - { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', 'P') }, - { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') }, - { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') }, - { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') }, - { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') }, - { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') }, - { CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') }, - { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') }, - { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') }, - { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') }, - { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') }, - { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') }, - { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') }, - { CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') }, - { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') }, - { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') }, - { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, - { CODEC_ID_PNG, MKTAG('M', 'P', 'N', 'G') }, - { CODEC_ID_PNG, MKTAG('P', 'N', 'G', '1') }, - { CODEC_ID_CLJR, MKTAG('c', 'l', 'j', 'r') }, - { CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') }, - { CODEC_ID_RPZA, MKTAG('a', 'z', 'p', 'r') }, - { CODEC_ID_RPZA, MKTAG('R', 'P', 'Z', 'A') }, - { CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') }, - { CODEC_ID_SP5X, MKTAG('S', 'P', '5', '4') }, - { CODEC_ID_AURA, MKTAG('A', 'U', 'R', 'A') }, - { CODEC_ID_AURA2, MKTAG('A', 'U', 'R', '2') }, - { CODEC_ID_DPX, MKTAG('d', 'p', 'x', ' ') }, - { CODEC_ID_KGV1, MKTAG('K', 'G', 'V', '1') }, - { CODEC_ID_LAGARITH, MKTAG('L', 'A', 'G', 'S') }, - { CODEC_ID_NONE, 0 } -}; - -const struct mp_AVCodecTag mp_ff_codec_wav_tags[] = { - { CODEC_ID_PCM_S16LE, 0x0001 }, - { CODEC_ID_PCM_U8, 0x0001 }, /* must come after s16le in this list */ - { CODEC_ID_PCM_S24LE, 0x0001 }, - { CODEC_ID_PCM_S32LE, 0x0001 }, - { CODEC_ID_ADPCM_MS, 0x0002 }, - { CODEC_ID_PCM_F32LE, 0x0003 }, - { CODEC_ID_PCM_F64LE, 0x0003 }, /* must come after f32le in this list */ - { CODEC_ID_PCM_ALAW, 0x0006 }, - { CODEC_ID_PCM_MULAW, 0x0007 }, - { CODEC_ID_WMAVOICE, 0x000A }, - { CODEC_ID_ADPCM_IMA_WAV, 0x0011 }, - { CODEC_ID_PCM_ZORK, 0x0011 }, /* must come after adpcm_ima_wav in this list */ - { CODEC_ID_ADPCM_YAMAHA, 0x0020 }, - { CODEC_ID_TRUESPEECH, 0x0022 }, - { CODEC_ID_GSM_MS, 0x0031 }, - { CODEC_ID_ADPCM_G726, 0x0045 }, - { CODEC_ID_MP2, 0x0050 }, - { CODEC_ID_MP3, 0x0055 }, - { CODEC_ID_AMR_NB, 0x0057 }, - { CODEC_ID_AMR_WB, 0x0058 }, - { CODEC_ID_ADPCM_IMA_DK4, 0x0061 }, /* rogue format number */ - { CODEC_ID_ADPCM_IMA_DK3, 0x0062 }, /* rogue format number */ - { CODEC_ID_ADPCM_IMA_WAV, 0x0069 }, - { CODEC_ID_VOXWARE, 0x0075 }, - { CODEC_ID_AAC, 0x00ff }, - { CODEC_ID_SIPR, 0x0130 }, - { CODEC_ID_WMAV1, 0x0160 }, - { CODEC_ID_WMAV2, 0x0161 }, - { CODEC_ID_WMAPRO, 0x0162 }, - { CODEC_ID_WMALOSSLESS, 0x0163 }, - { CODEC_ID_ADPCM_CT, 0x0200 }, - { CODEC_ID_ATRAC3, 0x0270 }, - { CODEC_ID_ADPCM_G722, 0x028F }, - { CODEC_ID_IMC, 0x0401 }, - { CODEC_ID_GSM_MS, 0x1500 }, - { CODEC_ID_TRUESPEECH, 0x1501 }, - { CODEC_ID_AAC_LATM, 0x1602 }, - { CODEC_ID_AC3, 0x2000 }, - { CODEC_ID_DTS, 0x2001 }, - { CODEC_ID_PCM_MULAW, 0x6c75 }, - { CODEC_ID_AAC, 0x706d }, - { CODEC_ID_AAC, 0x4143 }, - { CODEC_ID_FLAC, 0xF1AC }, - { CODEC_ID_ADPCM_SWF, ('S'<<8)+'F' }, - { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id? - - /* FIXME: All of the IDs below are not 16 bit and thus illegal. */ - // for NuppelVideo (nuv.c) - { CODEC_ID_PCM_S16LE, MKTAG('R', 'A', 'W', 'A') }, - { CODEC_ID_MP3, MKTAG('L', 'A', 'M', 'E') }, - { CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') }, - { CODEC_ID_NONE, 0 }, -}; - -static unsigned int ff_codec_get_tag(const struct mp_AVCodecTag *tags, int id) -{ - while (tags->id != CODEC_ID_NONE) { - if (tags->id == id) - return tags->tag; - tags++; - } - return 0; -} - -static enum CodecID ff_codec_get_id(const struct mp_AVCodecTag *tags, unsigned int tag) -{ - int i; - for(i=0; tags[i].id != CODEC_ID_NONE;i++) { - if(tag == tags[i].tag) - return tags[i].id; - } - for(i=0; tags[i].id != CODEC_ID_NONE; i++) { - if( toupper((tag >> 0)&0xFF) == toupper((tags[i].tag >> 0)&0xFF) - && toupper((tag >> 8)&0xFF) == toupper((tags[i].tag >> 8)&0xFF) - && toupper((tag >>16)&0xFF) == toupper((tags[i].tag >>16)&0xFF) - && toupper((tag >>24)&0xFF) == toupper((tags[i].tag >>24)&0xFF)) - return tags[i].id; - } - return CODEC_ID_NONE; -} - -unsigned int mp_av_codec_get_tag(const struct mp_AVCodecTag * const *tags, enum CodecID id) -{ - int i; - for(i=0; tags && tags[i]; i++){ - int tag= ff_codec_get_tag(tags[i], id); - if(tag) return tag; - } - return 0; -} - -enum CodecID mp_av_codec_get_id(const struct mp_AVCodecTag * const *tags, unsigned int tag) -{ - int i; - for(i=0; tags && tags[i]; i++){ - enum CodecID id= ff_codec_get_id(tags[i], tag); - if(id!=CODEC_ID_NONE) return id; - } - return CODEC_ID_NONE; -} diff --git a/ffmpeg_files/taglists.h b/ffmpeg_files/taglists.h deleted file mode 100644 index 4c8f9bfdbd..0000000000 --- a/ffmpeg_files/taglists.h +++ /dev/null @@ -1,9 +0,0 @@ -#include "libavcodec/avcodec.h" - -struct mp_AVCodecTag { - int id; - unsigned int tag; -}; - -unsigned int mp_av_codec_get_tag(const struct mp_AVCodecTag * const *tags, enum CodecID id); -enum CodecID mp_av_codec_get_id(const struct mp_AVCodecTag * const *tags, unsigned int tag); diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index cf17664aab..02eff0d4b8 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -293,8 +293,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) if (matches_avinputformat_name(priv, "mpeg") || matches_avinputformat_name(priv, "mpegts")) codec->codec_tag = 0; - int override_tag = mp_av_codec_get_tag(mp_codecid_override_taglists, - codec->codec_id); + int override_tag = mp_taglist_override(codec->codec_id); // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag if (override_tag) codec->codec_tag = override_tag; @@ -313,8 +312,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) if (codec->codec_tag == MKTAG('m', 'p', '4', 'a')) codec->codec_tag = 0; if (!codec->codec_tag) - codec->codec_tag = mp_av_codec_get_tag(mp_wav_taglists, - codec->codec_id); + codec->codec_tag = mp_taglist_audio(codec->codec_id); wf->wFormatTag = codec->codec_tag; wf->nChannels = codec->channels; wf->nSamplesPerSec = codec->sample_rate; @@ -399,8 +397,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) codec->codec_tag = avcodec_pix_fmt_to_codec_tag(codec->pix_fmt); } if (!codec->codec_tag) - codec->codec_tag = mp_av_codec_get_tag(mp_bmp_taglists, - codec->codec_id); + codec->codec_tag = mp_taglist_video(codec->codec_id); bih->biSize = sizeof(*bih) + codec->extradata_size; bih->biWidth = codec->width; bih->biHeight = codec->height; diff --git a/libmpdemux/mp_taglists.c b/libmpdemux/mp_taglists.c index c04c700f8a..afd1b971ce 100644 --- a/libmpdemux/mp_taglists.c +++ b/libmpdemux/mp_taglists.c @@ -16,16 +16,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" - -#include "libavformat/avformat.h" -#include +#include +#include "config.h" #include "mp_taglists.h" -#include "ffmpeg_files/taglists.c" +struct tag { + enum CodecID id; + unsigned int tag; +}; -static const struct mp_AVCodecTag mp_wav_tags[] = { +static const struct tag mp_wav_tags[] = { { CODEC_ID_ADPCM_4XM, MKTAG('4', 'X', 'M', 'A')}, { CODEC_ID_ADPCM_ADX, MKTAG('S', 'a', 'd', 'x')}, { CODEC_ID_ADPCM_EA, MKTAG('A', 'D', 'E', 'A')}, @@ -60,9 +61,7 @@ static const struct mp_AVCodecTag mp_wav_tags[] = { { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_wav_taglists[] = {mp_ff_codec_wav_tags, mp_wav_tags, 0}; - -static const struct mp_AVCodecTag mp_codecid_override_tags[] = { +static const struct tag mp_codecid_override_tags[] = { { CODEC_ID_AAC, MKTAG('M', 'P', '4', 'A')}, { CODEC_ID_AAC_LATM, MKTAG('M', 'P', '4', 'L')}, { CODEC_ID_AC3, 0x2000}, @@ -89,9 +88,7 @@ static const struct mp_AVCodecTag mp_codecid_override_tags[] = { { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_codecid_override_taglists[] = {mp_codecid_override_tags, 0}; - -static const struct mp_AVCodecTag mp_bmp_tags[] = { +static const struct tag mp_bmp_tags[] = { { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'V')}, { CODEC_ID_ANM, MKTAG('A', 'N', 'M', ' ')}, { CODEC_ID_AVS, MKTAG('A', 'V', 'S', ' ')}, @@ -127,4 +124,35 @@ static const struct mp_AVCodecTag mp_bmp_tags[] = { { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_bmp_taglists[] = {mp_ff_codec_bmp_tags, mp_bmp_tags, 0}; +static unsigned int codec_get_tag(const struct tag *tags, enum CodecID id) +{ + while (tags->id != CODEC_ID_NONE) { + if (tags->id == id) + return tags->tag; + tags++; + } + return 0; +} + +unsigned int mp_taglist_override(enum CodecID id) +{ + return codec_get_tag(mp_codecid_override_tags, id); +} + +unsigned int mp_taglist_video(enum CodecID id) +{ + const struct AVCodecTag *tags[] = {avformat_get_riff_video_tags(), NULL }; + unsigned int tag = av_codec_get_tag(tags, id); + if (tag) + return tag; + return codec_get_tag(mp_bmp_tags, id); +} + +unsigned int mp_taglist_audio(enum CodecID id) +{ + const struct AVCodecTag *tags[] = {avformat_get_riff_audio_tags(), NULL }; + unsigned int tag = av_codec_get_tag(tags, id); + if (tag) + return tag; + return codec_get_tag(mp_wav_tags, id); +} diff --git a/libmpdemux/mp_taglists.h b/libmpdemux/mp_taglists.h index 381b77a8db..d23a982a93 100644 --- a/libmpdemux/mp_taglists.h +++ b/libmpdemux/mp_taglists.h @@ -21,12 +21,8 @@ #include -#include "ffmpeg_files/taglists.h" - -extern const struct mp_AVCodecTag * const mp_wav_taglists[]; - -extern const struct mp_AVCodecTag * const mp_codecid_override_taglists[]; - -extern const struct mp_AVCodecTag * const mp_bmp_taglists[]; +unsigned int mp_taglist_override(enum CodecID id); +unsigned int mp_taglist_video(enum CodecID id); +unsigned int mp_taglist_audio(enum CodecID id); #endif /* MPLAYER_MP_TAGLISTS_H */ -- cgit v1.2.3 From fc6a9e4a3e0278e1a1f5c0bf570667306f716fed Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 1 Feb 2012 20:01:16 +0200 Subject: build: switch to libavutil bswap.h and intreadwrite.h Remove the private bswap and intreadwrite.h implementations and use libavutil headers instead. Originally these headers weren't publicly installed by libavutil at all. That already changed in 2010, but the pure C bswap version in installed headers was very inefficient. That was recently (2011-12) improved and now using the public bswap version probably shouldn't cause noticeable performance problems, at least if using a new enough compiler. --- ffmpeg_files/arm/bswap.h | 72 -------------- ffmpeg_files/bfin/bswap.h | 45 --------- ffmpeg_files/bswap.h | 103 -------------------- ffmpeg_files/intreadwrite.h | 226 -------------------------------------------- ffmpeg_files/sh4/bswap.h | 48 ---------- ffmpeg_files/x86/bswap.h | 61 ------------ libaf/af_lavcac3enc.c | 5 +- libmpcodecs/ad_dk3adpcm.c | 3 +- libmpcodecs/ad_hwac3.c | 5 +- libmpcodecs/ad_imaadpcm.c | 3 +- libmpcodecs/ad_msadpcm.c | 5 +- libmpcodecs/vd_ffmpeg.c | 2 +- libmpcodecs/vd_mtga.c | 3 +- libmpcodecs/vd_realvid.c | 3 +- libmpcodecs/vd_sgi.c | 3 +- libmpcodecs/vd_theora.c | 3 +- libmpdemux/asfheader.c | 5 +- libmpdemux/demux_asf.c | 3 +- libmpdemux/demux_audio.c | 11 ++- libmpdemux/demux_mkv.c | 22 ++--- libmpdemux/demux_mov.c | 21 ++-- libmpdemux/demux_ogg.c | 3 +- libmpdemux/demux_real.c | 5 +- libmpdemux/demux_ty.c | 5 +- libmpdemux/demux_vqf.c | 5 +- libvo/vo_sdl.c | 2 +- mpbswap.h | 14 +-- mplayer.c | 5 +- stream/asf_streaming.c | 4 +- stream/pnm.c | 8 +- stream/realrtsp/real.c | 14 +-- stream/realrtsp/rmff.c | 3 +- stream/stream.c | 6 +- stream/stream_dvd_common.c | 7 +- stream/vcd_read.h | 4 +- stream/vcd_read_fbsd.h | 4 +- sub/spudec.c | 14 +-- 37 files changed, 113 insertions(+), 642 deletions(-) delete mode 100644 ffmpeg_files/arm/bswap.h delete mode 100644 ffmpeg_files/bfin/bswap.h delete mode 100644 ffmpeg_files/bswap.h delete mode 100644 ffmpeg_files/intreadwrite.h delete mode 100644 ffmpeg_files/sh4/bswap.h delete mode 100644 ffmpeg_files/x86/bswap.h diff --git a/ffmpeg_files/arm/bswap.h b/ffmpeg_files/arm/bswap.h deleted file mode 100644 index 98147449b1..0000000000 --- a/ffmpeg_files/arm/bswap.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 MP_AVUTIL_ARM_BSWAP_H -#define MP_AVUTIL_ARM_BSWAP_H - -#include -#include "config.h" -#include "libavutil/common.h" - -#ifdef __ARMCC_VERSION - -#if HAVE_ARMV6 -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - __asm { rev16 x, x } - return x; -} - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ - return __rev(x); -} -#endif /* HAVE_ARMV6 */ - -#elif HAVE_INLINE_ASM - -#if HAVE_ARMV6 -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - __asm__("rev16 %0, %0" : "+r"(x)); - return x; -} -#endif - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ -#if HAVE_ARMV6 - __asm__("rev %0, %0" : "+r"(x)); -#else - uint32_t t; - __asm__ ("eor %1, %0, %0, ror #16 \n\t" - "bic %1, %1, #0xFF0000 \n\t" - "mov %0, %0, ror #8 \n\t" - "eor %0, %0, %1, lsr #8 \n\t" - : "+r"(x), "=&r"(t)); -#endif /* HAVE_ARMV6 */ - return x; -} - -#endif /* __ARMCC_VERSION */ - -#endif /* AVUTIL_ARM_BSWAP_H */ diff --git a/ffmpeg_files/bfin/bswap.h b/ffmpeg_files/bfin/bswap.h deleted file mode 100644 index 0f7e5a26eb..0000000000 --- a/ffmpeg_files/bfin/bswap.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2007 Marc Hoffman - * - * 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 - */ - -/** - * @file libavutil/bfin/bswap.h - * byte swapping routines - */ - -#ifndef MP_AVUTIL_BFIN_BSWAP_H -#define MP_AVUTIL_BFIN_BSWAP_H - -#include -#include "config.h" -#include "libavutil/common.h" - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ - unsigned tmp; - __asm__("%1 = %0 >> 8 (V); \n\t" - "%0 = %0 << 8 (V); \n\t" - "%0 = %0 | %1; \n\t" - "%0 = PACK(%0.L, %0.H); \n\t" - : "+d"(x), "=&d"(tmp)); - return x; -} - -#endif /* AVUTIL_BFIN_BSWAP_H */ diff --git a/ffmpeg_files/bswap.h b/ffmpeg_files/bswap.h deleted file mode 100644 index 3bfa6aa631..0000000000 --- a/ffmpeg_files/bswap.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * 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 - */ - - -// This file in MPlayer is otherwise the same as in FFmpeg, except it -// includes "libavutil/common.h" instead of "common.h". - -/** - * @file libavutil/bswap.h - * byte swapping routines - */ - -#ifndef MP_AVUTIL_BSWAP_H -#define MP_AVUTIL_BSWAP_H - -#include -#include "libavutil/common.h" -#include "config.h" - -#if ARCH_ARM -# include "arm/bswap.h" -#elif ARCH_BFIN -# include "bfin/bswap.h" -#elif ARCH_SH4 -# include "sh4/bswap.h" -#elif ARCH_X86 -# include "x86/bswap.h" -#endif - -#ifndef bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - x= (x>>8) | (x<<8); - return x; -} -#endif - -#ifndef bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ - x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); - x= (x>>16) | (x<<16); - return x; -} -#endif - -#ifndef bswap_64 -static inline uint64_t av_const bswap_64(uint64_t x) -{ -#if 0 - x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); - x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); - return (x>>32) | (x<<32); -#else - union { - uint64_t ll; - uint32_t l[2]; - } w, r; - w.ll = x; - r.l[0] = bswap_32 (w.l[1]); - r.l[1] = bswap_32 (w.l[0]); - return r.ll; -#endif -} -#endif - -// be2me ... big-endian to machine-endian -// le2me ... little-endian to machine-endian - -#ifdef WORDS_BIGENDIAN -#define be2me_16(x) (x) -#define be2me_32(x) (x) -#define be2me_64(x) (x) -#define le2me_16(x) bswap_16(x) -#define le2me_32(x) bswap_32(x) -#define le2me_64(x) bswap_64(x) -#else -#define be2me_16(x) bswap_16(x) -#define be2me_32(x) bswap_32(x) -#define be2me_64(x) bswap_64(x) -#define le2me_16(x) (x) -#define le2me_32(x) (x) -#define le2me_64(x) (x) -#endif - -#endif /* AVUTIL_BSWAP_H */ diff --git a/ffmpeg_files/intreadwrite.h b/ffmpeg_files/intreadwrite.h deleted file mode 100644 index 73eaa1badf..0000000000 --- a/ffmpeg_files/intreadwrite.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 MP_AVUTIL_INTREADWRITE_H -#define MP_AVUTIL_INTREADWRITE_H - -#include -#include "config.h" -#include "bswap.h" - -#ifndef AV_RB16 -#define AV_RB16(x) ((((const uint8_t*)(x))[0] << 8) | \ - ((const uint8_t*)(x))[1]) -#endif -#ifndef AV_WB16 -#define AV_WB16(p, d) do { \ - ((uint8_t*)(p))[1] = (d); \ - ((uint8_t*)(p))[0] = (d)>>8; } while(0) -#endif - -#ifndef AV_RL16 -#define AV_RL16(x) ((((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL16 -#define AV_WL16(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; } while(0) -#endif - -#ifndef AV_RB32 -#define AV_RB32(x) (((uint32_t)((const uint8_t*)(x))[0] << 24) | \ - (((const uint8_t*)(x))[1] << 16) | \ - (((const uint8_t*)(x))[2] << 8) | \ - ((const uint8_t*)(x))[3]) -#endif -#ifndef AV_WB32 -#define AV_WB32(p, d) do { \ - ((uint8_t*)(p))[3] = (d); \ - ((uint8_t*)(p))[2] = (d)>>8; \ - ((uint8_t*)(p))[1] = (d)>>16; \ - ((uint8_t*)(p))[0] = (d)>>24; } while(0) -#endif - -#ifndef AV_RL32 -#define AV_RL32(x) (((uint32_t)((const uint8_t*)(x))[3] << 24) | \ - (((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL32 -#define AV_WL32(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - ((uint8_t*)(p))[3] = (d)>>24; } while(0) -#endif - -#ifndef AV_RB64 -#define AV_RB64(x) (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ - (uint64_t)((const uint8_t*)(x))[7]) -#endif -#ifndef AV_WB64 -#define AV_WB64(p, d) do { \ - ((uint8_t*)(p))[7] = (d); \ - ((uint8_t*)(p))[6] = (d)>>8; \ - ((uint8_t*)(p))[5] = (d)>>16; \ - ((uint8_t*)(p))[4] = (d)>>24; \ - ((uint8_t*)(p))[3] = (d)>>32; \ - ((uint8_t*)(p))[2] = (d)>>40; \ - ((uint8_t*)(p))[1] = (d)>>48; \ - ((uint8_t*)(p))[0] = (d)>>56; } while(0) -#endif - -#ifndef AV_RL64 -#define AV_RL64(x) (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ - (uint64_t)((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL64 -#define AV_WL64(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ -