diff options
Diffstat (limited to 'libavcodec')
872 files changed, 15475 insertions, 5078 deletions
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 176feb94c0..d89b494b09 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -2,20 +2,20 @@ * 4XM codec * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -773,12 +773,9 @@ static int decode_frame(AVCodecContext *avctx, avctx->flags |= CODEC_FLAG_EMU_EDGE; // alternatively we would have to use our own buffer management - if(p->data[0]) - avctx->release_buffer(avctx, p); - p->reference= 1; - if(avctx->get_buffer(avctx, p) < 0){ - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if (avctx->reget_buffer(avctx, p) < 0) { + av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } @@ -835,6 +832,8 @@ static av_cold int decode_init(AVCodecContext *avctx){ return 1; } + avcodec_get_frame_defaults(&f->current_picture); + avcodec_get_frame_defaults(&f->last_picture); f->version= AV_RL32(avctx->extradata)>>16; common_init(avctx); init_vlcs(f); diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 055715fde5..832298b98e 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -2,20 +2,20 @@ * Quicktime Planar RGB (8BPS) Video Decoder * Copyright (C) 2003 Roberto Togni * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -162,6 +162,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; + avcodec_get_frame_defaults(&c->pic); c->pic.data[0] = NULL; switch (avctx->bits_per_coded_sample) { diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c index 5fdea915ff..5d94e005a2 100644 --- a/libavcodec/8svx.c +++ b/libavcodec/8svx.c @@ -1,94 +1,193 @@ /* - * 8SVX audio decoder * Copyright (C) 2008 Jaikrishnan Menon + * Copyright (C) 2011 Stefano Sabatini * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * 8svx audio decoder - * @author Jaikrishnan Menon * supports: fibonacci delta encoding * : exponential encoding + * + * For more information about the 8SVX format: + * http://netghost.narod.ru/gff/vendspec/iff/iff.txt + * http://sox.sourceforge.net/AudioFormats-11.html + * http://aminet.net/package/mus/misc/wavepak + * http://amigan.1emu.net/reg/8SVX.txt + * + * Samples can be found here: + * http://aminet.net/mods/smpl/ */ #include "avcodec.h" /** decoder context */ typedef struct EightSvxContext { - int16_t fib_acc; - const int16_t *table; + const int8_t *table; + + /* buffer used to store the whole audio decoded/interleaved chunk, + * which is sent with the first packet */ + uint8_t *samples; + size_t samples_size; + int samples_idx; } EightSvxContext; -static const int16_t fibonacci[16] = { -34<<8, -21<<8, -13<<8, -8<<8, -5<<8, -3<<8, -2<<8, -1<<8, - 0, 1<<8, 2<<8, 3<<8, 5<<8, 8<<8, 13<<8, 21<<8 }; -static const int16_t exponential[16] = { -128<<8, -64<<8, -32<<8, -16<<8, -8<<8, -4<<8, -2<<8, -1<<8, - 0, 1<<8, 2<<8, 4<<8, 8<<8, 16<<8, 32<<8, 64<<8 }; +static const int8_t fibonacci[16] = { -34, -21, -13, -8, -5, -3, -2, -1, 0, 1, 2, 3, 5, 8, 13, 21 }; +static const int8_t exponential[16] = { -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64 }; + +#define MAX_FRAME_SIZE 2048 + +/** + * Interleave samples in buffer containing all left channel samples + * at the beginning, and right channel samples at the end. + * Each sample is assumed to be in signed 8-bit format. + * + * @param size the size in bytes of the dst and src buffer + */ +static void interleave_stereo(uint8_t *dst, const uint8_t *src, int size) +{ + uint8_t *dst_end = dst + size; + size = size>>1; + + while (dst < dst_end) { + *dst++ = *src; + *dst++ = *(src+size); + src++; + } +} + +/** + * Delta decode the compressed values in src, and put the resulting + * decoded n samples in dst. + * + * @param val starting value assumed by the delta sequence + * @param table delta sequence table + * @return size in bytes of the decoded data, must be src_size*2 + */ +static int delta_decode(int8_t *dst, const uint8_t *src, int src_size, + int8_t val, const int8_t *table) +{ + int n = src_size; + int8_t *dst0 = dst; + + while (n--) { + uint8_t d = *src++; + val = av_clip(val + table[d & 0x0f], -127, 128); + *dst++ = val; + val = av_clip(val + table[d >> 4] , -127, 128); + *dst++ = val; + } + + return dst-dst0; +} -/** decode a frame */ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; EightSvxContext *esc = avctx->priv_data; - int16_t *out_data = data; - int consumed = buf_size; - const uint8_t *buf_end = buf + buf_size; + int out_data_size, n; + uint8_t *src, *dst; - if((*data_size >> 2) < buf_size) - return -1; + /* decode and interleave the first packet */ + if (!esc->samples && avpkt) { + uint8_t *deinterleaved_samples; - if(avctx->frame_number == 0) { - esc->fib_acc = buf[1] << 8; - buf_size -= 2; - buf += 2; - } + esc->samples_size = avctx->codec->id == CODEC_ID_8SVX_RAW ? + avpkt->size : avctx->channels + (avpkt->size-avctx->channels) * 2; + if (!(esc->samples = av_malloc(esc->samples_size))) + return AVERROR(ENOMEM); + + /* decompress */ + if (avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP) { + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + int n = esc->samples_size; + + if (!(deinterleaved_samples = av_mallocz(n))) + return AVERROR(ENOMEM); - *data_size = buf_size << 2; + /* the uncompressed starting value is contained in the first byte */ + if (avctx->channels == 2) { + delta_decode(deinterleaved_samples , buf+1, buf_size/2-1, buf[0], esc->table); + buf += buf_size/2; + delta_decode(deinterleaved_samples+n/2-1, buf+1, buf_size/2-1, buf[0], esc->table); + } else + delta_decode(deinterleaved_samples , buf+1, buf_size-1 , buf[0], esc->table); + } else { + deinterleaved_samples = avpkt->data; + } - while(buf < buf_end) { - uint8_t d = *buf++; - esc->fib_acc += esc->table[d & 0x0f]; - *out_data++ = esc->fib_acc; - esc->fib_acc += esc->table[d >> 4]; - *out_data++ = esc->fib_acc; + if (avctx->channels == 2) + interleave_stereo(esc->samples, deinterleaved_samples, esc->samples_size); + else + memcpy(esc->samples, deinterleaved_samples, esc->samples_size); } - return consumed; + /* return single packed with fixed size */ + out_data_size = FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx); + if (*data_size < out_data_size) { + av_log(avctx, AV_LOG_ERROR, "Provided buffer with size %d is too small.\n", *data_size); + return AVERROR(EINVAL); + } + + *data_size = out_data_size; + dst = data; + src = esc->samples + esc->samples_idx; + for (n = out_data_size; n > 0; n--) + *dst++ = *src++ + 128; + esc->samples_idx += *data_size; + + return avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP ? + (avctx->frame_number == 0)*2 + out_data_size / 2 : + out_data_size; } -/** initialize 8svx decoder */ static av_cold int eightsvx_decode_init(AVCodecContext *avctx) { EightSvxContext *esc = avctx->priv_data; - switch(avctx->codec->id) { - case CODEC_ID_8SVX_FIB: - esc->table = fibonacci; - break; - case CODEC_ID_8SVX_EXP: - esc->table = exponential; - break; - default: - return -1; + if (avctx->channels > 2) { + av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n"); + return AVERROR_INVALIDDATA; } - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + + switch (avctx->codec->id) { + case CODEC_ID_8SVX_FIB: esc->table = fibonacci; break; + case CODEC_ID_8SVX_EXP: esc->table = exponential; break; + case CODEC_ID_8SVX_RAW: esc->table = NULL; break; + default: + av_log(avctx, AV_LOG_ERROR, "Invalid codec id %d.\n", avctx->codec->id); + return AVERROR_INVALIDDATA; + } + avctx->sample_fmt = AV_SAMPLE_FMT_U8; + + return 0; +} + +static av_cold int eightsvx_decode_close(AVCodecContext *avctx) +{ + EightSvxContext *esc = avctx->priv_data; + + av_freep(&esc->samples); + esc->samples_size = 0; + esc->samples_idx = 0; + return 0; } @@ -99,6 +198,7 @@ AVCodec ff_eightsvx_fib_decoder = { .priv_data_size = sizeof (EightSvxContext), .init = eightsvx_decode_init, .decode = eightsvx_decode_frame, + .close = eightsvx_decode_close, .long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"), }; @@ -109,5 +209,17 @@ AVCodec ff_eightsvx_exp_decoder = { .priv_data_size = sizeof (EightSvxContext), .init = eightsvx_decode_init, .decode = eightsvx_decode_frame, + .close = eightsvx_decode_close, .long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"), }; + +AVCodec ff_eightsvx_raw_decoder = { + .name = "8svx_raw", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_8SVX_RAW, + .priv_data_size = sizeof(EightSvxContext), + .init = eightsvx_decode_init, + .decode = eightsvx_decode_frame, + .close = eightsvx_decode_close, + .long_name = NULL_IF_CONFIG_SMALL("8SVX rawaudio"), +}; diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0cfa08c1c3..f4613749a0 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -18,6 +18,7 @@ OBJS = allcodecs.o \ options.o \ parser.o \ raw.o \ + rawdec.o \ resample.o \ resample2.o \ simple_idct.o \ @@ -26,6 +27,7 @@ OBJS = allcodecs.o \ # parts needed for many different codecs OBJS-$(CONFIG_AANDCT) += aandcttab.o OBJS-$(CONFIG_AC3DSP) += ac3dsp.o +OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o OBJS-$(CONFIG_DWT) += dwt.o @@ -60,9 +62,9 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ mpeg4audio.o kbdwin.o OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o kbdwin.o -OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3enc.o ac3tab.o \ - ac3.o kbdwin.o -OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o +OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_combined.o ac3enc_fixed.o ac3enc_float.o ac3tab.o ac3.o kbdwin.o +OBJS-$(CONFIG_AC3_FLOAT_ENCODER) += ac3enc_float.o ac3tab.o ac3tab.o ac3.o kbdwin.o +OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3tab.o ac3tab.o ac3.o OBJS-$(CONFIG_ALAC_DECODER) += alac.o OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o @@ -78,7 +80,7 @@ OBJS-$(CONFIG_AMV_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o OBJS-$(CONFIG_ANM_DECODER) += anm.o OBJS-$(CONFIG_ANSI_DECODER) += ansi.o cga_data.o OBJS-$(CONFIG_APE_DECODER) += apedec.o -OBJS-$(CONFIG_ASS_DECODER) += assdec.o ass.o +OBJS-$(CONFIG_ASS_DECODER) += assdec.o ass.o ass_split.o OBJS-$(CONFIG_ASS_ENCODER) += assenc.o ass.o OBJS-$(CONFIG_ASV1_DECODER) += asv1.o mpeg12data.o OBJS-$(CONFIG_ASV1_ENCODER) += asv1.o mpeg12data.o @@ -107,6 +109,7 @@ OBJS-$(CONFIG_COOK_DECODER) += cook.o OBJS-$(CONFIG_CSCD_DECODER) += cscd.o OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o OBJS-$(CONFIG_DCA_DECODER) += dca.o synth_filter.o dcadsp.o +OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o OBJS-$(CONFIG_DFA_DECODER) += dfa.o OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o \ @@ -139,15 +142,17 @@ OBJS-$(CONFIG_EATQI_DECODER) += eatqi.o eaidct.o mpeg12.o \ OBJS-$(CONFIG_EIGHTBPS_DECODER) += 8bps.o OBJS-$(CONFIG_EIGHTSVX_EXP_DECODER) += 8svx.o OBJS-$(CONFIG_EIGHTSVX_FIB_DECODER) += 8svx.o +OBJS-$(CONFIG_EIGHTSVX_RAW_DECODER) += 8svx.o OBJS-$(CONFIG_ESCAPE124_DECODER) += escape124.o OBJS-$(CONFIG_FFV1_DECODER) += ffv1.o rangecoder.o OBJS-$(CONFIG_FFV1_ENCODER) += ffv1.o rangecoder.o OBJS-$(CONFIG_FFVHUFF_DECODER) += huffyuv.o OBJS-$(CONFIG_FFVHUFF_ENCODER) += huffyuv.o -OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o -OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o +OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o vorbis_data.o +OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o vorbis_data.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o +OBJS-$(CONFIG_FLASHSV2_ENCODER) += flashsv2enc.o OBJS-$(CONFIG_FLIC_DECODER) += flicvideo.o OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o @@ -190,6 +195,8 @@ OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o OBJS-$(CONFIG_INDEO5_DECODER) += indeo5.o ivi_common.o ivi_dsp.o OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o +OBJS-$(CONFIG_JPEG2000_DECODER) += j2kdec.o mqcdec.o mqc.o j2k.o j2k_dwt.o +#OBJS-$(CONFIG_JPEG2000_ENCODER) += j2kenc.o mqcenc.o mqc.o j2k.o j2k_dwt.o OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o \ mjpegdec.o mjpeg.o OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o @@ -275,6 +282,7 @@ OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \ h263.o ituh263dec.o mpeg4videodec.o OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o +OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o mjpegdec.o mjpeg.o OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o @@ -346,8 +354,12 @@ OBJS-$(CONFIG_SNOW_ENCODER) += snow.o rangecoder.o motion_est.o \ ituh263enc.o mpegvideo_enc.o \ mpeg12data.o OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o +OBJS-$(CONFIG_SONIC_DECODER) += sonic.o +OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o +OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o +OBJS-$(CONFIG_SRT_ENCODER) += srtenc.o ass_split.o OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o h263.o \ mpegvideo.o error_resilience.o @@ -527,33 +539,35 @@ OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o OBJS-$(CONFIG_CAF_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_DV_DEMUXER) += dvdata.o OBJS-$(CONFIG_DV_MUXER) += dvdata.o -OBJS-$(CONFIG_FLAC_DEMUXER) += flacdec.o flacdata.o flac.o -OBJS-$(CONFIG_FLAC_MUXER) += flacdec.o flacdata.o flac.o +OBJS-$(CONFIG_FLAC_DEMUXER) += flacdec.o flacdata.o flac.o vorbis_data.o +OBJS-$(CONFIG_FLAC_MUXER) += flacdec.o flacdata.o flac.o vorbis_data.o OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o OBJS-$(CONFIG_IFF_DEMUXER) += iff.o -OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o \ +OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o vorbis_data.o \ flacdec.o flacdata.o flac.o OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o mpeg4audio.o \ flacdec.o flacdata.o flac.o \ - mpegaudiodata.o + mpegaudiodata.o vorbis_data.o OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_MOV_MUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_MPEGTS_MUXER) += mpegvideo.o mpeg4audio.o OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o OBJS-$(CONFIG_OGG_DEMUXER) += flacdec.o flacdata.o flac.o \ - dirac.o mpeg12data.o -OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o + dirac.o mpeg12data.o vorbis_data.o +OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o \ + vorbis_data.o OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o mpegvideo.o xiph.o OBJS-$(CONFIG_SPDIF_DEMUXER) += aacadtsdec.o mpeg4audio.o OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \ flacdec.o flacdata.o flac.o \ - mpegaudiodata.o + mpegaudiodata.o vorbis_data.o OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o # external codec libraries +OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o @@ -594,7 +608,8 @@ OBJS-$(CONFIG_DIRAC_PARSER) += dirac_parser.o OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o -OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o +OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o \ + vorbis_data.o OBJS-$(CONFIG_H261_PARSER) += h261_parser.o OBJS-$(CONFIG_H263_PARSER) += h263_parser.o OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264.o \ @@ -666,8 +681,6 @@ SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h -EXAMPLES = api - TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow TESTPROGS-$(HAVE_MMX) += motion TESTOBJS = dctref.o diff --git a/libavcodec/a64colors.h b/libavcodec/a64colors.h index d977426fc0..a9cdb6fa76 100644 --- a/libavcodec/a64colors.h +++ b/libavcodec/a64colors.h @@ -2,20 +2,20 @@ * a64 video encoder - c64 colors in rgb (Pepto) * Copyright (c) 2009 Tobias Bindhammer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/a64enc.h b/libavcodec/a64enc.h index b64b952fe4..fb559ba82b 100644 --- a/libavcodec/a64enc.h +++ b/libavcodec/a64enc.h @@ -2,20 +2,20 @@ * a64 video encoder - basic headers * Copyright (c) 2009 Tobias Bindhammer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 532f2a2824..5a665d0592 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -2,20 +2,20 @@ * a64 video encoder - multicolor modes * Copyright (c) 2009 Tobias Bindhammer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/a64tables.h b/libavcodec/a64tables.h index b95c5ce754..a955ef4caa 100644 --- a/libavcodec/a64tables.h +++ b/libavcodec/a64tables.h @@ -2,20 +2,20 @@ * a64 video encoder - tables used by a64 encoders * Copyright (c) 2009 Tobias Bindhammer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 76b6a7821b..f089ee9a29 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -3,20 +3,20 @@ * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c index 58f30a4180..6f6ed895f0 100644 --- a/libavcodec/aac_ac3_parser.c +++ b/libavcodec/aac_ac3_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h index c4ed816d93..ccc387d3aa 100644 --- a/libavcodec/aac_ac3_parser.h +++ b/libavcodec/aac_ac3_parser.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c index fbb86f8af7..6558c0280f 100644 --- a/libavcodec/aac_adtstoasc_bsf.c +++ b/libavcodec/aac_adtstoasc_bsf.c @@ -2,20 +2,20 @@ * MPEG-2/4 AAC ADTS to MPEG-4 Audio Specific Configuration bitstream filter * Copyright (c) 2009 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c index 1c5546e7aa..9165178d15 100644 --- a/libavcodec/aac_parser.c +++ b/libavcodec/aac_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac_tablegen.c b/libavcodec/aac_tablegen.c index b2c6c954e0..33a179f51e 100644 --- a/libavcodec/aac_tablegen.c +++ b/libavcodec/aac_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac_tablegen.h b/libavcodec/aac_tablegen.h index 8773d9b975..7afa466139 100644 --- a/libavcodec/aac_tablegen.h +++ b/libavcodec/aac_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aac_tablegen_decl.h b/libavcodec/aac_tablegen_decl.h index 496ca0c677..0d86e80bc2 100644 --- a/libavcodec/aac_tablegen_decl.h +++ b/libavcodec/aac_tablegen_decl.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacadtsdec.c b/libavcodec/aacadtsdec.c index a9ff8ef63d..fd86d288a6 100644 --- a/libavcodec/aacadtsdec.c +++ b/libavcodec/aacadtsdec.c @@ -4,20 +4,20 @@ * Copyright (c) 2003 Michael Niedermayer * Copyright (c) 2009 Alex Converse * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacadtsdec.h b/libavcodec/aacadtsdec.h index 2fa1b4b2fc..6e0a869cc5 100644 --- a/libavcodec/aacadtsdec.h +++ b/libavcodec/aacadtsdec.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 4d5b98fa63..a68aa025de 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -2,20 +2,20 @@ * AAC coefficients encoder * Copyright (C) 2008-2009 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -33,6 +33,7 @@ #include "libavutil/libm.h" // brought forward to work around cygwin header breakage #include <float.h> +#include <math.h> #include "avcodec.h" #include "put_bits.h" #include "aac.h" diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 69aacb86d6..19d3b3678f 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -7,20 +7,20 @@ * Copyright (c) 2008-2010 Paul Kendall <paul@kcbbs.gen.nz> * Copyright (c) 2010 Janne Grunau <janne-ffmpeg@jannau.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -170,7 +170,7 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id) /** * Check for the channel element in the current channel position configuration. * If it exists, make sure the appropriate element is allocated and map the - * channel order to match the internal Libav channel layout. + * channel order to match the internal FFmpeg channel layout. * * @param che_pos current channel position configuration * @param type channel element type @@ -251,8 +251,6 @@ static av_cold int output_configure(AACContext *ac, } memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); - - avctx->channel_layout = 0; } avctx->channels = channels; @@ -315,6 +313,10 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, if (get_bits1(gb)) skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround + if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { + av_log(avctx, AV_LOG_ERROR, overread_err); + return -1; + } decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front); decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side ); decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back ); diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h index 23a7868ab2..22ae00ff32 100644 --- a/libavcodec/aacdectab.h +++ b/libavcodec/aacdectab.h @@ -3,20 +3,20 @@ * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index e8942a13f9..66af2b1915 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -2,20 +2,20 @@ * AAC encoder * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h index 067a9b04f3..44ad50bf80 100644 --- a/libavcodec/aacenc.h +++ b/libavcodec/aacenc.h @@ -2,20 +2,20 @@ * AAC encoder * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index 724c13256a..fc124d1972 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -2,20 +2,20 @@ * MPEG-4 Parametric Stereo decoding functions * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h index 59a9bff4bc..5fc211a986 100644 --- a/libavcodec/aacps.h +++ b/libavcodec/aacps.h @@ -2,20 +2,20 @@ * MPEG-4 Parametric Stereo definitions and declarations * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacps_tablegen.c b/libavcodec/aacps_tablegen.c index 8650226d71..dc7797f6b8 100644 --- a/libavcodec/aacps_tablegen.c +++ b/libavcodec/aacps_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacps_tablegen.h b/libavcodec/aacps_tablegen.h index 492cb0c56d..c7e062bdb7 100644 --- a/libavcodec/aacps_tablegen.h +++ b/libavcodec/aacps_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c index 675bd8e2b3..7431caebc6 100644 --- a/libavcodec/aacpsdata.c +++ b/libavcodec/aacpsdata.c @@ -2,20 +2,20 @@ * MPEG-4 Parametric Stereo data tables * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 5aea1faa40..baf9388398 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -2,20 +2,20 @@ * AAC encoder psychoacoustic model * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacpsy.h b/libavcodec/aacpsy.h index 5d1e14220c..05c93cddeb 100644 --- a/libavcodec/aacpsy.h +++ b/libavcodec/aacpsy.h @@ -2,20 +2,20 @@ * AAC encoder psychoacoustic model * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 81b0b4c001..82092b385d 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -3,20 +3,20 @@ * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) * Copyright (c) 2009-2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -36,6 +36,7 @@ #include <stdint.h> #include <float.h> +#include <math.h> #define ENVELOPE_ADJUSTMENT_OFFSET 2 #define NOISE_FLOOR_OFFSET 6.0f diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h index 153070d3f2..d0284981c3 100644 --- a/libavcodec/aacsbr.h +++ b/libavcodec/aacsbr.h @@ -3,20 +3,20 @@ * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index 44d578f7fc..5d33a60888 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -2,20 +2,20 @@ * AAC Spectral Band Replication decoding data * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index 46886b12df..17102a66f5 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -3,20 +3,20 @@ * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index c76d65db95..c6213999b5 100644 --- a/libavcodec/aactab.h +++ b/libavcodec/aactab.h @@ -3,20 +3,20 @@ * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aandcttab.c b/libavcodec/aandcttab.c index 0c5b573412..87c50b37cf 100644 --- a/libavcodec/aandcttab.c +++ b/libavcodec/aandcttab.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aandcttab.h b/libavcodec/aandcttab.h index daccb7bb0b..d774828a4d 100644 --- a/libavcodec/aandcttab.h +++ b/libavcodec/aandcttab.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c index e80e0945a1..e6f363de4c 100644 --- a/libavcodec/aasc.c +++ b/libavcodec/aasc.c @@ -2,20 +2,20 @@ * Autodesk RLE Decoder * Copyright (C) 2005 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -50,8 +50,8 @@ static av_cold int aasc_decode_init(AVCodecContext *avctx) AascContext *s = avctx->priv_data; s->avctx = avctx; - avctx->pix_fmt = PIX_FMT_BGR24; + avcodec_get_frame_defaults(&s->frame); return 0; } diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c index 99e5b50acb..29e132f5d1 100644 --- a/libavcodec/ac3.c +++ b/libavcodec/ac3.c @@ -2,20 +2,20 @@ * Common code between the AC-3 encoder and decoder * Copyright (c) 2000 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h index c06f3d542d..a53817e1b0 100644 --- a/libavcodec/ac3.h +++ b/libavcodec/ac3.h @@ -2,20 +2,20 @@ * Common code between the AC-3 encoder and decoder * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -39,6 +39,8 @@ #define AC3_CRITICAL_BANDS 50 #define AC3_MAX_CPL_BANDS 18 +#include "libavutil/opt.h" +#include "avcodec.h" #include "ac3tab.h" /* exponent encoding strategy */ @@ -129,8 +131,47 @@ typedef enum { EAC3_FRAME_TYPE_RESERVED } EAC3FrameType; +/** + * Encoding Options used by AVOption. + */ +typedef struct AC3EncOptions { + /* AC-3 metadata options*/ + int dialogue_level; + int bitstream_mode; + float center_mix_level; + float surround_mix_level; + int dolby_surround_mode; + int audio_production_info; + int mixing_level; + int room_type; + int copyright; + int original; + int extended_bsi_1; + int preferred_stereo_downmix; + float ltrt_center_mix_level; + float ltrt_surround_mix_level; + float loro_center_mix_level; + float loro_surround_mix_level; + int extended_bsi_2; + int dolby_surround_ex_mode; + int dolby_headphone_mode; + int ad_converter_type; + + /* other encoding options */ + int allow_per_frame_metadata; + int stereo_rematrixing; + int channel_coupling; + int cpl_start; +} AC3EncOptions; + void ff_ac3_common_init(void); +extern const int64_t ff_ac3_channel_layouts[]; +extern const AVOption ff_ac3_options[]; + +extern AVCodec ff_ac3_float_encoder; +extern AVCodec ff_ac3_fixed_encoder; + /** * Calculate the log power-spectral density of the input signal. * This gives a rough estimate of signal power in the frequency domain by using diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c index 82eeda3e61..43feb5bc38 100644 --- a/libavcodec/ac3_parser.c +++ b/libavcodec/ac3_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3_parser.h b/libavcodec/ac3_parser.h index d62490bc77..50b70b08e5 100644 --- a/libavcodec/ac3_parser.h +++ b/libavcodec/ac3_parser.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 2966c33b25..9b44668ae2 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -7,20 +7,20 @@ * Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -37,9 +37,6 @@ #include "ac3dec_data.h" #include "kbdwin.h" -/** Large enough for maximum possible frame size when the specification limit is ignored */ -#define AC3_FRAME_BUFFER_SIZE 32768 - /** * table for ungrouping 3 values in 7 bits. * used for exponents and bap=2 mantissas @@ -205,11 +202,6 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) } s->downmixed = 1; - /* allocate context input buffer */ - s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); - if (!s->input_buffer) - return AVERROR(ENOMEM); - return 0; } @@ -1307,6 +1299,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, float *out_samples_flt = data; int16_t *out_samples_s16 = data; int blk, ch, err; + int data_size_orig, data_size_tmp; const uint8_t *channel_map; const float *output[AC3_MAX_CHANNELS]; @@ -1323,6 +1316,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, init_get_bits(&s->gbc, buf, buf_size * 8); /* parse the syncinfo */ + data_size_orig = *data_size; *data_size = 0; err = parse_frame_header(s); @@ -1406,11 +1400,17 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on]; for (ch = 0; ch < s->out_channels; ch++) output[ch] = s->output[channel_map[ch]]; + data_size_tmp = s->num_blocks * 256 * avctx->channels; + data_size_tmp *= avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? sizeof(*out_samples_flt) : sizeof(*out_samples_s16); + if (data_size_orig < data_size_tmp) + return -1; + *data_size = data_size_tmp; for (blk = 0; blk < s->num_blocks; blk++) { if (!err && decode_audio_block(s, blk)) { av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n"); err = 1; } + if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { s->fmt_conv.float_interleave(out_samples_flt, output, 256, s->out_channels); @@ -1435,8 +1435,6 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx) ff_mdct_end(&s->imdct_512); ff_mdct_end(&s->imdct_256); - av_freep(&s->input_buffer); - return 0; } diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index 590bee6b6d..377e5154d7 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -2,20 +2,20 @@ * Common code between the AC-3 and E-AC-3 decoders * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -62,10 +62,12 @@ #define SPX_MAX_BANDS 17 +/** Large enough for maximum possible frame size when the specification limit is ignored */ +#define AC3_FRAME_BUFFER_SIZE 32768 + typedef struct { AVCodecContext *avctx; ///< parent context GetBitContext gbc; ///< bitstream reader - uint8_t *input_buffer; ///< temp buffer to prevent overread ///@defgroup bsi bit stream information ///@{ @@ -200,6 +202,7 @@ typedef struct { DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing + DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread ///@} } AC3DecodeContext; diff --git a/libavcodec/ac3dec_data.c b/libavcodec/ac3dec_data.c index 272a963f08..d0a9b1ec40 100644 --- a/libavcodec/ac3dec_data.c +++ b/libavcodec/ac3dec_data.c @@ -2,20 +2,20 @@ * AC-3 and E-AC-3 decoder tables * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3dec_data.h b/libavcodec/ac3dec_data.h index c0a584e7b3..975b52ef2c 100644 --- a/libavcodec/ac3dec_data.h +++ b/libavcodec/ac3dec_data.h @@ -2,20 +2,20 @@ * AC-3 and E-AC-3 decoder tables * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c index 8ce5f8d2c5..619addc3d5 100644 --- a/libavcodec/ac3dsp.c +++ b/libavcodec/ac3dsp.c @@ -2,20 +2,20 @@ * AC-3 DSP utils * Copyright (c) 2011 Justin Ruggles * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h index 8eeafd68ac..d7131d2c03 100644 --- a/libavcodec/ac3dsp.h +++ b/libavcodec/ac3dsp.h @@ -2,20 +2,20 @@ * AC-3 DSP utils * Copyright (c) 2011 Justin Ruggles * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 78e81654e3..f61e7f8c4d 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -4,20 +4,20 @@ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com> * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 1d17484321..d5f662b4aa 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -66,7 +66,7 @@ typedef struct AC3MDCTContext { const SampleType *window; ///< MDCT window function FFTContext fft; ///< FFT context for MDCT calculation } AC3MDCTContext; - +#if 0 /** * Encoding Options used by AVOption. */ @@ -99,7 +99,7 @@ typedef struct AC3EncOptions { int channel_coupling; int cpl_start; } AC3EncOptions; - +#endif /** * Data for a single audio block. */ diff --git a/libavcodec/ac3enc_combined.c b/libavcodec/ac3enc_combined.c new file mode 100644 index 0000000000..db832f1f03 --- /dev/null +++ b/libavcodec/ac3enc_combined.c @@ -0,0 +1,100 @@ + +#include "libavutil/opt.h" +#include "libavutil/samplefmt.h" +#include "avcodec.h" +#include "ac3.h" + +typedef struct CombineContext{ + AVClass *av_class; ///< AVClass used for AVOption + AC3EncOptions options; ///< encoding options + void *ctx; + AVCodec *codec; +}CombineContext; + +#define OFFSET(param) offsetof(CombineContext, options.param) +#define AC3ENC_PARAM (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) + +#define AC3ENC_TYPE_AC3_FIXED 0 +#define AC3ENC_TYPE_AC3 1 +#define AC3ENC_TYPE_EAC3 2 + +#define AC3ENC_TYPE 12354 +#include "ac3enc_opts_template.c" + +static AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name, + eac3_options, LIBAVUTIL_VERSION_INT }; + +static av_cold AVCodec *get_codec(enum AVSampleFormat s){ +#if CONFIG_AC3_FIXED_ENCODER + if(s==AV_SAMPLE_FMT_S16) return &ff_ac3_fixed_encoder; +#endif +#if CONFIG_AC3_FLOAT_ENCODER + if(s==AV_SAMPLE_FMT_FLT) return &ff_ac3_float_encoder; +#endif + return NULL; +} + + +static av_cold int encode_init(AVCodecContext *avctx) +{ + CombineContext *c= avctx->priv_data; + int ret; + int offset= (uint8_t*)&c->options - (uint8_t*)c; + + c->codec= get_codec(avctx->sample_fmt); + if(!c->codec){ + av_log(avctx, AV_LOG_ERROR, "Unsupported sample format\n"); + return -1; + } + c->ctx= av_mallocz(c->codec->priv_data_size); + memcpy((uint8_t*)c->ctx + offset, &c->options, (uint8_t*)&c->ctx - (uint8_t*)&c->options); + FFSWAP(void *,avctx->priv_data, c->ctx); + ret= c->codec->init(avctx); + FFSWAP(void *,avctx->priv_data, c->ctx); + return ret; +} + +static int encode_frame(AVCodecContext *avctx, unsigned char *frame, + int buf_size, void *data) +{ + CombineContext *c= avctx->priv_data; + int ret; + + FFSWAP(void *,avctx->priv_data, c->ctx); + ret= c->codec->encode(avctx, frame, buf_size, data); + FFSWAP(void *,avctx->priv_data, c->ctx); + return ret; +} + +static av_cold int encode_close(AVCodecContext *avctx) +{ + CombineContext *c= avctx->priv_data; + int ret; + + FFSWAP(void *,avctx->priv_data, c->ctx); + ret= c->codec->close(avctx); + FFSWAP(void *,avctx->priv_data, c->ctx); + return ret; +} + +AVCodec ff_ac3_encoder = { + "ac3", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_AC3, + sizeof(CombineContext), + encode_init, + encode_frame, + encode_close, + NULL, + .sample_fmts = (const enum AVSampleFormat[]){ +#if CONFIG_AC3_FLOAT_ENCODER + AV_SAMPLE_FMT_FLT, +#endif +#if CONFIG_AC3_FIXED_ENCODER + AV_SAMPLE_FMT_S16, +#endif + AV_SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), + .priv_class = &ac3enc_class, + .channel_layouts = ff_ac3_channel_layouts, +}; diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 0620a6ac1a..f4d447e3b2 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -4,20 +4,20 @@ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com> * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 43fbb954d6..9e798106f3 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -4,20 +4,20 @@ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com> * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -103,8 +103,8 @@ void ff_ac3_float_scale_coefficients(AC3EncodeContext *s) #if CONFIG_AC3_ENCODER -AVCodec ff_ac3_encoder = { - "ac3", +AVCodec ff_ac3_float_encoder = { + "ac3_float", AVMEDIA_TYPE_AUDIO, CODEC_ID_AC3, sizeof(AC3EncodeContext), diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c index 7df3d828fb..3b3e715655 100644 --- a/libavcodec/ac3tab.c +++ b/libavcodec/ac3tab.c @@ -2,20 +2,20 @@ * AC-3 tables * copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h index e5cd368bb7..aa13c8f6e5 100644 --- a/libavcodec/ac3tab.h +++ b/libavcodec/ac3tab.h @@ -2,20 +2,20 @@ * AC-3 tables * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/acelp_filters.c b/libavcodec/acelp_filters.c index 04f6d4a5f9..31f0e86f5b 100644 --- a/libavcodec/acelp_filters.c +++ b/libavcodec/acelp_filters.c @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/acelp_filters.h b/libavcodec/acelp_filters.h index b8715d266f..0b1ccf4e71 100644 --- a/libavcodec/acelp_filters.h +++ b/libavcodec/acelp_filters.h @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c index 4e44bc9122..cddf7262b6 100644 --- a/libavcodec/acelp_pitch_delay.c +++ b/libavcodec/acelp_pitch_delay.c @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/acelp_pitch_delay.h b/libavcodec/acelp_pitch_delay.h index 6d182bb7ad..ce06bc2539 100644 --- a/libavcodec/acelp_pitch_delay.h +++ b/libavcodec/acelp_pitch_delay.h @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c index 25a6ff27df..a44ab8cfe6 100644 --- a/libavcodec/acelp_vectors.c +++ b/libavcodec/acelp_vectors.c @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h index 07d1000d3f..f3bc781446 100644 --- a/libavcodec/acelp_vectors.h +++ b/libavcodec/acelp_vectors.h @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 70a5360ce8..ba312558b0 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -2,20 +2,20 @@ * ADPCM codecs * Copyright (c) 2001-2003 The ffmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" @@ -271,6 +271,42 @@ static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, sho return nibble; } +static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, short sample) +{ + int delta = sample - c->prev_sample; + int diff, step = step_table[c->step_index]; + int nibble = 8*(delta < 0); + + delta= abs(delta); + diff = delta + (step >> 3); + + if (delta >= step) { + nibble |= 4; + delta -= step; + } + step >>= 1; + if (delta >= step) { + nibble |= 2; + delta -= step; + } + step >>= 1; + if (delta >= step) { + nibble |= 1; + delta -= step; + } + diff -= delta; + + if (nibble & 8) + c->prev_sample -= diff; + else + c->prev_sample += diff; + + c->prev_sample = av_clip_int16(c->prev_sample); + c->step_index = av_clip(c->step_index + index_table[nibble], 0, 88); + + return nibble; +} + static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, short sample) { int predictor, nibble, bias; @@ -604,16 +640,14 @@ static int adpcm_encode_frame(AVCodecContext *avctx, adpcm_compress_trellis(avctx, samples+ch, buf, &c->status[ch], 64); for(i=0; i<64; i++) put_bits(&pb, 4, buf[i^1]); - c->status[ch].prev_sample = c->status[ch].predictor & ~0x7F; } else { for (i=0; i<64; i+=2){ int t1, t2; - t1 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]); - t2 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]); + t1 = adpcm_ima_qt_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]); + t2 = adpcm_ima_qt_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]); put_bits(&pb, 4, t2); put_bits(&pb, 4, t1); } - c->status[ch].prev_sample &= ~0x7F; } } @@ -750,6 +784,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: + case CODEC_ID_ADPCM_EA_XAS: max_channels = 6; break; } @@ -807,6 +842,32 @@ static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, return (short)c->predictor; } +static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift) +{ + int step_index; + int predictor; + int diff, step; + + step = step_table[c->step_index]; + step_index = c->step_index + index_table[nibble]; + step_index = av_clip(step_index, 0, 88); + + diff = step >> 3; + if (nibble & 4) diff += step; + if (nibble & 2) diff += step >> 1; + if (nibble & 1) diff += step >> 2; + + if (nibble & 8) + predictor = c->predictor - diff; + else + predictor = c->predictor + diff; + + c->predictor = av_clip_int16(predictor); + c->step_index = step_index; + + return c->predictor; +} + static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, char nibble) { int predictor; @@ -1009,35 +1070,41 @@ static int adpcm_decode_frame(AVCodecContext *avctx, case CODEC_ID_ADPCM_IMA_QT: n = buf_size - 2*avctx->channels; for (channel = 0; channel < avctx->channels; channel++) { + int16_t predictor; + int step_index; cs = &(c->status[channel]); /* (pppppp) (piiiiiii) */ /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */ - cs->predictor = (*src++) << 8; - cs->predictor |= (*src & 0x80); - cs->predictor &= 0xFF80; - - /* sign extension */ - if(cs->predictor & 0x8000) - cs->predictor -= 0x10000; - - cs->predictor = av_clip_int16(cs->predictor); - - cs->step_index = (*src++) & 0x7F; + predictor = AV_RB16(src); + step_index = predictor & 0x7F; + predictor &= 0xFF80; + + src += 2; + + if (cs->step_index == step_index) { + int diff = (int)predictor - cs->predictor; + if (diff < 0) + diff = - diff; + if (diff > 0x7f) + goto update; + } else { + update: + cs->step_index = step_index; + cs->predictor = predictor; + } if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } - cs->step = step_table[cs->step_index]; - samples = (short*)data + channel; for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */ - *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3); + *samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3); samples += avctx->channels; - *samples = adpcm_ima_expand_nibble(cs, src[0] >> 4 , 3); + *samples = adpcm_ima_qt_expand_nibble(cs, src[0] >> 4 , 3); samples += avctx->channels; src ++; } @@ -1291,7 +1358,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, } break; case CODEC_ID_ADPCM_EA: - if (buf_size < 4 || AV_RL32(src) >= ((buf_size - 12) * 2)) { + if (buf_size < 12 || AV_RL32(src) > (buf_size - 12)/30*28) { src += buf_size; break; } diff --git a/libavcodec/adx.h b/libavcodec/adx.h index c4206963d5..0fa1003ffc 100644 --- a/libavcodec/adx.h +++ b/libavcodec/adx.h @@ -2,20 +2,20 @@ * ADX ADPCM codecs * Copyright (c) 2001,2003 BERO * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index 48acc659cc..991528a7d2 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -2,20 +2,20 @@ * ADX ADPCM codecs * Copyright (c) 2001,2003 BERO * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index b0847f43ef..ca48f94b71 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -2,20 +2,20 @@ * ADX ADPCM codecs * Copyright (c) 2001,2003 BERO * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 4ea3f7ee84..96c15fffc9 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -2,20 +2,20 @@ * ALAC (Apple Lossless Audio Codec) decoder * Copyright (c) 2005 David Hammerton * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index acaa545915..bb618e16f2 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -2,20 +2,20 @@ * ALAC audio encoder * Copyright (c) 2008 Jaikrishnan Menon <realityman@gmx.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -389,6 +389,11 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) return -1; } + if(avctx->channels > 2) { + av_log(avctx, AV_LOG_ERROR, "channels > 2 not supported\n"); + return AVERROR_PATCHWELCOME; + } + // Set default compression level if(avctx->compression_level == FF_COMPRESSION_DEFAULT) s->compression_level = 2; diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 71b6094089..e6305cf7d2 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -2,20 +2,20 @@ * Provide registration of all codecs, parsers and bitstream filters for libavcodec. * Copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -57,8 +57,10 @@ void avcodec_register_all(void) REGISTER_HWACCEL (H263_VAAPI, h263_vaapi); REGISTER_HWACCEL (H264_DXVA2, h264_dxva2); REGISTER_HWACCEL (H264_VAAPI, h264_vaapi); + REGISTER_HWACCEL (MPEG1_VDPAU, mpeg1_vdpau); REGISTER_HWACCEL (MPEG2_DXVA2, mpeg2_dxva2); REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi); + REGISTER_HWACCEL (MPEG2_VDPAU, mpeg2_vdpau); REGISTER_HWACCEL (MPEG4_VAAPI, mpeg4_vaapi); REGISTER_HWACCEL (VC1_DXVA2, vc1_dxva2); REGISTER_HWACCEL (VC1_VAAPI, vc1_vaapi); @@ -102,10 +104,12 @@ void avcodec_register_all(void) REGISTER_DECODER (EIGHTBPS, eightbps); REGISTER_DECODER (EIGHTSVX_EXP, eightsvx_exp); REGISTER_DECODER (EIGHTSVX_FIB, eightsvx_fib); + REGISTER_DECODER (EIGHTSVX_RAW, eightsvx_raw); REGISTER_DECODER (ESCAPE124, escape124); REGISTER_ENCDEC (FFV1, ffv1); REGISTER_ENCDEC (FFVHUFF, ffvhuff); REGISTER_ENCDEC (FLASHSV, flashsv); + REGISTER_ENCODER (FLASHSV2, flashsv2); REGISTER_DECODER (FLIC, flic); REGISTER_ENCDEC (FLV, flv); REGISTER_DECODER (FOURXM, fourxm); @@ -117,6 +121,7 @@ void avcodec_register_all(void) REGISTER_DECODER (H263I, h263i); REGISTER_ENCODER (H263P, h263p); REGISTER_DECODER (H264, h264); + REGISTER_DECODER (H264_CRYSTALHD, h264_crystalhd); REGISTER_DECODER (H264_VDPAU, h264_vdpau); REGISTER_ENCDEC (HUFFYUV, huffyuv); REGISTER_DECODER (IDCIN, idcin); @@ -126,6 +131,7 @@ void avcodec_register_all(void) REGISTER_DECODER (INDEO3, indeo3); REGISTER_DECODER (INDEO5, indeo5); REGISTER_DECODER (INTERPLAY_VIDEO, interplay_video); + REGISTER_DECODER (JPEG2000, jpeg2000); REGISTER_ENCDEC (JPEGLS, jpegls); REGISTER_DECODER (JV, jv); REGISTER_DECODER (KGV1, kgv1); @@ -143,15 +149,18 @@ void avcodec_register_all(void) REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video); REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video); REGISTER_ENCDEC (MPEG4, mpeg4); + REGISTER_DECODER (MPEG4_CRYSTALHD, mpeg4_crystalhd); REGISTER_DECODER (MPEG4_VDPAU, mpeg4_vdpau); REGISTER_DECODER (MPEGVIDEO, mpegvideo); REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau); REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau); + REGISTER_DECODER (MPEG2_CRYSTALHD, mpeg2_crystalhd); + REGISTER_DECODER (MSMPEG4_CRYSTALHD, msmpeg4_crystalhd); REGISTER_DECODER (MSMPEG4V1, msmpeg4v1); REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2); REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3); REGISTER_DECODER (MSRLE, msrle); - REGISTER_DECODER (MSVIDEO1, msvideo1); + REGISTER_ENCDEC (MSVIDEO1, msvideo1); REGISTER_DECODER (MSZH, mszh); REGISTER_DECODER (MXPEG, mxpeg); REGISTER_DECODER (NUV, nuv); @@ -201,6 +210,7 @@ void avcodec_register_all(void) REGISTER_DECODER (V210X, v210x); REGISTER_DECODER (VB, vb); REGISTER_DECODER (VC1, vc1); + REGISTER_DECODER (VC1_CRYSTALHD, vc1_crystalhd); REGISTER_DECODER (VC1_VDPAU, vc1_vdpau); REGISTER_DECODER (VCR1, vcr1); REGISTER_DECODER (VMDVIDEO, vmdvideo); @@ -215,6 +225,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (WMV1, wmv1); REGISTER_ENCDEC (WMV2, wmv2); REGISTER_DECODER (WMV3, wmv3); + REGISTER_DECODER (WMV3_CRYSTALHD, wmv3_crystalhd); REGISTER_DECODER (WMV3_VDPAU, wmv3_vdpau); REGISTER_DECODER (WNV1, wnv1); REGISTER_DECODER (XAN_WC3, xan_wc3); @@ -228,7 +239,8 @@ void avcodec_register_all(void) REGISTER_ENCDEC (AAC, aac); REGISTER_DECODER (AAC_LATM, aac_latm); REGISTER_ENCDEC (AC3, ac3); - REGISTER_ENCODER (AC3_FIXED, ac3_fixed); + REGISTER_ENCODER (AC3_FIXED, ac3_fixed); //deprecated, just for libav compatibility +// REGISTER_ENCODER (AC3_FLOAT, ac3_float); dont remove dont outcomment, for configure REGISTER_ENCDEC (ALAC, alac); REGISTER_DECODER (ALS, als); REGISTER_DECODER (AMRNB, amrnb); @@ -239,7 +251,7 @@ void avcodec_register_all(void) REGISTER_DECODER (BINKAUDIO_DCT, binkaudio_dct); REGISTER_DECODER (BINKAUDIO_RDFT, binkaudio_rdft); REGISTER_DECODER (COOK, cook); - REGISTER_DECODER (DCA, dca); + REGISTER_ENCDEC (DCA, dca); REGISTER_DECODER (DSICINAUDIO, dsicinaudio); REGISTER_ENCDEC (EAC3, eac3); REGISTER_ENCDEC (FLAC, flac); @@ -269,6 +281,8 @@ void avcodec_register_all(void) REGISTER_DECODER (SHORTEN, shorten); REGISTER_DECODER (SIPR, sipr); REGISTER_DECODER (SMACKAUD, smackaud); + REGISTER_ENCDEC (SONIC, sonic); + REGISTER_ENCODER (SONIC_LS, sonic_ls); REGISTER_DECODER (TRUEHD, truehd); REGISTER_DECODER (TRUESPEECH, truespeech); REGISTER_DECODER (TTA, tta); @@ -352,10 +366,11 @@ void avcodec_register_all(void) REGISTER_ENCDEC (DVBSUB, dvbsub); REGISTER_ENCDEC (DVDSUB, dvdsub); REGISTER_DECODER (PGSSUB, pgssub); - REGISTER_DECODER (SRT, srt); + REGISTER_ENCDEC (SRT, srt); REGISTER_ENCDEC (XSUB, xsub); /* external libraries */ + REGISTER_DECODER (LIBCELT, libcelt); REGISTER_ENCDEC (LIBDIRAC, libdirac); REGISTER_ENCODER (LIBFAAC, libfaac); REGISTER_ENCDEC (LIBGSM, libgsm); diff --git a/libavcodec/alpha/asm.h b/libavcodec/alpha/asm.h index ab4cfccc87..827721e777 100644 --- a/libavcodec/alpha/asm.h +++ b/libavcodec/alpha/asm.h @@ -2,20 +2,20 @@ * Alpha optimized DSP utils * Copyright (c) 2002 Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c index 32bb0fc932..6ce3f4bf15 100644 --- a/libavcodec/alpha/dsputil_alpha.c +++ b/libavcodec/alpha/dsputil_alpha.c @@ -2,20 +2,20 @@ * Alpha optimized DSP utils * Copyright (c) 2002 Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/dsputil_alpha.h b/libavcodec/alpha/dsputil_alpha.h index 0dcacabb9d..a3fa3dd586 100644 --- a/libavcodec/alpha/dsputil_alpha.h +++ b/libavcodec/alpha/dsputil_alpha.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/dsputil_alpha_asm.S b/libavcodec/alpha/dsputil_alpha_asm.S index ca857ac152..32a8bc9562 100644 --- a/libavcodec/alpha/dsputil_alpha_asm.S +++ b/libavcodec/alpha/dsputil_alpha_asm.S @@ -2,20 +2,20 @@ * Alpha optimized DSP utils * Copyright (c) 2002 Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/motion_est_alpha.c b/libavcodec/alpha/motion_est_alpha.c index bb9ab134e9..863dd23da3 100644 --- a/libavcodec/alpha/motion_est_alpha.c +++ b/libavcodec/alpha/motion_est_alpha.c @@ -2,20 +2,20 @@ * Alpha optimized DSP utils * Copyright (c) 2002 Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/motion_est_mvi_asm.S b/libavcodec/alpha/motion_est_mvi_asm.S index 7fe4e168e0..2399085bcb 100644 --- a/libavcodec/alpha/motion_est_mvi_asm.S +++ b/libavcodec/alpha/motion_est_mvi_asm.S @@ -2,20 +2,20 @@ * Alpha optimized DSP utils * Copyright (c) 2002 Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/mpegvideo_alpha.c b/libavcodec/alpha/mpegvideo_alpha.c index add57364a3..de32545ade 100644 --- a/libavcodec/alpha/mpegvideo_alpha.c +++ b/libavcodec/alpha/mpegvideo_alpha.c @@ -2,20 +2,20 @@ * Alpha optimized DSP utils * Copyright (c) 2002 Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/regdef.h b/libavcodec/alpha/regdef.h index fa9ad98e5c..aa1959f46e 100644 --- a/libavcodec/alpha/regdef.h +++ b/libavcodec/alpha/regdef.h @@ -2,20 +2,20 @@ * Alpha optimized DSP utils * copyright (c) 2002 Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alpha/simple_idct_alpha.c b/libavcodec/alpha/simple_idct_alpha.c index 61bc5f2084..522efd2b4d 100644 --- a/libavcodec/alpha/simple_idct_alpha.c +++ b/libavcodec/alpha/simple_idct_alpha.c @@ -9,20 +9,20 @@ * Alpha optimizations by MÃ¥ns RullgÃ¥rd <mans@mansr.com> * and Falk Hueffner <falk@debian.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 17c54900f7..41b3f0caf5 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -2,20 +2,20 @@ * MPEG-4 ALS decoder * Copyright (c) 2009 Thilo Borgmann <thilo.borgmann _at_ googlemail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/amr.h b/libavcodec/amr.h index ae6e4d1490..7e5a4dce5b 100644 --- a/libavcodec/amr.h +++ b/libavcodec/amr.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Marcelo Galvao Povoa * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/amrnbdata.h b/libavcodec/amrnbdata.h index d6d1f34562..2f21439896 100644 --- a/libavcodec/amrnbdata.h +++ b/libavcodec/amrnbdata.h @@ -3,20 +3,20 @@ * Copyright (c) 2006-2007 Robert Swain * Copyright (c) 2009 Colin McQuillan * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 4e24e26d68..55dc8b05f5 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -3,20 +3,20 @@ * Copyright (c) 2006-2007 Robert Swain * Copyright (c) 2009 Colin McQuillan * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h index 5421c23afb..1327b0237a 100644 --- a/libavcodec/amrwbdata.h +++ b/libavcodec/amrwbdata.h @@ -2,20 +2,20 @@ * AMR wideband data and definitions * Copyright (c) 2010 Marcelo Galvao Povoa * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index d4bb7760ef..fa3f8dd050 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -2,20 +2,20 @@ * AMR wideband decoder * Copyright (c) 2010 Marcelo Galvao Povoa * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/anm.c b/libavcodec/anm.c index ef037f2468..02244f70e1 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -2,20 +2,20 @@ * Deluxe Paint Animation decoder * Copyright (c) 2009 Peter Ross * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,6 +29,7 @@ typedef struct AnmContext { AVFrame frame; + int palette[AVPALETTE_COUNT]; int x; ///< x coordinate position } AnmContext; @@ -43,15 +44,12 @@ static av_cold int decode_init(AVCodecContext *avctx) if (avctx->extradata_size != 16*8 + 4*256) return -1; + avcodec_get_frame_defaults(&s->frame); s->frame.reference = 1; - if (avctx->get_buffer(avctx, &s->frame) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - return -1; - } buf = avctx->extradata + 16*8; for (i = 0; i < 256; i++) - ((uint32_t*)s->frame.data[1])[i] = bytestream_get_le32(&buf); + s->palette[i] = bytestream_get_le32(&buf); return 0; } @@ -170,6 +168,8 @@ static int decode_frame(AVCodecContext *avctx, } } while (buf + 1 < buf_end); + memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); + *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index e46879dd6b..7043b7c9d9 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -2,20 +2,20 @@ * ASCII/ANSI art decoder * Copyright (c) 2010 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -81,6 +81,7 @@ static av_cold int decode_init(AVCodecContext *avctx) s->fg = DEFAULT_FG_COLOR; s->bg = DEFAULT_BG_COLOR; + avcodec_get_frame_defaults(&s->frame); if (!avctx->width || !avctx->height) avcodec_set_dimensions(avctx, 80<<3, 25<<4); diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index d5a7efd94d..05498777b4 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -3,20 +3,20 @@ * Copyright (c) 2007 Benjamin Zores <ben@geexbox.org> * based upon libdemac from Dave Chapman. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/api-example.c b/libavcodec/api-example.c deleted file mode 100644 index 0221a30925..0000000000 --- a/libavcodec/api-example.c +++ /dev/null @@ -1,467 +0,0 @@ -/* - * copyright (c) 2001 Fabrice Bellard - * - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * avcodec API use example. - * - * Note that this library only handles codecs (mpeg, mpeg4, etc...), - * not file formats (avi, vob, etc...). See library 'libavformat' for the - * format handling - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#ifdef HAVE_AV_CONFIG_H -#undef HAVE_AV_CONFIG_H -#endif - -#include "libavcodec/avcodec.h" -#include "libavutil/mathematics.h" - -#define INBUF_SIZE 4096 -#define AUDIO_INBUF_SIZE 20480 -#define AUDIO_REFILL_THRESH 4096 - -/* - * Audio encoding example - */ -static void audio_encode_example(const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int frame_size, i, j, out_size, outbuf_size; - FILE *f; - short *samples; - float t, tincr; - uint8_t *outbuf; - - printf("Audio encoding\n"); - - /* find the MP2 encoder */ - codec = avcodec_find_encoder(CODEC_ID_MP2); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c= avcodec_alloc_context(); - - /* put sample parameters */ - c->bit_rate = 64000; - c->sample_rate = 44100; - c->channels = 2; - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - /* the codec gives us the frame size, in samples */ - frame_size = c->frame_size; - samples = malloc(frame_size * 2 * c->channels); - outbuf_size = 10000; - outbuf = malloc(outbuf_size); - - f = fopen(filename, "wb"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - /* encode a single tone sound */ - t = 0; - tincr = 2 * M_PI * 440.0 / c->sample_rate; - for(i=0;i<200;i++) { - for(j=0;j<frame_size;j++) { - samples[2*j] = (int)(sin(t) * 10000); - samples[2*j+1] = samples[2*j]; - t += tincr; - } - /* encode the samples */ - out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples); - fwrite(outbuf, 1, out_size, f); - } - fclose(f); - free(outbuf); - free(samples); - - avcodec_close(c); - av_free(c); -} - -/* - * Audio decoding. - */ -static void audio_decode_example(const char *outfilename, const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int out_size, len; - FILE *f, *outfile; - uint8_t *outbuf; - uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; - AVPacket avpkt; - - av_init_packet(&avpkt); - - printf("Audio decoding\n"); - - /* find the mpeg audio decoder */ - codec = avcodec_find_decoder(CODEC_ID_MP2); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c= avcodec_alloc_context(); - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); - - f = fopen(filename, "rb"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - outfile = fopen(outfilename, "wb"); - if (!outfile) { - av_free(c); - exit(1); - } - - /* decode until eof */ - avpkt.data = inbuf; - avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); - - while (avpkt.size > 0) { - out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; - len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt); - if (len < 0) { - fprintf(stderr, "Error while decoding\n"); - exit(1); - } - if (out_size > 0) { - /* if a frame has been decoded, output it */ - fwrite(outbuf, 1, out_size, outfile); - } - avpkt.size -= len; - avpkt.data += len; - if (avpkt.size < AUDIO_REFILL_THRESH) { - /* Refill the input buffer, to avoid trying to decode - * incomplete frames. Instead of this, one could also use - * a parser, or use a proper container format through - * libavformat. */ - memmove(inbuf, avpkt.data, avpkt.size); - avpkt.data = inbuf; - len = fread(avpkt.data + avpkt.size, 1, - AUDIO_INBUF_SIZE - avpkt.size, f); - if (len > 0) - avpkt.size += len; - } - } - - fclose(outfile); - fclose(f); - free(outbuf); - - avcodec_close(c); - av_free(c); -} - -/* - * Video encoding example - */ -static void video_encode_example(const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int i, out_size, size, x, y, outbuf_size; - FILE *f; - AVFrame *picture; - uint8_t *outbuf, *picture_buf; - - printf("Video encoding\n"); - - /* find the mpeg1 video encoder */ - codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c= avcodec_alloc_context(); - picture= avcodec_alloc_frame(); - - /* put sample parameters */ - c->bit_rate = 400000; - /* resolution must be a multiple of two */ - c->width = 352; - c->height = 288; - /* frames per second */ - c->time_base= (AVRational){1,25}; - c->gop_size = 10; /* emit one intra frame every ten frames */ - c->max_b_frames=1; - c->pix_fmt = PIX_FMT_YUV420P; - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - f = fopen(filename, "wb"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - /* alloc image and output buffer */ - outbuf_size = 100000; - outbuf = malloc(outbuf_size); - size = c->width * c->height; - picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */ - - picture->data[0] = picture_buf; - picture->data[1] = picture->data[0] + size; - picture->data[2] = picture->data[1] + size / 4; - picture->linesize[0] = c->width; - picture->linesize[1] = c->width / 2; - picture->linesize[2] = c->width / 2; - - /* encode 1 second of video */ - for(i=0;i<25;i++) { - fflush(stdout); - /* prepare a dummy image */ - /* Y */ - for(y=0;y<c->height;y++) { - for(x=0;x<c->width;x++) { - picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3; - } - } - - /* Cb and Cr */ - for(y=0;y<c->height/2;y++) { - for(x=0;x<c->width/2;x++) { - picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2; - picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5; - } - } - - /* encode the image */ - out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); - printf("encoding frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); - } - - /* get the delayed frames */ - for(; out_size; i++) { - fflush(stdout); - - out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); - printf("write frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); - } - - /* add sequence end code to have a real mpeg file */ - outbuf[0] = 0x00; - outbuf[1] = 0x00; - outbuf[2] = 0x01; - outbuf[3] = 0xb7; - fwrite(outbuf, 1, 4, f); - fclose(f); - free(picture_buf); - free(outbuf); - - avcodec_close(c); - av_free(c); - av_free(picture); - printf("\n"); -} - -/* - * Video decoding example - */ - -static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, - char *filename) -{ - FILE *f; - int i; - - f=fopen(filename,"w"); - fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255); - for(i=0;i<ysize;i++) - fwrite(buf + i * wrap,1,xsize,f); - fclose(f); -} - -static void video_decode_example(const char *outfilename, const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int frame, got_picture, len; - FILE *f; - AVFrame *picture; - uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; - char buf[1024]; - AVPacket avpkt; - - av_init_packet(&avpkt); - - /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */ - memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE); - - printf("Video decoding\n"); - - /* find the mpeg1 video decoder */ - codec = avcodec_find_decoder(CODEC_ID_MPEG1VIDEO); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c= avcodec_alloc_context(); - picture= avcodec_alloc_frame(); - - if(codec->capabilities&CODEC_CAP_TRUNCATED) - c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ - - /* For some codecs, such as msmpeg4 and mpeg4, width and height - MUST be initialized there because this information is not - available in the bitstream. */ - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - /* the codec gives us the frame size, in samples */ - - f = fopen(filename, "rb"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - frame = 0; - for(;;) { - avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); - if (avpkt.size == 0) - break; - - /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio) - and this is the only method to use them because you cannot - know the compressed data size before analysing it. - - BUT some other codecs (msmpeg4, mpeg4) are inherently frame - based, so you must call them with all the data for one - frame exactly. You must also initialize 'width' and - 'height' before initializing them. */ - - /* NOTE2: some codecs allow the raw parameters (frame size, - sample rate) to be changed at any frame. We handle this, so - you should also take care of it */ - - /* here, we use a stream based decoder (mpeg1video), so we - feed decoder and see if it could decode a frame */ - avpkt.data = inbuf; - while (avpkt.size > 0) { - len = avcodec_decode_video2(c, picture, &got_picture, &avpkt); - if (len < 0) { - fprintf(stderr, "Error while decoding frame %d\n", frame); - exit(1); - } - if (got_picture) { - printf("saving frame %3d\n", frame); - fflush(stdout); - - /* the picture is allocated by the decoder. no need to - free it */ - snprintf(buf, sizeof(buf), outfilename, frame); - pgm_save(picture->data[0], picture->linesize[0], - c->width, c->height, buf); - frame++; - } - avpkt.size -= len; - avpkt.data += len; - } - } - - /* some codecs, such as MPEG, transmit the I and P frame with a - latency of one frame. You must do the following to have a - chance to get the last frame of the video */ - avpkt.data = NULL; - avpkt.size = 0; - len = avcodec_decode_video2(c, picture, &got_picture, &avpkt); - if (got_picture) { - printf("saving last frame %3d\n", frame); - fflush(stdout); - - /* the picture is allocated by the decoder. no need to - free it */ - snprintf(buf, sizeof(buf), outfilename, frame); - pgm_save(picture->data[0], picture->linesize[0], - c->width, c->height, buf); - frame++; - } - - fclose(f); - - avcodec_close(c); - av_free(c); - av_free(picture); - printf("\n"); -} - -int main(int argc, char **argv) -{ - const char *filename; - - /* must be called before using avcodec lib */ - avcodec_init(); - - /* register all the codecs */ - avcodec_register_all(); - - if (argc <= 1) { - audio_encode_example("/tmp/test.mp2"); - audio_decode_example("/tmp/test.sw", "/tmp/test.mp2"); - - video_encode_example("/tmp/test.mpg"); - filename = "/tmp/test.mpg"; - } else { - filename = argv[1]; - } - - // audio_decode_example("/tmp/test.sw", filename); - video_decode_example("/tmp/test%d.pgm", filename); - - return 0; -} diff --git a/libavcodec/arm/aac.h b/libavcodec/arm/aac.h index 6d5df4933a..3b14c094c6 100644 --- a/libavcodec/arm/aac.h +++ b/libavcodec/arm/aac.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S index 8026cb72e6..2b2f2acf22 100644 --- a/libavcodec/arm/ac3dsp_armv6.S +++ b/libavcodec/arm/ac3dsp_armv6.S @@ -37,7 +37,7 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1 ldrb r10, [r4], #1 1: ldrsh r9, [r0], #2 @ mask[band] - movw r8, #0x1fe0 + ldr r8, =0x1fe0 sub r9, r9, r12 @ - snr_offset mov r11, r10 ldrb r10, [r4], #1 @ band_start_tab[band++] diff --git a/libavcodec/arm/ac3dsp_init_arm.c b/libavcodec/arm/ac3dsp_init_arm.c index aed11f4bb8..5a9fdf0071 100644 --- a/libavcodec/arm/ac3dsp_init_arm.c +++ b/libavcodec/arm/ac3dsp_init_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2011 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/asm-offsets.h b/libavcodec/arm/asm-offsets.h index 110d33dbb5..fe124ba702 100644 --- a/libavcodec/arm/asm-offsets.h +++ b/libavcodec/arm/asm-offsets.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/asm.S b/libavcodec/arm/asm.S index 8d7fe98614..bb999fd61a 100644 --- a/libavcodec/arm/asm.S +++ b/libavcodec/arm/asm.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dcadsp_init_arm.c b/libavcodec/arm/dcadsp_init_arm.c index b5ac2068d5..5663cd7fc2 100644 --- a/libavcodec/arm/dcadsp_init_arm.c +++ b/libavcodec/arm/dcadsp_init_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dcadsp_neon.S b/libavcodec/arm/dcadsp_neon.S index 61208361df..c3bddd3e41 100644 --- a/libavcodec/arm/dcadsp_neon.S +++ b/libavcodec/arm/dcadsp_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_arm.S b/libavcodec/arm/dsputil_arm.S index 21176283c4..7ee85e808b 100644 --- a/libavcodec/arm/dsputil_arm.S +++ b/libavcodec/arm/dsputil_arm.S @@ -2,20 +2,20 @@ @ ARMv4 optimized DSP utils @ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp> @ -@ This file is part of Libav. +@ This file is part of FFmpeg. @ -@ Libav is free software; you can redistribute it and/or +@ 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. @ -@ Libav is distributed in the hope that it will be useful, +@ 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 Libav; if not, write to the Free Software +@ License along with FFmpeg; if not, write to the Free Software @ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @ diff --git a/libavcodec/arm/dsputil_arm.h b/libavcodec/arm/dsputil_arm.h index 6d7e6a6d16..b333c70226 100644 --- a/libavcodec/arm/dsputil_arm.h +++ b/libavcodec/arm/dsputil_arm.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_armv6.S b/libavcodec/arm/dsputil_armv6.S index 8acb96de2f..214d947da3 100644 --- a/libavcodec/arm/dsputil_armv6.S +++ b/libavcodec/arm/dsputil_armv6.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_init_arm.c b/libavcodec/arm/dsputil_init_arm.c index 777a2f954e..0351412761 100644 --- a/libavcodec/arm/dsputil_init_arm.c +++ b/libavcodec/arm/dsputil_init_arm.c @@ -2,20 +2,20 @@ * ARM optimized DSP utils * Copyright (c) 2001 Lionel Ulmer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_init_armv5te.c b/libavcodec/arm/dsputil_init_armv5te.c index 572e06cf36..750e5147b4 100644 --- a/libavcodec/arm/dsputil_init_armv5te.c +++ b/libavcodec/arm/dsputil_init_armv5te.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c index 7584aeefc6..9acea4a1d6 100644 --- a/libavcodec/arm/dsputil_init_armv6.c +++ b/libavcodec/arm/dsputil_init_armv6.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c index 3bc053c864..6faf3dc8d0 100644 --- a/libavcodec/arm/dsputil_init_neon.c +++ b/libavcodec/arm/dsputil_init_neon.c @@ -2,20 +2,20 @@ * ARM NEON optimised DSP functions * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_init_vfp.c b/libavcodec/arm/dsputil_init_vfp.c index 9cda890411..ee092dca10 100644 --- a/libavcodec/arm/dsputil_init_vfp.c +++ b/libavcodec/arm/dsputil_init_vfp.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_iwmmxt.c b/libavcodec/arm/dsputil_iwmmxt.c index 86f8fddfcf..85be83148a 100644 --- a/libavcodec/arm/dsputil_iwmmxt.c +++ b/libavcodec/arm/dsputil_iwmmxt.c @@ -2,20 +2,20 @@ * iWMMXt optimized DSP utils * Copyright (c) 2004 AGAWA Koji * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_iwmmxt_rnd_template.c b/libavcodec/arm/dsputil_iwmmxt_rnd_template.c index df0ead6d80..35a5a9b8b4 100644 --- a/libavcodec/arm/dsputil_iwmmxt_rnd_template.c +++ b/libavcodec/arm/dsputil_iwmmxt_rnd_template.c @@ -2,20 +2,20 @@ * iWMMXt optimized DSP utils * copyright (c) 2004 AGAWA Koji * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_neon.S b/libavcodec/arm/dsputil_neon.S index 5b80e40d6f..0dbf5ca48a 100644 --- a/libavcodec/arm/dsputil_neon.S +++ b/libavcodec/arm/dsputil_neon.S @@ -2,20 +2,20 @@ * ARM NEON optimised DSP functions * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/dsputil_vfp.S b/libavcodec/arm/dsputil_vfp.S index 16ea25afe6..497c02be92 100644 --- a/libavcodec/arm/dsputil_vfp.S +++ b/libavcodec/arm/dsputil_vfp.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/fft_fixed_init_arm.c b/libavcodec/arm/fft_fixed_init_arm.c index be412cde05..df71e7fe09 100644 --- a/libavcodec/arm/fft_fixed_init_arm.c +++ b/libavcodec/arm/fft_fixed_init_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S index 14884d3736..bd6c853ec8 100644 --- a/libavcodec/arm/fft_fixed_neon.S +++ b/libavcodec/arm/fft_fixed_neon.S @@ -122,7 +122,7 @@ endfunc function fft_pass_neon push {r4,lr} - movrel lr, coefs + 24 + movrel lr, coefs+24 vld1.16 {d30}, [lr,:64] lsl r12, r2, #3 vmov d31, d30 diff --git a/libavcodec/arm/fft_init_arm.c b/libavcodec/arm/fft_init_arm.c index 4ee4909682..3e0e41ec3b 100644 --- a/libavcodec/arm/fft_init_arm.c +++ b/libavcodec/arm/fft_init_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/fft_neon.S b/libavcodec/arm/fft_neon.S index 887621834e..1db7abd146 100644 --- a/libavcodec/arm/fft_neon.S +++ b/libavcodec/arm/fft_neon.S @@ -7,20 +7,20 @@ * This algorithm (though not any of the implementation details) is * based on libdjbfft by D. J. Bernstein. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/fmtconvert_init_arm.c b/libavcodec/arm/fmtconvert_init_arm.c index 92e07f17a0..4b6e3939f5 100644 --- a/libavcodec/arm/fmtconvert_init_arm.c +++ b/libavcodec/arm/fmtconvert_init_arm.c @@ -1,20 +1,20 @@ /* * ARM optimized Format Conversion Utils * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/fmtconvert_neon.S b/libavcodec/arm/fmtconvert_neon.S index 4b0e9a2d6a..359e57e40b 100644 --- a/libavcodec/arm/fmtconvert_neon.S +++ b/libavcodec/arm/fmtconvert_neon.S @@ -2,20 +2,20 @@ * ARM NEON optimised Format Conversion Utils * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/fmtconvert_vfp.S b/libavcodec/arm/fmtconvert_vfp.S index 1bb7f49801..da2ef8c158 100644 --- a/libavcodec/arm/fmtconvert_vfp.S +++ b/libavcodec/arm/fmtconvert_vfp.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/h264dsp_init_arm.c b/libavcodec/arm/h264dsp_init_arm.c index c2399e50ff..e9146405c2 100644 --- a/libavcodec/arm/h264dsp_init_arm.c +++ b/libavcodec/arm/h264dsp_init_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/h264dsp_neon.S b/libavcodec/arm/h264dsp_neon.S index b76e4479b5..bd15ced736 100644 --- a/libavcodec/arm/h264dsp_neon.S +++ b/libavcodec/arm/h264dsp_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/h264idct_neon.S b/libavcodec/arm/h264idct_neon.S index b7253542a8..6b6a669f35 100644 --- a/libavcodec/arm/h264idct_neon.S +++ b/libavcodec/arm/h264idct_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/h264pred_init_arm.c b/libavcodec/arm/h264pred_init_arm.c index e96f339a55..b1d4f005e8 100644 --- a/libavcodec/arm/h264pred_init_arm.c +++ b/libavcodec/arm/h264pred_init_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/h264pred_neon.S b/libavcodec/arm/h264pred_neon.S index fe8a369a90..63c96ee725 100644 --- a/libavcodec/arm/h264pred_neon.S +++ b/libavcodec/arm/h264pred_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/int_neon.S b/libavcodec/arm/int_neon.S index 5a149912f4..e8023e0686 100644 --- a/libavcodec/arm/int_neon.S +++ b/libavcodec/arm/int_neon.S @@ -2,20 +2,20 @@ * ARM NEON optimised integer operations * Copyright (c) 2009 Kostya Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mathops.h b/libavcodec/arm/mathops.h index b27b18f871..299a973cb6 100644 --- a/libavcodec/arm/mathops.h +++ b/libavcodec/arm/mathops.h @@ -2,20 +2,20 @@ * simple math operations * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mdct_neon.S b/libavcodec/arm/mdct_neon.S index c375f4c121..fcf802275f 100644 --- a/libavcodec/arm/mdct_neon.S +++ b/libavcodec/arm/mdct_neon.S @@ -2,20 +2,20 @@ * ARM NEON optimised MDCT * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mpegvideo_arm.c b/libavcodec/arm/mpegvideo_arm.c index b1d1312943..6cb1bc8582 100644 --- a/libavcodec/arm/mpegvideo_arm.c +++ b/libavcodec/arm/mpegvideo_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2002 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mpegvideo_arm.h b/libavcodec/arm/mpegvideo_arm.h index a36da6112b..3549bb244b 100644 --- a/libavcodec/arm/mpegvideo_arm.h +++ b/libavcodec/arm/mpegvideo_arm.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mpegvideo_armv5te.c b/libavcodec/arm/mpegvideo_armv5te.c index 30197d8bc1..1d383cae1e 100644 --- a/libavcodec/arm/mpegvideo_armv5te.c +++ b/libavcodec/arm/mpegvideo_armv5te.c @@ -2,20 +2,20 @@ * Optimization of some functions from mpegvideo.c for armv5te * Copyright (c) 2007 Siarhei Siamashka <ssvb@users.sourceforge.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mpegvideo_armv5te_s.S b/libavcodec/arm/mpegvideo_armv5te_s.S index e83fe991e6..0606bb43b6 100644 --- a/libavcodec/arm/mpegvideo_armv5te_s.S +++ b/libavcodec/arm/mpegvideo_armv5te_s.S @@ -2,20 +2,20 @@ * Optimization of some functions from mpegvideo.c for armv5te * Copyright (c) 2007 Siarhei Siamashka <ssvb@users.sourceforge.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mpegvideo_iwmmxt.c b/libavcodec/arm/mpegvideo_iwmmxt.c index 4d5edd8050..0a288630ab 100644 --- a/libavcodec/arm/mpegvideo_iwmmxt.c +++ b/libavcodec/arm/mpegvideo_iwmmxt.c @@ -1,20 +1,20 @@ /* * copyright (c) 2004 AGAWA Koji * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/mpegvideo_neon.S b/libavcodec/arm/mpegvideo_neon.S index 365dcf65cf..b695fb7c22 100644 --- a/libavcodec/arm/mpegvideo_neon.S +++ b/libavcodec/arm/mpegvideo_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/rdft_neon.S b/libavcodec/arm/rdft_neon.S index 8aafdc9cf4..4f8a1032cc 100644 --- a/libavcodec/arm/rdft_neon.S +++ b/libavcodec/arm/rdft_neon.S @@ -2,20 +2,20 @@ * ARM NEON optimised RDFT * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/simple_idct_arm.S b/libavcodec/arm/simple_idct_arm.S index 4e6dfa4391..ecb83d23ad 100644 --- a/libavcodec/arm/simple_idct_arm.S +++ b/libavcodec/arm/simple_idct_arm.S @@ -5,22 +5,22 @@ * Author: Frederic Boulay <dilb@handhelds.org> * * The function defined in this file is derived from the simple_idct function - * from the libavcodec library part of the Libav project. + * from the libavcodec library part of the FFmpeg project. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/simple_idct_armv5te.S b/libavcodec/arm/simple_idct_armv5te.S index 5d03c0c1c3..27aeca4448 100644 --- a/libavcodec/arm/simple_idct_armv5te.S +++ b/libavcodec/arm/simple_idct_armv5te.S @@ -4,20 +4,20 @@ * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2006 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/simple_idct_armv6.S b/libavcodec/arm/simple_idct_armv6.S index b2eb525de5..d61c1fd3ea 100644 --- a/libavcodec/arm/simple_idct_armv6.S +++ b/libavcodec/arm/simple_idct_armv6.S @@ -4,20 +4,20 @@ * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2007 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/simple_idct_neon.S b/libavcodec/arm/simple_idct_neon.S index 0628b9676a..17cde5835a 100644 --- a/libavcodec/arm/simple_idct_neon.S +++ b/libavcodec/arm/simple_idct_neon.S @@ -6,20 +6,20 @@ * Based on Simple IDCT * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/synth_filter_neon.S b/libavcodec/arm/synth_filter_neon.S index d4f67b785c..1464abe562 100644 --- a/libavcodec/arm/synth_filter_neon.S +++ b/libavcodec/arm/synth_filter_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp3dsp_neon.S b/libavcodec/arm/vp3dsp_neon.S index c1a55cad2f..d97ed3d21d 100644 --- a/libavcodec/arm/vp3dsp_neon.S +++ b/libavcodec/arm/vp3dsp_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp56_arith.h b/libavcodec/arm/vp56_arith.h index 9ce3fd0d91..cd02579e5b 100644 --- a/libavcodec/arm/vp56_arith.h +++ b/libavcodec/arm/vp56_arith.h @@ -1,20 +1,20 @@ /* * Copyright (C) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp56dsp_init_arm.c b/libavcodec/arm/vp56dsp_init_arm.c index 598960251a..ceab9a87d2 100644 --- a/libavcodec/arm/vp56dsp_init_arm.c +++ b/libavcodec/arm/vp56dsp_init_arm.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp56dsp_neon.S b/libavcodec/arm/vp56dsp_neon.S index b95d8ab28b..0353661009 100644 --- a/libavcodec/arm/vp56dsp_neon.S +++ b/libavcodec/arm/vp56dsp_neon.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp8.h b/libavcodec/arm/vp8.h index 76a0397a8d..55193394c5 100644 --- a/libavcodec/arm/vp8.h +++ b/libavcodec/arm/vp8.h @@ -1,18 +1,18 @@ /** - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp8_armv6.S b/libavcodec/arm/vp8_armv6.S index 602c8a58be..93f4dd664b 100644 --- a/libavcodec/arm/vp8_armv6.S +++ b/libavcodec/arm/vp8_armv6.S @@ -1,20 +1,20 @@ /** * Copyright (C) 2010 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp8dsp_init_arm.c b/libavcodec/arm/vp8dsp_init_arm.c index 269c6e3f72..c970ca548c 100644 --- a/libavcodec/arm/vp8dsp_init_arm.c +++ b/libavcodec/arm/vp8dsp_init_arm.c @@ -1,18 +1,18 @@ /** - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/arm/vp8dsp_neon.S b/libavcodec/arm/vp8dsp_neon.S index 92b1ef4eb7..23330900f7 100644 --- a/libavcodec/arm/vp8dsp_neon.S +++ b/libavcodec/arm/vp8dsp_neon.S @@ -4,20 +4,20 @@ * Copyright (c) 2010 Rob Clark <rob@ti.com> * Copyright (c) 2011 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 327a77bb45..cb0babf2c8 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -2,20 +2,20 @@ * SSA/ASS common funtions * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -23,26 +23,11 @@ #include "ass.h" #include "libavutil/avstring.h" -/** - * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS. - * - * @param avctx pointer to the AVCodecContext - * @param font name of the default font face to use - * @param font_size default font size to use - * @param color default text color to use (ABGR) - * @param back_color default background color to use (ABGR) - * @param bold 1 for bold text, 0 for normal text - * @param italic 1 for italic text, 0 for normal text - * @param underline 1 for underline text, 0 for normal text - * @param alignment position of the text (left, center, top...), defined after - * the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top) - * @return >= 0 on success otherwise an error code <0 - */ -static int ff_ass_subtitle_header(AVCodecContext *avctx, - const char *font, int font_size, - int color, int back_color, - int bold, int italic, int underline, - int alignment) +int ff_ass_subtitle_header(AVCodecContext *avctx, + const char *font, int font_size, + int color, int back_color, + int bold, int italic, int underline, + int alignment) { char header[512]; @@ -78,11 +63,6 @@ int ff_ass_subtitle_header_default(AVCodecContext *avctx) ASS_DEFAULT_ALIGNMENT); } -void ff_ass_init(AVSubtitle *sub) -{ - memset(sub, 0, sizeof(*sub)); -} - static int ts_to_string(char *str, int strlen, int ts) { int h, m, s; diff --git a/libavcodec/ass.h b/libavcodec/ass.h index d350cf3fc2..74ef61b776 100644 --- a/libavcodec/ass.h +++ b/libavcodec/ass.h @@ -2,20 +2,20 @@ * SSA/ASS common funtions * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -40,20 +40,34 @@ /** @} */ /** - * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS - * with default style. + * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS. * * @param avctx pointer to the AVCodecContext + * @param font name of the default font face to use + * @param font_size default font size to use + * @param color default text color to use (ABGR) + * @param back_color default background color to use (ABGR) + * @param bold 1 for bold text, 0 for normal text + * @param italic 1 for italic text, 0 for normal text + * @param underline 1 for underline text, 0 for normal text + * @param alignment position of the text (left, center, top...), defined after + * the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top) * @return >= 0 on success otherwise an error code <0 */ -int ff_ass_subtitle_header_default(AVCodecContext *avctx); +int ff_ass_subtitle_header(AVCodecContext *avctx, + const char *font, int font_size, + int color, int back_color, + int bold, int italic, int underline, + int alignment); /** - * Initialize an AVSubtitle structure for use with ff_ass_add_rect(). + * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS + * with default style. * - * @param sub pointer to the AVSubtitle + * @param avctx pointer to the AVCodecContext + * @return >= 0 on success otherwise an error code <0 */ -void ff_ass_init(AVSubtitle *sub); +int ff_ass_subtitle_header_default(AVCodecContext *avctx); /** * Add an ASS dialog line to an AVSubtitle as a new AVSubtitleRect. diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c new file mode 100644 index 0000000000..2a3b76445e --- /dev/null +++ b/libavcodec/ass_split.c @@ -0,0 +1,468 @@ +/* + * SSA/ASS spliting functions + * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avcodec.h" +#include "ass_split.h" + +typedef enum { + ASS_STR, + ASS_INT, + ASS_FLT, + ASS_COLOR, + ASS_TIMESTAMP, + ASS_ALGN, +} ASSFieldType; + +typedef struct { + const char *name; + int type; + int offset; +} ASSFields; + +typedef struct { + const char *section; + const char *format_header; + const char *fields_header; + int size; + int offset; + int offset_count; + ASSFields fields[10]; +} ASSSection; + +static const ASSSection ass_sections[] = { + { .section = "Script Info", + .offset = offsetof(ASS, script_info), + .fields = {{"ScriptType", ASS_STR, offsetof(ASSScriptInfo, script_type)}, + {"Collisions", ASS_STR, offsetof(ASSScriptInfo, collisions) }, + {"PlayResX", ASS_INT, offsetof(ASSScriptInfo, play_res_x) }, + {"PlayResY", ASS_INT, offsetof(ASSScriptInfo, play_res_y) }, + {"Timer", ASS_FLT, offsetof(ASSScriptInfo, timer) }, + {0}, + } + }, + { .section = "V4+ Styles", + .format_header = "Format", + .fields_header = "Style", + .size = sizeof(ASSStyle), + .offset = offsetof(ASS, styles), + .offset_count = offsetof(ASS, styles_count), + .fields = {{"Name", ASS_STR, offsetof(ASSStyle, name) }, + {"Fontname", ASS_STR, offsetof(ASSStyle, font_name) }, + {"Fontsize", ASS_INT, offsetof(ASSStyle, font_size) }, + {"PrimaryColour",ASS_COLOR,offsetof(ASSStyle, primary_color)}, + {"BackColour", ASS_COLOR,offsetof(ASSStyle, back_color) }, + {"Bold", ASS_INT, offsetof(ASSStyle, bold) }, + {"Italic", ASS_INT, offsetof(ASSStyle, italic) }, + {"Underline", ASS_INT, offsetof(ASSStyle, underline) }, + {"Alignment", ASS_INT, offsetof(ASSStyle, alignment) }, + {0}, + } + }, + { .section = "V4 Styles", + .format_header = "Format", + .fields_header = "Style", + .size = sizeof(ASSStyle), + .offset = offsetof(ASS, styles), + .offset_count = offsetof(ASS, styles_count), + .fields = {{"Name", ASS_STR, offsetof(ASSStyle, name) }, + {"Fontname", ASS_STR, offsetof(ASSStyle, font_name) }, + {"Fontsize", ASS_INT, offsetof(ASSStyle, font_size) }, + {"PrimaryColour",ASS_COLOR,offsetof(ASSStyle, primary_color)}, + {"BackColour", ASS_COLOR,offsetof(ASSStyle, back_color) }, + {"Bold", ASS_INT, offsetof(ASSStyle, bold) }, + {"Italic", ASS_INT, offsetof(ASSStyle, italic) }, + {"Alignment", ASS_ALGN, offsetof(ASSStyle, alignment) }, + {0}, + } + }, + { .section = "Events", + .format_header = "Format", + .fields_header = "Dialogue", + .size = sizeof(ASSDialog), + .offset = offsetof(ASS, dialogs), + .offset_count = offsetof(ASS, dialogs_count), + .fields = {{"Layer", ASS_INT, offsetof(ASSDialog, layer) }, + {"Start", ASS_TIMESTAMP, offsetof(ASSDialog, start) }, + {"End", ASS_TIMESTAMP, offsetof(ASSDialog, end) }, + {"Style", ASS_STR, offsetof(ASSDialog, style) }, + {"Text", ASS_STR, offsetof(ASSDialog, text) }, + {0}, + } + }, +}; + + +typedef int (*ASSConvertFunc)(void *dest, const char *buf, int len); + +static int convert_str(void *dest, const char *buf, int len) +{ + char *str = av_malloc(len + 1); + if (str) { + memcpy(str, buf, len); + str[len] = 0; + if (*(void **)dest) + av_free(*(void **)dest); + *(char **)dest = str; + } + return !str; +} +static int convert_int(void *dest, const char *buf, int len) +{ + return sscanf(buf, "%d", (int *)dest) == 1; +} +static int convert_flt(void *dest, const char *buf, int len) +{ + return sscanf(buf, "%f", (float *)dest) == 1; +} +static int convert_color(void *dest, const char *buf, int len) +{ + return sscanf(buf, "&H%8x", (int *)dest) == 1 || + sscanf(buf, "%d", (int *)dest) == 1; +} +static int convert_timestamp(void *dest, const char *buf, int len) +{ + int c, h, m, s, cs; + if ((c = sscanf(buf, "%d:%02d:%02d.%02d", &h, &m, &s, &cs)) == 4) + *(int *)dest = 360000*h + 6000*m + 100*s + cs; + return c == 4; +} +static int convert_alignment(void *dest, const char *buf, int len) +{ + int a; + if (sscanf(buf, "%d", &a) == 1) { + /* convert V4 Style alignment to V4+ Style */ + *(int *)dest = a + ((a&4) >> 1) - 5*!!(a&8); + return 1; + } + return 0; +} + +static const ASSConvertFunc convert_func[] = { + [ASS_STR] = convert_str, + [ASS_INT] = convert_int, + [ASS_FLT] = convert_flt, + [ASS_COLOR] = convert_color, + [ASS_TIMESTAMP] = convert_timestamp, + [ASS_ALGN] = convert_alignment, +}; + + +struct ASSSplitContext { + ASS ass; + int current_section; + int field_number[FF_ARRAY_ELEMS(ass_sections)]; + int *field_order[FF_ARRAY_ELEMS(ass_sections)]; +}; + + +static uint8_t *realloc_section_array(ASSSplitContext *ctx) +{ + const ASSSection *section = &ass_sections[ctx->current_section]; + int *count = (int *)((uint8_t *)&ctx->ass + section->offset_count); + void **section_ptr = (void **)((uint8_t *)&ctx->ass + section->offset); + uint8_t *tmp = av_realloc(*section_ptr, (*count+1)*section->size); + if (!tmp) + return NULL; + *section_ptr = tmp; + tmp += *count * section->size; + memset(tmp, 0, section->size); + (*count)++; + return tmp; +} + +static inline int is_eol(char buf) +{ + return buf == '\r' || buf == '\n' || buf == 0; +} + +static inline const char *skip_space(const char *buf) +{ + while (*buf == ' ') + buf++; + return buf; +} + +static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) +{ + const ASSSection *section = &ass_sections[ctx->current_section]; + int *number = &ctx->field_number[ctx->current_section]; + int *order = ctx->field_order[ctx->current_section]; + int *tmp, i, len; + + while (buf && *buf) { + if (buf[0] == '[') { + ctx->current_section = -1; + break; + } + if (buf[0] == ';' || (buf[0] == '!' && buf[1] == ':')) { + /* skip comments */ + } else if (section->format_header && !order) { + len = strlen(section->format_header); + if (strncmp(buf, section->format_header, len) || buf[len] != ':') + return NULL; + buf += len + 1; + while (!is_eol(*buf)) { + buf = skip_space(buf); + len = strcspn(buf, ", \r\n"); + if (!(tmp = av_realloc(order, (*number + 1) * sizeof(*order)))) + return NULL; + order = tmp; + order[*number] = -1; + for (i=0; section->fields[i].name; i++) + if (!strncmp(buf, section->fields[i].name, len)) { + order[*number] = i; + break; + } + (*number)++; + buf = skip_space(buf + len + 1); + } + ctx->field_order[ctx->current_section] = order; + } else if (section->fields_header) { + len = strlen(section->fields_header); + if (!strncmp(buf, section->fields_header, len) && buf[len] == ':') { + uint8_t *ptr, *struct_ptr = realloc_section_array(ctx); + if (!struct_ptr) return NULL; + buf += len + 1; + for (i=0; !is_eol(*buf) && i < *number; i++) { + int last = i == *number - 1; + buf = skip_space(buf); + len = strcspn(buf, last ? "\r\n" : ",\r\n"); + if (order[i] >= 0) { + ASSFieldType type = section->fields[order[i]].type; + ptr = struct_ptr + section->fields[order[i]].offset; + convert_func[type](ptr, buf, len); + } + buf = skip_space(buf + len + !last); + } + } + } else { + len = strcspn(buf, ":\r\n"); + if (buf[len] == ':') { + for (i=0; section->fields[i].name; i++) + if (!strncmp(buf, section->fields[i].name, len)) { + ASSFieldType type = section->fields[i].type; + uint8_t *ptr = (uint8_t *)&ctx->ass + section->offset; + ptr += section->fields[i].offset; + buf = skip_space(buf + len + 1); + convert_func[type](ptr, buf, strcspn(buf, "\r\n")); + break; + } + } + } + buf += strcspn(buf, "\n") + 1; + } + return buf; +} + +static int ass_split(ASSSplitContext *ctx, const char *buf) +{ + char c, section[16]; + int i; + + if (ctx->current_section >= 0) + buf = ass_split_section(ctx, buf); + + while (buf && *buf) { + if (sscanf(buf, "[%15[0-9A-Za-z+ ]]%c", section, &c) == 2) { + buf += strcspn(buf, "\n") + 1; + for (i=0; i<FF_ARRAY_ELEMS(ass_sections); i++) + if (!strcmp(section, ass_sections[i].section)) { + ctx->current_section = i; + buf = ass_split_section(ctx, buf); + } + } else + buf += strcspn(buf, "\n") + 1; + } + return buf ? 0 : AVERROR_INVALIDDATA; +} + +ASSSplitContext *ff_ass_split(const char *buf) +{ + ASSSplitContext *ctx = av_mallocz(sizeof(*ctx)); + ctx->current_section = -1; + if (ass_split(ctx, buf) < 0) { + ff_ass_split_free(ctx); + return NULL; + } + return ctx; +} + +static void free_section(ASSSplitContext *ctx, const ASSSection *section) +{ + uint8_t *ptr = (uint8_t *)&ctx->ass + section->offset; + int i, j, *count, c = 1; + + if (section->format_header) { + ptr = *(void **)ptr; + count = (int *)((uint8_t *)&ctx->ass + section->offset_count); + } else + count = &c; + + if (ptr) + for (i=0; i<*count; i++, ptr += section->size) + for (j=0; section->fields[j].name; j++) { + const ASSFields *field = §ion->fields[j]; + if (field->type == ASS_STR) + av_freep(ptr + field->offset); + } + *count = 0; + + if (section->format_header) + av_freep((uint8_t *)&ctx->ass + section->offset); +} + +ASSDialog *ff_ass_split_dialog(ASSSplitContext *ctx, const char *buf, + int cache, int *number) +{ + ASSDialog *dialog = NULL; + int i, count; + if (!cache) + for (i=0; i<FF_ARRAY_ELEMS(ass_sections); i++) + if (!strcmp(ass_sections[i].section, "Events")) { + free_section(ctx, &ass_sections[i]); + break; + } + count = ctx->ass.dialogs_count; + if (ass_split(ctx, buf) == 0) + dialog = ctx->ass.dialogs + count; + if (number) + *number = ctx->ass.dialogs_count - count; + return dialog; +} + +void ff_ass_split_free(ASSSplitContext *ctx) +{ + if (ctx) { + int i; + for (i=0; i<FF_ARRAY_ELEMS(ass_sections); i++) + free_section(ctx, &ass_sections[i]); + av_free(ctx); + } +} + + +int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv, + const char *buf) +{ + const char *text = NULL; + char new_line[2]; + int text_len = 0; + + while (*buf) { + if (text && callbacks->text && + (sscanf(buf, "\\%1[nN]", new_line) == 1 || + !strncmp(buf, "{\\", 2))) { + callbacks->text(priv, text, text_len); + text = NULL; + } + if (sscanf(buf, "\\%1[nN]", new_line) == 1) { + if (callbacks->new_line) + callbacks->new_line(priv, new_line[0] == 'N'); + buf += 2; + } else if (!strncmp(buf, "{\\", 2)) { + buf++; + while (*buf == '\\') { + char style[2], c[2], sep[2], c_num[2] = "0", tmp[128] = {0}; + unsigned int color = 0xFFFFFFFF; + int len, size = -1, an = -1, alpha = -1; + int x1, y1, x2, y2, t1 = -1, t2 = -1; + if (sscanf(buf, "\\%1[bisu]%1[01\\}]%n", style, c, &len) > 1) { + int close = c[0] == '0' ? 1 : c[0] == '1' ? 0 : -1; + len += close != -1; + if (callbacks->style) + callbacks->style(priv, style[0], close); + } else if (sscanf(buf, "\\c%1[\\}]%n", sep, &len) > 0 || + sscanf(buf, "\\c&H%X&%1[\\}]%n", &color, sep, &len) > 1 || + sscanf(buf, "\\%1[1234]c%1[\\}]%n", c_num, sep, &len) > 1 || + sscanf(buf, "\\%1[1234]c&H%X&%1[\\}]%n", c_num, &color, sep, &len) > 2) { + if (callbacks->color) + callbacks->color(priv, color, c_num[0] - '0'); + } else if (sscanf(buf, "\\alpha%1[\\}]%n", sep, &len) > 0 || + sscanf(buf, "\\alpha&H%2X&%1[\\}]%n", &alpha, sep, &len) > 1 || + sscanf(buf, "\\%1[1234]a%1[\\}]%n", c_num, sep, &len) > 1 || + sscanf(buf, "\\%1[1234]a&H%2X&%1[\\}]%n", c_num, &alpha, sep, &len) > 2) { + if (callbacks->alpha) + callbacks->alpha(priv, alpha, c_num[0] - '0'); + } else if (sscanf(buf, "\\fn%1[\\}]%n", sep, &len) > 0 || + sscanf(buf, "\\fn%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) { + if (callbacks->font_name) + callbacks->font_name(priv, tmp[0] ? tmp : NULL); + } else if (sscanf(buf, "\\fs%1[\\}]%n", sep, &len) > 0 || + sscanf(buf, "\\fs%u%1[\\}]%n", &size, sep, &len) > 1) { + if (callbacks->font_size) + callbacks->font_size(priv, size); + } else if (sscanf(buf, "\\a%1[\\}]%n", sep, &len) > 0 || + sscanf(buf, "\\a%2u%1[\\}]%n", &an, sep, &len) > 1 || + sscanf(buf, "\\an%1[\\}]%n", sep, &len) > 0 || + sscanf(buf, "\\an%1u%1[\\}]%n", &an, sep, &len) > 1) { + if (an != -1 && buf[2] != 'n') + an = (an&3) + (an&4 ? 6 : an&8 ? 3 : 0); + if (callbacks->alignment) + callbacks->alignment(priv, an); + } else if (sscanf(buf, "\\r%1[\\}]%n", sep, &len) > 0 || + sscanf(buf, "\\r%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) { + if (callbacks->cancel_overrides) + callbacks->cancel_overrides(priv, tmp); + } else if (sscanf(buf, "\\move(%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, sep, &len) > 4 || + sscanf(buf, "\\move(%d,%d,%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, &t1, &t2, sep, &len) > 6) { + if (callbacks->move) + callbacks->move(priv, x1, y1, x2, y2, t1, t2); + } else if (sscanf(buf, "\\pos(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) { + if (callbacks->move) + callbacks->move(priv, x1, y1, x1, y1, -1, -1); + } else if (sscanf(buf, "\\org(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) { + if (callbacks->origin) + callbacks->origin(priv, x1, y1); + } else { + len = strcspn(buf+1, "\\}") + 2; /* skip unknown code */ + } + buf += len - 1; + } + if (*buf++ != '}') + return AVERROR_INVALIDDATA; + } else { + if (!text) { + text = buf; + text_len = 1; + } else + text_len++; + buf++; + } + } + if (text && callbacks->text) + callbacks->text(priv, text, text_len); + if (callbacks->end) + callbacks->end(priv); + return 0; +} + +ASSStyle *ass_style_get(ASSSplitContext *ctx, const char *style) +{ + ASS *ass = &ctx->ass; + int i; + + if (!style || !*style) + style = "Default"; + for (i=0; i<ass->styles_count; i++) + if (!strcmp(ass->styles[i].name, style)) + return ass->styles + i; + return NULL; +} diff --git a/libavcodec/ass_split.h b/libavcodec/ass_split.h new file mode 100644 index 0000000000..66b452b7d4 --- /dev/null +++ b/libavcodec/ass_split.h @@ -0,0 +1,172 @@ +/* + * SSA/ASS spliting functions + * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> + * + * 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_ASS_SPLIT_H +#define AVCODEC_ASS_SPLIT_H + +/** + * fields extracted from the [Script Info] section + */ +typedef struct { + char *script_type; /**< SSA script format version (eg. v4.00) */ + char *collisions; /**< how subtitles are moved to prevent collisions */ + int play_res_x; /**< video width that ASS coords are referring to */ + int play_res_y; /**< video height that ASS coords are referring to */ + float timer; /**< time multiplier to apply to SSA clock (in %) */ +} ASSScriptInfo; + +/** + * fields extracted from the [V4(+) Styles] section + */ +typedef struct { + char *name; /**< name of the tyle (case sensitive) */ + char *font_name; /**< font face (case sensitive) */ + int font_size; /**< font height */ + int primary_color; /**< color that a subtitle will normally appear in */ + int back_color; /**< color of the subtitle outline or shadow */ + int bold; /**< whether text is bold (1) or not (0) */ + int italic; /**< whether text is italic (1) or not (0) */ + int underline; /**< whether text is underlined (1) or not (0) */ + int alignment; /**< position of the text (left, center, top...), + defined after the layout of the numpad + (1-3 sub, 4-6 mid, 7-9 top) */ +} ASSStyle; + +/** + * fields extracted from the [Events] section + */ +typedef struct { + int layer; /**< higher numbered layers are drawn over lower numbered */ + int start; /**< start time of the dialog in centiseconds */ + int end; /**< end time of the dialog in centiseconds */ + char *style; /**< name of the ASSStyle to use with this dialog */ + char *text; /**< actual text which will be displayed as a subtitle, + can include style override control codes (see + ff_ass_split_override_codes()) */ +} ASSDialog; + +/** + * structure containing the whole split ASS data + */ +typedef struct { + ASSScriptInfo script_info; /**< general information about the SSA script*/ + ASSStyle *styles; /**< array of split out styles */ + int styles_count; /**< number of ASSStyle in the styles array */ + ASSDialog *dialogs; /**< array of split out dialogs */ + int dialogs_count; /**< number of ASSDialog in the dialogs array*/ +} ASS; + +/** + * This struct can be casted to ASS to access to the split data. + */ +typedef struct ASSSplitContext ASSSplitContext; + +/** + * Split a full ASS file or a ASS header from a string buffer and store + * the split structure in a newly allocated context. + * + * @param buf String containing the ASS formated data. + * @return Newly allocated struct containing split data. + */ +ASSSplitContext *ff_ass_split(const char *buf); + +/** + * Split one or several ASS "Dialogue" lines from a string buffer and store + * them in a already initialized context. + * + * @param ctx Context previously initialized by ff_ass_split(). + * @param buf String containing the ASS "Dialogue" lines. + * @param cache Set to 1 to keep all the previously split ASSDialog in + * the context, or set to 0 to free all the previously split + * ASSDialog. + * @param number If not NULL, the pointed integer will be set to the number + * of split ASSDialog. + * @return Pointer to the first split ASSDialog. + */ +ASSDialog *ff_ass_split_dialog(ASSSplitContext *ctx, const char *buf, + int cache, int *number); + +/** + * Free all the memory allocated for an ASSSplitContext. + * + * @param ctx Context previously initialized by ff_ass_split(). + */ +void ff_ass_split_free(ASSSplitContext *ctx); + + +/** + * Set of callback functions corresponding to each override codes that can + * be encountered in a "Dialogue" Text field. + */ +typedef struct { + /** + * @defgroup ass_styles ASS styles + * @{ + */ + void (*text)(void *priv, const char *text, int len); + void (*new_line)(void *priv, int forced); + void (*style)(void *priv, char style, int close); + void (*color)(void *priv, unsigned int color, unsigned int color_id); + void (*alpha)(void *priv, int alpha, int alpha_id); + void (*font_name)(void *priv, const char *name); + void (*font_size)(void *priv, int size); + void (*alignment)(void *priv, int alignment); + void (*cancel_overrides)(void *priv, const char *style); + /**< @} */ + + /** + * @defgroup ass_functions ASS functions + * @{ + */ + void (*move)(void *priv, int x1, int y1, int x2, int y2, int t1, int t2); + void (*origin)(void *priv, int x, int y); + /**< @} */ + + /** + * @defgroup ass_end end of Dialogue Event + * @{ + */ + void (*end)(void *priv); + /**< @} */ +} ASSCodesCallbacks; + +/** + * Split override codes out of a ASS "Dialogue" Text field. + * + * @param callbacks Set of callback functions called for each override code + * encountered. + * @param priv Opaque pointer passed to the callback functions. + * @param buf The ASS "Dialogue" Text field to split. + * @return >= 0 on success otherwise an error code <0 + */ +int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv, + const char *buf); + +/** + * Find an ASSStyle structure by its name. + * + * @param ctx Context previously initialized by ff_ass_split(). + * @param style name of the style to search for. + * @return the ASSStyle corresponding to style, or NULL if style can't be found + */ +ASSStyle *ass_style_get(ASSSplitContext *ctx, const char *style); + +#endif /* AVCODEC_ASS_SPLIT_H */ diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c index 98f7be36a2..087a0c839b 100644 --- a/libavcodec/assdec.c +++ b/libavcodec/assdec.c @@ -2,25 +2,26 @@ * SSA/ASS decoder * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" #include "ass.h" +#include "ass_split.h" static av_cold int ass_decode_init(AVCodecContext *avctx) { @@ -29,6 +30,7 @@ static av_cold int ass_decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); memcpy(avctx->subtitle_header, avctx->extradata, avctx->extradata_size); avctx->subtitle_header_size = avctx->extradata_size; + avctx->priv_data = ff_ass_split(avctx->extradata); return 0; } @@ -38,10 +40,10 @@ static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, const char *ptr = avpkt->data; int len, size = avpkt->size; - ff_ass_init(data); - while (size > 0) { - len = ff_ass_add_rect(data, ptr, 0, 0/* FIXME: duration */, 1); + ASSDialog *dialog = ff_ass_split_dialog(avctx->priv_data, ptr, 0, NULL); + int duration = dialog->end - dialog->start; + len = ff_ass_add_rect(data, ptr, 0, duration, 1); if (len < 0) return len; ptr += len; @@ -52,6 +54,13 @@ static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, return avpkt->size; } +static int ass_decode_close(AVCodecContext *avctx) +{ + ff_ass_split_free(avctx->priv_data); + avctx->priv_data = NULL; + return 0; +} + AVCodec ff_ass_decoder = { .name = "ass", .long_name = NULL_IF_CONFIG_SMALL("Advanced SubStation Alpha subtitle"), @@ -59,4 +68,5 @@ AVCodec ff_ass_decoder = { .id = CODEC_ID_SSA, .init = ass_decode_init, .decode = ass_decode_frame, + .close = ass_decode_close, }; diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c index b7836ff29f..103f2ff276 100644 --- a/libavcodec/assenc.c +++ b/libavcodec/assenc.c @@ -2,20 +2,20 @@ * SSA/ASS encoder * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c index e8ab07b4cb..ff0d9eff01 100644 --- a/libavcodec/asv1.c +++ b/libavcodec/asv1.c @@ -2,20 +2,20 @@ * ASUS V1/V2 codec * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/atrac.c b/libavcodec/atrac.c index 2c39aade22..6c1b1f19ce 100644 --- a/libavcodec/atrac.c +++ b/libavcodec/atrac.c @@ -3,20 +3,20 @@ * Copyright (c) 2006-2008 Maxim Poliakovski * Copyright (c) 2006-2008 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/atrac.h b/libavcodec/atrac.h index 2223a5e620..e126935e12 100644 --- a/libavcodec/atrac.h +++ b/libavcodec/atrac.h @@ -3,20 +3,20 @@ * Copyright (c) 2009 Maxim Poliakovski * Copyright (c) 2009 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index 0ba2cf6bdd..1f4c36c141 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -3,20 +3,20 @@ * Copyright (c) 2009 Maxim Poliakovski * Copyright (c) 2009 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/atrac1data.h b/libavcodec/atrac1data.h index 7d5dbebc7f..ebebe4b105 100644 --- a/libavcodec/atrac1data.h +++ b/libavcodec/atrac1data.h @@ -3,20 +3,20 @@ * Copyright (c) 2009 Maxim Poliakovski * Copyright (c) 2009 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index accaae3d65..20ab75dfd7 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -3,20 +3,20 @@ * Copyright (c) 2006-2008 Maxim Poliakovski * Copyright (c) 2006-2008 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/atrac3data.h b/libavcodec/atrac3data.h index 9076d3ae8d..b5aa71f8ca 100644 --- a/libavcodec/atrac3data.h +++ b/libavcodec/atrac3data.h @@ -3,20 +3,20 @@ * Copyright (c) 2006-2007 Maxim Poliakovski * Copyright (c) 2006-2007 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c index 4bea30848f..e101095e40 100644 --- a/libavcodec/audioconvert.c +++ b/libavcodec/audioconvert.c @@ -2,20 +2,20 @@ * audio conversion * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/audioconvert.h b/libavcodec/audioconvert.h index e9a78fe495..5f38cca513 100644 --- a/libavcodec/audioconvert.h +++ b/libavcodec/audioconvert.h @@ -3,20 +3,20 @@ * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2008 Peter Ross * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/aura.c b/libavcodec/aura.c index e85e8225fd..18024f1c08 100644 --- a/libavcodec/aura.c +++ b/libavcodec/aura.c @@ -1,20 +1,20 @@ /* * Aura 2 decoder * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -39,6 +39,7 @@ static av_cold int aura_decode_init(AVCodecContext *avctx) if (avctx->width & 0x3) return -1; avctx->pix_fmt = PIX_FMT_YUV422P; + avcodec_get_frame_defaults(&s->frame); return 0; } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a70d8adb90..ef539a2a36 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1,20 +1,20 @@ /* * copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -204,6 +204,7 @@ enum CodecID { CODEC_ID_PRORES, CODEC_ID_JV, CODEC_ID_DFA, + CODEC_ID_8SVX_RAW, /* various PCM "codecs" */ CODEC_ID_PCM_S16LE= 0x10000, @@ -334,6 +335,7 @@ enum CodecID { CODEC_ID_BINKAUDIO_DCT, CODEC_ID_AAC_LATM, CODEC_ID_QDMC, + CODEC_ID_CELT, /* subtitle codecs */ CODEC_ID_DVD_SUBTITLE= 0x17000, @@ -345,6 +347,7 @@ enum CodecID { CODEC_ID_HDMV_PGS_SUBTITLE, CODEC_ID_DVB_TELETEXT, CODEC_ID_SRT, + CODEC_ID_MICRODVD, /* other specific kind of codecs (generally used for attachments) */ CODEC_ID_TTF= 0x18000, @@ -671,10 +674,12 @@ typedef struct RcOverride{ * Codec should fill in channel configuration and samplerate instead of container */ #define CODEC_CAP_CHANNEL_CONF 0x0400 + /** * Codec is able to deal with negative linesizes */ #define CODEC_CAP_NEG_LINESIZES 0x0800 + /** * Codec supports frame-level multithreading. */ @@ -963,7 +968,7 @@ typedef struct AVPanScan{ int64_t reordered_opaque;\ \ /**\ - * hardware accelerator private data (Libav-allocated)\ + * hardware accelerator private data (FFmpeg allocated)\ * - encoding: unused\ * - decoding: Set by libavcodec\ */\ @@ -996,6 +1001,44 @@ typedef struct AVPanScan{ * - decoding: Set by libavcodec.\ */\ void *thread_opaque;\ +\ + /**\ + * frame timestamp estimated using various heuristics, in stream time base\ + * - encoding: unused\ + * - decoding: set by libavcodec, read by user.\ + */\ + int64_t best_effort_timestamp;\ +\ + /**\ + * reordered pos from the last AVPacket that has been input into the decoder\ + * - encoding: unused\ + * - decoding: Read by user.\ + */\ + int64_t pkt_pos;\ +\ + /**\ + * reordered sample aspect ratio for the video frame, 0/1 if unknown\unspecified + * - encoding: unused\ + * - decoding: Read by user.\ + */\ + AVRational sample_aspect_ratio;\ +\ + /**\ + * width and height of the video frame\ + * - encoding: unused\ + * - decoding: Read by user.\ + */\ + int width, height;\ +\ + /**\ + * format of the frame, -1 if unknown or unset\ + * It should be cast to the corresponding enum (enum PixelFormat\ + * for video, enum AVSampleFormat for audio)\ + * - encoding: unused\ + * - decoding: Read by user.\ + */\ + int format;\ + #define FF_QSCALE_TYPE_MPEG1 0 #define FF_QSCALE_TYPE_MPEG2 1 @@ -2568,7 +2611,7 @@ typedef struct AVCodecContext { /** * Audio channel layout. * - encoding: set by user. - * - decoding: set by libavcodec. + * - decoding: set by user, may be overwritten by libavcodec. */ int64_t channel_layout; @@ -2613,8 +2656,8 @@ typedef struct AVCodecContext { * Hardware accelerator context. * For some hardware accelerators, a global context needs to be * provided by the user. In that case, this holds display-dependent - * data Libav cannot instantiate itself. Please refer to the - * Libav HW accelerator documentation to know how to fill this + * data FFmpeg cannot instantiate itself. Please refer to the + * FFmpeg HW accelerator documentation to know how to fill this * is. e.g. for VA API, this is a struct vaapi_context. * - encoding: unused * - decoding: Set by user @@ -2838,11 +2881,24 @@ typedef struct AVCodecContext { enum AVAudioServiceType audio_service_type; /** - * Used to request a sample format from the decoder. - * - encoding: unused. + * desired sample format + * - encoding: Not used. * - decoding: Set by user. + * Decoder will decode to this format if it can. */ enum AVSampleFormat request_sample_fmt; + + /** + * Current statistics for PTS correction. + * - decoding: maintained and used by libavcodec, not intended to be used by user apps + * - encoding: unused + */ + int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far + int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far + int64_t pts_correction_last_pts; /// PTS of the last frame + int64_t pts_correction_last_dts; /// DTS of the last frame + + } AVCodecContext; /** @@ -3173,6 +3229,11 @@ uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size); +int av_packet_merge_side_data(AVPacket *pkt); + +int av_packet_split_side_data(AVPacket *pkt); + + /* resample.c */ struct ReSampleContext; @@ -3332,6 +3393,9 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int * #if FF_API_GET_PIX_FMT_NAME /** + * Return the short name for a pixel format. + * + * \see av_get_pix_fmt(), av_get_pix_fmt_string(). * @deprecated Deprecated in favor of av_get_pix_fmt_name(). */ attribute_deprecated @@ -4123,7 +4187,7 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v); /** * Logs a generic warning message about a missing feature. This function is - * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) * only, and would normally not be used by applications. * @param[in] avc a pointer to an arbitrary struct of which the first field is * a pointer to an AVClass struct @@ -4137,7 +4201,7 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample); /** * Log a generic warning message asking for a sample. This function is - * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) * only, and would normally not be used by applications. * @param[in] avc a pointer to an arbitrary struct of which the first field is * a pointer to an AVClass struct @@ -4174,7 +4238,7 @@ enum AVLockOp { * lockmgr should store/get a pointer to a user allocated mutex. It's * NULL upon AV_LOCK_CREATE and != NULL for all other ops. * - * @param cb User defined callback. Note: Libav may invoke calls to this + * @param cb User defined callback. Note: FFmpeg may invoke calls to this * callback during the call to av_lockmgr_register(). * Thus, the application must be prepared to handle that. * If cb is set to NULL the lockmgr will be unregistered. diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c index 9ed06fbeb5..9e0ddaa627 100644 --- a/libavcodec/avfft.c +++ b/libavcodec/avfft.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/avfft.h b/libavcodec/avfft.h index 91fe2f4297..be2d9c7e10 100644 --- a/libavcodec/avfft.h +++ b/libavcodec/avfft.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index e0e4df46f2..ff34285b48 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -2,26 +2,26 @@ * AVPacket functions for libavcodec * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" #include "libavutil/avassert.h" - +#include "bytestream.h" void av_destruct_packet_nofree(AVPacket *pkt) { @@ -196,3 +196,82 @@ uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, } return NULL; } + +#define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL + +int av_packet_merge_side_data(AVPacket *pkt){ + if(pkt->side_data_elems){ + int i; + uint8_t *p; + uint64_t size= pkt->size + 8LL + FF_INPUT_BUFFER_PADDING_SIZE; + AVPacket old= *pkt; + for (i=0; i<old.side_data_elems; i++) { + size += old.side_data[i].size + 5LL; + } + if (size > INT_MAX) + return AVERROR(EINVAL); + p = av_malloc(size); + if (!p) + return AVERROR(ENOMEM); + pkt->data = p; + pkt->destruct = av_destruct_packet; + pkt->size = size - FF_INPUT_BUFFER_PADDING_SIZE; + bytestream_put_buffer(&p, old.data, old.size); + for (i=old.side_data_elems-1; i>=0; i--) { + bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size); + bytestream_put_be32(&p, old.side_data[i].size); + *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128); + } + bytestream_put_be64(&p, FF_MERGE_MARKER); + av_assert0(p-pkt->data == pkt->size); + memset(p, 0, FF_INPUT_BUFFER_PADDING_SIZE); + av_free_packet(&old); + pkt->side_data_elems = 0; + pkt->side_data = NULL; + return 1; + } + return 0; +} + +int av_packet_split_side_data(AVPacket *pkt){ + if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){ + int i; + unsigned int size; + uint8_t *p= pkt->data + pkt->size - 8 - 5; + + av_dup_packet(pkt); + + for (i=1; ; i++){ + size = AV_RB32(p); + if (size>INT_MAX || p - pkt->data <= size) + return 0; + if (p[4]&128) + break; + p-= size+5; + } + + pkt->side_data = av_malloc(i * sizeof(*pkt->side_data)); + if (!pkt->side_data) + return AVERROR(ENOMEM); + + p= pkt->data + pkt->size - 8 - 5; + for (i=0; ; i++){ + size= AV_RB32(p); + av_assert0(size<=INT_MAX && p - pkt->data > size); + pkt->side_data[i].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + pkt->side_data[i].size = size; + pkt->side_data[i].type = p[4]&127; + if (!pkt->side_data[i].data) + return AVERROR(ENOMEM); + memcpy(pkt->side_data[i].data, p-size, size); + pkt->size -= size + 5; + if(p[4]&128) + break; + p-= size+5; + } + pkt->size -= 8; + pkt->side_data_elems = i+1; + return 1; + } + return 0; +} diff --git a/libavcodec/avr32/mathops.h b/libavcodec/avr32/mathops.h index 528b7adb33..85f42b594d 100644 --- a/libavcodec/avr32/mathops.h +++ b/libavcodec/avr32/mathops.h @@ -2,20 +2,20 @@ * Simple math operations * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/avs.c b/libavcodec/avs.c index 1c2682b338..06fcd5cd0e 100644 --- a/libavcodec/avs.c +++ b/libavcodec/avs.c @@ -2,20 +2,20 @@ * AVS video decoder. * Copyright (c) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -146,7 +146,9 @@ avs_decode_frame(AVCodecContext * avctx, static av_cold int avs_decode_init(AVCodecContext * avctx) { + AvsContext *const avs = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&avs->picture); return 0; } diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index d294bbfe74..3869b87aa2 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -2,20 +2,20 @@ * Bethesda VID video decoder * Copyright (C) 2007 Nicholas Tung * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -39,6 +39,7 @@ typedef struct BethsoftvidContext { static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx) { BethsoftvidContext *vid = avctx->priv_data; + avcodec_get_frame_defaults(&vid->frame); vid->frame.reference = 1; vid->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; diff --git a/libavcodec/bethsoftvideo.h b/libavcodec/bethsoftvideo.h index 5cbbdfdff0..d5b5d0a525 100644 --- a/libavcodec/bethsoftvideo.h +++ b/libavcodec/bethsoftvideo.h @@ -2,20 +2,20 @@ * Bethesda VID video decoder * Copyright (C) 2007 Nicholas Tung * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c index c97dfe2dc0..9e40b86e50 100644 --- a/libavcodec/bfi.c +++ b/libavcodec/bfi.c @@ -2,20 +2,20 @@ * Brute Force & Ignorance (BFI) video decoder * Copyright (c) 2008 Sisir Koppaka * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -34,12 +34,14 @@ typedef struct BFIContext { AVCodecContext *avctx; AVFrame frame; uint8_t *dst; + uint32_t pal[256]; } BFIContext; static av_cold int bfi_decode_init(AVCodecContext * avctx) { BFIContext *bfi = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&bfi->frame); bfi->dst = av_mallocz(avctx->width * avctx->height); return 0; } @@ -85,10 +87,13 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data, (avctx->extradata[i * 3 + j] >> 4)) << shift; pal++; } + memcpy(bfi->pal, bfi->frame.data[1], sizeof(bfi->pal)); bfi->frame.palette_has_changed = 1; } else { bfi->frame.pict_type = AV_PICTURE_TYPE_P; bfi->frame.key_frame = 0; + bfi->frame.palette_has_changed = 0; + memcpy(bfi->frame.data[1], bfi->pal, sizeof(bfi->pal)); } buf += 4; //Unpacked size, not required. diff --git a/libavcodec/bfin/config_bfin.h b/libavcodec/bfin/config_bfin.h index 0fee494cc7..f3a2c6ebc6 100644 --- a/libavcodec/bfin/config_bfin.h +++ b/libavcodec/bfin/config_bfin.h @@ -1,20 +1,20 @@ /* * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index 0db2d8baf8..5b94472326 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -4,20 +4,20 @@ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> * Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bfin/dsputil_bfin.h b/libavcodec/bfin/dsputil_bfin.h index f1a9b32d64..7edcf97b6b 100644 --- a/libavcodec/bfin/dsputil_bfin.h +++ b/libavcodec/bfin/dsputil_bfin.h @@ -3,20 +3,20 @@ * * Copyright (C) 2007 Marc Hoffman <mmh@pleasantst.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bfin/fdct_bfin.S b/libavcodec/bfin/fdct_bfin.S index 4c32436e01..0eac7a3042 100644 --- a/libavcodec/bfin/fdct_bfin.S +++ b/libavcodec/bfin/fdct_bfin.S @@ -3,20 +3,20 @@ * * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/libavcodec/bfin/idct_bfin.S b/libavcodec/bfin/idct_bfin.S index b3dedd3410..04f9159d8d 100644 --- a/libavcodec/bfin/idct_bfin.S +++ b/libavcodec/bfin/idct_bfin.S @@ -3,20 +3,20 @@ * * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/libavcodec/bfin/mathops.h b/libavcodec/bfin/mathops.h index bbee49380e..50c03160ed 100644 --- a/libavcodec/bfin/mathops.h +++ b/libavcodec/bfin/mathops.h @@ -3,20 +3,20 @@ * * Copyright (C) 2007 Marc Hoffman <mmhoffm@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * 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_BFIN_MATHOPS_H diff --git a/libavcodec/bfin/mpegvideo_bfin.c b/libavcodec/bfin/mpegvideo_bfin.c index ad68876149..0373e22ff8 100644 --- a/libavcodec/bfin/mpegvideo_bfin.c +++ b/libavcodec/bfin/mpegvideo_bfin.c @@ -3,20 +3,20 @@ * * Copyright (C) 2007 Marc Hoffman <mmh@pleasantst.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bfin/pixels_bfin.S b/libavcodec/bfin/pixels_bfin.S index 085ff46147..69b493b647 100644 --- a/libavcodec/bfin/pixels_bfin.S +++ b/libavcodec/bfin/pixels_bfin.S @@ -2,20 +2,20 @@ * Blackfin Pixel Operations * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config_bfin.h" diff --git a/libavcodec/bfin/vp3_bfin.c b/libavcodec/bfin/vp3_bfin.c index 4b08042ff3..dfe34c5b3e 100644 --- a/libavcodec/bfin/vp3_bfin.c +++ b/libavcodec/bfin/vp3_bfin.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bfin/vp3_idct_bfin.S b/libavcodec/bfin/vp3_idct_bfin.S index 4c678f1bc6..21f732c58d 100644 --- a/libavcodec/bfin/vp3_idct_bfin.S +++ b/libavcodec/bfin/vp3_idct_bfin.S @@ -3,20 +3,20 @@ * * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/libavcodec/bgmc.c b/libavcodec/bgmc.c index b8aaa8d14a..b9041d080e 100644 --- a/libavcodec/bgmc.c +++ b/libavcodec/bgmc.c @@ -2,20 +2,20 @@ * Block Gilbert-Moore decoder * Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ googlemail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bgmc.h b/libavcodec/bgmc.h index 3d5b49034d..9e386fdbdd 100644 --- a/libavcodec/bgmc.h +++ b/libavcodec/bgmc.h @@ -2,20 +2,20 @@ * Block Gilbert-Moore decoder * Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ googlemail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bink.c b/libavcodec/bink.c index e085aa54e2..ef07747dbc 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -3,20 +3,20 @@ * Copyright (c) 2009 Konstantin Shishkov * Copyright (C) 2011 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index a05b0b56b2..bf1d412ed1 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -3,20 +3,20 @@ * Copyright (c) 2007-2011 Peter Ross (pross@xvid.org) * Copyright (c) 2009 Daniel Verkamp (daniel@drv.nu) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/binkdata.h b/libavcodec/binkdata.h index db289ad3a1..2c20b4a4c1 100644 --- a/libavcodec/binkdata.h +++ b/libavcodec/binkdata.h @@ -2,20 +2,20 @@ * Bink video decoder * Copyright (C) 2009 Kostya Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/binkidct.c b/libavcodec/binkidct.c index 2326a616d5..ddb6cc1af3 100644 --- a/libavcodec/binkidct.c +++ b/libavcodec/binkidct.c @@ -2,20 +2,20 @@ * Bink IDCT algorithm * Copyright (c) 2009 Kostya Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 17b1c69c84..f0fa9652c6 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -6,20 +6,20 @@ * * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bitstream_filter.c b/libavcodec/bitstream_filter.c index b803ca4ef9..1a6ba396d2 100644 --- a/libavcodec/bitstream_filter.c +++ b/libavcodec/bitstream_filter.c @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index b7fee130bc..4c5166404b 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -2,20 +2,20 @@ * BMP image format decoder * Copyright (c) 2005 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -245,7 +245,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, buf = buf0 + 14 + ihsize; //palette location if((hsize-ihsize-14) < (colors << 2)){ // OS/2 bitmap, 3 bytes per palette entry for(i = 0; i < colors; i++) - ((uint32_t*)p->data[1])[i] = bytestream_get_le24(&buf); + ((uint32_t*)p->data[1])[i] = (0xff<<24) | bytestream_get_le24(&buf); }else{ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = bytestream_get_le32(&buf); diff --git a/libavcodec/bmp.h b/libavcodec/bmp.h index ab11523379..b24a1faf00 100644 --- a/libavcodec/bmp.h +++ b/libavcodec/bmp.h @@ -2,20 +2,20 @@ * internals for BMP codecs * Copyright (c) 2005 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index b3630f094c..3719a539f5 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -3,20 +3,20 @@ * Copyright (c) 2006, 2007 Michel Bardiaux * Copyright (c) 2009 Daniel Verkamp <daniel at drv.nu> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h index 98f00879be..b56f6ce743 100644 --- a/libavcodec/bytestream.h +++ b/libavcodec/bytestream.h @@ -2,20 +2,20 @@ * Bytestream functions * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 0b6eb02614..31296395f7 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -2,20 +2,20 @@ * Interplay C93 video decoder * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -47,6 +47,10 @@ typedef enum { static av_cold int decode_init(AVCodecContext *avctx) { + C93DecoderContext * const c93 = avctx->priv_data; + + avcodec_get_frame_defaults(&c93->pictures[0]); + avcodec_get_frame_defaults(&c93->pictures[1]); avctx->pix_fmt = PIX_FMT_PAL8; return 0; } diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index 098cd6fad9..7b5e5b1de4 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index 4708563904..0af77e426f 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index 9a73e2a54b..db49ef3e67 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -2,20 +2,20 @@ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h index eda76a8d8e..cb4ab2630b 100644 --- a/libavcodec/cavs.h +++ b/libavcodec/cavs.h @@ -2,20 +2,20 @@ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cavs_parser.c b/libavcodec/cavs_parser.c index 2cc65665b8..be32345af8 100644 --- a/libavcodec/cavs_parser.c +++ b/libavcodec/cavs_parser.c @@ -2,20 +2,20 @@ * Chinese AVS video (AVS1-P2, JiZhun profile) parser. * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cavsdata.h b/libavcodec/cavsdata.h index 210169f844..a93405d380 100644 --- a/libavcodec/cavsdata.h +++ b/libavcodec/cavsdata.h @@ -2,20 +2,20 @@ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index a9e4d37c2a..c6ccb06524 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -2,20 +2,20 @@ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c index 04e521be75..192e0f976d 100644 --- a/libavcodec/cavsdsp.c +++ b/libavcodec/cavsdsp.c @@ -5,20 +5,20 @@ * * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cavsdsp.h b/libavcodec/cavsdsp.h index b1133b7264..b41ad21bca 100644 --- a/libavcodec/cavsdsp.h +++ b/libavcodec/cavsdsp.h @@ -2,20 +2,20 @@ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cbrt_tablegen.c b/libavcodec/cbrt_tablegen.c index e92c0f1db1..e0a8e63a8b 100644 --- a/libavcodec/cbrt_tablegen.c +++ b/libavcodec/cbrt_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h index 01963a3f9d..a9d34dc75d 100644 --- a/libavcodec/cbrt_tablegen.h +++ b/libavcodec/cbrt_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 2f8e98ca3d..aae7bbbb1b 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -2,20 +2,20 @@ * CD Graphics Video Decoder * Copyright (c) 2009 Michael Tison * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -377,6 +377,5 @@ AVCodec ff_cdgraphics_decoder = { cdg_decode_end, cdg_decode_frame, CODEC_CAP_DR1, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"), }; diff --git a/libavcodec/celp_filters.c b/libavcodec/celp_filters.c index 25a6744b04..8b68c2ffef 100644 --- a/libavcodec/celp_filters.c +++ b/libavcodec/celp_filters.c @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/celp_filters.h b/libavcodec/celp_filters.h index 03d481d859..145e3d3346 100644 --- a/libavcodec/celp_filters.h +++ b/libavcodec/celp_filters.h @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c index 4ab20ad29f..09111da819 100644 --- a/libavcodec/celp_math.c +++ b/libavcodec/celp_math.c @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/celp_math.h b/libavcodec/celp_math.h index 9cd9ae238d..4cf656fb7e 100644 --- a/libavcodec/celp_math.h +++ b/libavcodec/celp_math.h @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cga_data.c b/libavcodec/cga_data.c index 2c63ff2001..160d77cde2 100644 --- a/libavcodec/cga_data.c +++ b/libavcodec/cga_data.c @@ -1,20 +1,20 @@ /* * CGA/EGA/VGA ROM data * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cga_data.h b/libavcodec/cga_data.h index 2149cfd2f1..998dccaefb 100644 --- a/libavcodec/cga_data.h +++ b/libavcodec/cga_data.h @@ -1,20 +1,20 @@ /* * CGA/EGA/VGA ROM data * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/chomp_bsf.c b/libavcodec/chomp_bsf.c index 9ed7496930..eaefaaa539 100644 --- a/libavcodec/chomp_bsf.c +++ b/libavcodec/chomp_bsf.c @@ -2,20 +2,20 @@ * Chomp bitstream filter * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index 4bda2a74eb..57657afaa4 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -2,20 +2,20 @@ * Cinepak Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -404,6 +404,7 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index e2b01e2a6a..c9b0911674 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -2,20 +2,20 @@ * Cirrus Logic AccuPak (CLJR) codec * Copyright (c) 2003 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -118,6 +118,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, static av_cold void common_init(AVCodecContext *avctx){ CLJRContext * const a = avctx->priv_data; + avcodec_get_frame_defaults(&a->picture); avctx->coded_frame= (AVFrame*)&a->picture; a->avctx= avctx; } diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 84211a6d08..f0dee7905a 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Sascha Sommer * Copyright (c) 2005 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cookdata.h b/libavcodec/cookdata.h index e8d6ebfcb3..15e8e9519f 100644 --- a/libavcodec/cookdata.h +++ b/libavcodec/cookdata.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Sascha Sommer * Copyright (c) 2005 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/cos_tablegen.c b/libavcodec/cos_tablegen.c index 5e52c482c6..1577166a46 100644 --- a/libavcodec/cos_tablegen.c +++ b/libavcodec/cos_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c new file mode 100644 index 0000000000..3c8021748f --- /dev/null +++ b/libavcodec/crystalhd.c @@ -0,0 +1,1128 @@ +/* + * - CrystalHD decoder module - + * + * Copyright(C) 2010,2011 Philip Langdale <ffmpeg.philipl@overt.org> + * + * 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 + */ + +/* + * - Principles of Operation - + * + * The CrystalHD decoder operates at the bitstream level - which is an even + * higher level than the decoding hardware you typically see in modern GPUs. + * This means it has a very simple interface, in principle. You feed demuxed + * packets in one end and get decoded picture (fields/frames) out the other. + * + * Of course, nothing is ever that simple. Due, at the very least, to b-frame + * dependencies in the supported formats, the hardware has a delay between + * when a packet goes in, and when a picture comes out. Furthermore, this delay + * is not just a function of time, but also one of the dependency on additional + * frames being fed into the decoder to satisfy the b-frame dependencies. + * + * As such, a pipeline will build up that is roughly equivalent to the required + * DPB for the file being played. If that was all it took, things would still + * be simple - so, of course, it isn't. + * + * The hardware has a way of indicating that a picture is ready to be copied out, + * but this is unreliable - and sometimes the attempt will still fail so, based + * on testing, the code will wait until 3 pictures are ready before starting + * to copy out - and this has the effect of extending the pipeline. + * + * Finally, while it is tempting to say that once the decoder starts outputing + * frames, the software should never fail to return a frame from a decode(), + * this is a hard assertion to make, because the stream may switch between + * differently encoded content (number of b-frames, interlacing, etc) which + * might require a longer pipeline than before. If that happened, you could + * deadlock trying to retrieve a frame that can't be decoded without feeding + * in additional packets. + * + * As such, the code will return in the event that a picture cannot be copied + * out, leading to an increase in the length of the pipeline. This in turn, + * means we have to be sensitive to the time it takes to decode a picture; + * We do not want to give up just because the hardware needed a little more + * time to prepare the picture! For this reason, there are delays included + * in the decode() path that ensure that, under normal conditions, the hardware + * will only fail to return a frame if it really needs additional packets to + * complete the decoding. + * + * Finally, to be explicit, we do not want the pipeline to grow without bound + * for two reasons: 1) The hardware can only buffer a finite number of packets, + * and 2) The client application may not be able to cope with arbitrarily long + * delays in the video path relative to the audio path. For example. MPlayer + * can only handle a 20 picture delay (although this is arbitrary, and needs + * to be extended to fully support the CrystalHD where the delay could be up + * to 32 pictures - consider PAFF H.264 content with 16 b-frames). + */ + +/***************************************************************************** + * Includes + ****************************************************************************/ + +#define _XOPEN_SOURCE 600 +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <libcrystalhd/bc_dts_types.h> +#include <libcrystalhd/bc_dts_defs.h> +#include <libcrystalhd/libcrystalhd_if.h> + +#include "avcodec.h" +#include "h264.h" +#include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" + +/** Timeout parameter passed to DtsProcOutput() in us */ +#define OUTPUT_PROC_TIMEOUT 50 +/** Step between fake timestamps passed to hardware in units of 100ns */ +#define TIMESTAMP_UNIT 100000 +/** Initial value in us of the wait in decode() */ +#define BASE_WAIT 10000 +/** Increment in us to adjust wait in decode() */ +#define WAIT_UNIT 1000 + + +/***************************************************************************** + * Module private data + ****************************************************************************/ + +typedef enum { + RET_ERROR = -1, + RET_OK = 0, + RET_COPY_AGAIN = 1, + RET_SKIP_NEXT_COPY = 2, + RET_COPY_NEXT_FIELD = 3, +} CopyRet; + +typedef struct OpaqueList { + struct OpaqueList *next; + uint64_t fake_timestamp; + uint64_t reordered_opaque; + uint8_t pic_type; +} OpaqueList; + +typedef struct { + AVClass *av_class; + AVCodecContext *avctx; + AVFrame pic; + HANDLE dev; + + AVCodecParserContext *parser; + + uint8_t is_70012; + uint8_t *sps_pps_buf; + uint32_t sps_pps_size; + uint8_t is_nal; + uint8_t output_ready; + uint8_t need_second_field; + uint8_t skip_next_output; + uint64_t decode_wait; + + uint64_t last_picture; + + OpaqueList *head; + OpaqueList *tail; + + /* Options */ + uint32_t sWidth; + uint8_t bframe_bug; +} CHDContext; + +static const AVOption options[] = { + { "crystalhd_downscale_width", + "Turn on downscaling to the specified width", + offsetof(CHDContext, sWidth), + FF_OPT_TYPE_INT, 0, 0, UINT32_MAX, + AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, }, + { NULL, }, +}; + + +/***************************************************************************** + * Helper functions + ****************************************************************************/ + +static inline BC_MEDIA_SUBTYPE id2subtype(CHDContext *priv, enum CodecID id) +{ + switch (id) { + case CODEC_ID_MPEG4: + return BC_MSUBTYPE_DIVX; + case CODEC_ID_MSMPEG4V3: + return BC_MSUBTYPE_DIVX311; + case CODEC_ID_MPEG2VIDEO: + return BC_MSUBTYPE_MPEG2VIDEO; + case CODEC_ID_VC1: + return BC_MSUBTYPE_VC1; + case CODEC_ID_WMV3: + return BC_MSUBTYPE_WMV3; + case CODEC_ID_H264: + return priv->is_nal ? BC_MSUBTYPE_AVC1 : BC_MSUBTYPE_H264; + default: + return BC_MSUBTYPE_INVALID; + } +} + +static inline void print_frame_info(CHDContext *priv, BC_DTS_PROC_OUT *output) +{ + av_log(priv->avctx, AV_LOG_VERBOSE, "\tYBuffSz: %u\n", output->YbuffSz); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tYBuffDoneSz: %u\n", + output->YBuffDoneSz); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tUVBuffDoneSz: %u\n", + output->UVBuffDoneSz); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tTimestamp: %"PRIu64"\n", + output->PicInfo.timeStamp); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tPicture Number: %u\n", + output->PicInfo.picture_number); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tWidth: %u\n", + output->PicInfo.width); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tHeight: %u\n", + output->PicInfo.height); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tChroma: 0x%03x\n", + output->PicInfo.chroma_format); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tPulldown: %u\n", + output->PicInfo.pulldown); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tFlags: 0x%08x\n", + output->PicInfo.flags); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tFrame Rate/Res: %u\n", + output->PicInfo.frame_rate); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tAspect Ratio: %u\n", + output->PicInfo.aspect_ratio); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tColor Primaries: %u\n", + output->PicInfo.colour_primaries); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tMetaData: %u\n", + output->PicInfo.picture_meta_payload); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tSession Number: %u\n", + output->PicInfo.sess_num); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tycom: %u\n", + output->PicInfo.ycom); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tCustom Aspect: %u\n", + output->PicInfo.custom_aspect_ratio_width_height); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tFrames to Drop: %u\n", + output->PicInfo.n_drop); + av_log(priv->avctx, AV_LOG_VERBOSE, "\tH264 Valid Fields: 0x%08x\n", + output->PicInfo.other.h264.valid); +} + + +/***************************************************************************** + * OpaqueList functions + ****************************************************************************/ + +static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque, + uint8_t pic_type) +{ + OpaqueList *newNode = av_mallocz(sizeof (OpaqueList)); + if (!newNode) { + av_log(priv->avctx, AV_LOG_ERROR, + "Unable to allocate new node in OpaqueList.\n"); + return 0; + } + if (!priv->head) { + newNode->fake_timestamp = TIMESTAMP_UNIT; + priv->head = newNode; + } else { + newNode->fake_timestamp = priv->tail->fake_timestamp + TIMESTAMP_UNIT; + priv->tail->next = newNode; + } + priv->tail = newNode; + newNode->reordered_opaque = reordered_opaque; + newNode->pic_type = pic_type; + + return newNode->fake_timestamp; +} + +/* + * The OpaqueList is built in decode order, while elements will be removed + * in presentation order. If frames are reordered, this means we must be + * able to remove elements that are not the first element. + * + * Returned node must be freed by caller. + */ +static OpaqueList *opaque_list_pop(CHDContext *priv, uint64_t fake_timestamp) +{ + OpaqueList *node = priv->head; + + if (!priv->head) { + av_log(priv->avctx, AV_LOG_ERROR, + "CrystalHD: Attempted to query non-existent timestamps.\n"); + return NULL; + } + + /* + * The first element is special-cased because we have to manipulate + * the head pointer rather than the previous element in the list. + */ + if (priv->head->fake_timestamp == fake_timestamp) { + priv->head = node->next; + + if (!priv->head->next) + priv->tail = priv->head; + + node->next = NULL; + return node; + } + + /* + * The list is processed at arm's length so that we have the + * previous element available to rewrite its next pointer. + */ + while (node->next) { + OpaqueList *current = node->next; + if (current->fake_timestamp == fake_timestamp) { + node->next = current->next; + + if (!node->next) + priv->tail = node; + + current->next = NULL; + return current; + } else { + node = current; + } + } + + av_log(priv->avctx, AV_LOG_VERBOSE, + "CrystalHD: Couldn't match fake_timestamp.\n"); + return NULL; +} + + +/***************************************************************************** + * Video decoder API function definitions + ****************************************************************************/ + +static void flush(AVCodecContext *avctx) +{ + CHDContext *priv = avctx->priv_data; + + avctx->has_b_frames = 0; + priv->last_picture = -1; + priv->output_ready = 0; + priv->need_second_field = 0; + priv->skip_next_output = 0; + priv->decode_wait = BASE_WAIT; + + if (priv->pic.data[0]) + avctx->release_buffer(avctx, &priv->pic); + + /* Flush mode 4 flushes all software and hardware buffers. */ + DtsFlushInput(priv->dev, 4); +} + + +static av_cold int uninit(AVCodecContext *avctx) +{ + CHDContext *priv = avctx->priv_data; + HANDLE device; + + device = priv->dev; + DtsStopDecoder(device); + DtsCloseDecoder(device); + DtsDeviceClose(device); + + av_parser_close(priv->parser); + + av_free(priv->sps_pps_buf); + + if (priv->pic.data[0]) + avctx->release_buffer(avctx, &priv->pic); + + if (priv->head) { + OpaqueList *node = priv->head; + while (node) { + OpaqueList *next = node->next; + av_free(node); + node = next; + } + } + + return 0; +} + + +static av_cold int init(AVCodecContext *avctx) +{ + CHDContext* priv; + BC_STATUS ret; + BC_INFO_CRYSTAL version; + BC_INPUT_FORMAT format = { + .FGTEnable = FALSE, + .Progressive = TRUE, + .OptFlags = 0x80000000 | vdecFrameRate59_94 | 0x40, + .width = avctx->width, + .height = avctx->height, + }; + + BC_MEDIA_SUBTYPE subtype; + + uint32_t mode = DTS_PLAYBACK_MODE | + DTS_LOAD_FILE_PLAY_FW | + DTS_SKIP_TX_CHK_CPB | + DTS_PLAYBACK_DROP_RPT_MODE | + DTS_SINGLE_THREADED_MODE | + DTS_DFLT_RESOLUTION(vdecRESOLUTION_1080p23_976); + + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD Init for %s\n", + avctx->codec->name); + + avctx->pix_fmt = PIX_FMT_YUYV422; + + /* Initialize the library */ + priv = avctx->priv_data; + priv->avctx = avctx; + priv->is_nal = avctx->extradata_size > 0 && *(avctx->extradata) == 1; + priv->last_picture = -1; + priv->decode_wait = BASE_WAIT; + + subtype = id2subtype(priv, avctx->codec->id); + switch (subtype) { + case BC_MSUBTYPE_AVC1: + { + uint8_t *dummy_p; + int dummy_int; + AVBitStreamFilterContext *bsfc; + + uint32_t orig_data_size = avctx->extradata_size; + uint8_t *orig_data = av_malloc(orig_data_size); + if (!orig_data) { + av_log(avctx, AV_LOG_ERROR, + "Failed to allocate copy of extradata\n"); + return AVERROR(ENOMEM); + } + memcpy(orig_data, avctx->extradata, orig_data_size); + + + bsfc = av_bitstream_filter_init("h264_mp4toannexb"); + if (!bsfc) { + av_log(avctx, AV_LOG_ERROR, + "Cannot open the h264_mp4toannexb BSF!\n"); + av_free(orig_data); + return AVERROR_BSF_NOT_FOUND; + } + av_bitstream_filter_filter(bsfc, avctx, NULL, &dummy_p, + &dummy_int, NULL, 0, 0); + av_bitstream_filter_close(bsfc); + + priv->sps_pps_buf = avctx->extradata; + priv->sps_pps_size = avctx->extradata_size; + avctx->extradata = orig_data; + avctx->extradata_size = orig_data_size; + + format.pMetaData = priv->sps_pps_buf; + format.metaDataSz = priv->sps_pps_size; + format.startCodeSz = (avctx->extradata[4] & 0x03) + 1; + } + break; + case BC_MSUBTYPE_H264: + format.startCodeSz = 4; + // Fall-through + case BC_MSUBTYPE_VC1: + case BC_MSUBTYPE_WVC1: + case BC_MSUBTYPE_WMV3: + case BC_MSUBTYPE_WMVA: + case BC_MSUBTYPE_MPEG2VIDEO: + case BC_MSUBTYPE_DIVX: + case BC_MSUBTYPE_DIVX311: + format.pMetaData = avctx->extradata; + format.metaDataSz = avctx->extradata_size; + break; + default: + av_log(avctx, AV_LOG_ERROR, "CrystalHD: Unknown codec name\n"); + return AVERROR(EINVAL); + } + format.mSubtype = subtype; + + if (priv->sWidth) { + format.bEnableScaling = 1; + format.ScalingParams.sWidth = priv->sWidth; + } + + /* Get a decoder instance */ + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: starting up\n"); + // Initialize the Link and Decoder devices + ret = DtsDeviceOpen(&priv->dev, mode); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: DtsDeviceOpen failed\n"); + goto fail; + } + + ret = DtsCrystalHDVersion(priv->dev, &version); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_VERBOSE, + "CrystalHD: DtsCrystalHDVersion failed\n"); + goto fail; + } + priv->is_70012 = version.device == 0; + + if (priv->is_70012 && + (subtype == BC_MSUBTYPE_DIVX || subtype == BC_MSUBTYPE_DIVX311)) { + av_log(avctx, AV_LOG_VERBOSE, + "CrystalHD: BCM70012 doesn't support MPEG4-ASP/DivX/Xvid\n"); + goto fail; + } + + ret = DtsSetInputFormat(priv->dev, &format); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "CrystalHD: SetInputFormat failed\n"); + goto fail; + } + + ret = DtsOpenDecoder(priv->dev, BC_STREAM_TYPE_ES); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsOpenDecoder failed\n"); + goto fail; + } + + ret = DtsSetColorSpace(priv->dev, OUTPUT_MODE422_YUY2); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsSetColorSpace failed\n"); + goto fail; + } + ret = DtsStartDecoder(priv->dev); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsStartDecoder failed\n"); + goto fail; + } + ret = DtsStartCapture(priv->dev); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsStartCapture failed\n"); + goto fail; + } + + if (avctx->codec->id == CODEC_ID_H264) { + priv->parser = av_parser_init(avctx->codec->id); + if (!priv->parser) + av_log(avctx, AV_LOG_WARNING, + "Cannot open the h.264 parser! Interlaced h.264 content " + "will not be detected reliably.\n"); + } + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Init complete.\n"); + + return 0; + + fail: + uninit(avctx); + return -1; +} + + +static inline CopyRet copy_frame(AVCodecContext *avctx, + BC_DTS_PROC_OUT *output, + void *data, int *data_size) +{ + BC_STATUS ret; + BC_DTS_STATUS decoder_status; + uint8_t trust_interlaced; + uint8_t interlaced; + + CHDContext *priv = avctx->priv_data; + int64_t pkt_pts = AV_NOPTS_VALUE; + uint8_t pic_type = 0; + + uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) == + VDEC_FLAG_BOTTOMFIELD; + uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST); + + int width = output->PicInfo.width; + int height = output->PicInfo.height; + int bwidth; + uint8_t *src = output->Ybuff; + int sStride; + uint8_t *dst; + int dStride; + + if (output->PicInfo.timeStamp != 0) { + OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp); + if (node) { + pkt_pts = node->reordered_opaque; + pic_type = node->pic_type; + av_free(node); + } else { + /* + * We will encounter a situation where a timestamp cannot be + * popped if a second field is being returned. In this case, + * each field has the same timestamp and the first one will + * cause it to be popped. To keep subsequent calculations + * simple, pic_type should be set a FIELD value - doesn't + * matter which, but I chose BOTTOM. + */ + pic_type = PICT_BOTTOM_FIELD; + } + av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n", + output->PicInfo.timeStamp); + av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n", + pic_type); + } + + ret = DtsGetDriverStatus(priv->dev, &decoder_status); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, + "CrystalHD: GetDriverStatus failed: %u\n", ret); + return RET_ERROR; + } + + /* + * For most content, we can trust the interlaced flag returned + * by the hardware, but sometimes we can't. These are the + * conditions under which we can trust the flag: + * + * 1) It's not h.264 content + * 2) The UNKNOWN_SRC flag is not set + * 3) We know we're expecting a second field + * 4) The hardware reports this picture and the next picture + * have the same picture number. + * + * Note that there can still be interlaced content that will + * fail this check, if the hardware hasn't decoded the next + * picture or if there is a corruption in the stream. (In either + * case a 0 will be returned for the next picture number) + */ + trust_interlaced = avctx->codec->id != CODEC_ID_H264 || + !(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) || + priv->need_second_field || + (decoder_status.picNumFlags & ~0x40000000) == + output->PicInfo.picture_number; + + /* + * If we got a false negative for trust_interlaced on the first field, + * we will realise our mistake here when we see that the picture number is that + * of the previous picture. We cannot recover the frame and should discard the + * second field to keep the correct number of output frames. + */ + if (output->PicInfo.picture_number == priv->last_picture && !priv->need_second_field) { + av_log(avctx, AV_LOG_WARNING, + "Incorrectly guessed progressive frame. Discarding second field\n"); + /* Returning without providing a picture. */ + return RET_OK; + } + + interlaced = (output->PicInfo.flags & VDEC_FLAG_INTERLACED_SRC) && + trust_interlaced; + + if (!trust_interlaced && (decoder_status.picNumFlags & ~0x40000000) == 0) { + av_log(avctx, AV_LOG_VERBOSE, + "Next picture number unknown. Assuming progressive frame.\n"); + } + + av_log(avctx, AV_LOG_VERBOSE, "Interlaced state: %d | trust_interlaced %d\n", + interlaced, trust_interlaced); + + if (priv->pic.data[0] && !priv->need_second_field) + avctx->release_buffer(avctx, &priv->pic); + + priv->need_second_field = interlaced && !priv->need_second_field; + + priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | + FF_BUFFER_HINTS_REUSABLE; + if (!priv->pic.data[0]) { + if (avctx->get_buffer(avctx, &priv->pic) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return RET_ERROR; + } + } + + bwidth = av_image_get_linesize(avctx->pix_fmt, width, 0); + if (priv->is_70012) { + int pStride; + + if (width <= 720) + pStride = 720; + else if (width <= 1280) + pStride = 1280; + else if (width <= 1080) + pStride = 1080; + sStride = av_image_get_linesize(avctx->pix_fmt, pStride, 0); + } else { + sStride = bwidth; + } + + dStride = priv->pic.linesize[0]; + dst = priv->pic.data[0]; + + av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n"); + + if (interlaced) { + int dY = 0; + int sY = 0; + + height /= 2; + if (bottom_field) { + av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n"); + dY = 1; + } else { + av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n"); + dY = 0; + } + + for (sY = 0; sY < height; dY++, sY++) { + memcpy(&(dst[dY * dStride]), &(src[sY * sStride]), bwidth); + dY++; + } + } else { + av_image_copy_plane(dst, dStride, src, sStride, bwidth, height); + } + + priv->pic.interlaced_frame = interlaced; + if (interlaced) + priv->pic.top_field_first = !bottom_first; + + priv->pic.pkt_pts = pkt_pts; + + if (!priv->need_second_field) { + *data_size = sizeof(AVFrame); + *(AVFrame *)data = priv->pic; + } + + /* + * Two types of PAFF content have been observed. One form causes the + * hardware to return a field pair and the other individual fields, + * even though the input is always individual fields. We must skip + * copying on the next decode() call to maintain pipeline length in + * the first case. + */ + if (!interlaced && (output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) && + (pic_type == PICT_TOP_FIELD || pic_type == PICT_BOTTOM_FIELD)) { + av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n"); + return RET_SKIP_NEXT_COPY; + } + + /* + * Testing has shown that in all cases where we don't want to return the + * full frame immediately, VDEC_FLAG_UNKNOWN_SRC is set. + */ + return priv->need_second_field && + !(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ? + RET_COPY_NEXT_FIELD : RET_OK; +} + + +static inline CopyRet receive_frame(AVCodecContext *avctx, + void *data, int *data_size) +{ + BC_STATUS ret; + BC_DTS_PROC_OUT output = { + .PicInfo.width = avctx->width, + .PicInfo.height = avctx->height, + }; + CHDContext *priv = avctx->priv_data; + HANDLE dev = priv->dev; + + *data_size = 0; + + // Request decoded data from the driver + ret = DtsProcOutputNoCopy(dev, OUTPUT_PROC_TIMEOUT, &output); + if (ret == BC_STS_FMT_CHANGE) { + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Initial format change\n"); + avctx->width = output.PicInfo.width; + avctx->height = output.PicInfo.height; + return RET_COPY_AGAIN; + } else if (ret == BC_STS_SUCCESS) { + int copy_ret = -1; + if (output.PoutFlags & BC_POUT_FLAGS_PIB_VALID) { + if (priv->last_picture == -1) { + /* + * Init to one less, so that the incrementing code doesn't + * need to be special-cased. + */ + priv->last_picture = output.PicInfo.picture_number - 1; + } + + if (avctx->codec->id == CODEC_ID_MPEG4 && + output.PicInfo.timeStamp == 0 && priv->bframe_bug) { + av_log(avctx, AV_LOG_VERBOSE, + "CrystalHD: Not returning packed frame twice.\n"); + priv->last_picture++; + DtsReleaseOutputBuffs(dev, NULL, FALSE); + return RET_COPY_AGAIN; + } + + print_frame_info(priv, &output); + + if (priv->last_picture + 1 < output.PicInfo.picture_number) { + av_log(avctx, AV_LOG_WARNING, + "CrystalHD: Picture Number discontinuity\n"); + /* + * Have we lost frames? If so, we need to shrink the + * pipeline length appropriately. + * + * XXX: I have no idea what the semantics of this situation + * are so I don't even know if we've lost frames or which + * ones. + * + * In any case, only warn the first time. + */ + priv->last_picture = output.PicInfo.picture_number - 1; + } + + copy_ret = copy_frame(avctx, &output, data, data_size); + if (*data_size > 0) { + avctx->has_b_frames--; + priv->last_picture++; + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Pipeline length: %u\n", + avctx->has_b_frames); + } + } else { + /* + * An invalid frame has been consumed. + */ + av_log(avctx, AV_LOG_ERROR, "CrystalHD: ProcOutput succeeded with " + "invalid PIB\n"); + avctx->has_b_frames--; + copy_ret = RET_OK; + } + DtsReleaseOutputBuffs(dev, NULL, FALSE); + + return copy_ret; + } else if (ret == BC_STS_BUSY) { + return RET_COPY_AGAIN; + } else { + av_log(avctx, AV_LOG_ERROR, "CrystalHD: ProcOutput failed %d\n", ret); + return RET_ERROR; + } +} + + +static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) +{ + BC_STATUS ret; + BC_DTS_STATUS decoder_status; + CopyRet rec_ret; + CHDContext *priv = avctx->priv_data; + HANDLE dev = priv->dev; + int len = avpkt->size; + uint8_t pic_type = 0; + + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n"); + + if (avpkt->size == 7 && !priv->bframe_bug) { + /* + * The use of a drop frame triggers the bug + */ + av_log(avctx, AV_LOG_INFO, + "CrystalHD: Enabling work-around for packed b-frame bug\n"); + priv->bframe_bug = 1; + } else if (avpkt->size == 8 && priv->bframe_bug) { + /* + * Delay frames don't trigger the bug + */ + av_log(avctx, AV_LOG_INFO, + "CrystalHD: Disabling work-around for packed b-frame bug\n"); + priv->bframe_bug = 0; + } + + if (len) { + int32_t tx_free = (int32_t)DtsTxFreeSize(dev); + + if (priv->parser) { + uint8_t *pout; + int psize; + const uint8_t *in_data = avpkt->data; + int in_len = len; + H264Context *h = priv->parser->priv_data; + + while (in_len) { + int index; + index = av_parser_parse2(priv->parser, avctx, &pout, &psize, + in_data, in_len, avctx->pkt->pts, + avctx->pkt->dts, 0); + in_data += index; + in_len -= index; + } + av_log(avctx, AV_LOG_VERBOSE, + "CrystalHD: parser picture type %d\n", + h->s.picture_structure); + pic_type = h->s.picture_structure; + } + + if (len < tx_free - 1024) { + /* + * Despite being notionally opaque, either libcrystalhd or + * the hardware itself will mangle pts values that are too + * small or too large. The docs claim it should be in units + * of 100ns. Given that we're nominally dealing with a black + * box on both sides, any transform we do has no guarantee of + * avoiding mangling so we need to build a mapping to values + * we know will not be mangled. + */ + uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type); + if (!pts) { + return AVERROR(ENOMEM); + } + av_log(priv->avctx, AV_LOG_VERBOSE, + "input \"pts\": %"PRIu64"\n", pts); + ret = DtsProcInput(dev, avpkt->data, len, pts, 0); + if (ret == BC_STS_BUSY) { + av_log(avctx, AV_LOG_WARNING, + "CrystalHD: ProcInput returned busy\n"); + usleep(BASE_WAIT); + return AVERROR(EBUSY); + } else if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, + "CrystalHD: ProcInput failed: %u\n", ret); + return -1; + } + avctx->has_b_frames++; + } else { + av_log(avctx, AV_LOG_WARNING, "CrystalHD: Input buffer full\n"); + len = 0; // We didn't consume any bytes. + } + } else { + av_log(avctx, AV_LOG_INFO, "CrystalHD: No more input data\n"); + } + + if (priv->skip_next_output) { + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Skipping next output.\n"); + priv->skip_next_output = 0; + avctx->has_b_frames--; + return len; + } + + ret = DtsGetDriverStatus(dev, &decoder_status); + if (ret != BC_STS_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed\n"); + return -1; + } + + /* + * No frames ready. Don't try to extract. + * + * Empirical testing shows that ReadyListCount can be a damn lie, + * and ProcOut still fails when count > 0. The same testing showed + * that two more iterations were needed before ProcOutput would + * succeed. + */ + if (priv->output_ready < 2) { + if (decoder_status.ReadyListCount != 0) + priv->output_ready++; + usleep(BASE_WAIT); + av_log(avctx, AV_LOG_INFO, "CrystalHD: Filling pipeline.\n"); + return len; + } else if (decoder_status.ReadyListCount == 0) { + /* + * After the pipeline is established, if we encounter a lack of frames + * that probably means we're not giving the hardware enough time to + * decode them, so start increasing the wait time at the end of a + * decode call. + */ + usleep(BASE_WAIT); + priv->decode_wait += WAIT_UNIT; + av_log(avctx, AV_LOG_INFO, "CrystalHD: No frames ready. Returning\n"); + return len; + } + + do { + rec_ret = receive_frame(avctx, data, data_size); + if (rec_ret == RET_OK && *data_size == 0) { + /* + * This case is for when the encoded fields are stored + * separately and we get a separate avpkt for each one. To keep + * the pipeline stable, we should return nothing and wait for + * the next time round to grab the second field. + * H.264 PAFF is an example of this. + */ + av_log(avctx, AV_LOG_VERBOSE, "Returning after first field.\n"); + avctx->has_b_frames--; + } else if (rec_ret == RET_COPY_NEXT_FIELD) { + /* + * This case is for when the encoded fields are stored in a + * single avpkt but the hardware returns then separately. Unless + * we grab the second field before returning, we'll slip another + * frame in the pipeline and if that happens a lot, we're sunk. + * So we have to get that second field now. + * Interlaced mpeg2 and vc1 are examples of this. + */ + av_log(avctx, AV_LOG_VERBOSE, "Trying to get second field.\n"); + while (1) { + usleep(priv->decode_wait); + ret = DtsGetDriverStatus(dev, &decoder_status); + if (ret == BC_STS_SUCCESS && + decoder_status.ReadyListCount > 0) { + rec_ret = receive_frame(avctx, data, data_size); + if ((rec_ret == RET_OK && *data_size > 0) || + rec_ret == RET_ERROR) + break; + } + } + av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Got second field.\n"); + } else if (rec_ret == RET_SKIP_NEXT_COPY) { + /* + * Two input packets got turned into a field pair. Gawd. + */ + av_log(avctx, AV_LOG_VERBOSE, + "Don't output on next decode call.\n"); + priv->skip_next_output = 1; + } + /* + * If rec_ret == RET_COPY_AGAIN, that means that either we just handled + * a FMT_CHANGE event and need to go around again for the actual frame, + * we got a busy status and need to try again, or we're dealing with + * packed b-frames, where the hardware strangely returns the packed + * p-frame twice. We choose to keep the second copy as it carries the + * valid pts. + */ + } while (rec_ret == RET_COPY_AGAIN); + usleep(priv->decode_wait); + return len; +} + + +#if CONFIG_H264_CRYSTALHD_DECODER +static AVClass h264_class = { + "h264_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_h264_crystalhd_decoder = { + .name = "h264_crystalhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H264, + .priv_data_size = sizeof(CHDContext), + .init = init, + .close = uninit, + .decode = decode, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (CrystalHD acceleration)"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &h264_class, +}; +#endif + +#if CONFIG_MPEG2_CRYSTALHD_DECODER +static AVClass mpeg2_class = { + "mpeg2_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_mpeg2_crystalhd_decoder = { + .name = "mpeg2_crystalhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG2VIDEO, + .priv_data_size = sizeof(CHDContext), + .init = init, + .close = uninit, + .decode = decode, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Video (CrystalHD acceleration)"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &mpeg2_class, +}; +#endif + +#if CONFIG_MPEG4_CRYSTALHD_DECODER +static AVClass mpeg4_class = { + "mpeg4_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_mpeg4_crystalhd_decoder = { + .name = "mpeg4_crystalhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG4, + .priv_data_size = sizeof(CHDContext), + .init = init, + .close = uninit, + .decode = decode, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Part 2 (CrystalHD acceleration)"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &mpeg4_class, +}; +#endif + +#if CONFIG_MSMPEG4_CRYSTALHD_DECODER +static AVClass msmpeg4_class = { + "msmpeg4_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_msmpeg4_crystalhd_decoder = { + .name = "msmpeg4_crystalhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSMPEG4V3, + .priv_data_size = sizeof(CHDContext), + .init = init, + .close = uninit, + .decode = decode, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Part 2 Microsoft variant version 3 (CrystalHD acceleration)"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &msmpeg4_class, +}; +#endif + +#if CONFIG_VC1_CRYSTALHD_DECODER +static AVClass vc1_class = { + "vc1_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_vc1_crystalhd_decoder = { + .name = "vc1_crystalhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VC1, + .priv_data_size = sizeof(CHDContext), + .init = init, + .close = uninit, + .decode = decode, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 (CrystalHD acceleration)"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &vc1_class, +}; +#endif + +#if CONFIG_WMV3_CRYSTALHD_DECODER +static AVClass wmv3_class = { + "wmv3_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_wmv3_crystalhd_decoder = { + .name = "wmv3_crystalhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WMV3, + .priv_data_size = sizeof(CHDContext), + .init = init, + .close = uninit, + .decode = decode, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 (CrystalHD acceleration)"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &wmv3_class, +}; +#endif diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c index 3518929c18..9255503e05 100644 --- a/libavcodec/cscd.c +++ b/libavcodec/cscd.c @@ -2,20 +2,20 @@ * CamStudio decoder * Copyright (c) 2006 Reimar Doeffinger * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> @@ -231,6 +231,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { return 1; } c->bpp = avctx->bits_per_coded_sample; + avcodec_get_frame_defaults(&c->pic); c->pic.data[0] = NULL; c->linelen = avctx->width * avctx->bits_per_coded_sample / 8; c->height = avctx->height; diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c index ecdec17439..1c665aefc8 100644 --- a/libavcodec/cyuv.c +++ b/libavcodec/cyuv.c @@ -6,20 +6,20 @@ * * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -53,6 +53,7 @@ static av_cold int cyuv_decode_init(AVCodecContext *avctx) return -1; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV411P; + avcodec_get_frame_defaults(&s->frame); return 0; } diff --git a/libavcodec/dca.c b/libavcodec/dca.c index a9b2c9b0c9..0235a57a59 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -5,20 +5,20 @@ * Copyright (C) 2006 Benjamin Larsson * Copyright (C) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1791,6 +1791,10 @@ static int dca_decode_frame(AVCodecContext * avctx, s->output = DCA_STEREO; avctx->channel_layout = AV_CH_LAYOUT_STEREO; } + else if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) { + static const int8_t dca_channel_order_native[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; + s->channel_order_tab = dca_channel_order_native; + } } else { av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode); return -1; @@ -1798,7 +1802,7 @@ static int dca_decode_frame(AVCodecContext * avctx, /* There is nothing that prevents a dts frame to change channel configuration - but Libav doesn't support that so only set the channels if it is previously + but FFmpeg doesn't support that so only set the channels if it is previously unset. Ideally during the first probe for channels the crc should be checked and only set avctx->channels when the crc is ok. Right now the decoder could set the channels based on a broken first frame.*/ diff --git a/libavcodec/dca.h b/libavcodec/dca.h index 8ea6049e0d..02c0a51ea8 100644 --- a/libavcodec/dca.h +++ b/libavcodec/dca.h @@ -5,20 +5,20 @@ * Copyright (C) 2006 Benjamin Larsson * Copyright (C) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 70a3e989ba..a956e7506b 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -5,20 +5,20 @@ * Copyright (C) 2006 Benjamin Larsson * Copyright (C) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h index ed3ec4ee52..e8a31fd0a1 100644 --- a/libavcodec/dcadata.h +++ b/libavcodec/dcadata.h @@ -3,20 +3,20 @@ * Copyright (C) 2004 Gildas Bazin * Copyright (c) 2006 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dcadsp.c b/libavcodec/dcadsp.c index 14932e6786..dd4994d276 100644 --- a/libavcodec/dcadsp.c +++ b/libavcodec/dcadsp.c @@ -2,20 +2,20 @@ * Copyright (c) 2004 Gildas Bazin * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dcadsp.h b/libavcodec/dcadsp.h index 3c6f1f9a9f..bb157f7650 100644 --- a/libavcodec/dcadsp.h +++ b/libavcodec/dcadsp.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c new file mode 100644 index 0000000000..2b61bec98c --- /dev/null +++ b/libavcodec/dcaenc.c @@ -0,0 +1,587 @@ +/* + * DCA encoder + * Copyright (C) 2008 Alexander E. Patrakov + * 2010 Benjamin Larsson + * 2011 Xiang Wang + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "libavutil/avassert.h" +#include "libavutil/audioconvert.h" +#include "avcodec.h" +#include "get_bits.h" +#include "put_bits.h" +#include "dcaenc.h" +#include "dcadata.h" + +#undef NDEBUG + +#define MAX_CHANNELS 6 +#define DCA_SUBBANDS_32 32 +#define DCA_MAX_FRAME_SIZE 16383 +#define DCA_HEADER_SIZE 13 + +#define DCA_SUBBANDS 32 ///< Subband activity count +#define QUANTIZER_BITS 16 +#define SUBFRAMES 1 +#define SUBSUBFRAMES 4 +#define PCM_SAMPLES (SUBFRAMES*SUBSUBFRAMES*8) +#define LFE_BITS 8 +#define LFE_INTERPOLATION 64 +#define LFE_PRESENT 2 +#define LFE_MISSING 0 + +static const int8_t dca_lfe_index[] = { + 1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3 +}; + +static const int8_t dca_channel_reorder_lfe[][9] = { + { 0, -1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 1, 2, 0, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, 2, -1, -1, -1, -1, -1 }, + { 1, 2, 0, -1, 3, -1, -1, -1, -1 }, + { 0, 1, -1, 2, 3, -1, -1, -1, -1 }, + { 1, 2, 0, -1, 3, 4, -1, -1, -1 }, + { 2, 3, -1, 0, 1, 4, 5, -1, -1 }, + { 1, 2, 0, -1, 3, 4, 5, -1, -1 }, + { 0, -1, 4, 5, 2, 3, 1, -1, -1 }, + { 3, 4, 1, -1, 0, 2, 5, 6, -1 }, + { 2, 3, -1, 5, 7, 0, 1, 4, 6 }, + { 3, 4, 1, -1, 0, 2, 5, 7, 6 }, +}; + +static const int8_t dca_channel_reorder_nolfe[][9] = { + { 0, -1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 0, 1, -1, -1, -1, -1, -1, -1, -1 }, + { 1, 2, 0, -1, -1, -1, -1, -1, -1 }, + { 0, 1, 2, -1, -1, -1, -1, -1, -1 }, + { 1, 2, 0, 3, -1, -1, -1, -1, -1 }, + { 0, 1, 2, 3, -1, -1, -1, -1, -1 }, + { 1, 2, 0, 3, 4, -1, -1, -1, -1 }, + { 2, 3, 0, 1, 4, 5, -1, -1, -1 }, + { 1, 2, 0, 3, 4, 5, -1, -1, -1 }, + { 0, 4, 5, 2, 3, 1, -1, -1, -1 }, + { 3, 4, 1, 0, 2, 5, 6, -1, -1 }, + { 2, 3, 5, 7, 0, 1, 4, 6, -1 }, + { 3, 4, 1, 0, 2, 5, 7, 6, -1 }, +}; + +typedef struct { + PutBitContext pb; + int32_t history[MAX_CHANNELS][512]; /* This is a circular buffer */ + int start[MAX_CHANNELS]; + int frame_size; + int prim_channels; + int lfe_channel; + int sample_rate_code; + int scale_factor[MAX_CHANNELS][DCA_SUBBANDS_32]; + int lfe_scale_factor; + int lfe_data[SUBFRAMES*SUBSUBFRAMES*4]; + + int a_mode; ///< audio channels arrangement + int num_channel; + int lfe_state; + int lfe_offset; + const int8_t *channel_order_tab; ///< channel reordering table, lfe and non lfe + + int32_t pcm[FFMAX(LFE_INTERPOLATION, DCA_SUBBANDS_32)]; + int32_t subband[PCM_SAMPLES][MAX_CHANNELS][DCA_SUBBANDS_32]; /* [sample][channel][subband] */ +} DCAContext; + +static int32_t cos_table[128]; + +static inline int32_t mul32(int32_t a, int32_t b) +{ + int64_t r = (int64_t) a * b; + /* round the result before truncating - improves accuracy */ + return (r + 0x80000000) >> 32; +} + +/* Integer version of the cosine modulated Pseudo QMF */ + +static void qmf_init(void) +{ + int i; + int32_t c[17], s[17]; + s[0] = 0; /* sin(index * PI / 64) * 0x7fffffff */ + c[0] = 0x7fffffff; /* cos(index * PI / 64) * 0x7fffffff */ + + for (i = 1; i <= 16; i++) { + s[i] = 2 * (mul32(c[i - 1], 105372028) + mul32(s[i - 1], 2144896908)); + c[i] = 2 * (mul32(c[i - 1], 2144896908) - mul32(s[i - 1], 105372028)); + } + + for (i = 0; i < 16; i++) { + cos_table[i ] = c[i] >> 3; /* avoid output overflow */ + cos_table[i + 16] = s[16 - i] >> 3; + cos_table[i + 32] = -s[i] >> 3; + cos_table[i + 48] = -c[16 - i] >> 3; + cos_table[i + 64] = -c[i] >> 3; + cos_table[i + 80] = -s[16 - i] >> 3; + cos_table[i + 96] = s[i] >> 3; + cos_table[i + 112] = c[16 - i] >> 3; + } +} + +static int32_t band_delta_factor(int band, int sample_num) +{ + int index = band * (2 * sample_num + 1); + if (band == 0) + return 0x07ffffff; + else + return cos_table[index & 127]; +} + +static void add_new_samples(DCAContext *c, const int32_t *in, + int count, int channel) +{ + int i; + + /* Place new samples into the history buffer */ + for (i = 0; i < count; i++) { + c->history[channel][c->start[channel] + i] = in[i]; + av_assert0(c->start[channel] + i < 512); + } + c->start[channel] += count; + if (c->start[channel] == 512) + c->start[channel] = 0; + av_assert0(c->start[channel] < 512); +} + +static void qmf_decompose(DCAContext *c, int32_t in[32], int32_t out[32], + int channel) +{ + int band, i, j, k; + int32_t resp; + int32_t accum[DCA_SUBBANDS_32] = {0}; + + add_new_samples(c, in, DCA_SUBBANDS_32, channel); + + /* Calculate the dot product of the signal with the (possibly inverted) + reference decoder's response to this vector: + (0.0, 0.0, ..., 0.0, -1.0, 1.0, 0.0, ..., 0.0) + so that -1.0 cancels 1.0 from the previous step */ + + for (k = 48, j = 0, i = c->start[channel]; i < 512; k++, j++, i++) + accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] += mul32(c->history[channel][i], UnQMF[j]); + for (i = 0; i < c->start[channel]; k++, j++, i++) + accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] += mul32(c->history[channel][i], UnQMF[j]); + + resp = 0; + /* TODO: implement FFT instead of this naive calculation */ + for (band = 0; band < DCA_SUBBANDS_32; band++) { + for (j = 0; j < 32; j++) + resp += mul32(accum[j], band_delta_factor(band, j)); + + out[band] = (band & 2) ? (-resp) : resp; + } +} + +static int32_t lfe_fir_64i[512]; +static int lfe_downsample(DCAContext *c, int32_t in[LFE_INTERPOLATION]) +{ + int i, j; + int channel = c->prim_channels; + int32_t accum = 0; + + add_new_samples(c, in, LFE_INTERPOLATION, channel); + for (i = c->start[channel], j = 0; i < 512; i++, j++) + accum += mul32(c->history[channel][i], lfe_fir_64i[j]); + for (i = 0; i < c->start[channel]; i++, j++) + accum += mul32(c->history[channel][i], lfe_fir_64i[j]); + return accum; +} + +static void init_lfe_fir(void) +{ + static int initialized = 0; + int i; + if (initialized) + return; + + for (i = 0; i < 512; i++) + lfe_fir_64i[i] = lfe_fir_64[i] * (1 << 25); //float -> int32_t + initialized = 1; +} + +static void put_frame_header(DCAContext *c) +{ + /* SYNC */ + put_bits(&c->pb, 16, 0x7ffe); + put_bits(&c->pb, 16, 0x8001); + + /* Frame type: normal */ + put_bits(&c->pb, 1, 1); + + /* Deficit sample count: none */ + put_bits(&c->pb, 5, 31); + + /* CRC is not present */ + put_bits(&c->pb, 1, 0); + + /* Number of PCM sample blocks */ + put_bits(&c->pb, 7, PCM_SAMPLES-1); + + /* Primary frame byte size */ + put_bits(&c->pb, 14, c->frame_size-1); + + /* Audio channel arrangement: L + R (stereo) */ + put_bits(&c->pb, 6, c->num_channel); + + /* Core audio sampling frequency */ + put_bits(&c->pb, 4, c->sample_rate_code); + + /* Transmission bit rate: 1411.2 kbps */ + put_bits(&c->pb, 5, 0x16); /* FIXME: magic number */ + + /* Embedded down mix: disabled */ + put_bits(&c->pb, 1, 0); + + /* Embedded dynamic range flag: not present */ + put_bits(&c->pb, 1, 0); + + /* Embedded time stamp flag: not present */ + put_bits(&c->pb, 1, 0); + + /* Auxiliary data flag: not present */ + put_bits(&c->pb, 1, 0); + + /* HDCD source: no */ + put_bits(&c->pb, 1, 0); + + /* Extension audio ID: N/A */ + put_bits(&c->pb, 3, 0); + + /* Extended audio data: not present */ + put_bits(&c->pb, 1, 0); + + /* Audio sync word insertion flag: after each sub-frame */ + put_bits(&c->pb, 1, 0); + + /* Low frequency effects flag: not present or interpolation factor=64 */ + put_bits(&c->pb, 2, c->lfe_state); + + /* Predictor history switch flag: on */ + put_bits(&c->pb, 1, 1); + + /* No CRC */ + /* Multirate interpolator switch: non-perfect reconstruction */ + put_bits(&c->pb, 1, 0); + + /* Encoder software revision: 7 */ + put_bits(&c->pb, 4, 7); + + /* Copy history: 0 */ + put_bits(&c->pb, 2, 0); + + /* Source PCM resolution: 16 bits, not DTS ES */ + put_bits(&c->pb, 3, 0); + + /* Front sum/difference coding: no */ + put_bits(&c->pb, 1, 0); + + /* Surrounds sum/difference coding: no */ + put_bits(&c->pb, 1, 0); + + /* Dialog normalization: 0 dB */ + put_bits(&c->pb, 4, 0); +} + +static void put_primary_audio_header(DCAContext *c) +{ + static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }; + static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; + + int ch, i; + /* Number of subframes */ + put_bits(&c->pb, 4, SUBFRAMES - 1); + + /* Number of primary audio channels */ + put_bits(&c->pb, 3, c->prim_channels - 1); + + /* Subband activity count */ + for (ch = 0; ch < c->prim_channels; ch++) + put_bits(&c->pb, 5, DCA_SUBBANDS - 2); + + /* High frequency VQ start subband */ + for (ch = 0; ch < c->prim_channels; ch++) + put_bits(&c->pb, 5, DCA_SUBBANDS - 1); + + /* Joint intensity coding index: 0, 0 */ + for (ch = 0; ch < c->prim_channels; ch++) + put_bits(&c->pb, 3, 0); + + /* Transient mode codebook: A4, A4 (arbitrary) */ + for (ch = 0; ch < c->prim_channels; ch++) + put_bits(&c->pb, 2, 0); + + /* Scale factor code book: 7 bit linear, 7-bit sqrt table (for each channel) */ + for (ch = 0; ch < c->prim_channels; ch++) + put_bits(&c->pb, 3, 6); + + /* Bit allocation quantizer select: linear 5-bit */ + for (ch = 0; ch < c->prim_channels; ch++) + put_bits(&c->pb, 3, 6); + + /* Quantization index codebook select: dummy data + to avoid transmission of scale factor adjustment */ + + for (i = 1; i < 11; i++) + for (ch = 0; ch < c->prim_channels; ch++) + put_bits(&c->pb, bitlen[i], thr[i]); + + /* Scale factor adjustment index: not transmitted */ +} + +/** + * 8-23 bits quantization + * @param sample + * @param bits + */ +static inline uint32_t quantize(int32_t sample, int bits) +{ + av_assert0(sample < 1 << (bits - 1)); + av_assert0(sample >= -(1 << (bits - 1))); + sample &= sample & ((1 << bits) - 1); + return sample; +} + +static inline int find_scale_factor7(int64_t max_value, int bits) +{ + int i = 0, j = 128, q; + max_value = ((max_value << 15) / lossy_quant[bits + 3]) >> (bits - 1); + while (i < j) { + q = (i + j) >> 1; + if (max_value < scale_factor_quant7[q]) + j = q; + else + i = q + 1; + } + av_assert1(i < 128); + return i; +} + +static inline void put_sample7(DCAContext *c, int64_t sample, int bits, + int scale_factor) +{ + sample = (sample << 15) / ((int64_t) lossy_quant[bits + 3] * scale_factor_quant7[scale_factor]); + put_bits(&c->pb, bits, quantize((int) sample, bits)); +} + +static void put_subframe(DCAContext *c, + int32_t subband_data[8 * SUBSUBFRAMES][MAX_CHANNELS][32], + int subframe) +{ + int i, sub, ss, ch, max_value; + int32_t *lfe_data = c->lfe_data + 4 * SUBSUBFRAMES * subframe; + + /* Subsubframes count */ + put_bits(&c->pb, 2, SUBSUBFRAMES -1); + + /* Partial subsubframe sample count: dummy */ + put_bits(&c->pb, 3, 0); + + /* Prediction mode: no ADPCM, in each channel and subband */ + for (ch = 0; ch < c->prim_channels; ch++) + for (sub = 0; sub < DCA_SUBBANDS; sub++) + put_bits(&c->pb, 1, 0); + + /* Prediction VQ addres: not transmitted */ + /* Bit allocation index */ + for (ch = 0; ch < c->prim_channels; ch++) + for (sub = 0; sub < DCA_SUBBANDS; sub++) + put_bits(&c->pb, 5, QUANTIZER_BITS+3); + + if (SUBSUBFRAMES > 1) { + /* Transition mode: none for each channel and subband */ + for (ch = 0; ch < c->prim_channels; ch++) + for (sub = 0; sub < DCA_SUBBANDS; sub++) + put_bits(&c->pb, 1, 0); /* codebook A4 */ + } + + /* Determine scale_factor */ + for (ch = 0; ch < c->prim_channels; ch++) + for (sub = 0; sub < DCA_SUBBANDS; sub++) { + max_value = 0; + for (i = 0; i < 8 * SUBSUBFRAMES; i++) + max_value = FFMAX(max_value, FFABS(subband_data[i][ch][sub])); + c->scale_factor[ch][sub] = find_scale_factor7(max_value, QUANTIZER_BITS); + } + + if (c->lfe_channel) { + max_value = 0; + for (i = 0; i < 4 * SUBSUBFRAMES; i++) + max_value = FFMAX(max_value, FFABS(lfe_data[i])); + c->lfe_scale_factor = find_scale_factor7(max_value, LFE_BITS); + } + + /* Scale factors: the same for each channel and subband, + encoded according to Table D.1.2 */ + for (ch = 0; ch < c->prim_channels; ch++) + for (sub = 0; sub < DCA_SUBBANDS; sub++) + put_bits(&c->pb, 7, c->scale_factor[ch][sub]); + + /* Joint subband scale factor codebook select: not transmitted */ + /* Scale factors for joint subband coding: not transmitted */ + /* Stereo down-mix coefficients: not transmitted */ + /* Dynamic range coefficient: not transmitted */ + /* Stde information CRC check word: not transmitted */ + /* VQ encoded high frequency subbands: not transmitted */ + + /* LFE data */ + if (c->lfe_channel) { + for (i = 0; i < 4 * SUBSUBFRAMES; i++) + put_sample7(c, lfe_data[i], LFE_BITS, c->lfe_scale_factor); + put_bits(&c->pb, 8, c->lfe_scale_factor); + } + + /* Audio data (subsubframes) */ + + for (ss = 0; ss < SUBSUBFRAMES ; ss++) + for (ch = 0; ch < c->prim_channels; ch++) + for (sub = 0; sub < DCA_SUBBANDS; sub++) + for (i = 0; i < 8; i++) + put_sample7(c, subband_data[ss * 8 + i][ch][sub], QUANTIZER_BITS, c->scale_factor[ch][sub]); + + /* DSYNC */ + put_bits(&c->pb, 16, 0xffff); +} + +static void put_frame(DCAContext *c, + int32_t subband_data[PCM_SAMPLES][MAX_CHANNELS][32], + uint8_t *frame) +{ + int i; + init_put_bits(&c->pb, frame + DCA_HEADER_SIZE, DCA_MAX_FRAME_SIZE-DCA_HEADER_SIZE); + + put_primary_audio_header(c); + for (i = 0; i < SUBFRAMES; i++) + put_subframe(c, &subband_data[SUBSUBFRAMES * 8 * i], i); + + flush_put_bits(&c->pb); + c->frame_size = (put_bits_count(&c->pb) >> 3) + DCA_HEADER_SIZE; + + init_put_bits(&c->pb, frame, DCA_HEADER_SIZE); + put_frame_header(c); + flush_put_bits(&c->pb); +} + +static int encode_frame(AVCodecContext *avctx, uint8_t *frame, + int buf_size, void *data) +{ + int i, k, channel; + DCAContext *c = avctx->priv_data; + int16_t *samples = data; + int real_channel = 0; + + for (i = 0; i < PCM_SAMPLES; i ++) { /* i is the decimated sample number */ + for (channel = 0; channel < c->prim_channels + 1; channel++) { + /* Get 32 PCM samples */ + for (k = 0; k < 32; k++) { /* k is the sample number in a 32-sample block */ + c->pcm[k] = samples[avctx->channels * (32 * i + k) + channel] << 16; + } + /* Put subband samples into the proper place */ + real_channel = c->channel_order_tab[channel]; + if (real_channel >= 0) { + qmf_decompose(c, c->pcm, &c->subband[i][real_channel][0], real_channel); + } + } + } + + if (c->lfe_channel) { + for (i = 0; i < PCM_SAMPLES / 2; i++) { + for (k = 0; k < LFE_INTERPOLATION; k++) /* k is the sample number in a 32-sample block */ + c->pcm[k] = samples[avctx->channels * (LFE_INTERPOLATION*i+k) + c->lfe_offset] << 16; + c->lfe_data[i] = lfe_downsample(c, c->pcm); + } + } + + put_frame(c, c->subband, frame); + + return c->frame_size; +} + +static int encode_init(AVCodecContext *avctx) +{ + DCAContext *c = avctx->priv_data; + int i; + + c->prim_channels = avctx->channels; + c->lfe_channel = (avctx->channels == 3 || avctx->channels == 6); + + switch (avctx->channel_layout) { + case AV_CH_LAYOUT_STEREO: c->a_mode = 2; c->num_channel = 2; break; + case AV_CH_LAYOUT_5POINT0: c->a_mode = 9; c->num_channel = 9; break; + case AV_CH_LAYOUT_5POINT1: c->a_mode = 9; c->num_channel = 9; break; + case AV_CH_LAYOUT_5POINT0_BACK: c->a_mode = 9; c->num_channel = 9; break; + case AV_CH_LAYOUT_5POINT1_BACK: c->a_mode = 9; c->num_channel = 9; break; + default: + av_log(avctx, AV_LOG_ERROR, + "Only stereo, 5.0, 5.1 channel layouts supported at the moment!\n"); + return AVERROR_PATCHWELCOME; + } + + if (c->lfe_channel) { + init_lfe_fir(); + c->prim_channels--; + c->channel_order_tab = dca_channel_reorder_lfe[c->a_mode]; + c->lfe_state = LFE_PRESENT; + c->lfe_offset = dca_lfe_index[c->a_mode]; + } else { + c->channel_order_tab = dca_channel_reorder_nolfe[c->a_mode]; + c->lfe_state = LFE_MISSING; + } + + for (i = 0; i < 16; i++) { + if (dca_sample_rates[i] && (dca_sample_rates[i] == avctx->sample_rate)) + break; + } + if (i == 16) { + av_log(avctx, AV_LOG_ERROR, "Sample rate %iHz not supported, only ", avctx->sample_rate); + for (i = 0; i < 16; i++) + av_log(avctx, AV_LOG_ERROR, "%d, ", dca_sample_rates[i]); + av_log(avctx, AV_LOG_ERROR, "supported.\n"); + return -1; + } + c->sample_rate_code = i; + + avctx->frame_size = 32 * PCM_SAMPLES; + + if (!cos_table[127]) + qmf_init(); + return 0; +} + +AVCodec ff_dca_encoder = { + .name = "dca", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_DTS, + .priv_data_size = sizeof(DCAContext), + .init = encode_init, + .encode = encode_frame, + .capabilities = CODEC_CAP_EXPERIMENTAL, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, +}; diff --git a/libavcodec/dcaenc.h b/libavcodec/dcaenc.h new file mode 100644 index 0000000000..63d03dc449 --- /dev/null +++ b/libavcodec/dcaenc.h @@ -0,0 +1,544 @@ +/* + * DCA encoder tables + * Copyright (C) 2008 Alexander E. Patrakov + * + * 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_DCAENC_H +#define AVCODEC_DCAENC_H + +/* This is a scaled version of the response of the reference decoder to + this vector of subband samples: ( 1.0 0.0 0.0 ... 0.0 ) + */ + +static const int32_t UnQMF[512] = { + 7, + 4, + -961, + -2844, + -8024, + -18978, + -32081, + -15635, + -16582, + -18359, + -17180, + -14868, + -11664, + -8051, + -4477, + -1327, + -1670, + -6019, + -11590, + -18030, + -24762, + -30965, + -35947, + -36145, + -37223, + -86311, + -57024, + -27215, + -11274, + -4684, + 42, + 108, + 188, + 250, + -1007, + -596, + -2289, + -12218, + -27191, + -124367, + -184256, + -250538, + -323499, + -397784, + -468855, + -532072, + -583000, + -618041, + -777916, + -783868, + -765968, + -724740, + -662468, + -583058, + -490548, + -401623, + -296090, + -73154, + -36711, + -7766, + -2363, + -4905, + 2388, + 2681, + 5651, + 4086, + 71110, + 139742, + 188067, + 151237, + 101355, + 309917, + 343690, + 358839, + 357555, + 334606, + 289625, + 224152, + 142063, + 48725, + 74996, + 238425, + 411666, + 584160, + 744276, + 880730, + 983272, + 1041933, + 1054396, + 789531, + 851022, + 864032, + 675431, + 418134, + 35762, + 66911, + 103502, + 136403, + -55147, + -245269, + -499595, + -808470, + -1136858, + -2010912, + -2581654, + -3151901, + -3696328, + -4196599, + -4633761, + -4993229, + -5262495, + -5436311, + -477650, + -901314, + -1308090, + -1677468, + -1985525, + -2212848, + -2341196, + -2373915, + -2269552, + -2620489, + -2173858, + -1629954, + -946595, + -193499, + 1119459, + 1138657, + 1335311, + 1126544, + 2765033, + 3139603, + 3414913, + 3599213, + 3676363, + 3448981, + 3328726, + 3111551, + 2810887, + 2428657, + 1973684, + 1457278, + 893848, + 300995, + -292521, + -867621, + -1404936, + -1871278, + -2229831, + -2440932, + -2462684, + -2255006, + -1768898, + -1079574, + 82115, + 1660302, + 3660715, + 6123610, + 8329598, + 11888744, + 15722147, + 19737089, + 25647773, + 31039399, + 36868007, + 43124253, + 49737161, + 56495958, + 63668945, + 71039511, + 78540240, + 86089058, + 93600041, + 100981151, + 108136061, + 114970055, + 121718321, + 127566038, + 132774642, + 137247294, + 140894737, + 143635018, + 145395599, + 146114032, + 145742999, + 144211606, + 141594341, + 137808404, + 132914122, + 126912246, + 120243281, + 112155281, + 103338368, + 93904953, + 83439152, + 72921548, + 62192990, + 51434918, + 40894003, + 30786726, + 21384955, + 12939112, + 5718193, + -5790, + -3959261, + -5870978, + -5475538, + -2517061, + 3247310, + 12042937, + 24076729, + 39531397, + 58562863, + 81297002, + 107826748, + 138209187, + 172464115, + 210569037, + 252468018, + 298045453, + 347168648, + 399634888, + 455137189, + 513586535, + 574537650, + 637645129, + 702597163, + 768856566, + 836022040, + 903618096, + 971159680, + 1038137214, + 1103987353, + 1168195035, + 1230223053, + 1289539180, + 1345620373, + 1397957958, + 1446063657, + 1489474689, + 1527740502, + 1560502307, + 1587383079, + 1608071145, + 1622301248, + 1629859340, + 1630584888, + 1624373875, + 1611178348, + 1591018893, + 1563948667, + 1530105004, + 1489673227, + 1442904075, + 1390107674, + 1331590427, + 1267779478, + 1199115126, + 1126053392, + 1049146257, + 968928307, + 885965976, + 800851610, + 714186243, + 626590147, + 538672486, + 451042824, + 364299927, + 279026812, + 195785029, + 115109565, + 37503924, + -36564551, + -106668063, + -172421668, + -233487283, + -289575706, + -340448569, + -385919511, + -425854915, + -460174578, + -488840702, + -511893328, + -529405118, + -541489888, + -548312207, + -550036471, + -547005316, + -539436808, + -527630488, + -512084785, + -492941605, + -470665204, + -445668379, + -418328829, + -389072810, + -358293846, + -326396227, + -293769619, + -260792276, + -227825056, + -195208961, + -163262121, + -132280748, + -102533727, + -74230062, + -47600637, + -22817785, + -25786, + 20662895, + 39167253, + 55438413, + 69453741, + 81242430, + 90795329, + 98213465, + 103540643, + 106917392, + 108861938, + 108539682, + 106780704, + 103722568, + 99043289, + 93608686, + 87266209, + 80212203, + 72590022, + 64603428, + 56362402, + 48032218, + 39749162, + 31638971, + 23814664, + 16376190, + 9409836, + 2988017, + -2822356, + -7976595, + -12454837, + -16241147, + -19331944, + -21735011, + -23468284, + -24559822, + -25042936, + -25035583, + -24429587, + -23346408, + -21860411, + -20015718, + -17025330, + -14968728, + -12487138, + -9656319, + -7846681, + -5197816, + -2621904, + -144953, + 2144746, + 3990570, + 5845884, + 7454650, + 8820394, + 9929891, + 10784445, + 11390921, + 11762056, + 11916017, + 12261189, + 12117604, + 11815303, + 11374622, + 10815301, + 10157241, + 9418799, + 8629399, + 7780776, + 7303680, + 6353499, + 5392738, + 4457895, + 3543062, + 1305978, + 1402521, + 1084092, + 965652, + -151008, + -666667, + -1032157, + -1231475, + -1319043, + -1006023, + -915720, + -773426, + -612377, + -445864, + -291068, + -161337, + -66484, + -11725, + 133453, + 388184, + 615856, + 804033, + 942377, + 1022911, + 1041247, + 995854, + 891376, + 572246, + 457992, + 316365, + 172738, + 43037, + -117662, + -98542, + -70279, + -41458, + -535790, + -959038, + -1364456, + -1502265, + -1568530, + -2378681, + -2701111, + -2976407, + -3182552, + -3314415, + -3366600, + -3337701, + -3232252, + -3054999, + 1984841, + 1925903, + 1817377, + 1669153, + 1490069, + 1292040, + 1086223, + 890983, + 699163, + 201358, + 266971, + 296990, + 198419, + 91119, + 4737, + 5936, + 2553, + 2060, + -3828, + -1664, + -4917, + -20796, + -36822, + -131247, + -154923, + -162055, + -161354, + -148762, + -125754, + -94473, + -57821, + -19096, + 15172, + 43004, + 65624, + 81354, + 89325, + 89524, + 82766, + 71075, + 55128, + 13686, + 6921, + 1449, + 420, + 785, + -215, + -179, + -113, + -49, + 6002, + 16007, + 42978, + 100662, + 171472, + 83975, + 93702, + 108813, + 111893, + 110272, + 103914, + 93973, + 81606, + 68041, + -54058, + -60695, + -65277, + -67224, + -66213, + -62082, + -55574, + -42988, + -35272, + -63735, + -33501, + -12671, + -4038, + -1232, + 5, + 7 +}; + +#endif /* AVCODEC_DCAENC_H */ diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index 254fc76a91..cbc8429e59 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -3,20 +3,20 @@ * Copyright (C) 2004 Gildas Bazin * Copyright (C) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index d0fe34e1d7..2abb05bd3b 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -2,20 +2,20 @@ * (c) 2001 Fabrice Bellard * 2007 Marc Hoffman <marc.hoffman@analog.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -195,7 +195,7 @@ static inline void mmx_emms(void) static void dct_error(const char *name, int is_idct, void (*fdct_func)(DCTELEM *block), - void (*fdct_ref)(DCTELEM *block), int form, int test) + void (*fdct_ref)(DCTELEM *block), int form, int test, const int bits) { int it, i, scale; int err_inf, v; @@ -204,6 +204,7 @@ static void dct_error(const char *name, int is_idct, int maxout=0; int blockSumErrMax=0, blockSumErr; AVLFG prng; + const int vals=1<<bits; av_lfg_init(&prng, 1); @@ -216,7 +217,7 @@ static void dct_error(const char *name, int is_idct, switch(test){ case 0: for(i=0;i<64;i++) - block1[i] = (av_lfg_get(&prng) % 512) -256; + block1[i] = (av_lfg_get(&prng) % (2*vals)) -vals; if (is_idct){ ff_ref_fdct(block1); @@ -227,10 +228,10 @@ static void dct_error(const char *name, int is_idct, case 1:{ int num = av_lfg_get(&prng) % 10 + 1; for(i=0;i<num;i++) - block1[av_lfg_get(&prng) % 64] = av_lfg_get(&prng) % 512 -256; + block1[av_lfg_get(&prng) % 64] = av_lfg_get(&prng) % (2*vals) -vals; }break; case 2: - block1[0] = av_lfg_get(&prng) % 4096 - 2048; + block1[0] = av_lfg_get(&prng) % (16*vals) - (8*vals); block1[63]= (block1[0]&1)^1; break; } @@ -328,7 +329,7 @@ static void dct_error(const char *name, int is_idct, switch(test){ case 0: for(i=0;i<64;i++) - block1[i] = av_lfg_get(&prng) % 512 -256; + block1[i] = av_lfg_get(&prng) % (2*vals) -vals; if (is_idct){ ff_ref_fdct(block1); @@ -338,10 +339,10 @@ static void dct_error(const char *name, int is_idct, break; case 1:{ case 2: - block1[0] = av_lfg_get(&prng) % 512 -256; - block1[1] = av_lfg_get(&prng) % 512 -256; - block1[2] = av_lfg_get(&prng) % 512 -256; - block1[3] = av_lfg_get(&prng) % 512 -256; + block1[0] = av_lfg_get(&prng) % (2*vals) -vals; + block1[1] = av_lfg_get(&prng) % (2*vals) -vals; + block1[2] = av_lfg_get(&prng) % (2*vals) -vals; + block1[3] = av_lfg_get(&prng) % (2*vals) -vals; }break; } @@ -493,6 +494,25 @@ static void idct248_error(const char *name, if (v > err_max) err_max = v; } +#if 0 + printf("ref=\n"); + for(i=0;i<8;i++) { + int j; + for(j=0;j<8;j++) { + printf(" %3d", img_dest1[i*8+j]); + } + printf("\n"); + } + + printf("out=\n"); + for(i=0;i<8;i++) { + int j; + for(j=0;j<8;j++) { + printf(" %3d", img_dest[i*8+j]); + } + printf("\n"); + } +#endif } printf("%s %s: err_inf=%d\n", 1 ? "IDCT248" : "DCT248", @@ -533,6 +553,7 @@ int main(int argc, char **argv) int test_idct = 0, test_248_dct = 0; int c,i; int test=1; + int bits=8; cpu_flags = av_get_cpu_flags(); ff_ref_dct_init(); @@ -563,6 +584,7 @@ int main(int argc, char **argv) } if(optind <argc) test= atoi(argv[optind]); + if(optind+1 < argc) bits= atoi(argv[optind+1]); printf("ffmpeg DCT/IDCT test\n"); @@ -571,7 +593,7 @@ int main(int argc, char **argv) } else { for (i=0;algos[i].name;i++) if (algos[i].is_idct == test_idct && !(~cpu_flags & algos[i].mm_support)) { - dct_error (algos[i].name, algos[i].is_idct, algos[i].func, algos[i].ref, algos[i].format, test); + dct_error (algos[i].name, algos[i].is_idct, algos[i].func, algos[i].ref, algos[i].format, test, bits); } } return 0; diff --git a/libavcodec/dct.c b/libavcodec/dct.c index 5c63af30a1..c30cff664e 100644 --- a/libavcodec/dct.c +++ b/libavcodec/dct.c @@ -4,20 +4,20 @@ * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * Copyright (c) 2010 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dct.h b/libavcodec/dct.h index c898856279..bb17d75d0c 100644 --- a/libavcodec/dct.h +++ b/libavcodec/dct.h @@ -4,20 +4,20 @@ * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * Copyright (c) 2010 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dct32.c b/libavcodec/dct32.c index 272e0dbf95..fb53d53ab1 100644 --- a/libavcodec/dct32.c +++ b/libavcodec/dct32.c @@ -2,20 +2,20 @@ * Template for the Discrete Cosine Transform for 32 samples * Copyright (c) 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dctref.c b/libavcodec/dctref.c index ae3dec51cd..851014b664 100644 --- a/libavcodec/dctref.c +++ b/libavcodec/dctref.c @@ -2,20 +2,20 @@ * reference discrete cosine transform (double precision) * Copyright (C) 2009 Dylan Yudaken * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dctref.h b/libavcodec/dctref.h index ba89abd752..be481f07b0 100644 --- a/libavcodec/dctref.h +++ b/libavcodec/dctref.h @@ -2,20 +2,20 @@ * reference discrete cosine transform (double precision) * Copyright (C) 2009 Dylan Yudaken * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c index 919375baf0..598fedc980 100644 --- a/libavcodec/dfa.c +++ b/libavcodec/dfa.c @@ -3,20 +3,20 @@ * Copyright (c) 2011 Konstantin Shishkov * based on work by Vladimir "VAG" Gneushev * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c index 09da1cbd56..af0d799acc 100644 --- a/libavcodec/dirac.c +++ b/libavcodec/dirac.c @@ -2,20 +2,20 @@ * Copyright (C) 2007 Marco Gerards <marco@gnu.org> * Copyright (C) 2009 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dirac.h b/libavcodec/dirac.h index 0be66c2d91..87d66ccab6 100644 --- a/libavcodec/dirac.h +++ b/libavcodec/dirac.h @@ -2,20 +2,20 @@ * Copyright (C) 2007 Marco Gerards <marco@gnu.org> * Copyright (C) 2009 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dirac_parser.c b/libavcodec/dirac_parser.c index 87c3a04b91..b407168b41 100644 --- a/libavcodec/dirac_parser.c +++ b/libavcodec/dirac_parser.c @@ -4,20 +4,20 @@ * Copyright (c) 2007-2008 Marco Gerards <marco@gnu.org> * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dnxhd_parser.c b/libavcodec/dnxhd_parser.c index 44ea8f06f5..e5a5aa09f5 100644 --- a/libavcodec/dnxhd_parser.c +++ b/libavcodec/dnxhd_parser.c @@ -2,20 +2,20 @@ * DNxHD/VC-3 parser * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c index 82d083c1e2..f628a642a5 100644 --- a/libavcodec/dnxhddata.c +++ b/libavcodec/dnxhddata.c @@ -2,20 +2,20 @@ * VC3/DNxHD data. * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -243,11 +243,11 @@ static const uint8_t dnxhd_1238_ac_index_flag[257] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -static const uint16_t dnxhd_1238_run_codes[62] = { +static const uint16_t dnxhd_1235_1238_1241_run_codes[62] = { 0, 4, 10, 11, 24, 25, 26, 27, 56, 57, 58, 59, 120, 242, 486, 487, 488, 489, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, }; -static const uint8_t dnxhd_1238_run_bits[62] = { +static const uint8_t dnxhd_1235_1238_1241_run_bits[62] = { 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, }; @@ -255,34 +255,34 @@ static const uint8_t dnxhd_1238_run[62] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, }; -static const uint8_t dnxhd_1241_dc_codes[14] = { +static const uint8_t dnxhd_1235_1241_dc_codes[14] = { 10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127, }; -static const uint8_t dnxhd_1241_dc_bits[14] = { +static const uint8_t dnxhd_1235_1241_dc_bits[14] = { 4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7, }; -static const uint16_t dnxhd_1241_ac_codes[257] = { +static const uint16_t dnxhd_1235_1241_ac_codes[257] = { 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, 494, 495, 496, 497, 498, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 16316, 16317, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, 32676, 32677, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, 32706, 32707, 32708, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, }; -static const uint8_t dnxhd_1241_ac_bits[257] = { +static const uint8_t dnxhd_1235_1241_ac_bits[257] = { 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; -static const uint8_t dnxhd_1241_ac_level[257] = { +static const uint8_t dnxhd_1235_1241_ac_level[257] = { 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 7, 22, 23, 24, 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, 10, 11, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 12, 13, 14, 15, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 1, 16, 17, 18, 19, 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 25, 26, 27, 28, 29, 30, 31, 32, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, }; -static const uint8_t dnxhd_1241_ac_run_flag[257] = { +static const uint8_t dnxhd_1235_1241_ac_run_flag[257] = { 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -static const uint8_t dnxhd_1241_ac_index_flag[257] = { +static const uint8_t dnxhd_1235_1241_ac_index_flag[257] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -static const uint8_t dnxhd_1241_run[62] = { +static const uint8_t dnxhd_1235_1241_run[62] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, }; @@ -352,14 +352,14 @@ const CIDEntry ff_dnxhd_cid_table[] = { dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, - dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run, + dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run, { 175, 185, 220, 365, 440 } }, { 1241, 1920, 1080, 1, 917504, 458752, 6, 10, dnxhd_1241_luma_weight, dnxhd_1241_chroma_weight, - dnxhd_1241_dc_codes, dnxhd_1241_dc_bits, - dnxhd_1241_ac_codes, dnxhd_1241_ac_bits, dnxhd_1241_ac_level, - dnxhd_1241_ac_run_flag, dnxhd_1241_ac_index_flag, - dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1241_run, + dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits, + dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level, + dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag, + dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run, { 185, 220 } }, { 1242, 1920, 1080, 1, 606208, 303104, 4, 8, dnxhd_1242_luma_weight, dnxhd_1242_chroma_weight, @@ -373,7 +373,7 @@ const CIDEntry ff_dnxhd_cid_table[] = { dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, - dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run, + dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run, { 185, 220 } }, { 1251, 1280, 720, 0, 458752, 458752, 4, 8, dnxhd_1251_luma_weight, dnxhd_1251_chroma_weight, diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h index df841872fc..32c77db0ef 100644 --- a/libavcodec/dnxhddata.h +++ b/libavcodec/dnxhddata.h @@ -2,20 +2,20 @@ * VC3/DNxHD decoder. * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 6928b32263..8cbe1a8111 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -2,20 +2,20 @@ * VC3/DNxHD decoder. * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -55,6 +55,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx) ctx->avctx = avctx; dsputil_init(&ctx->dsp, avctx); avctx->coded_frame = &ctx->picture; + avcodec_get_frame_defaults(&ctx->picture); ctx->picture.type = AV_PICTURE_TYPE_I; ctx->picture.key_frame = 1; return 0; diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 78da1c15e2..62bc9f0dd5 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -4,20 +4,20 @@ * * VC-3 encoder funded by the British Broadcasting Corporation * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index bb24540a9f..a968ae0223 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -4,20 +4,20 @@ * * VC-3 encoder funded by the British Broadcasting Corporation * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index af5bf8abea..ee8eb6a722 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -2,20 +2,20 @@ * Assorted DPCM codecs * Copyright (c) 2003 The ffmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 0722dd07ef..afd71cc173 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -2,20 +2,20 @@ * DPX (.dpx) image decoder * Copyright (c) 2009 Jimmy Christensen * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c index 7ae929238d..f69cfdc94e 100644 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@ -2,20 +2,20 @@ * DPX (.dpx) image encoder * Copyright (c) 2011 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -35,7 +35,7 @@ static av_cold int encode_init(AVCodecContext *avctx) DPXContext *s = avctx->priv_data; avctx->coded_frame = &s->picture; - avctx->coded_frame->pict_type = FF_I_TYPE; + avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; s->big_endian = 1; @@ -73,8 +73,7 @@ do { \ else AV_WL32(p, value); \ } while(0) -static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, - uint8_t *dst) +static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst) { DPXContext *s = avctx->priv_data; const uint8_t *src = pic->data[0]; @@ -99,8 +98,7 @@ static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, } } -static int encode_frame(AVCodecContext *avctx, unsigned char *buf, - int buf_size, void *data) +static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data) { DPXContext *s = avctx->priv_data; int size; @@ -135,7 +133,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, write32(buf + 1628, avctx->sample_aspect_ratio.num); write32(buf + 1632, avctx->sample_aspect_ratio.den); - switch (s->bits_per_component) { + switch(s->bits_per_component) { case 8: case 16: size = avpicture_layout(data, avctx->pix_fmt, diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c index 643aed946b..f12560714a 100644 --- a/libavcodec/dsicinav.c +++ b/libavcodec/dsicinav.c @@ -2,20 +2,20 @@ * Delphine Software International CIN Audio/Video Decoders * Copyright (c) 2006 Gregory Montoir (cyx@users.sourceforge.net) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -94,6 +94,7 @@ static av_cold int cinvideo_decode_init(AVCodecContext *avctx) cin->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&cin->frame); cin->frame.data[0] = NULL; cin->bitmap_size = avctx->width * avctx->height; diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 4389289d82..0e596b1b01 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -5,20 +5,20 @@ * * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -38,7 +38,6 @@ #include "config.h" #include "ac3dec.h" #include "vorbis.h" -#include "png.h" uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; uint32_t ff_squareTbl[512] = {0, }; @@ -1924,17 +1923,6 @@ static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){ dst[i+0] += src[i+0]; } -static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ - long i; - for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ - long a = *(long*)(src1+i); - long b = *(long*)(src2+i); - *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80); - } - for(; i<w; i++) - dst[i] = src1[i]+src2[i]; -} - static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ long i; #if !HAVE_FAST_UNALIGNED @@ -2837,7 +2825,7 @@ int ff_check_alignment(void){ "Compiler did not align stack variables. Libavcodec has been miscompiled\n" "and may be very slow or crash. This is not a bug in libavcodec,\n" "but in the compiler. You may try recompiling using gcc >= 4.2.\n" - "Do not report crashes to Libav developers.\n"); + "Do not report crashes to FFmpeg developers.\n"); #endif did_fail=1; } @@ -3080,7 +3068,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c; c->add_bytes= add_bytes_c; - c->add_bytes_l2= add_bytes_l2_c; c->diff_bytes= diff_bytes_c; c->add_hfyu_median_prediction= add_hfyu_median_prediction_c; c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; @@ -3088,9 +3075,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c; c->bswap_buf= bswap_buf; c->bswap16_buf = bswap16_buf; -#if CONFIG_PNG_DECODER - c->add_png_paeth_prediction= ff_add_png_paeth_prediction; -#endif if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { c->h263_h_loop_filter= h263_h_loop_filter_c; diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index cfc574aebb..f2c36b37e8 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -130,7 +130,7 @@ void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, /* minimum alignment rules ;) If you notice errors in the align stuff, need more alignment for some ASM code for some CPU or need to use a function with less aligned data then send a mail -to the libav-devel mailing list, ... +to the ffmpeg-devel mailing list, ... !warning These alignments might not match reality, (missing attribute((align)) stuff somewhere possible). @@ -371,7 +371,6 @@ typedef struct DSPContext { /* huffyuv specific */ void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w); - void (*add_bytes_l2)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 16*/, int w); void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w); /** * subtract huffyuv's variant of median prediction @@ -382,7 +381,6 @@ typedef struct DSPContext { int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left); void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha); /* this might write to dst[w] */ - void (*add_png_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp); void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w); void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len); @@ -647,8 +645,10 @@ void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx); void ff_mlp_init(DSPContext* c, AVCodecContext *avctx); void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx); + #if ARCH_ARM + #if HAVE_NEON # define STRIDE_ALIGN 16 #endif diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index 8ca6d3e414..1d73a7d858 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -5,20 +5,20 @@ * * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -79,10 +79,10 @@ static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *src, int dstS /* draw the edges of width 'w' of an image of size width, height */ //FIXME check that this is ok for mpeg4 interlaced -static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, int w, int sides) +static void FUNCC(draw_edges)(uint8_t *p_buf, int p_wrap, int width, int height, int w, int sides) { - pixel *buf = (pixel*)_buf; - int wrap = _wrap / sizeof(pixel); + pixel *buf = (pixel*)p_buf; + int wrap = p_wrap / sizeof(pixel); pixel *ptr, *last_line; int i; @@ -192,12 +192,12 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, i } } -static void FUNCC(add_pixels8)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size) +static void FUNCC(add_pixels8)(uint8_t *restrict p_pixels, DCTELEM *p_block, int line_size) { int i; - pixel *restrict pixels = (pixel *restrict)_pixels; - dctcoef *block = (dctcoef*)_block; - line_size /= sizeof(pixel); + pixel *restrict pixels = (pixel *restrict)p_pixels; + dctcoef *block = (dctcoef*)p_block; + line_size >>= sizeof(pixel)-1; for(i=0;i<8;i++) { pixels[0] += block[0]; @@ -213,12 +213,12 @@ static void FUNCC(add_pixels8)(uint8_t *restrict _pixels, DCTELEM *_block, int l } } -static void FUNCC(add_pixels4)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size) +static void FUNCC(add_pixels4)(uint8_t *restrict p_pixels, DCTELEM *p_block, int line_size) { int i; - pixel *restrict pixels = (pixel *restrict)_pixels; - dctcoef *block = (dctcoef*)_block; - line_size /= sizeof(pixel); + pixel *restrict pixels = (pixel *restrict)p_pixels; + dctcoef *block = (dctcoef*)p_block; + line_size >>= sizeof(pixel)-1; for(i=0;i<4;i++) { pixels[0] += block[0]; @@ -582,12 +582,12 @@ static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, const uint8 FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ }\ \ -static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *_block, const uint8_t *_pixels, int line_size, int h)\ +static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *p_block, const uint8_t *p_pixels, int line_size, int h)\ {\ int i, a0, b0, a1, b1;\ - pixel *block = (pixel*)_block;\ - const pixel *pixels = (const pixel*)_pixels;\ - line_size /= sizeof(pixel);\ + pixel *block = (pixel*)p_block;\ + const pixel *pixels = (const pixel*)p_pixels;\ + line_size >>= sizeof(pixel)-1;\ a0= pixels[0];\ b0= pixels[1] + 2;\ a0 += b0;\ @@ -769,15 +769,15 @@ static void FUNCC(put_no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *a, const u } #define H264_CHROMA_MC(OPNAME, OP)\ -static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ +static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *p_dst/*align 8*/, uint8_t *p_src/*align 1*/, int stride, int h, int x, int y){\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ const int A=(8-x)*(8-y);\ const int B=( x)*(8-y);\ const int C=(8-x)*( y);\ const int D=( x)*( y);\ int i;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ \ assert(x<8 && y<8 && x>=0 && y>=0);\ \ @@ -800,15 +800,15 @@ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t * }\ }\ \ -static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ +static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *p_dst/*align 8*/, uint8_t *p_src/*align 1*/, int stride, int h, int x, int y){\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ const int A=(8-x)*(8-y);\ const int B=( x)*(8-y);\ const int C=(8-x)*( y);\ const int D=( x)*( y);\ int i;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ \ assert(x<8 && y<8 && x>=0 && y>=0);\ \ @@ -835,15 +835,15 @@ static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t * }\ }\ \ -static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ +static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *p_dst/*align 8*/, uint8_t *p_src/*align 1*/, int stride, int h, int x, int y){\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ const int A=(8-x)*(8-y);\ const int B=( x)*(8-y);\ const int C=(8-x)*( y);\ const int D=( x)*( y);\ int i;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ \ assert(x<8 && y<8 && x>=0 && y>=0);\ \ @@ -887,14 +887,14 @@ H264_CHROMA_MC(avg_ , op_avg) #undef op_put #define H264_LOWPASS(OPNAME, OP, OP2) \ -static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\ +static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\ const int h=2;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ for(i=0; i<h; i++)\ {\ OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\ @@ -904,14 +904,14 @@ static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *_dst, uint8_ }\ }\ \ -static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\ +static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\ const int w=2;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ for(i=0; i<w; i++)\ {\ const int srcB= src[-2*srcStride];\ @@ -928,16 +928,16 @@ static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *_dst, uint8_ }\ }\ \ -static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\ +static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *p_dst, int16_t *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\ const int h=2;\ const int w=2;\ const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ src -= 2*srcStride;\ for(i=0; i<h+5; i++)\ {\ @@ -962,14 +962,14 @@ static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *_dst, int16 tmp++;\ }\ }\ -static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\ const int h=4;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ for(i=0; i<h; i++)\ {\ OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\ @@ -981,14 +981,14 @@ static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, uint8_t *_src, i }\ }\ \ -static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\ const int w=4;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ for(i=0; i<w; i++)\ {\ const int srcB= src[-2*srcStride];\ @@ -1009,16 +1009,16 @@ static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *_dst, uint8_t *_src, i }\ }\ \ -static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *p_dst, int16_t *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\ const int h=4;\ const int w=4;\ const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ src -= 2*srcStride;\ for(i=0; i<h+5; i++)\ {\ @@ -1050,14 +1050,14 @@ static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, int16_t *tmp, u }\ }\ \ -static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\ const int h=8;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ for(i=0; i<h; i++)\ {\ OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\ @@ -1073,14 +1073,14 @@ static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, uint8_t *_src, i }\ }\ \ -static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\ const int w=8;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ for(i=0; i<w; i++)\ {\ const int srcB= src[-2*srcStride];\ @@ -1109,16 +1109,16 @@ static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *_dst, uint8_t *_src, i }\ }\ \ -static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *p_dst, int16_t *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\ const int h=8;\ const int w=8;\ const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\ INIT_CLIP\ int i;\ - pixel *dst = (pixel*)_dst;\ - pixel *src = (pixel*)_src;\ - dstStride /= sizeof(pixel);\ - srcStride /= sizeof(pixel);\ + pixel *dst = (pixel*)p_dst;\ + pixel *src = (pixel*)p_src;\ + dstStride >>= sizeof(pixel)-1;\ + srcStride >>= sizeof(pixel)-1;\ src -= 2*srcStride;\ for(i=0; i<h+5; i++)\ {\ @@ -1389,3 +1389,4 @@ static void FUNCC(clear_blocks)(DCTELEM *blocks) { memset(blocks, 0, sizeof(dctcoef)*6*64); } + diff --git a/libavcodec/dump_extradata_bsf.c b/libavcodec/dump_extradata_bsf.c index ba77b15c6b..9499d6d8d8 100644 --- a/libavcodec/dump_extradata_bsf.c +++ b/libavcodec/dump_extradata_bsf.c @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 4fde2a7899..d6c49c86cb 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -16,20 +16,20 @@ * Many thanks to Dan Dennedy <dan@dennedy.org> for providing wealth * of DV technical info. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -774,7 +774,7 @@ static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, i method suggested in SMPTE 314M Table 22, and an improved method. The SMPTE method is very conservative; it assigns class 3 (i.e. severe quantization) to any block where the largest AC - component is greater than 36. Libav's DV encoder tracks AC bit + component is greater than 36. FFmpeg's DV encoder tracks AC bit consumption precisely, so there is no need to bias most blocks towards strongly lossy compression. Instead, we assign class 2 to most blocks, and use class 3 only when strictly necessary @@ -782,7 +782,7 @@ static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, i #if 0 /* SMPTE spec method */ static const int classes[] = {12, 24, 36, 0xffff}; -#else /* improved Libav method */ +#else /* improved FFmpeg method */ static const int classes[] = {-1, -1, 255, 0xffff}; #endif int max = classes[0]; @@ -1080,6 +1080,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, if (s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); + avcodec_get_frame_defaults(&s->picture); s->picture.reference = 0; s->picture.key_frame = 1; s->picture.pict_type = AV_PICTURE_TYPE_I; diff --git a/libavcodec/dv_tablegen.c b/libavcodec/dv_tablegen.c index f463550365..5d3793e11d 100644 --- a/libavcodec/dv_tablegen.c +++ b/libavcodec/dv_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dv_tablegen.h b/libavcodec/dv_tablegen.h index 4fa8d91374..678be73940 100644 --- a/libavcodec/dv_tablegen.h +++ b/libavcodec/dv_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dv_vlc_data.h b/libavcodec/dv_vlc_data.h index b5c1ddecb4..c23c564613 100644 --- a/libavcodec/dv_vlc_data.h +++ b/libavcodec/dv_vlc_data.h @@ -2,20 +2,20 @@ * VLC constants for DV codec * Copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c index 206e50e1d2..ed128234e8 100644 --- a/libavcodec/dvbsub.c +++ b/libavcodec/dvbsub.c @@ -2,20 +2,20 @@ * DVB subtitle encoding for ffmpeg * Copyright (c) 2005 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" diff --git a/libavcodec/dvbsub_parser.c b/libavcodec/dvbsub_parser.c index 8f3b0653d4..59d03d1d46 100644 --- a/libavcodec/dvbsub_parser.c +++ b/libavcodec/dvbsub_parser.c @@ -1,21 +1,21 @@ /* - * DVB subtitle parser for Libav + * DVB subtitle parser for FFmpeg * Copyright (c) 2005 Ian Caulfield * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 3f39a960cb..5b09eb14d6 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -2,20 +2,20 @@ * DVB subtitle decoding for ffmpeg * Copyright (c) 2005 Ian Caulfield * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" @@ -318,21 +318,10 @@ static void delete_region_display_list(DVBSubContext *ctx, DVBSubRegion *region) } -static void delete_state(DVBSubContext *ctx) +static void delete_cluts(DVBSubContext *ctx) { - DVBSubRegion *region; DVBSubCLUT *clut; - while (ctx->region_list) { - region = ctx->region_list; - - ctx->region_list = region->next; - - delete_region_display_list(ctx, region); - av_free(region->pbuf); - av_free(region); - } - while (ctx->clut_list) { clut = ctx->clut_list; @@ -340,12 +329,35 @@ static void delete_state(DVBSubContext *ctx) av_free(clut); } +} - av_freep(&ctx->display_definition); +static void delete_objects(DVBSubContext *ctx) +{ + DVBSubObject *object; - /* Should already be null */ - if (ctx->object_list) - av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n"); + while (ctx->object_list) { + object = ctx->object_list; + + ctx->object_list = object->next; + + av_free(object); + } +} + +static void delete_regions(DVBSubContext *ctx) +{ + DVBSubRegion *region; + + while (ctx->region_list) { + region = ctx->region_list; + + ctx->region_list = region->next; + + delete_region_display_list(ctx, region); + + av_free(region->pbuf); + av_free(region); + } } static av_cold int dvbsub_init_decoder(AVCodecContext *avctx) @@ -430,7 +442,13 @@ static av_cold int dvbsub_close_decoder(AVCodecContext *avctx) DVBSubContext *ctx = avctx->priv_data; DVBSubRegionDisplay *display; - delete_state(ctx); + delete_regions(ctx); + + delete_objects(ctx); + + delete_cluts(ctx); + + av_freep(&ctx->display_definition); while (ctx->display_list) { display = ctx->display_list; @@ -1114,7 +1132,9 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state); if (page_state == 2) { - delete_state(ctx); + delete_regions(ctx); + delete_objects(ctx); + delete_cluts(ctx); } tmp_display_list = ctx->display_list; @@ -1312,10 +1332,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, int i; int offset_x=0, offset_y=0; - sub->rects = NULL; - sub->start_display_time = 0; sub->end_display_time = ctx->time_out * 1000; - sub->format = 0; if (display_def) { offset_x = display_def->x; diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c index a80d2da803..05993d874f 100644 --- a/libavcodec/dvdata.c +++ b/libavcodec/dvdata.c @@ -2,20 +2,20 @@ * Constants for DV codec * Copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h index 817b50639f..90f4059839 100644 --- a/libavcodec/dvdata.h +++ b/libavcodec/dvdata.h @@ -2,20 +2,20 @@ * Constants for DV codec * Copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dvdsub_parser.c b/libavcodec/dvdsub_parser.c index 5b07de60df..3bbf0dcb8b 100644 --- a/libavcodec/dvdsub_parser.c +++ b/libavcodec/dvdsub_parser.c @@ -2,20 +2,20 @@ * DVD subtitle decoding for ffmpeg * Copyright (c) 2005 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 8f3ba63229..6d5973c59b 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -2,20 +2,20 @@ * DVD subtitle decoding for ffmpeg * Copyright (c) 2005 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" @@ -120,6 +120,14 @@ static void guess_palette(uint32_t *rgba_palette, uint8_t *alpha, uint32_t subtitle_color) { + static const uint8_t level_map[4][4] = { + // this configuration (full range, lowest to highest) in tests + // seemed most common, so assume this + {0xff}, + {0x00, 0xff}, + {0x00, 0x80, 0xff}, + {0x00, 0x55, 0xaa, 0xff}, + }; uint8_t color_used[16]; int nb_opaque_colors, i, level, j, r, g, b; @@ -138,18 +146,18 @@ static void guess_palette(uint32_t *rgba_palette, if (nb_opaque_colors == 0) return; - j = nb_opaque_colors; + j = 0; memset(color_used, 0, 16); for(i = 0; i < 4; i++) { if (alpha[i] != 0) { if (!color_used[colormap[i]]) { - level = (0xff * j) / nb_opaque_colors; + level = level_map[nb_opaque_colors][j]; r = (((subtitle_color >> 16) & 0xff) * level) >> 8; g = (((subtitle_color >> 8) & 0xff) * level) >> 8; b = (((subtitle_color >> 0) & 0xff) * level) >> 8; rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24); color_used[colormap[i]] = (i + 1); - j--; + j++; } else { rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) | ((alpha[i] * 17) << 24); @@ -173,7 +181,6 @@ static int decode_dvd_subtitles(AVSubtitle *sub_header, if (buf_size < 10) return -1; - memset(sub_header, 0, sizeof(*sub_header)); if (AV_RB16(buf) == 0) { /* HD subpicture with 4-byte offsets */ big_offsets = 1; diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c index 71c5e792d0..d09ac269ed 100644 --- a/libavcodec/dvdsubenc.c +++ b/libavcodec/dvdsubenc.c @@ -2,20 +2,20 @@ * DVD subtitle encoding for ffmpeg * Copyright (c) 2005 Wolfram Gloger * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" diff --git a/libavcodec/dwt.c b/libavcodec/dwt.c index 2c5b56ca48..d9d58de8b2 100644 --- a/libavcodec/dwt.c +++ b/libavcodec/dwt.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dwt.h b/libavcodec/dwt.h index fc73fe7e8e..b10e4f5596 100644 --- a/libavcodec/dwt.h +++ b/libavcodec/dwt.h @@ -1,20 +1,20 @@ /* * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c index 75f3212232..807ecd85ee 100644 --- a/libavcodec/dxa.c +++ b/libavcodec/dxa.c @@ -2,20 +2,20 @@ * Feeble Files/ScummVM DXA decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -295,6 +295,9 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&c->pic); + avcodec_get_frame_defaults(&c->prev); + c->dsize = avctx->width * avctx->height * 2; if((c->decomp_buf = av_malloc(c->dsize)) == NULL) { av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 25b021ae11..3f14311c9a 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -3,20 +3,20 @@ * * copyright (c) 2010 Laurent Aimar * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h index 5db5d0bc9f..5c5fe21e2f 100644 --- a/libavcodec/dxva2.h +++ b/libavcodec/dxva2.h @@ -3,20 +3,20 @@ * * copyright (c) 2009 Laurent Aimar * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,7 +29,7 @@ /** * This structure is used to provides the necessary configurations and data - * to the DXVA2 Libav HWAccel implementation. + * to the DXVA2 FFmpeg HWAccel implementation. * * The application must make it available as AVCodecContext.hwaccel_context. */ @@ -60,7 +60,7 @@ struct dxva_context { uint64_t workaround; /** - * Private to the Libav AVHWAccel implementation + * Private to the FFmpeg AVHWAccel implementation */ unsigned report_id; }; diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 8de4c51082..bc80e982fb 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -3,20 +3,20 @@ * * copyright (c) 2009 Laurent Aimar * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -95,7 +95,7 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context pp->wBitFields = ((s->picture_structure != PICT_FRAME) << 0) | (h->sps.mb_aff << 1) | (h->sps.residual_color_transform_flag << 2) | - /* sp_for_switch_flag (not implemented by Libav) */ + /* sp_for_switch_flag (not implemented by FFmpeg) */ (0 << 3) | (h->sps.chroma_format_idc << 4) | ((h->nal_ref_idc != 0) << 6) | @@ -146,8 +146,8 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context pp->deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; pp->redundant_pic_cnt_present_flag= h->pps.redundant_pic_cnt_present; pp->Reserved8BitsB = 0; - pp->slice_group_change_rate_minus1= 0; /* XXX not implemented by Libav */ - //pp->SliceGroupMap[810]; /* XXX not implemented by Libav */ + pp->slice_group_change_rate_minus1= 0; /* XXX not implemented by FFmpeg */ + //pp->SliceGroupMap[810]; /* XXX not implemented by FFmpeg */ } static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm) @@ -243,7 +243,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, } } } - slice->slice_qs_delta = 0; /* XXX not implemented by Libav */ + slice->slice_qs_delta = 0; /* XXX not implemented by FFmpeg */ slice->slice_qp_delta = s->qscale - h->pps.init_qp; slice->redundant_pic_cnt = h->redundant_pic_count; if (h->slice_type == AV_PICTURE_TYPE_B) diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 57fc7bd6f9..23d4d87522 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -3,20 +3,20 @@ * * copyright (c) 2010 Laurent Aimar * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index f14aabd540..62e6ec1cfa 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -3,20 +3,20 @@ * * copyright (c) 2010 Laurent Aimar * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index 112d7df785..5b9bb692e0 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -3,20 +3,20 @@ * * copyright (c) 2010 Laurent Aimar * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c index 54007686dd..40f571ffc7 100644 --- a/libavcodec/eac3dec.c +++ b/libavcodec/eac3dec.c @@ -3,20 +3,20 @@ * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * Copyright (c) 2008 Justin Ruggles * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/eac3dec_data.c b/libavcodec/eac3dec_data.c index 4cea26fcb3..031702e9e9 100644 --- a/libavcodec/eac3dec_data.c +++ b/libavcodec/eac3dec_data.c @@ -2,20 +2,20 @@ * E-AC-3 decoder tables * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/eac3dec_data.h b/libavcodec/eac3dec_data.h index 91892a30d6..133183398f 100644 --- a/libavcodec/eac3dec_data.h +++ b/libavcodec/eac3dec_data.h @@ -2,20 +2,20 @@ * E-AC-3 decoder tables * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index c968a3d403..408d948812 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -2,20 +2,20 @@ * Electronic Arts CMV Video Decoder * Copyright (c) 2007-2008 Peter Ross * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -43,6 +43,10 @@ typedef struct CmvContext { static av_cold int cmv_decode_init(AVCodecContext *avctx){ CmvContext *s = avctx->priv_data; + avcodec_get_frame_defaults(&s->frame); + avcodec_get_frame_defaults(&s->last_frame); + avcodec_get_frame_defaults(&s->last2_frame); + s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; return 0; diff --git a/libavcodec/eaidct.c b/libavcodec/eaidct.c index 9d829c4161..9972e422ed 100644 --- a/libavcodec/eaidct.c +++ b/libavcodec/eaidct.c @@ -2,20 +2,20 @@ * Electronic Arts TGQ/TQI/MAD IDCT algorithm * Copyright (c) 2007-2008 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index db22781588..d4881ab843 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -2,20 +2,20 @@ * Electronic Arts Madcow Video Decoder * Copyright (c) 2007-2009 Peter Ross * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index d4f8b8fb5f..a353580a15 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -2,20 +2,20 @@ * Electronic Arts TGQ Video Decoder * Copyright (c) 2007-2008 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index ee5c094169..0855f10417 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -2,20 +2,20 @@ * Electronic Arts TGV Video Decoder * Copyright (c) 2007-2008 Peter Ross * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -55,6 +55,8 @@ static av_cold int tgv_decode_init(AVCodecContext *avctx){ s->avctx = avctx; avctx->time_base = (AVRational){1, 15}; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); + avcodec_get_frame_defaults(&s->last_frame); return 0; } diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index aa96437013..44792f0483 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -2,20 +2,20 @@ * Electronic Arts TQI Video Decoder * Copyright (c) 2007-2009 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c index 030c3a68c4..ede863e9be 100644 --- a/libavcodec/elbg.c +++ b/libavcodec/elbg.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2007 Vitor Sessak <vitor1001@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/elbg.h b/libavcodec/elbg.h index b8ea489b24..e6f577e3e5 100644 --- a/libavcodec/elbg.h +++ b/libavcodec/elbg.h @@ -1,20 +1,20 @@ /* * Copyright (C) 2007 Vitor Sessak <vitor1001@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index aea0e15b34..68e465796a 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -3,20 +3,20 @@ * * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -382,6 +382,14 @@ static void guess_mv(MpegEncContext *s){ fixed[mb_xy]= f; if(f==MV_FROZEN) num_avail++; + else if(s->last_picture.data[0] && s->last_picture.motion_val[0]){ + const int mb_y= mb_xy / s->mb_stride; + const int mb_x= mb_xy % s->mb_stride; + const int mot_index= (mb_x + mb_y*mot_stride) * mot_step; + s->current_picture.motion_val[0][mot_index][0]= s->last_picture.motion_val[0][mot_index][0]; + s->current_picture.motion_val[0][mot_index][1]= s->last_picture.motion_val[0][mot_index][1]; + s->current_picture.ref_index[0][4*mb_xy] = s->last_picture.ref_index[0][4*mb_xy]; + } } if((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <= mb_width/2){ @@ -527,7 +535,7 @@ skip_mean_and_median: /* zero MV */ pred_count++; - if (!fixed[mb_xy]) { + if (!fixed[mb_xy] && 0) { if (s->avctx->codec_id == CODEC_ID_H264) { // FIXME } else { @@ -547,6 +555,7 @@ skip_mean_and_median: mv_predictor[pred_count][0]= prev_x; mv_predictor[pred_count][1]= prev_y; ref [pred_count] = prev_ref; + pred_count++; s->mv_dir = MV_DIR_FORWARD; s->mb_intra=0; @@ -684,6 +693,7 @@ static int is_intra_more_likely(MpegEncContext *s){ mb_y, 0); } is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16); + // FIXME need await_progress() here is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16); }else{ if(IS_INTRA(s->current_picture.mb_type[mb_xy])) @@ -811,6 +821,7 @@ void ff_er_frame_end(MpegEncContext *s){ } } +#if 1 /* handle overlapping slices */ for(error_type=1; error_type<=3; error_type++){ int end_ok=0; @@ -831,7 +842,8 @@ void ff_er_frame_end(MpegEncContext *s){ end_ok=0; } } - +#endif +#if 1 /* handle slices with partitions of different length */ if(s->partitioned_frame){ int end_ok=0; @@ -852,7 +864,7 @@ void ff_er_frame_end(MpegEncContext *s){ end_ok=0; } } - +#endif /* handle missing slices */ if(s->error_recognition>=4){ int end_ok=1; @@ -876,6 +888,7 @@ void ff_er_frame_end(MpegEncContext *s){ } } +#if 1 /* backward mark errors */ distance=9999999; for(error_type=1; error_type<=3; error_type++){ @@ -900,6 +913,7 @@ void ff_er_frame_end(MpegEncContext *s){ distance= 9999999; } } +#endif /* forward mark errors */ error=0; @@ -914,7 +928,7 @@ void ff_er_frame_end(MpegEncContext *s){ s->error_status_table[mb_xy]|= error; } } - +#if 1 /* handle not partitioned case */ if(!s->partitioned_frame){ for(i=0; i<s->mb_num; i++){ @@ -925,6 +939,7 @@ void ff_er_frame_end(MpegEncContext *s){ s->error_status_table[mb_xy]= error; } } +#endif dc_error= ac_error= mv_error=0; for(i=0; i<s->mb_num; i++){ @@ -1091,15 +1106,16 @@ void ff_er_frame_end(MpegEncContext *s){ s->dc_val[2][mb_x + mb_y*s->mb_stride]= (dcv+4)>>3; } } - +#if 1 /* guess DC for damaged blocks */ guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride, 1); guess_dc(s, s->dc_val[1], s->mb_width , s->mb_height , s->mb_stride, 0); guess_dc(s, s->dc_val[2], s->mb_width , s->mb_height , s->mb_stride, 0); - +#endif /* filter luma DC */ filter181(s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride); +#if 1 /* render DC only intra */ for(mb_y=0; mb_y<s->mb_height; mb_y++){ for(mb_x=0; mb_x<s->mb_width; mb_x++){ @@ -1119,6 +1135,7 @@ void ff_er_frame_end(MpegEncContext *s){ put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y); } } +#endif if(s->avctx->error_concealment&FF_EC_DEBLOCK){ /* filter horizontal block boundaries */ diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index 9d216a4c95..12e478fe19 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -2,20 +2,20 @@ * Escape 124 Video Decoder * Copyright (C) 2008 Eli Friedman (eli.friedman@gmail.com) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -61,6 +61,7 @@ static av_cold int escape124_decode_init(AVCodecContext *avctx) { Escape124Context *s = avctx->priv_data; + avcodec_get_frame_defaults(&s->frame); avctx->pix_fmt = PIX_FMT_RGB555; s->num_superblocks = ((unsigned)avctx->width / 8) * @@ -214,7 +215,8 @@ static int escape124_decode_frame(AVCodecContext *avctx, uint16_t* old_frame_data, *new_frame_data; unsigned old_stride, new_stride; - AVFrame new_frame = { { 0 } }; + AVFrame new_frame; + avcodec_get_frame_defaults(&new_frame); init_get_bits(&gb, buf, buf_size * 8); diff --git a/libavcodec/faandct.h b/libavcodec/faandct.h index da8c0e42d9..f43b62f168 100644 --- a/libavcodec/faandct.h +++ b/libavcodec/faandct.h @@ -2,20 +2,20 @@ * Floating point AAN DCT * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/faanidct.c b/libavcodec/faanidct.c index 0b9b458284..dc3d8fbb81 100644 --- a/libavcodec/faanidct.c +++ b/libavcodec/faanidct.c @@ -2,20 +2,20 @@ * Floating point AAN IDCT * Copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "faanidct.h" diff --git a/libavcodec/faanidct.h b/libavcodec/faanidct.h index f3896f7a48..4cf1189286 100644 --- a/libavcodec/faanidct.h +++ b/libavcodec/faanidct.h @@ -2,20 +2,20 @@ * Floating point AAN IDCT * Copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c index 79e8d757af..34aa576660 100644 --- a/libavcodec/faxcompr.c +++ b/libavcodec/faxcompr.c @@ -2,20 +2,20 @@ * CCITT Fax Group 3 and 4 decompression * Copyright (c) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/faxcompr.h b/libavcodec/faxcompr.h index 4742d15e59..62f591ceee 100644 --- a/libavcodec/faxcompr.h +++ b/libavcodec/faxcompr.h @@ -2,20 +2,20 @@ * CCITT Fax Group 3 and 4 decompression * Copyright (c) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fft-fixed-test.c b/libavcodec/fft-fixed-test.c index 63cd194576..fa750b6326 100644 --- a/libavcodec/fft-fixed-test.c +++ b/libavcodec/fft-fixed-test.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fft-internal.h b/libavcodec/fft-internal.h index d30571b733..61066bb18b 100644 --- a/libavcodec/fft-internal.h +++ b/libavcodec/fft-internal.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fft-test.c b/libavcodec/fft-test.c index 0112c6fcbb..a676627de2 100644 --- a/libavcodec/fft-test.c +++ b/libavcodec/fft-test.c @@ -1,20 +1,20 @@ /* * (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fft.c b/libavcodec/fft.c index aa34b34152..4eb46f14c8 100644 --- a/libavcodec/fft.c +++ b/libavcodec/fft.c @@ -4,20 +4,20 @@ * Copyright (c) 2002 Fabrice Bellard * Partly based on libdjbfft by D. J. Bernstein * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fft.h b/libavcodec/fft.h index dc3c1909b0..24db7e3d24 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -2,20 +2,20 @@ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fft_fixed.c b/libavcodec/fft_fixed.c index b28091d35c..3955efea05 100644 --- a/libavcodec/fft_fixed.c +++ b/libavcodec/fft_fixed.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fft_float.c b/libavcodec/fft_float.c index 24c9fdb366..214964631b 100644 --- a/libavcodec/fft_float.c +++ b/libavcodec/fft_float.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 50f1062ad4..a0a4a1d009 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -3,20 +3,20 @@ * * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -252,6 +252,7 @@ typedef struct FFV1Context{ int colorspace; int16_t *sample_buffer; int gob_count; + int packed_at_lsb; int quant_table_count; @@ -615,8 +616,14 @@ static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, } encode_line(s, w, sample, plane_index, 8); }else{ - for(x=0; x<w; x++){ - sample[0][x]= ((uint16_t*)(src + stride*y))[x] >> (16 - s->avctx->bits_per_raw_sample); + if(s->packed_at_lsb){ + for(x=0; x<w; x++){ + sample[0][x]= ((uint16_t*)(src + stride*y))[x]; + } + }else{ + for(x=0; x<w; x++){ + sample[0][x]= ((uint16_t*)(src + stride*y))[x] >> (16 - s->avctx->bits_per_raw_sample); + } } encode_line(s, w, sample, plane_index, s->avctx->bits_per_raw_sample); } @@ -731,6 +738,8 @@ static av_cold int common_init(AVCodecContext *avctx){ s->avctx= avctx; s->flags= avctx->flags; + avcodec_get_frame_defaults(&s->picture); + dsputil_init(&s->dsp, avctx); s->width = avctx->width; @@ -970,6 +979,10 @@ static av_cold int encode_init(AVCodecContext *avctx) avctx->coded_frame= &s->picture; switch(avctx->pix_fmt){ + case PIX_FMT_YUV420P9: + case PIX_FMT_YUV420P10: + case PIX_FMT_YUV422P10: + s->packed_at_lsb = 1; case PIX_FMT_YUV444P16: case PIX_FMT_YUV422P16: case PIX_FMT_YUV420P16: @@ -1133,6 +1146,7 @@ static int encode_slice(AVCodecContext *c, void *arg){ int x= fs->slice_x; int y= fs->slice_y; AVFrame * const p= &f->picture; + const int ps= (c->bits_per_raw_sample>8)+1; if(f->colorspace==0){ const int chroma_width = -((-width )>>f->chroma_h_shift); @@ -1140,12 +1154,12 @@ static int encode_slice(AVCodecContext *c, void *arg){ const int cx= x>>f->chroma_h_shift; const int cy= y>>f->chroma_v_shift; - encode_plane(fs, p->data[0] + x + y*p->linesize[0], width, height, p->linesize[0], 0); + encode_plane(fs, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0); - encode_plane(fs, p->data[1] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); - encode_plane(fs, p->data[2] + cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1); + encode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); + encode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1); }else{ - encode_rgb_frame(fs, (uint32_t*)(p->data[0]) + x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); + encode_rgb_frame(fs, (uint32_t*)(p->data[0]) + ps*x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); } emms_c(); @@ -1399,8 +1413,14 @@ static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, } }else{ decode_line(s, w, sample, plane_index, s->avctx->bits_per_raw_sample); - for(x=0; x<w; x++){ - ((uint16_t*)(src + stride*y))[x]= sample[1][x] << (16 - s->avctx->bits_per_raw_sample); + if(s->packed_at_lsb){ + for(x=0; x<w; x++){ + ((uint16_t*)(src + stride*y))[x]= sample[1][x]; + } + }else{ + for(x=0; x<w; x++){ + ((uint16_t*)(src + stride*y))[x]= sample[1][x] << (16 - s->avctx->bits_per_raw_sample); + } } } //STOP_TIMER("decode-line")} @@ -1456,6 +1476,7 @@ static int decode_slice(AVCodecContext *c, void *arg){ int height= fs->slice_height; int x= fs->slice_x; int y= fs->slice_y; + const int ps= (c->bits_per_raw_sample>8)+1; AVFrame * const p= &f->picture; av_assert1(width && height); @@ -1464,12 +1485,12 @@ static int decode_slice(AVCodecContext *c, void *arg){ const int chroma_height= -((-height)>>f->chroma_v_shift); const int cx= x>>f->chroma_h_shift; const int cy= y>>f->chroma_v_shift; - decode_plane(fs, p->data[0] + x + y*p->linesize[0], width, height, p->linesize[0], 0); + decode_plane(fs, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0); - decode_plane(fs, p->data[1] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); - decode_plane(fs, p->data[2] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[2], 1); + decode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); + decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[2], 1); }else{ - decode_rgb_frame(fs, (uint32_t*)p->data[0] + x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); + decode_rgb_frame(fs, (uint32_t*)p->data[0] + ps*x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); } emms_c(); @@ -1615,7 +1636,25 @@ static int read_header(FFV1Context *f){ av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); return -1; } - }else{ + }else if(f->avctx->bits_per_raw_sample==9) { + switch(16*f->chroma_h_shift + f->chroma_v_shift){ + case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P16; break; + case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P16; break; + case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P9 ; f->packed_at_lsb=1; break; + default: + av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); + return -1; + } + }else if(f->avctx->bits_per_raw_sample==10) { + switch(16*f->chroma_h_shift + f->chroma_v_shift){ + case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P16; break; + case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P10; f->packed_at_lsb=1; break; + case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P10; f->packed_at_lsb=1; break; + default: + av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); + return -1; + } + }else { switch(16*f->chroma_h_shift + f->chroma_v_shift){ case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P16; break; case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P16; break; @@ -1652,6 +1691,7 @@ static int read_header(FFV1Context *f){ for(j=0; j<f->slice_count; j++){ FFV1Context *fs= f->slice_context[j]; fs->ac= f->ac; + fs->packed_at_lsb= f->packed_at_lsb; if(f->version >= 2){ fs->slice_x = get_symbol(c, state, 0) *f->width ; @@ -1819,7 +1859,7 @@ AVCodec ff_ffv1_encoder = { encode_frame, common_end, .capabilities = CODEC_CAP_SLICE_THREADS, - .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_NONE}, + .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_YUV420P9, PIX_FMT_YUV420P10, PIX_FMT_YUV422P10, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }; #endif diff --git a/libavcodec/flac.c b/libavcodec/flac.c index e6a427af11..5ed3ef7fc3 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -2,26 +2,27 @@ * FLAC common code * Copyright (c) 2009 Justin Ruggles * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/crc.h" #include "flac.h" #include "flacdata.h" +#include "vorbis.h" static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; @@ -54,9 +55,12 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, fi->ch_mode = get_bits(gb, 4); if (fi->ch_mode < FLAC_MAX_CHANNELS) { fi->channels = fi->ch_mode + 1; + if (fi->ch_mode <= 5) + avctx->channel_layout = ff_vorbis_channel_layouts[fi->ch_mode]; fi->ch_mode = FLAC_CHMODE_INDEPENDENT; } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) { fi->channels = 2; + avctx->channel_layout = AV_CH_LAYOUT_STEREO; } else { av_log(avctx, AV_LOG_ERROR + log_level_offset, "invalid channel mode: %d\n", fi->ch_mode); diff --git a/libavcodec/flac.h b/libavcodec/flac.h index 6ec8a3752d..fcd80996dc 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -2,20 +2,20 @@ * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions * Copyright (c) 2008 Justin Ruggles * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 947a5b6e15..50ad72b7c0 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -2,20 +2,20 @@ * FLAC parser * Copyright (c) 2010 Michael Chinen * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flacdata.c b/libavcodec/flacdata.c index 820c3aa492..6fcbe3955a 100644 --- a/libavcodec/flacdata.c +++ b/libavcodec/flacdata.c @@ -2,20 +2,20 @@ * FLAC data * Copyright (c) 2003 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flacdata.h b/libavcodec/flacdata.h index f56637773c..96a50b9183 100644 --- a/libavcodec/flacdata.h +++ b/libavcodec/flacdata.h @@ -2,20 +2,20 @@ * FLAC data header * Copyright (c) 2003 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 1ce8559de6..ece095cf09 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -2,20 +2,20 @@ * FLAC (Free Lossless Audio Codec) decoder * Copyright (c) 2003 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index be775cabd3..b8d0e10631 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -2,20 +2,20 @@ * FLAC audio encoder * Copyright (c) 2006 Justin Ruggles <justin.ruggles@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -439,6 +439,28 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) if (!avctx->coded_frame) return AVERROR(ENOMEM); + if (channels == 3 && + avctx->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) || + channels == 4 && + avctx->channel_layout != AV_CH_LAYOUT_2_2 && + avctx->channel_layout != AV_CH_LAYOUT_QUAD || + channels == 5 && + avctx->channel_layout != AV_CH_LAYOUT_5POINT0 && + avctx->channel_layout != AV_CH_LAYOUT_5POINT0_BACK || + channels == 6 && + avctx->channel_layout != AV_CH_LAYOUT_5POINT1 && + avctx->channel_layout != AV_CH_LAYOUT_5POINT1_BACK) { + if (avctx->channel_layout) { + av_log(avctx, AV_LOG_ERROR, "Channel layout not supported by Flac, " + "output stream will have incorrect " + "channel layout.\n"); + } else { + av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The encoder " + "will use Flac channel layout for " + "%d channels.\n", channels); + } + } + ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->options.max_prediction_order, FF_LPC_TYPE_LEVINSON); diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index a958bdaa53..a57e851078 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -3,20 +3,20 @@ * Copyright (C) 2004 Alex Beregszaszi * Copyright (C) 2006 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -92,6 +92,7 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) return 1; } avctx->pix_fmt = PIX_FMT_BGR24; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c new file mode 100644 index 0000000000..7ee299cf7c --- /dev/null +++ b/libavcodec/flashsv2enc.c @@ -0,0 +1,907 @@ +/* + * Flash Screen Video Version 2 encoder + * Copyright (C) 2009 Joshua Warner + * + * 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 libavcodec/flashsv2enc.c + * Flash Screen Video Version 2 encoder + * @author Joshua Warner + */ + +/* Differences from version 1 stream: + * NOTE: Currently, the only player that supports version 2 streams is Adobe Flash Player itself. + * * Supports sending only a range of scanlines in a block, + * indicating a difference from the corresponding block in the last keyframe. + * * Supports initializing the zlib dictionary with data from the corresponding + * block in the last keyframe, to improve compression. + * * Supports a hybrid 15-bit rgb / 7-bit palette color space. + */ + +/* TODO: + * Don't keep Block structures for both current frame and keyframe. + * Make better heuristics for deciding stream parameters (optimum_* functions). Currently these return constants. + * Figure out how to encode palette information in the stream, choose an optimum palette at each keyframe. + * Figure out how the zlibPrimeCompressCurrent flag works, implement support. + * Find other sample files (that weren't generated here), develop a decoder. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <zlib.h> + +#include "libavutil/imgutils.h" +#include "avcodec.h" +#include "put_bits.h" +#include "bytestream.h" + +#define HAS_IFRAME_IMAGE 0x02 +#define HAS_PALLET_INFO 0x01 + +#define COLORSPACE_BGR 0x00 +#define COLORSPACE_15_7 0x10 +#define HAS_DIFF_BLOCKS 0x04 +#define ZLIB_PRIME_COMPRESS_CURRENT 0x02 +#define ZLIB_PRIME_COMPRESS_PREVIOUS 0x01 + +// Disables experimental "smart" parameter-choosing code, as well as the statistics that it depends on. +// At the moment, the "smart" code is a great example of how the parameters *shouldn't* be chosen. +#define FLASHSV2_DUMB + +typedef struct Block { + uint8_t *enc; + uint8_t *sl_begin, *sl_end; + int enc_size; + uint8_t *data; + unsigned long data_size; + + uint8_t start, len; + uint8_t dirty; + uint8_t col, row, width, height; + uint8_t flags; +} Block; + +typedef struct Palette { + unsigned colors[128]; + uint8_t index[1 << 15]; +} Palette; + +typedef struct FlashSV2Context { + AVCodecContext *avctx; + uint8_t *current_frame; + uint8_t *key_frame; + AVFrame frame; + uint8_t *encbuffer; + uint8_t *keybuffer; + uint8_t *databuffer; + + Block *frame_blocks; + Block *key_blocks; + int frame_size; + int blocks_size; + + int use15_7, dist, comp; + + int rows, cols; + + int last_key_frame; + + int image_width, image_height; + int block_width, block_height; + uint8_t flags; + uint8_t use_custom_palette; + uint8_t palette_type; ///< 0=>default, 1=>custom - changed when palette regenerated. + Palette palette; +#ifndef FLASHSV2_DUMB + double tot_blocks; ///< blocks encoded since last keyframe + double diff_blocks; ///< blocks that were different since last keyframe + double tot_lines; ///< total scanlines in image since last keyframe + double diff_lines; ///< scanlines that were different since last keyframe + double raw_size; ///< size of raw frames since last keyframe + double comp_size; ///< size of compressed data since last keyframe + double uncomp_size; ///< size of uncompressed data since last keyframe + + double total_bits; ///< total bits written to stream so far +#endif +} FlashSV2Context; + +static av_cold void cleanup(FlashSV2Context * s) +{ + av_freep(&s->encbuffer); + av_freep(&s->keybuffer); + av_freep(&s->databuffer); + av_freep(&s->current_frame); + av_freep(&s->key_frame); + + av_freep(&s->frame_blocks); + av_freep(&s->key_blocks); +} + +static void init_blocks(FlashSV2Context * s, Block * blocks, + uint8_t * encbuf, uint8_t * databuf) +{ + int row, col; + Block *b; + for (col = 0; col < s->cols; col++) { + for (row = 0; row < s->rows; row++) { + b = blocks + (col + row * s->cols); + b->width = (col < s->cols - 1) ? + s->block_width : + s->image_width - col * s->block_width; + + b->height = (row < s->rows - 1) ? + s->block_height : + s->image_height - row * s->block_height; + + b->row = row; + b->col = col; + b->enc = encbuf; + b->data = databuf; + encbuf += b->width * b->height * 3; + databuf += !databuf ? 0 : b->width * b->height * 6; + } + } +} + +static void reset_stats(FlashSV2Context * s) +{ +#ifndef FLASHSV2_DUMB + s->diff_blocks = 0.1; + s->tot_blocks = 1; + s->diff_lines = 0.1; + s->tot_lines = 1; + s->raw_size = s->comp_size = s->uncomp_size = 10; +#endif +} + +static av_cold int flashsv2_encode_init(AVCodecContext * avctx) +{ + FlashSV2Context *s = avctx->priv_data; + + s->avctx = avctx; + + s->comp = avctx->compression_level; + if (s->comp == -1) + s->comp = 9; + if (s->comp < 0 || s->comp > 9) { + av_log(avctx, AV_LOG_ERROR, + "Compression level should be 0-9, not %d\n", s->comp); + return -1; + } + + + if ((avctx->width > 4095) || (avctx->height > 4095)) { + av_log(avctx, AV_LOG_ERROR, + "Input dimensions too large, input must be max 4096x4096 !\n"); + return -1; + } + + if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) + return -1; + + + s->last_key_frame = 0; + + s->image_width = avctx->width; + s->image_height = avctx->height; + + s->block_width = (s->image_width / 12) & ~15; + s->block_height = (s->image_height / 12) & ~15; + + s->rows = (s->image_height + s->block_height - 1) / s->block_height; + s->cols = (s->image_width + s->block_width - 1) / s->block_width; + + s->frame_size = s->image_width * s->image_height * 3; + s->blocks_size = s->rows * s->cols * sizeof(Block); + + s->encbuffer = av_mallocz(s->frame_size); + s->keybuffer = av_mallocz(s->frame_size); + s->databuffer = av_mallocz(s->frame_size * 6); + s->current_frame = av_mallocz(s->frame_size); + s->key_frame = av_mallocz(s->frame_size); + s->frame_blocks = av_mallocz(s->blocks_size); + s->key_blocks = av_mallocz(s->blocks_size); + + init_blocks(s, s->frame_blocks, s->encbuffer, s->databuffer); + init_blocks(s, s->key_blocks, s->keybuffer, 0); + reset_stats(s); +#ifndef FLASHSV2_DUMB + s->total_bits = 1; +#endif + + s->use_custom_palette = 0; + s->palette_type = -1; // so that the palette will be generated in reconfigure_at_keyframe + + if (!s->encbuffer || !s->keybuffer || !s->databuffer + || !s->current_frame || !s->key_frame || !s->key_blocks + || !s->frame_blocks) { + av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); + cleanup(s); + return -1; + } + + return 0; +} + +static int new_key_frame(FlashSV2Context * s) +{ + int i; + memcpy(s->key_blocks, s->frame_blocks, s->blocks_size); + memcpy(s->key_frame, s->current_frame, s->frame_size); + + for (i = 0; i < s->rows * s->cols; i++) { + s->key_blocks[i].enc += (s->keybuffer - s->encbuffer); + s->key_blocks[i].sl_begin = 0; + s->key_blocks[i].sl_end = 0; + s->key_blocks[i].data = 0; + } + FFSWAP(uint8_t * , s->keybuffer, s->encbuffer); + + return 0; +} + +static int write_palette(FlashSV2Context * s, uint8_t * buf, int buf_size) +{ + //this isn't implemented yet! Default palette only! + return -1; +} + +static int write_header(FlashSV2Context * s, uint8_t * buf, int buf_size) +{ + PutBitContext pb; + int buf_pos, len; + + if (buf_size < 5) + return -1; + + init_put_bits(&pb, buf, buf_size * 8); + + put_bits(&pb, 4, (s->block_width >> 4) - 1); + put_bits(&pb, 12, s->image_width); + put_bits(&pb, 4, (s->block_height >> 4) - 1); + put_bits(&pb, 12, s->image_height); + + flush_put_bits(&pb); + buf_pos = 4; + + buf[buf_pos++] = s->flags; + + if (s->flags & HAS_PALLET_INFO) { + len = write_palette(s, buf + buf_pos, buf_size - buf_pos); + if (len < 0) + return -1; + buf_pos += len; + } + + return buf_pos; +} + +static int write_block(Block * b, uint8_t * buf, int buf_size) +{ + int buf_pos = 0; + unsigned block_size = b->data_size; + + if (b->flags & HAS_DIFF_BLOCKS) + block_size += 2; + if (b->flags & ZLIB_PRIME_COMPRESS_CURRENT) + block_size += 2; + if (block_size > 0) + block_size += 1; + if (buf_size < block_size + 2) + return -1; + + buf[buf_pos++] = block_size >> 8; + buf[buf_pos++] = block_size; + + if (block_size == 0) + return buf_pos; + + buf[buf_pos++] = b->flags; + + if (b->flags & HAS_DIFF_BLOCKS) { + buf[buf_pos++] = (b->start); + buf[buf_pos++] = (b->len); + } + + if (b->flags & ZLIB_PRIME_COMPRESS_CURRENT) { + //This feature of the format is poorly understood, and as of now, unused. + buf[buf_pos++] = (b->col); + buf[buf_pos++] = (b->row); + } + + memcpy(buf + buf_pos, b->data, b->data_size); + + buf_pos += b->data_size; + + return buf_pos; +} + +static int encode_zlib(Block * b, uint8_t * buf, unsigned long *buf_size, int comp) +{ + int res = compress2(buf, buf_size, b->sl_begin, b->sl_end - b->sl_begin, comp); + return res == Z_OK ? 0 : -1; +} + +static int encode_zlibprime(Block * b, Block * prime, uint8_t * buf, + int *buf_size, int comp) +{ + z_stream s; + int res; + s.zalloc = NULL; + s.zfree = NULL; + s.opaque = NULL; + res = deflateInit(&s, comp); + if (res < 0) + return -1; + + s.next_in = prime->enc; + s.avail_in = prime->enc_size; + while (s.avail_in > 0) { + s.next_out = buf; + s.avail_out = *buf_size; + res = deflate(&s, Z_SYNC_FLUSH); + if (res < 0) + return -1; + } + + s.next_in = b->sl_begin; + s.avail_in = b->sl_end - b->sl_begin; + s.next_out = buf; + s.avail_out = *buf_size; + res = deflate(&s, Z_FINISH); + deflateEnd(&s); + *buf_size -= s.avail_out; + if (res != Z_STREAM_END) + return -1; + return 0; +} + +static int encode_bgr(Block * b, const uint8_t * src, int stride) +{ + int i; + uint8_t *ptr = b->enc; + for (i = 0; i < b->start; i++) + memcpy(ptr + i * b->width * 3, src + i * stride, b->width * 3); + b->sl_begin = ptr + i * b->width * 3; + for (; i < b->start + b->len; i++) + memcpy(ptr + i * b->width * 3, src + i * stride, b->width * 3); + b->sl_end = ptr + i * b->width * 3; + for (; i < b->height; i++) + memcpy(ptr + i * b->width * 3, src + i * stride, b->width * 3); + b->enc_size = ptr + i * b->width * 3 - b->enc; + return b->enc_size; +} + +static inline unsigned pixel_color15(const uint8_t * src) +{ + return (src[0] >> 3) | ((src[1] & 0xf8) << 2) | ((src[2] & 0xf8) << 7); +} + +static inline unsigned int chroma_diff(unsigned int c1, unsigned int c2) +{ + unsigned int t1 = (c1 & 0x000000ff) + ((c1 & 0x0000ff00) >> 8) + ((c1 & 0x00ff0000) >> 16); + unsigned int t2 = (c2 & 0x000000ff) + ((c2 & 0x0000ff00) >> 8) + ((c2 & 0x00ff0000) >> 16); + + return abs(t1 - t2) + abs((c1 & 0x000000ff) - (c2 & 0x000000ff)) + + abs(((c1 & 0x0000ff00) >> 8) - ((c2 & 0x0000ff00) >> 8)) + + abs(((c1 & 0x00ff0000) >> 16) - ((c2 & 0x00ff0000) >> 16)); +} + +static inline int pixel_color7_fast(Palette * palette, unsigned c15) +{ + return palette->index[c15]; +} + +static int pixel_color7_slow(Palette * palette, unsigned color) +{ + int i, min = 0x7fffffff; + int minc = -1; + for (i = 0; i < 128; i++) { + int c1 = palette->colors[i]; + int diff = chroma_diff(c1, color); + if (diff < min) { + min = diff; + minc = i; + } + } + return minc; +} + +static inline unsigned pixel_bgr(const uint8_t * src) +{ + return (src[0]) | (src[1] << 8) | (src[2] << 16); +} + +static int write_pixel_15_7(Palette * palette, uint8_t * dest, const uint8_t * src, + int dist) +{ + unsigned c15 = pixel_color15(src); + unsigned color = pixel_bgr(src); + int d15 = chroma_diff(color, color & 0x00f8f8f8); + int c7 = pixel_color7_fast(palette, c15); + int d7 = chroma_diff(color, palette->colors[c7]); + if (dist + d15 >= d7) { + dest[0] = c7; + return 1; + } else { + dest[0] = 0x80 | (c15 >> 8); + dest[1] = c15 & 0xff; + return 2; + } +} + +static int update_palette_index(Palette * palette) +{ + int r, g, b; + unsigned int bgr, c15, index; + for (r = 4; r < 256; r += 8) { + for (g = 4; g < 256; g += 8) { + for (b = 4; b < 256; b += 8) { + bgr = b | (g << 8) | (r << 16); + c15 = (b >> 3) | ((g & 0xf8) << 2) | ((r & 0xf8) << 7); + index = pixel_color7_slow(palette, bgr); + + palette->index[c15] = index; + } + } + } + return 0; +} + +static const unsigned int default_screen_video_v2_palette[128] = { + 0x00000000, 0x00333333, 0x00666666, 0x00999999, 0x00CCCCCC, 0x00FFFFFF, + 0x00330000, 0x00660000, 0x00990000, 0x00CC0000, 0x00FF0000, 0x00003300, + 0x00006600, 0x00009900, 0x0000CC00, 0x0000FF00, 0x00000033, 0x00000066, + 0x00000099, 0x000000CC, 0x000000FF, 0x00333300, 0x00666600, 0x00999900, + 0x00CCCC00, 0x00FFFF00, 0x00003333, 0x00006666, 0x00009999, 0x0000CCCC, + 0x0000FFFF, 0x00330033, 0x00660066, 0x00990099, 0x00CC00CC, 0x00FF00FF, + 0x00FFFF33, 0x00FFFF66, 0x00FFFF99, 0x00FFFFCC, 0x00FF33FF, 0x00FF66FF, + 0x00FF99FF, 0x00FFCCFF, 0x0033FFFF, 0x0066FFFF, 0x0099FFFF, 0x00CCFFFF, + 0x00CCCC33, 0x00CCCC66, 0x00CCCC99, 0x00CCCCFF, 0x00CC33CC, 0x00CC66CC, + 0x00CC99CC, 0x00CCFFCC, 0x0033CCCC, 0x0066CCCC, 0x0099CCCC, 0x00FFCCCC, + 0x00999933, 0x00999966, 0x009999CC, 0x009999FF, 0x00993399, 0x00996699, + 0x0099CC99, 0x0099FF99, 0x00339999, 0x00669999, 0x00CC9999, 0x00FF9999, + 0x00666633, 0x00666699, 0x006666CC, 0x006666FF, 0x00663366, 0x00669966, + 0x0066CC66, 0x0066FF66, 0x00336666, 0x00996666, 0x00CC6666, 0x00FF6666, + 0x00333366, 0x00333399, 0x003333CC, 0x003333FF, 0x00336633, 0x00339933, + 0x0033CC33, 0x0033FF33, 0x00663333, 0x00993333, 0x00CC3333, 0x00FF3333, + 0x00003366, 0x00336600, 0x00660033, 0x00006633, 0x00330066, 0x00663300, + 0x00336699, 0x00669933, 0x00993366, 0x00339966, 0x00663399, 0x00996633, + 0x006699CC, 0x0099CC66, 0x00CC6699, 0x0066CC99, 0x009966CC, 0x00CC9966, + 0x0099CCFF, 0x00CCFF99, 0x00FF99CC, 0x0099FFCC, 0x00CC99FF, 0x00FFCC99, + 0x00111111, 0x00222222, 0x00444444, 0x00555555, 0x00AAAAAA, 0x00BBBBBB, + 0x00DDDDDD, 0x00EEEEEE +}; + +static int generate_default_palette(Palette * palette) +{ + memcpy(palette->colors, default_screen_video_v2_palette, + sizeof(default_screen_video_v2_palette)); + + return update_palette_index(palette); +} + +static int generate_optimum_palette(Palette * palette, const uint8_t * image, + int width, int height, int stride) +{ + //this isn't implemented yet! Default palette only! + return -1; +} + +static inline int encode_15_7_sl(Palette * palette, uint8_t * dest, + const uint8_t * src, int width, int dist) +{ + int len = 0, x; + for (x = 0; x < width; x++) { + len += write_pixel_15_7(palette, dest + len, src + 3 * x, dist); + } + return len; +} + +static int encode_15_7(Palette * palette, Block * b, const uint8_t * src, + int stride, int dist) +{ + int i; + uint8_t *ptr = b->enc; + for (i = 0; i < b->start; i++) + ptr += encode_15_7_sl(palette, ptr, src + i * stride, b->width, dist); + b->sl_begin = ptr; + for (; i < b->start + b->len; i++) + ptr += encode_15_7_sl(palette, ptr, src + i * stride, b->width, dist); + b->sl_end = ptr; + for (; i < b->height; i++) + ptr += encode_15_7_sl(palette, ptr, src + i * stride, b->width, dist); + b->enc_size = ptr - b->enc; + return b->enc_size; +} + +static int encode_block(Palette * palette, Block * b, Block * prev, + const uint8_t * src, int stride, int comp, int dist, + int keyframe) +{ + unsigned buf_size = b->width * b->height * 6; + uint8_t buf[buf_size]; + int res; + if (b->flags & COLORSPACE_15_7) { + encode_15_7(palette, b, src, stride, dist); + } else { + encode_bgr(b, src, stride); + } + + if (b->len > 0) { + b->data_size = buf_size; + res = encode_zlib(b, b->data, &b->data_size, comp); + if (res) + return res; + + if (!keyframe) { + res = encode_zlibprime(b, prev, buf, &buf_size, comp); + if (res) + return res; + + if (buf_size < b->data_size) { + b->data_size = buf_size; + memcpy(b->data, buf, buf_size); + b->flags |= ZLIB_PRIME_COMPRESS_PREVIOUS; + } + } + } else { + b->data_size = 0; + } + return 0; +} + +static int compare_sl(FlashSV2Context * s, Block * b, const uint8_t * src, + uint8_t * frame, uint8_t * key, int y, int keyframe) +{ + if (memcmp(src, frame, b->width * 3) != 0) { + b->dirty = 1; + memcpy(frame, src, b->width * 3); +#ifndef FLASHSV2_DUMB + s->diff_lines++; +#endif + } + if (memcmp(src, key, b->width * 3) != 0) { + if (b->len == 0) + b->start = y; + b->len = y + 1 - b->start; + } + return 0; +} + +static int mark_all_blocks(FlashSV2Context * s, const uint8_t * src, int stride, + int keyframe) +{ + int sl, rsl, col, pos, possl; + Block *b; + for (sl = s->image_height - 1; sl >= 0; sl--) { + for (col = 0; col < s->cols; col++) { + rsl = s->image_height - sl - 1; + b = s->frame_blocks + col + rsl / s->block_height * s->cols; + possl = stride * sl + col * s->block_width * 3; + pos = s->image_width * rsl * 3 + col * s->block_width * 3; + compare_sl(s, b, src + possl, s->current_frame + pos, + s->key_frame + pos, rsl % s->block_height, keyframe); + } + } +#ifndef FLASHSV2_DUMB + s->tot_lines += s->image_height * s->cols; +#endif + return 0; +} + +static int encode_all_blocks(FlashSV2Context * s, int keyframe) +{ + int row, col, res; + uint8_t *data; + Block *b, *prev; + for (row = 0; row < s->rows; row++) { + for (col = 0; col < s->cols; col++) { + b = s->frame_blocks + (row * s->cols + col); + prev = s->key_blocks + (row * s->cols + col); + if (keyframe) { + b->start = 0; + b->len = b->height; + b->flags = s->use15_7 ? COLORSPACE_15_7 : 0; + } else if (!b->dirty) { + b->start = 0; + b->len = 0; + b->data_size = 0; + b->flags = s->use15_7 ? COLORSPACE_15_7 : 0; + continue; + } else { + b->flags = s->use15_7 ? COLORSPACE_15_7 | HAS_DIFF_BLOCKS : HAS_DIFF_BLOCKS; + } + data = s->current_frame + s->image_width * 3 * s->block_height * row + s->block_width * col * 3; + res = encode_block(&s->palette, b, prev, data, s->image_width * 3, s->comp, s->dist, keyframe); +#ifndef FLASHSV2_DUMB + if (b->dirty) + s->diff_blocks++; + s->comp_size += b->data_size; + s->uncomp_size += b->enc_size; +#endif + if (res) + return res; + } + } +#ifndef FLASHSV2_DUMB + s->raw_size += s->image_width * s->image_height * 3; + s->tot_blocks += s->rows * s->cols; +#endif + return 0; +} + +static int write_all_blocks(FlashSV2Context * s, uint8_t * buf, + int buf_size) +{ + int row, col, buf_pos = 0, len; + Block *b; + for (row = 0; row < s->rows; row++) { + for (col = 0; col < s->cols; col++) { + b = s->frame_blocks + row * s->cols + col; + len = write_block(b, buf + buf_pos, buf_size - buf_pos); + b->start = b->len = b->dirty = 0; + if (len < 0) + return len; + buf_pos += len; + } + } + return buf_pos; +} + +static int write_bitstream(FlashSV2Context * s, const uint8_t * src, int stride, + uint8_t * buf, int buf_size, int keyframe) +{ + int buf_pos, res; + + res = mark_all_blocks(s, src, stride, keyframe); + if (res) + return res; + res = encode_all_blocks(s, keyframe); + if (res) + return res; + + res = write_header(s, buf, buf_size); + if (res < 0) { + return res; + } else { + buf_pos = res; + } + res = write_all_blocks(s, buf + buf_pos, buf_size - buf_pos); + if (res < 0) + return res; + buf_pos += res; +#ifndef FLASHSV2_DUMB + s->total_bits += ((double) buf_pos) * 8.0; +#endif + + return buf_pos; +} + +static void recommend_keyframe(FlashSV2Context * s, int *keyframe) +{ +#ifndef FLASHSV2_DUMB + double block_ratio, line_ratio, enc_ratio, comp_ratio, data_ratio; + if (s->avctx->gop_size > 0) { + block_ratio = s->diff_blocks / s->tot_blocks; + line_ratio = s->diff_lines / s->tot_lines; + enc_ratio = s->uncomp_size / s->raw_size; + comp_ratio = s->comp_size / s->uncomp_size; + data_ratio = s->comp_size / s->raw_size; + + if ((block_ratio >= 0.5 && line_ratio / block_ratio <= 0.5) || line_ratio >= 0.95) { + *keyframe = 1; + return; + } + } +#else + return; +#endif +} + +static const double block_size_fraction = 1.0 / 300; +static int optimum_block_width(FlashSV2Context * s) +{ +#ifndef FLASHSV2_DUMB + double save = (1-pow(s->diff_lines/s->diff_blocks/s->block_height, 0.5)) * s->comp_size/s->tot_blocks; + double width = block_size_fraction * sqrt(0.5 * save * s->rows * s->cols) * s->image_width; + int pwidth = ((int) width); + return FFCLIP(pwidth & ~15, 256, 16); +#else + return 64; +#endif +} + +static int optimum_block_height(FlashSV2Context * s) +{ +#ifndef FLASHSV2_DUMB + double save = (1-pow(s->diff_lines/s->diff_blocks/s->block_height, 0.5)) * s->comp_size/s->tot_blocks; + double height = block_size_fraction * sqrt(0.5 * save * s->rows * s->cols) * s->image_height; + int pheight = ((int) height); + return FFCLIP(pheight & ~15, 256, 16); +#else + return 64; +#endif +} + +static const double use15_7_threshold = 8192; + +static int optimum_use15_7(FlashSV2Context * s) +{ +#ifndef FLASHSV2_DUMB + double ideal = ((double)(s->avctx->bit_rate * s->avctx->time_base.den * s->avctx->ticks_per_frame)) / + ((double) s->avctx->time_base.num) * s->avctx->frame_number; + if (ideal + use15_7_threshold < s->total_bits) { + return 1; + } else { + return 0; + } +#else + return s->avctx->global_quality == 0; +#endif +} + +static const double color15_7_factor = 100; + +static int optimum_dist(FlashSV2Context * s) +{ +#ifndef FLASHSV2_DUMB + double ideal = + s->avctx->bit_rate * s->avctx->time_base.den * + s->avctx->ticks_per_frame; + int dist = pow((s->total_bits / ideal) * color15_7_factor, 3); + av_log(s->avctx, AV_LOG_DEBUG, "dist: %d\n", dist); + return dist; +#else + return 15; +#endif +} + + +static int reconfigure_at_keyframe(FlashSV2Context * s, const uint8_t * image, + int stride) +{ + int update_palette = 0; + int res; + s->block_width = optimum_block_width(s); + s->block_height = optimum_block_height(s); + + s->rows = (s->image_height + s->block_height - 1) / s->block_height; + s->cols = (s->image_width + s->block_width - 1) / s->block_width; + + if (s->rows * s->cols != s->blocks_size / sizeof(Block)) { + if (s->rows * s->cols > s->blocks_size / sizeof(Block)) { + s->frame_blocks = av_realloc(s->frame_blocks, s->rows * s->cols * sizeof(Block)); + s->key_blocks = av_realloc(s->key_blocks, s->cols * s->rows * sizeof(Block)); + if (!s->frame_blocks || !s->key_blocks) { + av_log(s->avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); + return -1; + } + s->blocks_size = s->rows * s->cols * sizeof(Block); + } + init_blocks(s, s->frame_blocks, s->encbuffer, s->databuffer); + init_blocks(s, s->key_blocks, s->keybuffer, 0); + + } + + s->use15_7 = optimum_use15_7(s); + if (s->use15_7) { + if ((s->use_custom_palette && s->palette_type != 1) || update_palette) { + res = generate_optimum_palette(&s->palette, image, s->image_width, s->image_height, stride); + if (res) + return res; + s->palette_type = 1; + av_log(s->avctx, AV_LOG_DEBUG, "Generated optimum palette\n"); + } else if (!s->use_custom_palette && s->palette_type != 0) { + res = generate_default_palette(&s->palette); + if (res) + return res; + s->palette_type = 0; + av_log(s->avctx, AV_LOG_DEBUG, "Generated default palette\n"); + } + } + + + reset_stats(s); + + return 0; +} + +static int flashsv2_encode_frame(AVCodecContext * avctx, uint8_t * buf, + int buf_size, void *data) +{ + FlashSV2Context *const s = avctx->priv_data; + AVFrame *pict = data; + AVFrame *const p = &s->frame; + int res; + int keyframe = 0; + + *p = *pict; + + /* First frame needs to be a keyframe */ + if (avctx->frame_number == 0) + keyframe = 1; + + /* Check the placement of keyframes */ + if (avctx->gop_size > 0) { + if (avctx->frame_number >= s->last_key_frame + avctx->gop_size) + keyframe = 1; + } + + if (buf_size < s->frame_size) { + //Conservative upper bound check for compressed data + av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", buf_size, s->frame_size); + return -1; + } + + if (!keyframe + && avctx->frame_number > s->last_key_frame + avctx->keyint_min) { + recommend_keyframe(s, &keyframe); + if (keyframe) + av_log(avctx, AV_LOG_DEBUG, "Recommending key frame at frame %d\n", avctx->frame_number); + } + + if (keyframe) { + res = reconfigure_at_keyframe(s, p->data[0], p->linesize[0]); + if (res) + return res; + } + + if (s->use15_7) + s->dist = optimum_dist(s); + + res = write_bitstream(s, p->data[0], p->linesize[0], buf, buf_size, keyframe); + + if (keyframe) { + new_key_frame(s); + p->pict_type = FF_I_TYPE; + p->key_frame = 1; + s->last_key_frame = avctx->frame_number; + av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number); + } else { + p->pict_type = FF_P_TYPE; + p->key_frame = 0; + } + + avctx->coded_frame = p; + + return res; +} + +static av_cold int flashsv2_encode_end(AVCodecContext * avctx) +{ + FlashSV2Context *s = avctx->priv_data; + + cleanup(s); + + return 0; +} + +AVCodec ff_flashsv2_encoder = { + "flashsv2", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_FLASHSV2, + sizeof(FlashSV2Context), + flashsv2_encode_init, + flashsv2_encode_frame, + flashsv2_encode_end, + .pix_fmts = (enum PixelFormat[]) {PIX_FMT_BGR24, PIX_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video Version 2"), + .capabilities = CODEC_CAP_EXPERIMENTAL, +}; diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index ad14104112..c0327a911b 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -3,20 +3,20 @@ * Copyright (C) 2004 Alex Beregszaszi * Copyright (C) 2006 Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index ed9972c018..8cc72e241e 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -2,20 +2,20 @@ * FLI/FLC Animation Video Decoder * Copyright (C) 2003, 2004 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -61,9 +61,9 @@ #define CHECK_PIXEL_PTR(n) \ if (pixel_ptr + n > pixel_limit) { \ - av_log (s->avctx, AV_LOG_INFO, "Problem: pixel_ptr >= pixel_limit (%d >= %d)\n", \ + av_log (s->avctx, AV_LOG_ERROR, "Invalid pixel_ptr = %d > pixel_limit = %d\n", \ pixel_ptr + n, pixel_limit); \ - return -1; \ + return AVERROR_INVALIDDATA; \ } \ typedef struct FlicDecodeContext { @@ -118,6 +118,7 @@ static av_cold int flic_decode_init(AVCodecContext *avctx) return -1; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; s->new_palette = 0; @@ -181,6 +182,11 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, /* iterate through the chunks */ while ((frame_size > 0) && (num_chunks > 0)) { chunk_size = AV_RL32(&buf[stream_ptr]); + if (chunk_size > frame_size) { + av_log(avctx, AV_LOG_WARNING, + "Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size); + chunk_size = frame_size; + } stream_ptr += 4; chunk_type = AV_RL16(&buf[stream_ptr]); stream_ptr += 2; diff --git a/libavcodec/flv.h b/libavcodec/flv.h index 3d9a2d5232..16bc88b663 100644 --- a/libavcodec/flv.h +++ b/libavcodec/flv.h @@ -1,19 +1,19 @@ /* * FLV specific private header. - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 9546c1c2ce..2a6694403b 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -1,19 +1,19 @@ /* * FLV decoding. - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 28bca2ea6a..fc8c2a474f 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -1,19 +1,19 @@ /* * FLV Encoding specific code. - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c index 58fece70b2..c03117c2cd 100644 --- a/libavcodec/fmtconvert.c +++ b/libavcodec/fmtconvert.c @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -86,3 +86,34 @@ av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) if (HAVE_ALTIVEC) ff_fmt_convert_init_altivec(c, avctx); if (HAVE_MMX) ff_fmt_convert_init_x86(c, avctx); } + +/* ffdshow custom code */ +void float_interleave(float *dst, const float **src, long len, int channels) +{ + int i,j,c; + if(channels==2){ + for(i=0; i<len; i++){ + dst[2*i] = src[0][i] / 32768.0f; + dst[2*i+1] = src[1][i] / 32768.0f; + } + }else{ + for(c=0; c<channels; c++) + for(i=0, j=c; i<len; i++, j+=channels) + dst[j] = src[c][i] / 32768.0f; + } +} + +void float_interleave_noscale(float *dst, const float **src, long len, int channels) +{ + int i,j,c; + if(channels==2){ + for(i=0; i<len; i++){ + dst[2*i] = src[0][i]; + dst[2*i+1] = src[1][i]; + } + }else{ + for(c=0; c<channels; c++) + for(i=0, j=c; i<len; i++, j+=channels) + dst[j] = src[c][i]; + } +} diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h index d7741135b7..825422bed6 100644 --- a/libavcodec/fmtconvert.h +++ b/libavcodec/fmtconvert.h @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -85,4 +85,8 @@ void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx); void ff_fmt_convert_init_altivec(FmtConvertContext *c, AVCodecContext *avctx); void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx); +/* ffdshow custom code */ +void float_interleave(float *dst, const float **src, long len, int channels); +void float_interleave_noscale(float *dst, const float **src, long len, int channels); + #endif /* AVCODEC_FMTCONVERT_H */ diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 2bbc7b9f01..7e96b0d312 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -3,20 +3,20 @@ * Copyright (c) 2005 Roine Gustafsson * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -46,6 +46,7 @@ typedef struct FrapsContext{ AVCodecContext *avctx; AVFrame frame; uint8_t *tmpbuf; + int tmpbuf_size; DSPContext dsp; } FrapsContext; @@ -59,8 +60,8 @@ static av_cold int decode_init(AVCodecContext *avctx) { FrapsContext * const s = avctx->priv_data; + avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = (AVFrame*)&s->frame; - avctx->pix_fmt= PIX_FMT_NONE; /* set in decode_frame */ s->avctx = avctx; s->tmpbuf = NULL; @@ -272,7 +273,9 @@ static int decode_frame(AVCodecContext *avctx, offs[planes] = buf_size; for(i = 0; i < planes; i++){ is_chroma = !!i; - s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&s->tmpbuf, &s->tmpbuf_size, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->tmpbuf) + return AVERROR(ENOMEM); if(fraps2_decode_plane(s, f->data[i], f->linesize[i], avctx->width >> is_chroma, avctx->height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); @@ -314,7 +317,9 @@ static int decode_frame(AVCodecContext *avctx, } offs[planes] = buf_size; for(i = 0; i < planes; i++){ - s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&s->tmpbuf, &s->tmpbuf_size, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->tmpbuf) + return AVERROR(ENOMEM); if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0], avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); diff --git a/libavcodec/frwu.c b/libavcodec/frwu.c index ee3d2e47a0..08dfbf0c9b 100644 --- a/libavcodec/frwu.c +++ b/libavcodec/frwu.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -27,7 +27,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { if (avctx->width & 1) { - av_log(avctx, AV_LOG_ERROR, "FRWU needs even width\n"); + av_log(avctx, AV_LOG_ERROR, "frwu needs even width\n"); return -1; } avctx->pix_fmt = PIX_FMT_UYVY422; @@ -110,7 +110,7 @@ static av_cold int decode_close(AVCodecContext *avctx) } AVCodec ff_frwu_decoder = { - "FRWU", + "frwu", AVMEDIA_TYPE_VIDEO, CODEC_ID_FRWU, 0, diff --git a/libavcodec/g722.c b/libavcodec/g722.c index 257292de7f..f00fa6a0e2 100644 --- a/libavcodec/g722.c +++ b/libavcodec/g722.c @@ -7,20 +7,20 @@ * Copyright (c) 2009 Kenan Gillet * Copyright (c) 2010 Martin Storsjo * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 09df727c0f..30bd96fcc9 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -5,20 +5,20 @@ * This is a very straightforward rendition of the G.726 * Section 4 "Computational Details". * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <limits.h> diff --git a/libavcodec/g729data.h b/libavcodec/g729data.h index 48010a7683..1d64553f20 100644 --- a/libavcodec/g729data.h +++ b/libavcodec/g729data.h @@ -2,20 +2,20 @@ * data for G.729 decoder * Copyright (c) 2007 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index 979b87fd27..32db0597e3 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -2,20 +2,20 @@ * G.729 decoder * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdlib.h> diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index 4136498c71..8579c87cd1 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -1,20 +1,20 @@ /* * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -127,7 +127,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc # define OPEN_READER(name, gb) \ unsigned int name##_index = (gb)->index; \ - unsigned int av_unused name##_cache = 0 + av_unused unsigned int name##_cache # define CLOSE_READER(name, gb) (gb)->index = name##_index diff --git a/libavcodec/gif.c b/libavcodec/gif.c index a34d710a10..121b873888 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -4,20 +4,20 @@ * Copyright (c) 2002 Francois Revol * Copyright (c) 2006 Baptiste Coudurier * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index 934c944a5b..39d0db9c24 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2006 Baptiste Coudurier * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/golomb.c b/libavcodec/golomb.c index 550c41ebfe..937ac22ce1 100644 --- a/libavcodec/golomb.c +++ b/libavcodec/golomb.c @@ -2,20 +2,20 @@ * exp golomb vlc stuff * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 83d277f963..90eeb30b54 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/gsmdec.c b/libavcodec/gsmdec.c index 693febd673..4ce36b48bc 100644 --- a/libavcodec/gsmdec.c +++ b/libavcodec/gsmdec.c @@ -2,20 +2,20 @@ * gsm 06.10 decoder * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/gsmdec_data.c b/libavcodec/gsmdec_data.c index 8b75bb6a67..4324ea28a9 100644 --- a/libavcodec/gsmdec_data.c +++ b/libavcodec/gsmdec_data.c @@ -2,20 +2,20 @@ * gsm 06.10 decoder data * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/gsmdec_data.h b/libavcodec/gsmdec_data.h index b78daa7335..bb4f159c60 100644 --- a/libavcodec/gsmdec_data.h +++ b/libavcodec/gsmdec_data.h @@ -2,20 +2,20 @@ * gsm 06.10 decoder data * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/gsmdec_template.c b/libavcodec/gsmdec_template.c index 7e57c7183f..b63ec9ed27 100644 --- a/libavcodec/gsmdec_template.c +++ b/libavcodec/gsmdec_template.c @@ -2,20 +2,20 @@ * gsm 06.10 decoder * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h261.c b/libavcodec/h261.c index eab36402ee..562a151e90 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -3,20 +3,20 @@ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h261.h b/libavcodec/h261.h index 6461329343..5b60dd65a3 100644 --- a/libavcodec/h261.h +++ b/libavcodec/h261.h @@ -3,20 +3,20 @@ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h261_parser.c b/libavcodec/h261_parser.c index 20c2862549..3fb86db125 100644 --- a/libavcodec/h261_parser.c +++ b/libavcodec/h261_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -70,11 +70,15 @@ static int h261_parse(AVCodecParserContext *s, ParseContext *pc = s->priv_data; int next; - next= h261_find_frame_end(pc,avctx, buf, buf_size); - if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { + next= h261_find_frame_end(pc,avctx, buf, buf_size); + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } } *poutbuf = buf; *poutbuf_size = buf_size; diff --git a/libavcodec/h261data.h b/libavcodec/h261data.h index 2c610151c7..82bae163df 100644 --- a/libavcodec/h261data.h +++ b/libavcodec/h261data.h @@ -2,20 +2,20 @@ * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * copyright (c) 2004 Maarten Daniels * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index a335d68ff1..108bd0e841 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -3,20 +3,20 @@ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 27746d5d8c..cd282fba75 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -3,20 +3,20 @@ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 5c25df2272..43d5b4b3e9 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -5,20 +5,20 @@ * Copyright (c) 2001 Juan J. Sierralta P * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h263.h b/libavcodec/h263.h index 1dc300709e..b2b6613536 100644 --- a/libavcodec/h263.h +++ b/libavcodec/h263.h @@ -1,20 +1,20 @@ /* * H263 internal header * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * 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_H263_H diff --git a/libavcodec/h263_parser.c b/libavcodec/h263_parser.c index 4b9fc110f2..a3d24ea433 100644 --- a/libavcodec/h263_parser.c +++ b/libavcodec/h263_parser.c @@ -2,20 +2,20 @@ * H.263 parser * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -70,12 +70,16 @@ static int h263_parse(AVCodecParserContext *s, ParseContext *pc = s->priv_data; int next; - next= ff_h263_find_frame_end(pc, buf, buf_size); + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { + next= ff_h263_find_frame_end(pc, buf, buf_size); - if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } } *poutbuf = buf; diff --git a/libavcodec/h263_parser.h b/libavcodec/h263_parser.h index 5bd715f49d..565a222bc1 100644 --- a/libavcodec/h263_parser.h +++ b/libavcodec/h263_parser.h @@ -2,20 +2,20 @@ * H.263 parser * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h263data.h b/libavcodec/h263data.h index 966da56110..81e3ddd2e0 100644 --- a/libavcodec/h263data.h +++ b/libavcodec/h263data.h @@ -4,20 +4,20 @@ * copyright (c) 2001 Juan J. Sierralta P * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index bc6d613be4..f079557759 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -3,20 +3,20 @@ * Copyright (c) 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -380,6 +380,18 @@ uint64_t time= rdtsc(); retry: + if(s->divx_packed && s->xvid_build>=0 && s->bitstream_buffer_size){ + int i; + for(i=0; i<buf_size-3; i++){ + if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1){ + if(buf[i+3]==0xB0){ + av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n"); + s->bitstream_buffer_size=0; + } + break; + } + } + } if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 5.01+/xvid frame reorder init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8); @@ -666,22 +678,18 @@ retry: frame_end: /* divx 5.01+ bistream reorder stuff */ if(s->codec_id==CODEC_ID_MPEG4 && s->divx_packed){ - int current_pos= get_bits_count(&s->gb)>>3; + int current_pos= s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb)>>3); int startcode_found=0; if(buf_size - current_pos > 5){ int i; - for(i=current_pos; i<buf_size-3; i++){ + for(i=current_pos; i<buf_size-4; i++){ if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ - startcode_found=1; + startcode_found=!(buf[i+4]&0x40); break; } } } - if(s->gb.buffer == s->bitstream_buffer && buf_size>7 && s->xvid_build>=0){ //xvid style - startcode_found=1; - current_pos=0; - } if(startcode_found){ av_fast_malloc( diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 276d6e6d6c..5c812144c9 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -636,9 +636,9 @@ static inline void prefetch_motion(H264Context *h, int list, int pixel_shift){ const int mx= (h->mv_cache[list][scan8[0]][0]>>2) + 16*s->mb_x + 8; const int my= (h->mv_cache[list][scan8[0]][1]>>2) + 16*s->mb_y; uint8_t **src= h->ref_list[list][refn].data; - int off= (mx << pixel_shift) + (my + (s->mb_x&3)*4)*h->mb_linesize + (64 << pixel_shift); + int off= ((mx+64)<<h->pixel_shift) + (my + (s->mb_x&3)*4)*h->mb_linesize; s->dsp.prefetch(src[0]+off, s->linesize, 4); - off= ((mx>>1) << pixel_shift) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + (64 << pixel_shift); + off= (((mx>>1)+64)<<h->pixel_shift) + ((my>>1) + (s->mb_x&7))*s->uvlinesize; s->dsp.prefetch(src[1]+off, src[2]-src[1], 2); } } @@ -1704,9 +1704,12 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16)) idct_dc_add(ptr, h->mb + (i*16 << pixel_shift), linesize); else - idct_add (ptr, h->mb + (i*16 << pixel_shift), linesize); - }else + idct_add (ptr, h->mb + (i*16<<pixel_shift), linesize); + } +#if CONFIG_SVQ3_DECODER + else ff_svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); +#endif } } } @@ -1725,8 +1728,11 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i dctcoef_set(h->mb, pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc, pixel_shift, i)); } } - }else + } +#if CONFIG_SVQ3_DECODER + else ff_svq3_luma_dc_dequant_idct_c(h->mb, h->mb_luma_dc, s->qscale); +#endif } if(h->deblocking_filter) xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, simple, pixel_shift); @@ -1778,7 +1784,9 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i } } } - }else{ + } +#if CONFIG_SVQ3_DECODER + else{ for(i=0; i<16; i++){ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below uint8_t * const ptr= dest_y + block_offset[i]; @@ -1786,6 +1794,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i } } } +#endif } if((simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) && (h->cbp&0x30)){ @@ -1810,7 +1819,9 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i h->h264dsp.h264_idct_add8(dest, block_offset, h->mb, uvlinesize, h->non_zero_count_cache); - }else{ + } +#if CONFIG_SVQ3_DECODER + else{ h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); for(i=16; i<16+8; i++){ @@ -1820,6 +1831,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i } } } +#endif } } } @@ -2441,9 +2453,20 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ h->mb_field_decoding_flag= s->picture_structure != PICT_FRAME; if(h0->current_slice == 0){ - if(h->frame_num != h->prev_frame_num && - (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num) < (h->frame_num - h->sps.ref_frame_count)) - h->prev_frame_num = h->frame_num - h->sps.ref_frame_count - 1; + // Shorten frame num gaps so we don't have to allocate reference frames just to throw them away + if(h->frame_num != h->prev_frame_num) { + int unwrap_prev_frame_num = h->prev_frame_num, max_frame_num = 1<<h->sps.log2_max_frame_num; + + if (unwrap_prev_frame_num > h->frame_num) unwrap_prev_frame_num -= max_frame_num; + + if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) { + unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1; + if (unwrap_prev_frame_num < 0) + unwrap_prev_frame_num += max_frame_num; + + h->prev_frame_num = unwrap_prev_frame_num; + } + } while(h->frame_num != h->prev_frame_num && h->frame_num != (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num)){ @@ -2873,11 +2896,10 @@ static int fill_filter_caches(H264Context *h, int mb_type){ if(IS_INTRA(mb_type)) return 0; - AV_COPY64(&h->non_zero_count_cache[0+8*1], &h->non_zero_count[mb_xy][ 0]); - AV_COPY64(&h->non_zero_count_cache[0+8*2], &h->non_zero_count[mb_xy][ 8]); - AV_COPY32(&h->non_zero_count_cache[0+8*5], &h->non_zero_count[mb_xy][16]); + AV_COPY32(&h->non_zero_count_cache[4+8*1], &h->non_zero_count[mb_xy][ 4]); + AV_COPY32(&h->non_zero_count_cache[4+8*2], &h->non_zero_count[mb_xy][12]); AV_COPY32(&h->non_zero_count_cache[4+8*3], &h->non_zero_count[mb_xy][20]); - AV_COPY64(&h->non_zero_count_cache[0+8*4], &h->non_zero_count[mb_xy][24]); + AV_COPY32(&h->non_zero_count_cache[4+8*4], &h->non_zero_count[mb_xy][28]); h->cbp= h->cbp_table[mb_xy]; @@ -3228,7 +3250,8 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){ if(s->mb_y >= s->mb_height){ tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits); - if(get_bits_count(&s->gb) == s->gb.size_in_bits ) { + if( get_bits_count(&s->gb) == s->gb.size_in_bits + || get_bits_count(&s->gb) < s->gb.size_in_bits && s->avctx->error_recognition < FF_ER_AGGRESSIVE) { ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); return 0; @@ -3327,6 +3350,7 @@ static void execute_decode_slices(H264Context *h, int context_count){ hx = h->thread_context[i]; hx->s.error_recognition = avctx->error_recognition; hx->s.error_count = 0; + hx->x264_build= h->x264_build; } avctx->execute(avctx, (void *)decode_slice, @@ -3418,7 +3442,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ bit_length= !dst_length ? 0 : (8*dst_length - ff_h264_decode_rbsp_trailing(h, ptr + dst_length - 1)); if(s->avctx->debug&FF_DEBUG_STARTCODE){ - av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", hx->nal_unit_type, buf_index, buf_size, dst_length); + av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d/%d at %d/%d length %d\n", hx->nal_unit_type, hx->nal_ref_idc, buf_index, buf_size, dst_length); } if (h->is_avc && (nalsize != consumed) && nalsize){ @@ -3529,7 +3553,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ init_get_bits(&s->gb, ptr, bit_length); ff_h264_decode_seq_parameter_set(h); - if(s->flags& CODEC_FLAG_LOW_DELAY) + if(s->flags& CODEC_FLAG_LOW_DELAY || + (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames)) s->low_delay=1; if(avctx->has_b_frames < 2) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 8c4f1ab21a..c075c4b48e 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -394,9 +394,9 @@ typedef struct H264Context{ /** * num_ref_idx_l0/1_active_minus1 + 1 */ + uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode unsigned int list_count; - uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. Reordered version of default_ref_list according to picture reordering in slice header */ diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 69af1e2ded..925ac44498 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... cabac decoding * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1101,6 +1101,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT } } + #define STORE_BLOCK(type) \ do { \ uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base; \ @@ -1144,11 +1145,11 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT } \ } while ( coeff_count ); - if (h->pixel_shift) { - STORE_BLOCK(int32_t) - } else { - STORE_BLOCK(int16_t) - } + if (h->pixel_shift) { + STORE_BLOCK(int32_t) + } else { + STORE_BLOCK(int16_t) + } #ifdef CABAC_ON_STACK h->cabac.range = cc.range ; h->cabac.low = cc.low ; diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 2e5ea54679..62e30f1311 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... cavlc bitstream decoding * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c index a7e6853b5c..34a4ff727f 100644 --- a/libavcodec/h264_direct.c +++ b/libavcodec/h264_direct.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... direct mb/block decoding * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 72b1905936..2e61a3110a 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... loop filter * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index bc49b146ab..e85bdb6712 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -2,20 +2,20 @@ * H.264 MP4 to Annex B byte stream format filter * Copyright (c) 2007 Benoit Fouet <benoit.fouet@free.fr> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -87,11 +87,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, /* retrieve sps and pps unit(s) */ unit_nb = *extradata++ & 0x1f; /* number of sps unit(s) */ if (!unit_nb) { - unit_nb = *extradata++; /* number of pps unit(s) */ - sps_done++; - - if (unit_nb) - pps_seen = 1; + goto pps; } else { sps_seen = 1; } @@ -115,7 +111,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, memcpy(out+total_size-unit_size-4, nalu_header, 4); memcpy(out+total_size-unit_size, extradata+2, unit_size); extradata += 2+unit_size; - +pps: if (!unit_nb && !sps_done++) { unit_nb = *extradata++; /* number of pps unit(s) */ if (unit_nb) diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index 1359072dc8..661ef6c381 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... motion vector predicion * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index c39baeb739..080b6a93b5 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... parser * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index a98f14aaf6..f77a013112 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... parameter set decoding * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -414,7 +414,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ sps->sar.den= 1; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ - av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\n", + av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d b%d\n", sps_id, sps->profile_idc, sps->level_idc, sps->poc_type, sps->ref_frame_count, @@ -426,7 +426,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ sps->vui_parameters_present_flag ? "VUI" : "", ((const char*[]){"Gray","420","422","444"})[sps->chroma_format_idc], sps->timing_info_present_flag ? sps->num_units_in_tick : 0, - sps->timing_info_present_flag ? sps->time_scale : 0 + sps->timing_info_present_flag ? sps->time_scale : 0, + sps->bit_depth_luma ); } diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index a025f7d352..9554201522 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... reference picture handling * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -25,6 +25,7 @@ * @author Michael Niedermayer <michaelni@gmx.at> */ +#include "libavutil/avassert.h" #include "internal.h" #include "dsputil.h" #include "avcodec.h" @@ -476,7 +477,7 @@ static void print_long_term(H264Context *h) { void ff_generate_sliding_window_mmcos(H264Context *h) { MpegEncContext * const s = &h->s; - assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); + av_assert0(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); h->mmco_index= 0; if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && @@ -621,8 +622,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ } } - if (h->long_ref_count + h->short_ref_count - - (h->short_ref[0] == s->current_picture_ptr) > h->sps.ref_frame_count){ + if (h->long_ref_count + h->short_ref_count > FFMAX(h->sps.ref_frame_count, 1)){ /* We have too many reference frames, probably due to corrupted * stream. Need to discard one frame. Prevents overrun of the diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 4f52bbe969..195ea2856f 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... sei decoding * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h index 1851169dd3..c459523f71 100644 --- a/libavcodec/h264data.h +++ b/libavcodec/h264data.h @@ -2,20 +2,20 @@ * H26L/H264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index 64f4856189..96a38ff77d 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h index 864c118bb5..6ed0b537cd 100644 --- a/libavcodec/h264dsp.h +++ b/libavcodec/h264dsp.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264dsp_template.c b/libavcodec/h264dsp_template.c index be88f7487f..eb336f7e62 100644 --- a/libavcodec/h264dsp_template.c +++ b/libavcodec/h264dsp_template.c @@ -1,21 +1,21 @@ /* * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder - * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at> + * Copyright (c) 2003-2011 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,10 +30,10 @@ #define op_scale1(x) block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom ) #define op_scale2(x) dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1)) #define H264_WEIGHT(W,H) \ -static void FUNCC(weight_h264_pixels ## W ## x ## H)(uint8_t *_block, int stride, int log2_denom, int weight, int offset){ \ +static void FUNCC(weight_h264_pixels ## W ## x ## H)(uint8_t *p_block, int stride, int log2_denom, int weight, int offset){ \ int y; \ - pixel *block = (pixel*)_block; \ - stride /= sizeof(pixel); \ + pixel *block = (pixel*)p_block; \ + stride >>= sizeof(pixel)-1; \ offset <<= (log2_denom + (BIT_DEPTH-8)); \ if(log2_denom) offset += 1<<(log2_denom-1); \ for(y=0; y<H; y++, block += stride){ \ @@ -62,7 +62,7 @@ static void FUNCC(biweight_h264_pixels ## W ## x ## H)(uint8_t *_dst, uint8_t *_ int y; \ pixel *dst = (pixel*)_dst; \ pixel *src = (pixel*)_src; \ - stride /= sizeof(pixel); \ + stride >>= sizeof(pixel)-1; \ offset <<= (BIT_DEPTH-8); \ offset = ((offset + 1) | 1) << log2_denom; \ for(y=0; y<H; y++, dst += stride, src += stride){ \ @@ -103,12 +103,12 @@ H264_WEIGHT(2,2) #undef op_scale2 #undef H264_WEIGHT -static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) { - pixel *pix = (pixel*)_pix; + pixel *pix = (pixel*)p_pix; int i, d; - xstride /= sizeof(pixel); - ystride /= sizeof(pixel); + xstride >>= sizeof(pixel)-1; + ystride >>= sizeof(pixel)-1; alpha <<= BIT_DEPTH - 8; beta <<= BIT_DEPTH - 8; for( i = 0; i < 4; i++ ) { @@ -164,12 +164,12 @@ static void FUNCC(h264_h_loop_filter_luma_mbaff)(uint8_t *pix, int stride, int a FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, 2, alpha, beta, tc0); } -static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma_intra)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma_intra)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta) { - pixel *pix = (pixel*)_pix; + pixel *pix = (pixel*)p_pix; int d; - xstride /= sizeof(pixel); - ystride /= sizeof(pixel); + xstride >>= sizeof(pixel)-1; + ystride >>= sizeof(pixel)-1; alpha <<= BIT_DEPTH - 8; beta <<= BIT_DEPTH - 8; for( d = 0; d < 4 * inner_iters; d++ ) { @@ -230,14 +230,14 @@ static void FUNCC(h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix, int stride, FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta); } -static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) { - pixel *pix = (pixel*)_pix; + pixel *pix = (pixel*)p_pix; int i, d; - xstride /= sizeof(pixel); - ystride /= sizeof(pixel); alpha <<= BIT_DEPTH - 8; beta <<= BIT_DEPTH - 8; + xstride >>= sizeof(pixel)-1; + ystride >>= sizeof(pixel)-1; for( i = 0; i < 4; i++ ) { const int tc = ((tc0[i] - 1) << (BIT_DEPTH - 8)) + 1; if( tc <= 0 ) { @@ -276,12 +276,12 @@ static void FUNCC(h264_h_loop_filter_chroma_mbaff)(uint8_t *pix, int stride, int FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 1, alpha, beta, tc0); } -static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma_intra)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma_intra)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta) { - pixel *pix = (pixel*)_pix; + pixel *pix = (pixel*)p_pix; int d; - xstride /= sizeof(pixel); - ystride /= sizeof(pixel); + xstride >>= sizeof(pixel)-1; + ystride >>= sizeof(pixel)-1; alpha <<= BIT_DEPTH - 8; beta <<= BIT_DEPTH - 8; for( d = 0; d < 4 * inner_iters; d++ ) { diff --git a/libavcodec/h264idct.c b/libavcodec/h264idct.c index 1634a00835..7d1ee007bc 100644 --- a/libavcodec/h264idct.c +++ b/libavcodec/h264idct.c @@ -2,20 +2,20 @@ * H.264 IDCT * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index 39c9a1c9eb..1b3c635319 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -2,20 +2,20 @@ * H.264 IDCT * Copyright (c) 2004-2011 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -42,12 +42,12 @@ static const uint8_t scan8[16 + 2*4]={ }; #endif -static av_always_inline void FUNCC(idct_internal)(uint8_t *_dst, DCTELEM *_block, int stride, int block_stride, int shift, int add){ +static av_always_inline void FUNCC(idct_internal)(uint8_t *p_dst, DCTELEM *p_block, int stride, int block_stride, int shift, int add){ int i; INIT_CLIP - pixel *dst = (pixel*)_dst; - dctcoef *block = (dctcoef*)_block; - stride /= sizeof(pixel); + pixel *dst = (pixel*)p_dst; + dctcoef *block = (dctcoef*)p_block; + stride >>= sizeof(pixel)-1; block[0] += 1<<(shift-1); @@ -88,12 +88,12 @@ void FUNCC(ff_h264_lowres_idct_put)(uint8_t *dst, int stride, DCTELEM *block){ FUNCC(idct_internal)(dst, block, stride, 8, 3, 0); } -void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, DCTELEM *_block, int stride){ +void FUNCC(ff_h264_idct8_add)(uint8_t *p_dst, DCTELEM *p_block, int stride){ int i; INIT_CLIP - pixel *dst = (pixel*)_dst; - dctcoef *block = (dctcoef*)_block; - stride /= sizeof(pixel); + pixel *dst = (pixel*)p_dst; + dctcoef *block = (dctcoef*)p_block; + stride >>= sizeof(pixel)-1; block[0] += 32; @@ -162,12 +162,12 @@ void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, DCTELEM *_block, int stride){ } // assumes all AC coefs are 0 -void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){ +void FUNCC(ff_h264_idct_dc_add)(uint8_t *p_dst, DCTELEM *block, int stride){ int i, j; int dc = (((dctcoef*)block)[0] + 32) >> 6; INIT_CLIP - pixel *dst = (pixel*)_dst; - stride /= sizeof(pixel); + pixel *dst = (pixel*)p_dst; + stride >>= sizeof(pixel)-1; for( j = 0; j < 4; j++ ) { for( i = 0; i < 4; i++ ) @@ -176,12 +176,12 @@ void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){ } } -void FUNCC(ff_h264_idct8_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){ +void FUNCC(ff_h264_idct8_dc_add)(uint8_t *p_dst, DCTELEM *block, int stride){ int i, j; int dc = (((dctcoef*)block)[0] + 32) >> 6; INIT_CLIP - pixel *dst = (pixel*)_dst; - stride /= sizeof(pixel); + pixel *dst = (pixel*)p_dst; + stride >>= sizeof(pixel)-1; for( j = 0; j < 8; j++ ) { for( i = 0; i < 8; i++ ) @@ -233,13 +233,13 @@ void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, DCTELEM * * IDCT transforms the 16 dc values and dequantizes them. * @param qp quantization parameter */ -void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *_output, DCTELEM *_input, int qmul){ +void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *p_output, DCTELEM *p_input, int qmul){ #define stride 16 int i; int temp[16]; static const uint8_t x_offset[4]={0, 2*stride, 8*stride, 10*stride}; - dctcoef *input = (dctcoef*)_input; - dctcoef *output = (dctcoef*)_output; + dctcoef *input = (dctcoef*)p_input; + dctcoef *output = (dctcoef*)p_output; for(i=0; i<4; i++){ const int z0= input[4*i+0] + input[4*i+1]; @@ -268,11 +268,11 @@ void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *_output, DCTELEM *_input, int #undef stride } -void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *_block, int qmul){ +void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *p_block, int qmul){ const int stride= 16*2; const int xStride= 16; int a,b,c,d,e; - dctcoef *block = (dctcoef*)_block; + dctcoef *block = (dctcoef*)p_block; a= block[stride*0 + xStride*0]; b= block[stride*0 + xStride*1]; diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c index b3701ef3b8..f6533cf9ba 100644 --- a/libavcodec/h264pred.c +++ b/libavcodec/h264pred.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h index 34b1e90bbc..daf123f968 100644 --- a/libavcodec/h264pred.h +++ b/libavcodec/h264pred.h @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c index 1c1fe0bc31..3cd4463d76 100644 --- a/libavcodec/h264pred_template.c +++ b/libavcodec/h264pred_template.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003-2011 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,7 +30,7 @@ static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const pixel4 a= AV_RN4PA(src-stride); AV_WN4PA(src+0*stride, a); @@ -41,7 +41,7 @@ static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int static void FUNCC(pred4x4_horizontal)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); AV_WN4PA(src+0*stride, PIXEL_SPLAT_X4(src[-1+0*stride])); AV_WN4PA(src+1*stride, PIXEL_SPLAT_X4(src[-1+1*stride])); AV_WN4PA(src+2*stride, PIXEL_SPLAT_X4(src[-1+2*stride])); @@ -50,7 +50,7 @@ static void FUNCC(pred4x4_horizontal)(uint8_t *_src, const uint8_t *topright, in static void FUNCC(pred4x4_dc)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3; const pixel4 a = PIXEL_SPLAT_X4(dc); @@ -63,7 +63,7 @@ static void FUNCC(pred4x4_dc)(uint8_t *_src, const uint8_t *topright, int _strid static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2; const pixel4 a = PIXEL_SPLAT_X4(dc); @@ -75,7 +75,7 @@ static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _ static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2; const pixel4 a = PIXEL_SPLAT_X4(dc); @@ -87,7 +87,7 @@ static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright, int _s static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const pixel4 a = PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1)); AV_WN4PA(src+0*stride, a); @@ -98,7 +98,7 @@ static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright, int _s static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))-1); AV_WN4PA(src+0*stride, a); @@ -109,7 +109,7 @@ static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright, int _s static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))+1); AV_WN4PA(src+0*stride, a); @@ -145,7 +145,7 @@ static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright, int _s static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const int lt= src[-1-1*stride]; LOAD_TOP_EDGE LOAD_LEFT_EDGE @@ -171,7 +171,7 @@ static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright, in static void FUNCC(pred4x4_down_left)(uint8_t *_src, const uint8_t *_topright, int _stride){ pixel *src = (pixel*)_src; const pixel *topright = (const pixel*)_topright; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE // LOAD_LEFT_EDGE @@ -196,7 +196,7 @@ static void FUNCC(pred4x4_down_left)(uint8_t *_src, const uint8_t *_topright, in static void FUNCC(pred4x4_vertical_right)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const int lt= src[-1-1*stride]; LOAD_TOP_EDGE LOAD_LEFT_EDGE @@ -222,7 +222,7 @@ static void FUNCC(pred4x4_vertical_right)(uint8_t *_src, const uint8_t *topright static void FUNCC(pred4x4_vertical_left)(uint8_t *_src, const uint8_t *_topright, int _stride){ pixel *src = (pixel*)_src; const pixel *topright = (const pixel*)_topright; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE @@ -246,7 +246,7 @@ static void FUNCC(pred4x4_vertical_left)(uint8_t *_src, const uint8_t *_topright static void FUNCC(pred4x4_horizontal_up)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); LOAD_LEFT_EDGE src[0+0*stride]=(l0 + l1 + 1)>>1; @@ -269,7 +269,7 @@ static void FUNCC(pred4x4_horizontal_up)(uint8_t *_src, const uint8_t *topright, static void FUNCC(pred4x4_horizontal_down)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const int lt= src[-1-1*stride]; LOAD_TOP_EDGE LOAD_LEFT_EDGE @@ -295,7 +295,7 @@ static void FUNCC(pred4x4_horizontal_down)(uint8_t *_src, const uint8_t *toprigh static void FUNCC(pred16x16_vertical)(uint8_t *_src, int _stride){ int i; pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const pixel4 a = AV_RN4PA(((pixel4*)(src-stride))+0); const pixel4 b = AV_RN4PA(((pixel4*)(src-stride))+1); const pixel4 c = AV_RN4PA(((pixel4*)(src-stride))+2); @@ -312,7 +312,7 @@ static void FUNCC(pred16x16_vertical)(uint8_t *_src, int _stride){ static void FUNCC(pred16x16_horizontal)(uint8_t *_src, int stride){ int i; pixel *src = (pixel*)_src; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; for(i=0; i<16; i++){ const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]); @@ -337,7 +337,7 @@ static void FUNCC(pred16x16_dc)(uint8_t *_src, int stride){ int i, dc=0; pixel *src = (pixel*)_src; pixel4 dcsplat; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; for(i=0;i<16; i++){ dc+= src[-1+i*stride]; @@ -355,7 +355,7 @@ static void FUNCC(pred16x16_left_dc)(uint8_t *_src, int stride){ int i, dc=0; pixel *src = (pixel*)_src; pixel4 dcsplat; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; for(i=0;i<16; i++){ dc+= src[-1+i*stride]; @@ -369,7 +369,7 @@ static void FUNCC(pred16x16_top_dc)(uint8_t *_src, int stride){ int i, dc=0; pixel *src = (pixel*)_src; pixel4 dcsplat; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; for(i=0;i<16; i++){ dc+= src[i-stride]; @@ -383,7 +383,7 @@ static void FUNCC(pred16x16_top_dc)(uint8_t *_src, int stride){ static void FUNCC(pred16x16_##n##_dc)(uint8_t *_src, int stride){\ int i;\ pixel *src = (pixel*)_src;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ PREDICT_16x16_DC(PIXEL_SPLAT_X4(v));\ } @@ -391,12 +391,12 @@ PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1); PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0); PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1); -static inline void FUNCC(pred16x16_plane_compat)(uint8_t *_src, int _stride, const int svq3, const int rv40){ +static inline void FUNCC(pred16x16_plane_compat)(uint8_t *p_src, int p_stride, const int svq3, const int rv40){ int i, j, k; int a; INIT_CLIP - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); const pixel * const src0 = src +7-stride; const pixel * src1 = src +8*stride-1; const pixel * src2 = src1-2*stride; // == src+6*stride-1; @@ -443,7 +443,7 @@ static void FUNCC(pred16x16_plane)(uint8_t *src, int stride){ static void FUNCC(pred8x8_vertical)(uint8_t *_src, int _stride){ int i; pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0); const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1); @@ -456,7 +456,7 @@ static void FUNCC(pred8x8_vertical)(uint8_t *_src, int _stride){ static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){ int i; pixel *src = (pixel*)_src; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; for(i=0; i<8; i++){ const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]); @@ -470,7 +470,7 @@ static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\ int i;\ const pixel4 a = PIXEL_SPLAT_X4(v);\ pixel *src = (pixel*)_src;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ for(i=0; i<8; i++){\ AV_WN4PA(((pixel4*)(src+i*stride))+0, a);\ AV_WN4PA(((pixel4*)(src+i*stride))+1, a);\ @@ -486,7 +486,7 @@ static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){ int dc0, dc2; pixel4 dc0splat, dc2splat; pixel *src = (pixel*)_src; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; dc0=dc2=0; for(i=0;i<4; i++){ @@ -511,7 +511,7 @@ static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){ int dc0, dc1; pixel4 dc0splat, dc1splat; pixel *src = (pixel*)_src; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; dc0=dc1=0; for(i=0;i<4; i++){ @@ -536,7 +536,7 @@ static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){ int dc0, dc1, dc2; pixel4 dc0splat, dc1splat, dc2splat, dc3splat; pixel *src = (pixel*)_src; - stride /= sizeof(pixel); + stride >>= sizeof(pixel)-1; dc0=dc1=dc2=0; for(i=0;i<4; i++){ @@ -587,7 +587,7 @@ static void FUNCC(pred8x8_plane)(uint8_t *_src, int _stride){ int a; INIT_CLIP pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); const pixel * const src0 = src +3-stride; const pixel * src1 = src +4*stride-1; const pixel * src2 = src1-2*stride; // == src+2*stride-1; @@ -658,32 +658,32 @@ static void FUNCC(pred8x8_plane)(uint8_t *_src, int _stride){ static void FUNCC(pred8x8l_128_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride) { pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); PREDICT_8x8_DC(PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1))); } static void FUNCC(pred8x8l_left_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride) { pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_LEFT; const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7+4) >> 3); PREDICT_8x8_DC(dc); } -static void FUNCC(pred8x8l_top_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_top_dc)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_TOP; const pixel4 dc = PIXEL_SPLAT_X4((t0+t1+t2+t3+t4+t5+t6+t7+4) >> 3); PREDICT_8x8_DC(dc); } -static void FUNCC(pred8x8l_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_dc)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_LEFT; PREDICT_8x8_LOAD_TOP; @@ -691,10 +691,10 @@ static void FUNCC(pred8x8l_dc)(uint8_t *_src, int has_topleft, int has_topright, +t0+t1+t2+t3+t4+t5+t6+t7+8) >> 4); PREDICT_8x8_DC(dc); } -static void FUNCC(pred8x8l_horizontal)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_horizontal)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); pixel4 a; PREDICT_8x8_LOAD_LEFT; @@ -708,7 +708,7 @@ static void FUNCC(pred8x8l_vertical)(uint8_t *_src, int has_topleft, int has_top { int y; pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + int stride = _stride>>(sizeof(pixel)-1); pixel4 a, b; PREDICT_8x8_LOAD_TOP; @@ -727,10 +727,10 @@ static void FUNCC(pred8x8l_vertical)(uint8_t *_src, int has_topleft, int has_top AV_WN4PA(((pixel4*)(src+y*stride))+1, b); } } -static void FUNCC(pred8x8l_down_left)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_down_left)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_TOP; PREDICT_8x8_LOAD_TOPRIGHT; SRC(0,0)= (t0 + 2*t1 + t2 + 2) >> 2; @@ -749,10 +749,10 @@ static void FUNCC(pred8x8l_down_left)(uint8_t *_src, int has_topleft, int has_to SRC(6,7)=SRC(7,6)= (t13 + 2*t14 + t15 + 2) >> 2; SRC(7,7)= (t14 + 3*t15 + 2) >> 2; } -static void FUNCC(pred8x8l_down_right)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_down_right)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_TOP; PREDICT_8x8_LOAD_LEFT; PREDICT_8x8_LOAD_TOPLEFT; @@ -772,10 +772,10 @@ static void FUNCC(pred8x8l_down_right)(uint8_t *_src, int has_topleft, int has_t SRC(6,0)=SRC(7,1)= (t4 + 2*t5 + t6 + 2) >> 2; SRC(7,0)= (t5 + 2*t6 + t7 + 2) >> 2; } -static void FUNCC(pred8x8l_vertical_right)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_vertical_right)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_TOP; PREDICT_8x8_LOAD_LEFT; PREDICT_8x8_LOAD_TOPLEFT; @@ -802,10 +802,10 @@ static void FUNCC(pred8x8l_vertical_right)(uint8_t *_src, int has_topleft, int h SRC(7,1)= (t5 + 2*t6 + t7 + 2) >> 2; SRC(7,0)= (t6 + t7 + 1) >> 1; } -static void FUNCC(pred8x8l_horizontal_down)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_horizontal_down)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_TOP; PREDICT_8x8_LOAD_LEFT; PREDICT_8x8_LOAD_TOPLEFT; @@ -832,10 +832,10 @@ static void FUNCC(pred8x8l_horizontal_down)(uint8_t *_src, int has_topleft, int SRC(6,0)= (t5 + 2*t4 + t3 + 2) >> 2; SRC(7,0)= (t6 + 2*t5 + t4 + 2) >> 2; } -static void FUNCC(pred8x8l_vertical_left)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_vertical_left)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_TOP; PREDICT_8x8_LOAD_TOPRIGHT; SRC(0,0)= (t0 + t1 + 1) >> 1; @@ -861,10 +861,10 @@ static void FUNCC(pred8x8l_vertical_left)(uint8_t *_src, int has_topleft, int ha SRC(7,6)= (t10 + t11 + 1) >> 1; SRC(7,7)= (t10 + 2*t11 + t12 + 2) >> 2; } -static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft, int has_topright, int _stride) +static void FUNCC(pred8x8l_horizontal_up)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride) { - pixel *src = (pixel*)_src; - int stride = _stride/sizeof(pixel); + pixel *src = (pixel*)p_src; + int stride = p_stride>>(sizeof(pixel)-1); PREDICT_8x8_LOAD_LEFT; SRC(0,0)= (l0 + l1 + 1) >> 1; SRC(1,0)= (l0 + 2*l1 + l2 + 2) >> 2; @@ -895,11 +895,11 @@ static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft, int ha #undef PL #undef SRC -static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const DCTELEM *_block, int stride){ +static void FUNCC(pred4x4_vertical_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){ int i; - pixel *pix = (pixel*)_pix; - const dctcoef *block = (const dctcoef*)_block; - stride /= sizeof(pixel); + pixel *pix = (pixel*)p_pix; + const dctcoef *block = (const dctcoef*)p_block; + stride >>= sizeof(pixel)-1; pix -= stride; for(i=0; i<4; i++){ pixel v = pix[0]; @@ -912,11 +912,11 @@ static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const DCTELEM *_block, in } } -static void FUNCC(pred4x4_horizontal_add)(uint8_t *_pix, const DCTELEM *_block, int stride){ +static void FUNCC(pred4x4_horizontal_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){ int i; - pixel *pix = (pixel*)_pix; - const dctcoef *block = (const dctcoef*)_block; - stride /= sizeof(pixel); + pixel *pix = (pixel*)p_pix; + const dctcoef *block = (const dctcoef*)p_block; + stride >>= sizeof(pixel)-1; for(i=0; i<4; i++){ pixel v = pix[-1]; pix[0]= v += block[0]; @@ -928,11 +928,11 @@ static void FUNCC(pred4x4_horizontal_add)(uint8_t *_pix, const DCTELEM *_block, } } -static void FUNCC(pred8x8l_vertical_add)(uint8_t *_pix, const DCTELEM *_block, int stride){ +static void FUNCC(pred8x8l_vertical_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){ int i; - pixel *pix = (pixel*)_pix; - const dctcoef *block = (const dctcoef*)_block; - stride /= sizeof(pixel); + pixel *pix = (pixel*)p_pix; + const dctcoef *block = (const dctcoef*)p_block; + stride >>= sizeof(pixel)-1; pix -= stride; for(i=0; i<8; i++){ pixel v = pix[0]; @@ -949,11 +949,11 @@ static void FUNCC(pred8x8l_vertical_add)(uint8_t *_pix, const DCTELEM *_block, i } } -static void FUNCC(pred8x8l_horizontal_add)(uint8_t *_pix, const DCTELEM *_block, int stride){ +static void FUNCC(pred8x8l_horizontal_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){ int i; - pixel *pix = (pixel*)_pix; - const dctcoef *block = (const dctcoef*)_block; - stride /= sizeof(pixel); + pixel *pix = (pixel*)p_pix; + const dctcoef *block = (const dctcoef*)p_block; + stride >>= sizeof(pixel)-1; for(i=0; i<8; i++){ pixel v = pix[-1]; pix[0]= v += block[0]; diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c index 211ea63750..853fa64a48 100644 --- a/libavcodec/huffman.c +++ b/libavcodec/huffman.c @@ -3,20 +3,20 @@ * huffman tree builder and VLC generator * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/huffman.h b/libavcodec/huffman.h index 4a60187b3c..3c08e6fb1b 100644 --- a/libavcodec/huffman.h +++ b/libavcodec/huffman.h @@ -3,20 +3,20 @@ * huffman tree builder and VLC generator * Copyright (C) 2007 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index a399142d59..0f59421bb7 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -6,20 +6,20 @@ * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of * the algorithm used * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -433,6 +433,7 @@ static av_cold int decode_init(AVCodecContext *avctx) memset(s->vlc, 0, 3*sizeof(VLC)); avctx->coded_frame= &s->picture; + avcodec_get_frame_defaults(&s->picture); s->interlaced= s->height > 288; s->bgr32=1; diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c index ac56e19442..362ba3bde9 100644 --- a/libavcodec/idcinvideo.c +++ b/libavcodec/idcinvideo.c @@ -2,20 +2,20 @@ * id Quake II CIN Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -166,6 +166,7 @@ static av_cold int idcin_decode_init(AVCodecContext *avctx) huff_build_tree(s, i); } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 63e1f31a4e..195ef10ac7 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -3,20 +3,20 @@ * Copyright (c) 2010 Peter Ross <pross@xvid.org> * Copyright (c) 2010 Sebastian Vater <cdgs.basty@googlemail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,10 +30,26 @@ #include "avcodec.h" #include "get_bits.h" +// TODO: masking bits +typedef enum { + MASK_NONE, + MASK_HAS_MASK, + MASK_HAS_TRANSPARENT_COLOR, + MASK_LASSO +} mask_type; + typedef struct { AVFrame frame; int planesize; uint8_t * planebuf; + uint8_t * ham_buf; ///< temporary buffer for planar to chunky conversation + uint32_t *ham_palbuf; ///< HAM decode table + unsigned compression; ///< delta compression method used + unsigned bpp; ///< bits per plane to decode (differs from bits_per_coded_sample if HAM) + unsigned ham; ///< 0 if non-HAM or number of hold bits (6 for bpp > 6, 4 otherwise) + unsigned flags; ///< 1 for EHB, 0 is no extra half darkening + unsigned transparency; ///< TODO: transparency color index in palette + unsigned masking; ///< TODO: masking method used int init; // 1 if buffer and palette data already initialized, 0 otherwise } IffContext; @@ -122,6 +138,8 @@ static av_always_inline uint32_t gray2rgb(const uint32_t x) { static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) { int count, i; + const uint8_t *const palette = avctx->extradata + AV_RB16(avctx->extradata); + int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); if (avctx->bits_per_coded_sample > 8) { av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n"); @@ -130,10 +148,10 @@ static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) count = 1 << avctx->bits_per_coded_sample; // If extradata is smaller than actually needed, fill the remaining with black. - count = FFMIN(avctx->extradata_size / 3, count); + count = FFMIN(palette_size / 3, count); if (count) { for (i=0; i < count; i++) { - pal[i] = 0xFF000000 | AV_RB24( avctx->extradata + i*3 ); + pal[i] = 0xFF000000 | AV_RB24(palette + i*3); } } else { // Create gray-scale color palette for bps < 8 count = 1 << avctx->bits_per_coded_sample; @@ -145,15 +163,127 @@ static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) return 0; } +/** + * Extracts the IFF extra context and updates internal + * decoder structures. + * + * @param avctx the AVCodecContext where to extract extra context to + * @param avpkt the AVPacket to extract extra context from or NULL to use avctx + * @return 0 in case of success, a negative error code otherwise + */ +static int extract_header(AVCodecContext *const avctx, + const AVPacket *const avpkt) { + const uint8_t *buf; + unsigned buf_size; + IffContext *s = avctx->priv_data; + int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); + + if (avpkt) { + int image_size; + if (avpkt->size < 2) + return AVERROR_INVALIDDATA; + image_size = avpkt->size - AV_RB16(avpkt->data); + buf = avpkt->data; + buf_size = bytestream_get_be16(&buf); + if (buf_size <= 1 || image_size <= 1) { + av_log(avctx, AV_LOG_ERROR, + "Invalid image size received: %u -> image data offset: %d\n", + buf_size, image_size); + return AVERROR_INVALIDDATA; + } + } else { + if (avctx->extradata_size < 2) + return AVERROR_INVALIDDATA; + buf = avctx->extradata; + buf_size = bytestream_get_be16(&buf); + if (buf_size <= 1 || palette_size < 0) { + av_log(avctx, AV_LOG_ERROR, + "Invalid palette size received: %u -> palette data offset: %d\n", + buf_size, palette_size); + return AVERROR_INVALIDDATA; + } + } + + if (buf_size > 8) { + s->compression = bytestream_get_byte(&buf); + s->bpp = bytestream_get_byte(&buf); + s->ham = bytestream_get_byte(&buf); + s->flags = bytestream_get_byte(&buf); + s->transparency = bytestream_get_be16(&buf); + s->masking = bytestream_get_byte(&buf); + if (s->masking == MASK_HAS_TRANSPARENT_COLOR) { + av_log(avctx, AV_LOG_ERROR, "Transparency not supported\n"); + return AVERROR_PATCHWELCOME; + } else if (s->masking != MASK_NONE) { + av_log(avctx, AV_LOG_ERROR, "Masking not supported\n"); + return AVERROR_PATCHWELCOME; + } + if (!s->bpp || s->bpp > 32) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", s->bpp); + return AVERROR_INVALIDDATA; + } else if (s->ham >= 8) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: %u\n", s->ham); + return AVERROR_INVALIDDATA; + } + + av_freep(&s->ham_buf); + av_freep(&s->ham_palbuf); + + if (s->ham) { + int i, count = FFMIN(palette_size / 3, 1 << s->ham); + const uint8_t *const palette = avctx->extradata + AV_RB16(avctx->extradata); + s->ham_buf = av_malloc((s->planesize * 8) + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->ham_buf) + return AVERROR(ENOMEM); + + s->ham_palbuf = av_malloc((8 * (1 << s->ham) * sizeof (uint32_t)) + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->ham_palbuf) { + av_freep(&s->ham_buf); + return AVERROR(ENOMEM); + } + + if (count) { // HAM with color palette attached + // prefill with black and palette and set HAM take direct value mask to zero + memset(s->ham_palbuf, 0, (1 << s->ham) * 2 * sizeof (uint32_t)); + for (i=0; i < count; i++) { + s->ham_palbuf[i*2+1] = AV_RL24(palette + i*3); + } + count = 1 << s->ham; + } else { // HAM with grayscale color palette + count = 1 << s->ham; + for (i=0; i < count; i++) { + s->ham_palbuf[i*2] = 0; // take direct color value from palette + s->ham_palbuf[i*2+1] = av_le2ne32(gray2rgb((i * 255) >> s->ham)); + } + } + for (i=0; i < count; i++) { + uint32_t tmp = i << (8 - s->ham); + tmp |= tmp >> s->ham; + s->ham_palbuf[(i+count)*2] = 0x00FFFF; // just modify blue color component + s->ham_palbuf[(i+count*2)*2] = 0xFFFF00; // just modify red color component + s->ham_palbuf[(i+count*3)*2] = 0xFF00FF; // just modify green color component + s->ham_palbuf[(i+count)*2+1] = tmp << 16; + s->ham_palbuf[(i+count*2)*2+1] = tmp; + s->ham_palbuf[(i+count*3)*2+1] = tmp << 8; + } + } else if (s->flags & 1) { // EHB (ExtraHalfBrite) color palette + av_log(avctx, AV_LOG_ERROR, "ExtraHalfBrite (EHB) mode not supported\n"); + return AVERROR_PATCHWELCOME; + } + } + + return 0; +} + static av_cold int decode_init(AVCodecContext *avctx) { IffContext *s = avctx->priv_data; int err; if (avctx->bits_per_coded_sample <= 8) { - avctx->pix_fmt = (avctx->bits_per_coded_sample < 8 || - avctx->extradata_size) ? PIX_FMT_PAL8 - : PIX_FMT_GRAY8; + int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); + avctx->pix_fmt = (avctx->bits_per_coded_sample < 8) || + (avctx->extradata_size >= 2 && palette_size) ? PIX_FMT_PAL8 : PIX_FMT_GRAY8; } else if (avctx->bits_per_coded_sample <= 32) { avctx->pix_fmt = PIX_FMT_BGR32; } else { @@ -167,6 +297,11 @@ static av_cold int decode_init(AVCodecContext *avctx) if (!s->planebuf) return AVERROR(ENOMEM); + s->bpp = avctx->bits_per_coded_sample; + avcodec_get_frame_defaults(&s->frame); + + if ((err = extract_header(avctx, NULL)) < 0) + return err; s->frame.reference = 1; return 0; @@ -214,6 +349,39 @@ static void decodeplane32(uint32_t *dst, const uint8_t *buf, int buf_size, int p } while (--buf_size); } +#define DECODE_HAM_PLANE32(x) \ + first = buf[x] << 1; \ + second = buf[(x)+1] << 1; \ + delta &= pal[first++]; \ + delta |= pal[first]; \ + dst[x] = delta; \ + delta &= pal[second++]; \ + delta |= pal[second]; \ + dst[(x)+1] = delta + +/** + * Converts one line of HAM6/8-encoded chunky buffer to 24bpp. + * + * @param dst the destination 24bpp buffer + * @param buf the source 8bpp chunky buffer + * @param pal the HAM decode table + * @param buf_size the plane size in bytes + */ +static void decode_ham_plane32(uint32_t *dst, const uint8_t *buf, + const uint32_t *const pal, unsigned buf_size) +{ + uint32_t delta = 0; + do { + uint32_t first, second; + DECODE_HAM_PLANE32(0); + DECODE_HAM_PLANE32(2); + DECODE_HAM_PLANE32(4); + DECODE_HAM_PLANE32(6); + buf += 8; + dst += 8; + } while (--buf_size); +} + /** * Decode one complete byterun1 encoded line. * @@ -250,11 +418,14 @@ static int decode_frame_ilbm(AVCodecContext *avctx, AVPacket *avpkt) { IffContext *s = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL; + const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0; const uint8_t *buf_end = buf+buf_size; int y, plane, res; + if ((res = extract_header(avctx, avpkt)) < 0) + return res; + if (s->init) { if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); @@ -274,16 +445,26 @@ static int decode_frame_ilbm(AVCodecContext *avctx, for(y = 0; y < avctx->height; y++ ) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memset(row, 0, avctx->width); - for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) { + for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane); buf += s->planesize; } } + } else if (s->ham) { // HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height; y++) { + uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; + memset(s->ham_buf, 0, avctx->width); + for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { + decodeplane8(s->ham_buf, buf, FFMIN(s->planesize, buf_end - buf), plane); + buf += s->planesize; + } + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); + } } else { // PIX_FMT_BGR32 for(y = 0; y < avctx->height; y++ ) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; memset(row, 0, avctx->width << 2); - for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) { + for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { decodeplane32((uint32_t *) row, buf, FFMIN(s->planesize, buf_end - buf), plane); buf += s->planesize; } @@ -295,6 +476,13 @@ static int decode_frame_ilbm(AVCodecContext *avctx, memcpy(row, buf, FFMIN(avctx->width, buf_end - buf)); buf += avctx->width + (avctx->width % 2); // padding if odd } + } else { // IFF-PBM: HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height; y++) { + uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; + memcpy(s->ham_buf, buf, FFMIN(avctx->width, buf_end - buf)); + buf += avctx->width + (avctx->width & 1); // padding if odd + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, avctx->width); + } } *data_size = sizeof(AVFrame); @@ -307,11 +495,13 @@ static int decode_frame_byterun1(AVCodecContext *avctx, AVPacket *avpkt) { IffContext *s = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL; + const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0; const uint8_t *buf_end = buf+buf_size; int y, plane, res; + if ((res = extract_header(avctx, avpkt)) < 0) + return res; if (s->init) { if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); @@ -331,26 +521,42 @@ static int decode_frame_byterun1(AVCodecContext *avctx, for(y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memset(row, 0, avctx->width); - for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) { + for (plane = 0; plane < s->bpp; plane++) { buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); decodeplane8(row, s->planebuf, s->planesize, plane); } } + } else if (s->ham) { // HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height ; y++) { + uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; + memset(s->ham_buf, 0, avctx->width); + for (plane = 0; plane < s->bpp; plane++) { + buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); + decodeplane8(s->ham_buf, s->planebuf, s->planesize, plane); + } + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); + } } else { //PIX_FMT_BGR32 for(y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; memset(row, 0, avctx->width << 2); - for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) { + for (plane = 0; plane < s->bpp; plane++) { buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); decodeplane32((uint32_t *) row, s->planebuf, s->planesize, plane); } } } - } else { + } else if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) { // IFF-PBM for(y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(row, avctx->width, buf, buf_end); } + } else { // IFF-PBM: HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height ; y++) { + uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; + buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end); + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, avctx->width); + } } *data_size = sizeof(AVFrame); @@ -364,6 +570,8 @@ static av_cold int decode_end(AVCodecContext *avctx) if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); av_freep(&s->planebuf); + av_freep(&s->ham_buf); + av_freep(&s->ham_palbuf); return 0; } diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c index a942068aee..4b9aae2a5d 100644 --- a/libavcodec/iirfilter.c +++ b/libavcodec/iirfilter.c @@ -2,20 +2,20 @@ * IIR filter * Copyright (c) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/iirfilter.h b/libavcodec/iirfilter.h index bc65a96b59..b29e035811 100644 --- a/libavcodec/iirfilter.h +++ b/libavcodec/iirfilter.h @@ -2,20 +2,20 @@ * IIR filter * Copyright (c) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 07d6cadcfd..f08efe46ec 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -4,20 +4,20 @@ * Copyright (c) 2006 Benjamin Larsson * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/imcdata.h b/libavcodec/imcdata.h index 8e99391d61..64e7c7185e 100644 --- a/libavcodec/imcdata.h +++ b/libavcodec/imcdata.h @@ -4,20 +4,20 @@ * Copyright (c) 2006 Benjamin Larsson * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 351ed7ada7..9aa584fa5c 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -2,20 +2,20 @@ * Misc image conversion routines * Copyright (c) 2001, 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -789,15 +789,23 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src, int y_shift; int x_shift; - if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt])) + if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB) return -1; y_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h; x_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w; + if (is_yuv_planar(&pix_fmt_info[pix_fmt])) { dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band; dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift); dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift); + } else{ + if(top_band % (1<<y_shift) || left_band % (1<<x_shift)) + return -1; + if(left_band) //FIXME add support for this too + return -1; + dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band; + } dst->linesize[0] = src->linesize[0]; dst->linesize[1] = src->linesize[1]; diff --git a/libavcodec/imgconvert.h b/libavcodec/imgconvert.h index c99e587906..64da317d27 100644 --- a/libavcodec/imgconvert.h +++ b/libavcodec/imgconvert.h @@ -4,20 +4,20 @@ * * Copyright (c) 2008 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/imx_dump_header_bsf.c b/libavcodec/imx_dump_header_bsf.c index 3724daf008..8119809faa 100644 --- a/libavcodec/imx_dump_header_bsf.c +++ b/libavcodec/imx_dump_header_bsf.c @@ -2,20 +2,20 @@ * imx dump header bitstream filter * Copyright (c) 2007 Baptiste Coudurier * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 0e588c3966..f58804bab3 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -2,20 +2,20 @@ * Intel Indeo 2 codec * Copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -146,9 +146,6 @@ static int ir2_decode_frame(AVCodecContext *avctx, AVFrame * const p= (AVFrame*)&s->picture; int start; - if(p->data[0]) - avctx->release_buffer(avctx, p); - p->reference = 1; p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, p)) { @@ -195,6 +192,7 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){ Ir2Context * const ic = avctx->priv_data; static VLC_TYPE vlc_tables[1 << CODE_VLC_BITS][2]; + avcodec_get_frame_defaults(&ic->picture); ic->avctx = avctx; avctx->pix_fmt= PIX_FMT_YUV410P; diff --git a/libavcodec/indeo2data.h b/libavcodec/indeo2data.h index ef85e32d87..b2e0b8a509 100644 --- a/libavcodec/indeo2data.h +++ b/libavcodec/indeo2data.h @@ -2,20 +2,20 @@ * Intel Indeo 2 codec * copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 30b70850f8..8e55fbe443 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -1,27 +1,29 @@ /* - * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg - * written, produced, and directed by Alan Smithee - * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +/** + * @file + * Intel Indeo 3 (IV31, IV32, etc.) video decoder for FFmpeg + * written, produced, and directed by Alan Smithee + * + * For some documentation see: + * http://wiki.multimedia.cx/index.php?title=Indeo_3 + */ #include "libavutil/imgutils.h" #include "avcodec.h" @@ -211,6 +213,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, int *width_tbl, width_tbl_arr[10]; const signed char *ref_vectors; uint8_t *cur_frm_pos, *ref_frm_pos, *cp, *cp2; + uint8_t *cur_end = cur + width*height + width; uint32_t *cur_lp, *ref_lp; const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2]; uint8_t *correction_type_sp[2]; @@ -357,6 +360,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2]; ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2]; + if ((uint8_t *)cur_lp >= cur_end-3) + break; switch(correction_type_sp[0][k]) { case 0: @@ -967,6 +972,7 @@ static av_cold int indeo3_decode_init(AVCodecContext *avctx) s->width = avctx->width; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV410P; + avcodec_get_frame_defaults(&s->frame); if (!(ret = build_modpred(s))) ret = iv_alloc_frames(s); @@ -1134,6 +1140,9 @@ static av_cold int indeo3_decode_end(AVCodecContext *avctx) iv_free_func(s); + if (s->frame.data[0]) + avctx->release_buffer(avctx, &s->frame); + return 0; } diff --git a/libavcodec/indeo3data.h b/libavcodec/indeo3data.h index 334c3e0c97..bbc4c952ff 100644 --- a/libavcodec/indeo3data.h +++ b/libavcodec/indeo3data.h @@ -2,20 +2,20 @@ * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg * written, produced, and directed by Alan Smithee * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c index ba1bc18eff..4c6bfd66d1 100644 --- a/libavcodec/indeo5.c +++ b/libavcodec/indeo5.c @@ -2,20 +2,20 @@ * Indeo Video Interactive v5 compatible decoder * Copyright (c) 2009 Maxim Poliakovski * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -713,6 +713,8 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->pic_conf.tile_height = avctx->height; ctx->pic_conf.luma_bands = ctx->pic_conf.chroma_bands = 1; + avcodec_get_frame_defaults(&ctx->frame); + result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n"); diff --git a/libavcodec/indeo5data.h b/libavcodec/indeo5data.h index f4252b59f6..a6217d0bf8 100644 --- a/libavcodec/indeo5data.h +++ b/libavcodec/indeo5data.h @@ -2,20 +2,20 @@ * Indeo Video Interactive 5 compatible decoder * Copyright (c) 2009 Maxim Poliakovski * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 83049bcc6f..a011a9f597 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -1,20 +1,20 @@ /* * H.263i decoder * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/internal.h b/libavcodec/internal.h index fe853ab87e..24aca6b28b 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 3bbb464aff..7e26e1db7d 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -2,20 +2,20 @@ * Interplay MVE Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1022,6 +1022,9 @@ static av_cold int ipvideo_decode_init(AVCodecContext *avctx) /* decoding map contains 4 bits of information per 8x8 block */ s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2); + avcodec_get_frame_defaults(&s->second_last_frame); + avcodec_get_frame_defaults(&s->last_frame); + avcodec_get_frame_defaults(&s->current_frame); s->current_frame.data[0] = s->last_frame.data[0] = s->second_last_frame.data[0] = NULL; diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index 69f940a162..75166e8ffd 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h index 3a58938cc3..8ce4f8d098 100644 --- a/libavcodec/intrax8.h +++ b/libavcodec/intrax8.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/intrax8dsp.c b/libavcodec/intrax8dsp.c index 1a62fcde77..692e1b102f 100644 --- a/libavcodec/intrax8dsp.c +++ b/libavcodec/intrax8dsp.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/intrax8huf.h b/libavcodec/intrax8huf.h index 6bf01f388a..375906bab2 100644 --- a/libavcodec/intrax8huf.h +++ b/libavcodec/intrax8huf.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 0bb92da833..b1e67231fd 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -5,20 +5,20 @@ * Copyright (c) 2001 Juan J. Sierralta P * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index cadf389866..320f82a83f 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -5,20 +5,20 @@ * Copyright (c) 2001 Juan J. Sierralta P * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c index bd3d4e6fd4..7f14a89f33 100644 --- a/libavcodec/ivi_common.c +++ b/libavcodec/ivi_common.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Maxim Poliakovski * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ivi_common.h b/libavcodec/ivi_common.h index fd3d82515a..10cca26045 100644 --- a/libavcodec/ivi_common.h +++ b/libavcodec/ivi_common.h @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Maxim Poliakovski * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -219,7 +219,7 @@ static inline int ivi_scale_mv(int mv, int mv_scale) /** * Generate a huffman codebook from the given descriptor - * and convert it into the Libav VLC table. + * and convert it into the FFmpeg VLC table. * * @param[in] cb pointer to codebook descriptor * @param[out] vlc where to place the generated VLC table diff --git a/libavcodec/ivi_dsp.c b/libavcodec/ivi_dsp.c index 6b62dc8fdb..913fdc31b2 100644 --- a/libavcodec/ivi_dsp.c +++ b/libavcodec/ivi_dsp.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Maxim Poliakovski * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ivi_dsp.h b/libavcodec/ivi_dsp.h index 9632966a9a..4fb2f80035 100644 --- a/libavcodec/ivi_dsp.h +++ b/libavcodec/ivi_dsp.h @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Maxim Poliakovski * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/j2k.c b/libavcodec/j2k.c new file mode 100644 index 0000000000..33a7e3100b --- /dev/null +++ b/libavcodec/j2k.c @@ -0,0 +1,392 @@ +/* + * JPEG2000 encoder and decoder common functions + * Copyright (c) 2007 Kamil Nowosad + * + * 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 + */ + +/** + * JPEG2000 image encoder and decoder common functions + * @file + * @author Kamil Nowosad + */ + + +#include "avcodec.h" +#include "j2k.h" + +#define SHL(a, n) ((n)>=0 ? (a) << (n) : (a) >> -(n)) + +#if 0 +void ff_j2k_printv(int *tab, int l) +{ + int i; + for (i = 0; i < l; i++) + printf("%.3d ", tab[i]); + printf("\n"); +} + +void ff_j2k_printu(uint8_t *tab, int l) +{ + int i; + for (i = 0; i < l; i++) + printf("%.3hd ", tab[i]); + printf("\n"); +} +#endif + +/* tag tree routines */ + +/** allocate the memory for tag tree */ + +static int tag_tree_size(int w, int h) +{ + int res = 0; + while (w > 1 || h > 1){ + res += w * h; + w = (w+1) >> 1; + h = (h+1) >> 1; + } + return res + 1; +} + +J2kTgtNode *ff_j2k_tag_tree_init(int w, int h) +{ + int pw = w, ph = h; + J2kTgtNode *res, *t, *t2; + + t = res = av_mallocz(tag_tree_size(w, h)*sizeof(J2kTgtNode)); + + if (res == NULL) + return NULL; + + while (w > 1 || h > 1){ + int i, j; + pw = w; + ph = h; + + w = (w+1) >> 1; + h = (h+1) >> 1; + t2 = t + pw*ph; + + for (i = 0; i < ph; i++) + for (j = 0; j < pw; j++){ + t[i*pw + j].parent = &t2[(i>>1)*w + (j>>1)]; + } + t = t2; + } + t[0].parent = NULL; + return res; +} + +static void tag_tree_zero(J2kTgtNode *t, int w, int h) +{ + int i, siz = tag_tree_size(w, h); + + for (i = 0; i < siz; i++){ + t[i].val = 0; + t[i].vis = 0; + } +} + +uint8_t ff_j2k_nbctxno_lut[256][4]; + +static int getnbctxno(int flag, int bandno, int vert_causal_ctx_csty_symbol) +{ + int h, v, d; + + h = ((flag & J2K_T1_SIG_E) ? 1:0)+ + ((flag & J2K_T1_SIG_W) ? 1:0); + v = ((flag & J2K_T1_SIG_N) ? 1:0); + if (!vert_causal_ctx_csty_symbol) + v = v + ((flag & J2K_T1_SIG_S) ? 1:0); + d = ((flag & J2K_T1_SIG_NE) ? 1:0)+ + ((flag & J2K_T1_SIG_NW) ? 1:0); + if (!vert_causal_ctx_csty_symbol) + d = d + ((flag & J2K_T1_SIG_SE) ? 1:0)+ + ((flag & J2K_T1_SIG_SW) ? 1:0); + if (bandno < 3){ + if (bandno == 1) + FFSWAP(int, h, v); + if (h == 2) return 8; + if (h == 1){ + if (v >= 1) return 7; + if (d >= 1) return 6; + return 5; + } + if (v == 2) return 4; + if (v == 1) return 3; + if (d >= 2) return 2; + if (d == 1) return 1; + return 0; + } else{ + if (d >= 3) return 8; + if (d == 2){ + if (h+v >= 1) return 7; + return 6; + } + if (d == 1){ + if (h+v >= 2) return 5; + if (h+v == 1) return 4; + return 3; + } + if (h+v >= 2) return 2; + if (h+v == 1) return 1; + return 0; + } + assert(0); +} + +uint8_t ff_j2k_sgnctxno_lut[16][16], ff_j2k_xorbit_lut[16][16]; + +static int getsgnctxno(int flag, uint8_t *xorbit) +{ + int vcontrib, hcontrib; + static const int contribtab[3][3] = {{0, -1, 1}, {-1, -1, 0}, {1, 0, 1}}; + static const int ctxlbltab[3][3] = {{13, 12, 11}, {10, 9, 10}, {11, 12, 13}}; + static const int xorbittab[3][3] = {{1, 1, 1,}, {1, 0, 0}, {0, 0, 0}}; + + hcontrib = contribtab[flag & J2K_T1_SIG_E ? flag & J2K_T1_SGN_E ? 1:2:0] + [flag & J2K_T1_SIG_W ? flag & J2K_T1_SGN_W ? 1:2:0]+1; + vcontrib = contribtab[flag & J2K_T1_SIG_S ? flag & J2K_T1_SGN_S ? 1:2:0] + [flag & J2K_T1_SIG_N ? flag & J2K_T1_SGN_N ? 1:2:0]+1; + *xorbit = xorbittab[hcontrib][vcontrib]; + return ctxlbltab[hcontrib][vcontrib]; +} + +void ff_j2k_init_tier1_luts(void) +{ + int i, j; + for (i = 0; i < 256; i++) + for (j = 0; j < 4; j++) + ff_j2k_nbctxno_lut[i][j] = getnbctxno(i, j, 0); + for (i = 0; i < 16; i++) + for (j = 0; j < 16; j++) + ff_j2k_sgnctxno_lut[i][j] = getsgnctxno(i + (j << 8), &ff_j2k_xorbit_lut[i][j]); +} + +void ff_j2k_set_significant(J2kT1Context *t1, int x, int y, int negative) +{ + x++; y++; + t1->flags[y][x] |= J2K_T1_SIG; + if (negative){ + t1->flags[y][x+1] |= J2K_T1_SIG_W | J2K_T1_SGN_W; + t1->flags[y][x-1] |= J2K_T1_SIG_E | J2K_T1_SGN_E; + t1->flags[y+1][x] |= J2K_T1_SIG_N | J2K_T1_SGN_N; + t1->flags[y-1][x] |= J2K_T1_SIG_S | J2K_T1_SGN_S; + } else{ + t1->flags[y][x+1] |= J2K_T1_SIG_W; + t1->flags[y][x-1] |= J2K_T1_SIG_E; + t1->flags[y+1][x] |= J2K_T1_SIG_N; + t1->flags[y-1][x] |= J2K_T1_SIG_S; + } + t1->flags[y+1][x+1] |= J2K_T1_SIG_NW; + t1->flags[y+1][x-1] |= J2K_T1_SIG_NE; + t1->flags[y-1][x+1] |= J2K_T1_SIG_SW; + t1->flags[y-1][x-1] |= J2K_T1_SIG_SE; +} + +int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps, int dx, int dy) +{ + int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1; + + if (ret=ff_j2k_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels-1, codsty->transform)) + return ret; + for (i = 0; i < 2; i++) + csize *= comp->coord[i][1] - comp->coord[i][0]; + + comp->data = av_malloc(csize * sizeof(int)); + if (!comp->data) + return AVERROR(ENOMEM); + comp->reslevel = av_malloc(codsty->nreslevels * sizeof(J2kResLevel)); + + if (!comp->reslevel) + return AVERROR(ENOMEM); + for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + int declvl = codsty->nreslevels - reslevelno; + J2kResLevel *reslevel = comp->reslevel + reslevelno; + + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + reslevel->coord[i][j] = + ff_j2k_ceildivpow2(comp->coord[i][j], declvl - 1); + + if (reslevelno == 0) + reslevel->nbands = 1; + else + reslevel->nbands = 3; + + if (reslevel->coord[0][1] == reslevel->coord[0][0]) + reslevel->num_precincts_x = 0; + else + reslevel->num_precincts_x = ff_j2k_ceildivpow2(reslevel->coord[0][1], codsty->log2_prec_width) + - (reslevel->coord[0][0] >> codsty->log2_prec_width); + + if (reslevel->coord[1][1] == reslevel->coord[1][0]) + reslevel->num_precincts_y = 0; + else + reslevel->num_precincts_y = ff_j2k_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height) + - (reslevel->coord[1][0] >> codsty->log2_prec_height); + + reslevel->band = av_malloc(reslevel->nbands * sizeof(J2kBand)); + if (!reslevel->band) + return AVERROR(ENOMEM); + for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++){ + J2kBand *band = reslevel->band + bandno; + int cblkno, precx, precy, precno; + int x0, y0, x1, y1; + int xi0, yi0, xi1, yi1; + int cblkperprecw, cblkperprech; + + if (qntsty->quantsty != J2K_QSTY_NONE){ + const static uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}}; + int numbps; + + numbps = cbps + lut_gain[codsty->transform][bandno + reslevelno>0]; + band->stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]); + } else + band->stepsize = 1 << 13; + + if (reslevelno == 0){ // the same everywhere + band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width-1); + band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height-1); + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + band->coord[i][j] = ff_j2k_ceildivpow2(comp->coord[i][j], declvl-1); + } else{ + band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width); + band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height); + + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + band->coord[i][j] = ff_j2k_ceildivpow2(comp->coord[i][j] - (((bandno+1>>i)&1) << declvl-1), declvl); + } + band->cblknx = ff_j2k_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width; + band->cblkny = ff_j2k_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height; + + for (j = 0; j < 2; j++) + band->coord[0][j] = ff_j2k_ceildiv(band->coord[0][j], dx); + for (j = 0; j < 2; j++) + band->coord[1][j] = ff_j2k_ceildiv(band->coord[1][j], dy); + + band->cblknx = ff_j2k_ceildiv(band->cblknx, dx); + band->cblkny = ff_j2k_ceildiv(band->cblkny, dy); + + band->cblk = av_malloc(band->cblknx * band->cblkny * sizeof(J2kCblk)); + if (!band->cblk) + return AVERROR(ENOMEM); + band->prec = av_malloc(reslevel->num_precincts_x * reslevel->num_precincts_y * sizeof(J2kPrec)); + if (!band->prec) + return AVERROR(ENOMEM); + + for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){ + J2kCblk *cblk = band->cblk + cblkno; + cblk->zero = 0; + cblk->lblock = 3; + cblk->length = 0; + cblk->lengthinc = 0; + cblk->npasses = 0; + } + + y0 = band->coord[1][0]; + y1 = ((band->coord[1][0] + (1<<codsty->log2_prec_height)) & ~((1<<codsty->log2_prec_height)-1)) - y0; + yi0 = 0; + yi1 = ff_j2k_ceildivpow2(y1 - y0, codsty->log2_cblk_height) << codsty->log2_cblk_height; + yi1 = FFMIN(yi1, band->cblkny); + cblkperprech = 1<<(codsty->log2_prec_height - codsty->log2_cblk_height); + for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++){ + for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++){ + band->prec[precno].yi0 = yi0; + band->prec[precno].yi1 = yi1; + } + yi1 += cblkperprech; + yi0 = yi1 - cblkperprech; + yi1 = FFMIN(yi1, band->cblkny); + } + x0 = band->coord[0][0]; + x1 = ((band->coord[0][0] + (1<<codsty->log2_prec_width)) & ~((1<<codsty->log2_prec_width)-1)) - x0; + xi0 = 0; + xi1 = ff_j2k_ceildivpow2(x1 - x0, codsty->log2_cblk_width) << codsty->log2_cblk_width; + xi1 = FFMIN(xi1, band->cblknx); + + cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width); + for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++){ + for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0){ + J2kPrec *prec = band->prec + precno; + prec->xi0 = xi0; + prec->xi1 = xi1; + prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0, + prec->yi1 - prec->yi0); + prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0, + prec->yi1 - prec->yi0); + if (!prec->cblkincl || !prec->zerobits) + return AVERROR(ENOMEM); + + } + xi1 += cblkperprecw; + xi0 = xi1 - cblkperprecw; + xi1 = FFMIN(xi1, band->cblknx); + } + } + } + return 0; +} + +void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty) +{ + int reslevelno, bandno, cblkno, precno; + for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + J2kResLevel *rlevel = comp->reslevel + reslevelno; + for (bandno = 0; bandno < rlevel->nbands; bandno++){ + J2kBand *band = rlevel->band + bandno; + for(precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++){ + J2kPrec *prec = band->prec + precno; + tag_tree_zero(prec->zerobits, prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); + tag_tree_zero(prec->cblkincl, prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); + } + for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){ + J2kCblk *cblk = band->cblk + cblkno; + cblk->length = 0; + cblk->lblock = 3; + } + } + } +} + +void ff_j2k_cleanup(J2kComponent *comp, J2kCodingStyle *codsty) +{ + int reslevelno, bandno, precno; + for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + J2kResLevel *reslevel = comp->reslevel + reslevelno; + + for (bandno = 0; bandno < reslevel->nbands ; bandno++){ + J2kBand *band = reslevel->band + bandno; + for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){ + J2kPrec *prec = band->prec + precno; + av_freep(&prec->zerobits); + av_freep(&prec->cblkincl); + } + av_freep(&band->cblk); + av_freep(&band->prec); + } + av_freep(&reslevel->band); + } + + ff_j2k_dwt_destroy(&comp->dwt); + av_freep(&comp->reslevel); + av_freep(&comp->data); +} diff --git a/libavcodec/j2k.h b/libavcodec/j2k.h new file mode 100644 index 0000000000..85d5cd079c --- /dev/null +++ b/libavcodec/j2k.h @@ -0,0 +1,234 @@ +/* + * JPEG2000 tables + * Copyright (c) 2007 Kamil Nowosad + * + * 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_J2K_H +#define AVCODEC_J2K_H + +/** + * JPEG2000 tables + * @file + * @author Kamil Nowosad + */ + +#include "mqc.h" +#include "j2k_dwt.h" + +enum J2kMarkers{ + J2K_SOC = 0xff4f, ///< start of codestream + J2K_SIZ = 0xff51, ///< image and tile size + J2K_COD, ///< coding style default + J2K_COC, ///< coding style component + J2K_TLM = 0xff55, ///< packed packet headers, tile-part header + J2K_PLM = 0xff57, ///< tile-part lengths + J2K_PLT, ///< packet length, main header + J2K_QCD = 0xff5c, ///< quantization default + J2K_QCC, ///< quantization component + J2K_RGN, ///< region of interest + J2K_POC, ///< progression order change + J2K_PPM, ///< packet length, tile-part header + J2K_PPT, ///< packed packet headers, main header + J2K_CRG = 0xff63, ///< component registration + J2K_COM, ///< comment + J2K_SOT = 0xff90, ///< start of tile-part + J2K_SOP, ///< start of packet + J2K_EPH, ///< end of packet header + J2K_SOD, ///< start of data + J2K_EOC = 0xffd9, ///< end of codestream +}; + +enum J2kQuantsty{ ///< quantization style + J2K_QSTY_NONE, ///< no quantization + J2K_QSTY_SI, ///< scalar derived + J2K_QSTY_SE ///< scalar expoounded +}; + +#define J2K_MAX_CBLKW 64 +#define J2K_MAX_CBLKH 64 + +// T1 flags +// flags determining significance of neighbour coefficients +#define J2K_T1_SIG_N 0x0001 +#define J2K_T1_SIG_E 0x0002 +#define J2K_T1_SIG_W 0x0004 +#define J2K_T1_SIG_S 0x0008 +#define J2K_T1_SIG_NE 0x0010 +#define J2K_T1_SIG_NW 0x0020 +#define J2K_T1_SIG_SE 0x0040 +#define J2K_T1_SIG_SW 0x0080 +#define J2K_T1_SIG_NB (J2K_T1_SIG_N | J2K_T1_SIG_E | J2K_T1_SIG_S | J2K_T1_SIG_W \ + |J2K_T1_SIG_NE | J2K_T1_SIG_NW | J2K_T1_SIG_SE | J2K_T1_SIG_SW) +// flags determining sign bit of neighbour coefficients +#define J2K_T1_SGN_N 0x0100 +#define J2K_T1_SGN_S 0x0200 +#define J2K_T1_SGN_W 0x0400 +#define J2K_T1_SGN_E 0x0800 + +#define J2K_T1_VIS 0x1000 +#define J2K_T1_SIG 0x2000 +#define J2K_T1_REF 0x4000 + +#define J2K_T1_SGN 0x8000 + +// Codeblock coding styles +#define J2K_CBLK_BYPASS 0x01 // Selective arithmetic coding bypass +#define J2K_CBLK_RESET 0x02 // Reset context probabilities +#define J2K_CBLK_TERMALL 0x04 // Terminate after each coding pass +#define J2K_CBLK_VSC 0x08 // Vertical stripe causal context formation +#define J2K_CBLK_PREDTERM 0x10 // Predictable termination +#define J2K_CBLK_SEGSYM 0x20 // Segmentation symbols present + +// Coding styles +#define J2K_CSTY_PREC 0x01 // Precincts defined in coding style +#define J2K_CSTY_SOP 0x02 // SOP marker present +#define J2K_CSTY_EPH 0x04 // EPH marker present + +typedef struct { + int data[J2K_MAX_CBLKW][J2K_MAX_CBLKH]; + int flags[J2K_MAX_CBLKW+2][J2K_MAX_CBLKH+2]; + MqcState mqc; +} J2kT1Context; + +typedef struct J2kTgtNode { + uint8_t val; + uint8_t vis; + struct J2kTgtNode *parent; +} J2kTgtNode; + +typedef struct { + uint8_t nreslevels; ///< number of resolution levels + uint8_t log2_cblk_width, + log2_cblk_height; ///< exponent of codeblock size + uint8_t transform; ///< DWT type + uint8_t csty; ///< coding style + uint8_t log2_prec_width, + log2_prec_height; ///< precinct size + uint8_t nlayers; ///< number of layers + uint8_t mct; ///< multiple component transformation + uint8_t cblk_style; ///< codeblock coding style +} J2kCodingStyle; + +typedef struct { + uint8_t expn[32 * 3]; ///< quantization exponent + uint16_t mant[32 * 3]; ///< quantization mantissa + uint8_t quantsty; ///< quantization style + uint8_t nguardbits; ///< number of guard bits +} J2kQuantStyle; + +typedef struct { + uint16_t rate; + int64_t disto; +} J2kPass; + +typedef struct { + uint8_t npasses; + uint8_t ninclpasses; ///< number coding of passes included in codestream + uint8_t nonzerobits; + uint16_t length; + uint16_t lengthinc; + uint8_t lblock; + uint8_t zero; + uint8_t data[8192]; + J2kPass passes[100]; +} J2kCblk; ///< code block + +typedef struct { + uint16_t xi0, xi1, yi0, yi1; ///< codeblock indexes ([xi0, xi1)) + J2kTgtNode *zerobits; + J2kTgtNode *cblkincl; +} J2kPrec; ///< precinct + +typedef struct { + uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}} + uint16_t codeblock_width, codeblock_height; + uint16_t cblknx, cblkny; + uint32_t stepsize; ///< quantization stepsize (* 2^13) + J2kPrec *prec; + J2kCblk *cblk; +} J2kBand; ///< subband + +typedef struct { + uint8_t nbands; + uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}} + uint16_t num_precincts_x, num_precincts_y; ///< number of precincts in x/y direction + uint8_t log2_prec_width, log2_prec_height; ///< exponent of precinct size + J2kBand *band; +} J2kResLevel; ///< resolution level + +typedef struct { + J2kResLevel *reslevel; + DWTContext dwt; + int *data; + uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}} +} J2kComponent; + +/* debug routines */ +#if 0 +#undef fprintf +#undef printf +void ff_j2k_printv(int *tab, int l); +void ff_j2k_printu(uint8_t *tab, int l); +#endif + +/* misc tools */ +static inline int ff_j2k_ceildivpow2(int a, int b) +{ + return (a + (1 << b) - 1)>> b; +} + +static inline int ff_j2k_ceildiv(int a, int b) +{ + return (a + b - 1) / b; +} + +/* tag tree routines */ +J2kTgtNode *ff_j2k_tag_tree_init(int w, int h); + +/* TIER-1 routines */ +void ff_j2k_init_tier1_luts(void); + +void ff_j2k_set_significant(J2kT1Context *t1, int x, int y, int negative); + +extern uint8_t ff_j2k_nbctxno_lut[256][4]; + +static inline int ff_j2k_getnbctxno(int flag, int bandno, int vert_causal_ctx_csty_symbol) +{ + return ff_j2k_nbctxno_lut[flag&255][bandno]; +} + +static inline int ff_j2k_getrefctxno(int flag) +{ + static const uint8_t refctxno_lut[2][2] = {{14, 15}, {16, 16}}; + return refctxno_lut[(flag>>14)&1][(flag & 255) != 0]; +} + +extern uint8_t ff_j2k_sgnctxno_lut[16][16], ff_j2k_xorbit_lut[16][16]; + +static inline int ff_j2k_getsgnctxno(int flag, int *xorbit) +{ + *xorbit = ff_j2k_xorbit_lut[flag&15][(flag>>8)&15]; + return ff_j2k_sgnctxno_lut[flag&15][(flag>>8)&15]; +} + +int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps, int dx, int dy); +void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty); +void ff_j2k_cleanup(J2kComponent *comp, J2kCodingStyle *codsty); + +#endif /* AVCODEC_J2K_H */ diff --git a/libavcodec/j2k_dwt.c b/libavcodec/j2k_dwt.c new file mode 100644 index 0000000000..9ba770ad83 --- /dev/null +++ b/libavcodec/j2k_dwt.c @@ -0,0 +1,384 @@ +/* + * Discrete wavelet transform + * Copyright (c) 2007 Kamil Nowosad + * + * 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 + */ + +/** + * Discrete wavelet transform + * @file + * @author Kamil Nowosad + */ + +#include "j2k_dwt.h" + +const static float scale97[] = {1.625786, 1.230174}; + +static inline void extend53(int *p, int i0, int i1) +{ + p[i0 - 1] = p[i0 + 1]; + p[i1 ] = p[i1 - 2]; + p[i0 - 2] = p[i0 + 2]; + p[i1 + 1] = p[i1 - 3]; +} + +static inline void extend97(float *p, int i0, int i1) +{ + int i; + + for (i = 1; i <= 4; i++){ + p[i0 - i] = p[i0 + i]; + p[i1 + i - 1] = p[i1 - i - 1]; + } +} + +static void sd_1d53(int *p, int i0, int i1) +{ + int i; + + if (i1 == i0 + 1) + return; + + extend53(p, i0, i1); + + for (i = (i0+1)/2 - 1; i < (i1+1)/2; i++) + p[2*i+1] -= (p[2*i] + p[2*i+2]) >> 1; + for (i = (i0+1)/2; i < (i1+1)/2; i++) + p[2*i] += (p[2*i-1] + p[2*i+1] + 2) >> 2; +} + +static void dwt_encode53(DWTContext *s, int *t) +{ + int lev, + w = s->linelen[s->ndeclevels-1][0]; + int *line = s->linebuf; + line += 3; + + for (lev = s->ndeclevels-1; lev >= 0; lev--){ + int lh = s->linelen[lev][0], + lv = s->linelen[lev][1], + mh = s->mod[lev][0], + mv = s->mod[lev][1], + lp; + int *l; + + // HOR_SD + l = line + mh; + for (lp = 0; lp < lv; lp++){ + int i, j = 0; + + for (i = 0; i < lh; i++) + l[i] = t[w*lp + i]; + + sd_1d53(line, mh, mh + lh); + + // copy back and deinterleave + for (i = mh; i < lh; i+=2, j++) + t[w*lp + j] = l[i]; + for (i = 1-mh; i < lh; i+=2, j++) + t[w*lp + j] = l[i]; + } + + // VER_SD + l = line + mv; + for (lp = 0; lp < lh; lp++) { + int i, j = 0; + + for (i = 0; i < lv; i++) + l[i] = t[w*i + lp]; + + sd_1d53(line, mv, mv + lv); + + // copy back and deinterleave + for (i = mv; i < lv; i+=2, j++) + t[w*j + lp] = l[i]; + for (i = 1-mv; i < lv; i+=2, j++) + t[w*j + lp] = l[i]; + } + } +} + +static void sd_1d97(float *p, int i0, int i1) +{ + int i; + + if (i1 == i0 + 1) + return; + + extend97(p, i0, i1); + i0++; i1++; + + for (i = i0/2 - 2; i < i1/2 + 1; i++) + p[2*i+1] -= 1.586134 * (p[2*i] + p[2*i+2]); + for (i = i0/2 - 1; i < i1/2 + 1; i++) + p[2*i] -= 0.052980 * (p[2*i-1] + p[2*i+1]); + for (i = i0/2 - 1; i < i1/2; i++) + p[2*i+1] += 0.882911 * (p[2*i] + p[2*i+2]); + for (i = i0/2; i < i1/2; i++) + p[2*i] += 0.443506 * (p[2*i-1] + p[2*i+1]); +} + +static void dwt_encode97(DWTContext *s, int *t) +{ + int lev, + w = s->linelen[s->ndeclevels-1][0]; + float *line = s->linebuf; + line += 5; + + for (lev = s->ndeclevels-1; lev >= 0; lev--){ + int lh = s->linelen[lev][0], + lv = s->linelen[lev][1], + mh = s->mod[lev][0], + mv = s->mod[lev][1], + lp; + float *l; + + // HOR_SD + l = line + mh; + for (lp = 0; lp < lv; lp++){ + int i, j = 0; + + for (i = 0; i < lh; i++) + l[i] = t[w*lp + i]; + + sd_1d97(line, mh, mh + lh); + + // copy back and deinterleave + for (i = mh; i < lh; i+=2, j++) + t[w*lp + j] = scale97[mh] * l[i] / 2; + for (i = 1-mh; i < lh; i+=2, j++) + t[w*lp + j] = scale97[mh] * l[i] / 2; + } + + // VER_SD + l = line + mv; + for (lp = 0; lp < lh; lp++) { + int i, j = 0; + + for (i = 0; i < lv; i++) + l[i] = t[w*i + lp]; + + sd_1d97(line, mv, mv + lv); + + // copy back and deinterleave + for (i = mv; i < lv; i+=2, j++) + t[w*j + lp] = scale97[mv] * l[i] / 2; + for (i = 1-mv; i < lv; i+=2, j++) + t[w*j + lp] = scale97[mv] * l[i] / 2; + } + } +} + +static void sr_1d53(int *p, int i0, int i1) +{ + int i; + + if (i1 == i0 + 1) + return; + + extend53(p, i0, i1); + + for (i = i0/2; i < i1/2 + 1; i++) + p[2*i] -= (p[2*i-1] + p[2*i+1] + 2) >> 2; + for (i = i0/2; i < i1/2; i++) + p[2*i+1] += (p[2*i] + p[2*i+2]) >> 1; +} + +static void dwt_decode53(DWTContext *s, int *t) +{ + int lev, + w = s->linelen[s->ndeclevels-1][0]; + int *line = s->linebuf; + line += 3; + + for (lev = 0; lev < s->ndeclevels; lev++){ + int lh = s->linelen[lev][0], + lv = s->linelen[lev][1], + mh = s->mod[lev][0], + mv = s->mod[lev][1], + lp; + int *l; + + // HOR_SD + l = line + mh; + for (lp = 0; lp < lv; lp++){ + int i, j = 0; + // copy with interleaving + for (i = mh; i < lh; i+=2, j++) + l[i] = t[w*lp + j]; + for (i = 1-mh; i < lh; i+=2, j++) + l[i] = t[w*lp + j]; + + sr_1d53(line, mh, mh + lh); + + for (i = 0; i < lh; i++) + t[w*lp + i] = l[i]; + } + + // VER_SD + l = line + mv; + for (lp = 0; lp < lh; lp++){ + int i, j = 0; + // copy with interleaving + for (i = mv; i < lv; i+=2, j++) + l[i] = t[w*j + lp]; + for (i = 1-mv; i < lv; i+=2, j++) + l[i] = t[w*j + lp]; + + sr_1d53(line, mv, mv + lv); + + for (i = 0; i < lv; i++) + t[w*i + lp] = l[i]; + } + } +} + +static void sr_1d97(float *p, int i0, int i1) +{ + int i; + + if (i1 == i0 + 1) + return; + + extend97(p, i0, i1); + + for (i = i0/2 - 1; i < i1/2 + 2; i++) + p[2*i] -= 0.443506 * (p[2*i-1] + p[2*i+1]); + for (i = i0/2 - 1; i < i1/2 + 1; i++) + p[2*i+1] -= 0.882911 * (p[2*i] + p[2*i+2]); + for (i = i0/2; i < i1/2 + 1; i++) + p[2*i] += 0.052980 * (p[2*i-1] + p[2*i+1]); + for (i = i0/2; i < i1/2; i++) + p[2*i+1] += 1.586134 * (p[2*i] + p[2*i+2]); +} + +static void dwt_decode97(DWTContext *s, int *t) +{ + int lev, + w = s->linelen[s->ndeclevels-1][0]; + float *line = s->linebuf; + line += 5; + + for (lev = 0; lev < s->ndeclevels; lev++){ + int lh = s->linelen[lev][0], + lv = s->linelen[lev][1], + mh = s->mod[lev][0], + mv = s->mod[lev][1], + lp; + float *l; + + // HOR_SD + l = line + mh; + for (lp = 0; lp < lv; lp++){ + int i, j = 0; + // copy with interleaving + for (i = mh; i < lh; i+=2, j++) + l[i] = scale97[1-mh] * t[w*lp + j]; + for (i = 1-mh; i < lh; i+=2, j++) + l[i] = scale97[1-mh] * t[w*lp + j]; + + sr_1d97(line, mh, mh + lh); + + for (i = 0; i < lh; i++) + t[w*lp + i] = l[i]; + } + + // VER_SD + l = line + mv; + for (lp = 0; lp < lh; lp++){ + int i, j = 0; + // copy with interleaving + for (i = mv; i < lv; i+=2, j++) + l[i] = scale97[1-mv] * t[w*j + lp]; + for (i = 1-mv; i < lv; i+=2, j++) + l[i] = scale97[1-mv] * t[w*j + lp]; + + sr_1d97(line, mv, mv + lv); + + for (i = 0; i < lv; i++) + t[w*i + lp] = l[i]; + } + } +} + +int ff_j2k_dwt_init(DWTContext *s, uint16_t border[2][2], int decomp_levels, int type) +{ + int i, j, lev = decomp_levels, maxlen, + b[2][2]; + + s->ndeclevels = decomp_levels; + s->type = type; + + for (i = 0; i < 2; i++) + for(j = 0; j < 2; j++) + b[i][j] = border[i][j]; + + maxlen = FFMAX(b[0][1] - b[0][0], + b[1][1] - b[1][0]); + + while(--lev >= 0){ + for (i = 0; i < 2; i++){ + s->linelen[lev][i] = b[i][1] - b[i][0]; + s->mod[lev][i] = b[i][0] & 1; + for (j = 0; j < 2; j++) + b[i][j] = (b[i][j] + 1) >> 1; + } + } + if (type == FF_DWT97) + s->linebuf = av_malloc((maxlen + 12) * sizeof(float)); + else if (type == FF_DWT53) + s->linebuf = av_malloc((maxlen + 6) * sizeof(int)); + else + return -1; + + if (!s->linebuf) + return AVERROR(ENOMEM); + + return 0; +} + +int ff_j2k_dwt_encode(DWTContext *s, int *t) +{ + switch(s->type){ + case FF_DWT97: + dwt_encode97(s, t); break; + case FF_DWT53: + dwt_encode53(s, t); break; + default: + return -1; + } + return 0; +} + +int ff_j2k_dwt_decode(DWTContext *s, int *t) +{ + switch(s->type){ + case FF_DWT97: + dwt_decode97(s, t); break; + case FF_DWT53: + dwt_decode53(s, t); break; + default: + return -1; + } + return 0; +} + +void ff_j2k_dwt_destroy(DWTContext *s) +{ + av_freep(&s->linebuf); +} diff --git a/libavcodec/j2k_dwt.h b/libavcodec/j2k_dwt.h new file mode 100644 index 0000000000..a2a25a6891 --- /dev/null +++ b/libavcodec/j2k_dwt.h @@ -0,0 +1,63 @@ +/* + * Discrete wavelet transform + * Copyright (c) 2007 Kamil Nowosad + * + * 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_DWT_H +#define AVCODEC_DWT_H + +/** + * Discrete wavelet transform + * @file + * @author Kamil Nowosad + */ + +#include "avcodec.h" + +#define FF_DWT_MAX_DECLVLS 32 ///< max number of decomposition levels + +enum DWTType{ + FF_DWT97, + FF_DWT53 +}; + +typedef struct { + ///line lengths {horizontal, vertical} in consecutive decomposition levels + uint16_t linelen[FF_DWT_MAX_DECLVLS][2]; + uint8_t mod[FF_DWT_MAX_DECLVLS][2]; ///< coordinates (x0, y0) of decomp. levels mod 2 + uint8_t ndeclevels; ///< number of decomposition levels + uint8_t type; ///< 0 for 9/7; 1 for 5/3 + void *linebuf; ///< buffer used by transform (int or float) +} DWTContext; + +/** + * initialize DWT + * @param s DWT context + * @param border coordinates of transformed region {{x0, x1}, {y0, y1}} + * @param decomp_levels number of decomposition levels + * @param type 0 for DWT 9/7; 1 for DWT 5/3 + */ +int ff_j2k_dwt_init(DWTContext *s, uint16_t border[2][2], int decomp_levels, int type); + +int ff_j2k_dwt_encode(DWTContext *s, int *t); +int ff_j2k_dwt_decode(DWTContext *s, int *t); + +void ff_j2k_dwt_destroy(DWTContext *s); + +#endif /* AVCODEC_DWT_H */ diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c new file mode 100644 index 0000000000..73af6a73df --- /dev/null +++ b/libavcodec/j2kdec.c @@ -0,0 +1,1067 @@ +/* + * JPEG2000 image decoder + * Copyright (c) 2007 Kamil Nowosad + * + * 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 + */ + +/** + * JPEG2000 image decoder + * @file + * @author Kamil Nowosad + */ + +#include "avcodec.h" +#include "bytestream.h" +#include "j2k.h" +#include "libavutil/common.h" + +#define JP2_SIG_TYPE 0x6A502020 +#define JP2_SIG_VALUE 0x0D0A870A +#define JP2_CODESTREAM 0x6A703263 + +#define HAD_COC 0x01 +#define HAD_QCC 0x02 + +typedef struct { + J2kComponent *comp; + uint8_t properties[4]; + J2kCodingStyle codsty[4]; + J2kQuantStyle qntsty[4]; +} J2kTile; + +typedef struct { + AVCodecContext *avctx; + AVFrame picture; + + int width, height; ///< image width and height + int image_offset_x, image_offset_y; + int tile_offset_x, tile_offset_y; + uint8_t cbps[4]; ///< bits per sample in particular components + uint8_t sgnd[4]; ///< if a component is signed + uint8_t properties[4]; + int cdx[4], cdy[4]; + int precision; + int ncomponents; + int tile_width, tile_height; ///< tile size + int numXtiles, numYtiles; + int maxtilelen; + + J2kCodingStyle codsty[4]; + J2kQuantStyle qntsty[4]; + + uint8_t *buf_start; + uint8_t *buf; + uint8_t *buf_end; + int bit_index; + + int16_t curtileno; + + J2kTile *tile; +} J2kDecoderContext; + +static int get_bits(J2kDecoderContext *s, int n) +{ + int res = 0; + if (s->buf_end - s->buf < ((n - s->bit_index) >> 8)) + return AVERROR(EINVAL); + while (--n >= 0){ + res <<= 1; + if (s->bit_index == 0){ + s->bit_index = 7 + (*s->buf != 0xff); + s->buf++; + } + s->bit_index--; + res |= (*s->buf >> s->bit_index) & 1; + } + return res; +} + +static void j2k_flush(J2kDecoderContext *s) +{ + if (*s->buf == 0xff) + s->buf++; + s->bit_index = 8; + s->buf++; +} +#if 0 +void printcomp(J2kComponent *comp) +{ + int i; + for (i = 0; i < comp->y1 - comp->y0; i++) + ff_j2k_printv(comp->data + i * (comp->x1 - comp->x0), comp->x1 - comp->x0); +} + +static void nspaces(FILE *fd, int n) +{ + while(n--) putc(' ', fd); +} + +static void dump(J2kDecoderContext *s, FILE *fd) +{ + int tileno, compno, reslevelno, bandno, precno; + fprintf(fd, "XSiz = %d, YSiz = %d, tile_width = %d, tile_height = %d\n" + "numXtiles = %d, numYtiles = %d, ncomponents = %d\n" + "tiles:\n", + s->width, s->height, s->tile_width, s->tile_height, + s->numXtiles, s->numYtiles, s->ncomponents); + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ + J2kTile *tile = s->tile + tileno; + nspaces(fd, 2); + fprintf(fd, "tile %d:\n", tileno); + for(compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = tile->comp + compno; + nspaces(fd, 4); + fprintf(fd, "component %d:\n", compno); + nspaces(fd, 4); + fprintf(fd, "x0 = %d, x1 = %d, y0 = %d, y1 = %d\n", + comp->x0, comp->x1, comp->y0, comp->y1); + for(reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + J2kResLevel *reslevel = comp->reslevel + reslevelno; + nspaces(fd, 6); + fprintf(fd, "reslevel %d:\n", reslevelno); + nspaces(fd, 6); + fprintf(fd, "x0 = %d, x1 = %d, y0 = %d, y1 = %d, nbands = %d\n", + reslevel->x0, reslevel->x1, reslevel->y0, + reslevel->y1, reslevel->nbands); + for(bandno = 0; bandno < reslevel->nbands; bandno++){ + J2kBand *band = reslevel->band + bandno; + nspaces(fd, 8); + fprintf(fd, "band %d:\n", bandno); + nspaces(fd, 8); + fprintf(fd, "x0 = %d, x1 = %d, y0 = %d, y1 = %d," + "codeblock_width = %d, codeblock_height = %d cblknx = %d cblkny = %d\n", + band->x0, band->x1, + band->y0, band->y1, + band->codeblock_width, band->codeblock_height, + band->cblknx, band->cblkny); + for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){ + J2kPrec *prec = band->prec + precno; + nspaces(fd, 10); + fprintf(fd, "prec %d:\n", precno); + nspaces(fd, 10); + fprintf(fd, "xi0 = %d, xi1 = %d, yi0 = %d, yi1 = %d\n", + prec->xi0, prec->xi1, prec->yi0, prec->yi1); + } + } + } + } + } +} +#endif + +/** decode the value stored in node */ +static int tag_tree_decode(J2kDecoderContext *s, J2kTgtNode *node, int threshold) +{ + J2kTgtNode *stack[30]; + int sp = -1, curval = 0; + + while(node && !node->vis){ + stack[++sp] = node; + node = node->parent; + } + + if (node) + curval = node->val; + else + curval = stack[sp]->val; + + while(curval < threshold && sp >= 0){ + if (curval < stack[sp]->val) + curval = stack[sp]->val; + while (curval < threshold){ + int ret; + if ((ret = get_bits(s, 1)) > 0){ + stack[sp]->vis++; + break; + } else if (!ret) + curval++; + else + return ret; + } + stack[sp]->val = curval; + sp--; + } + return curval; +} + +/* marker segments */ +/** get sizes and offsets of image, tiles; number of components */ +static int get_siz(J2kDecoderContext *s) +{ + int i, ret; + + if (s->buf_end - s->buf < 36) + return AVERROR(EINVAL); + + bytestream_get_be16(&s->buf); // Rsiz (skipped) + s->width = bytestream_get_be32(&s->buf); // width + s->height = bytestream_get_be32(&s->buf); // height + s->image_offset_x = bytestream_get_be32(&s->buf); // X0Siz + s->image_offset_y = bytestream_get_be32(&s->buf); // Y0Siz + + s->tile_width = bytestream_get_be32(&s->buf); // XTSiz + s->tile_height = bytestream_get_be32(&s->buf); // YTSiz + s->tile_offset_x = bytestream_get_be32(&s->buf); // XT0Siz + s->tile_offset_y = bytestream_get_be32(&s->buf); // YT0Siz + s->ncomponents = bytestream_get_be16(&s->buf); // CSiz + + if (s->buf_end - s->buf < 2 * s->ncomponents) + return AVERROR(EINVAL); + + for (i = 0; i < s->ncomponents; i++){ // Ssiz_i XRsiz_i, YRsiz_i + uint8_t x = bytestream_get_byte(&s->buf); + s->cbps[i] = (x & 0x7f) + 1; + s->precision = FFMAX(s->cbps[i], s->precision); + s->sgnd[i] = (x & 0x80) == 1; + s->cdx[i] = bytestream_get_byte(&s->buf); + s->cdy[i] = bytestream_get_byte(&s->buf); + } + + s->numXtiles = ff_j2k_ceildiv(s->width - s->tile_offset_x, s->tile_width); + s->numYtiles = ff_j2k_ceildiv(s->height - s->tile_offset_y, s->tile_height); + + s->tile = av_mallocz(s->numXtiles * s->numYtiles * sizeof(J2kTile)); + if (!s->tile) + return AVERROR(ENOMEM); + + for (i = 0; i < s->numXtiles * s->numYtiles; i++){ + J2kTile *tile = s->tile + i; + + tile->comp = av_mallocz(s->ncomponents * sizeof(J2kComponent)); + if (!tile->comp) + return AVERROR(ENOMEM); + } + + s->avctx->width = s->width - s->image_offset_x; + s->avctx->height = s->height - s->image_offset_y; + + switch(s->ncomponents){ + case 1: if (s->precision > 8) { + s->avctx->pix_fmt = PIX_FMT_GRAY16; + } else s->avctx->pix_fmt = PIX_FMT_GRAY8; + break; + case 3: if (s->precision > 8) { + s->avctx->pix_fmt = PIX_FMT_RGB48; + } else s->avctx->pix_fmt = PIX_FMT_RGB24; + break; + case 4: s->avctx->pix_fmt = PIX_FMT_BGRA; break; + } + + if (s->picture.data[0]) + s->avctx->release_buffer(s->avctx, &s->picture); + + if ((ret = s->avctx->get_buffer(s->avctx, &s->picture)) < 0) + return ret; + + s->picture.pict_type = FF_I_TYPE; + s->picture.key_frame = 1; + + return 0; +} + +/** get common part for COD and COC segments */ +static int get_cox(J2kDecoderContext *s, J2kCodingStyle *c) +{ + if (s->buf_end - s->buf < 5) + return AVERROR(EINVAL); + c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of resolution levels - 1 + c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; // cblk width + c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; // cblk height + + c->cblk_style = bytestream_get_byte(&s->buf); + if (c->cblk_style != 0){ // cblk style + av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", c->cblk_style); + } + c->transform = bytestream_get_byte(&s->buf); // transformation + if (c->csty & J2K_CSTY_PREC) { + int i; + for (i = 0; i < c->nreslevels; i++) + bytestream_get_byte(&s->buf); + } + return 0; +} + +/** get coding parameters for a particular tile or whole image*/ +static int get_cod(J2kDecoderContext *s, J2kCodingStyle *c, uint8_t *properties) +{ + J2kCodingStyle tmp; + int compno; + + if (s->buf_end - s->buf < 5) + return AVERROR(EINVAL); + + tmp.log2_prec_width = + tmp.log2_prec_height = 15; + + tmp.csty = bytestream_get_byte(&s->buf); + + if (bytestream_get_byte(&s->buf)){ // progression level + av_log(s->avctx, AV_LOG_ERROR, "only LRCP progression supported\n"); + return -1; + } + + tmp.nlayers = bytestream_get_be16(&s->buf); + tmp.mct = bytestream_get_byte(&s->buf); // multiple component transformation + + get_cox(s, &tmp); + for (compno = 0; compno < s->ncomponents; compno++){ + if (!(properties[compno] & HAD_COC)) + memcpy(c + compno, &tmp, sizeof(J2kCodingStyle)); + } + return 0; +} + +/** get coding parameters for a component in the whole image on a particular tile */ +static int get_coc(J2kDecoderContext *s, J2kCodingStyle *c, uint8_t *properties) +{ + int compno; + + if (s->buf_end - s->buf < 2) + return AVERROR(EINVAL); + + compno = bytestream_get_byte(&s->buf); + + c += compno; + c->csty = bytestream_get_byte(&s->buf); + get_cox(s, c); + + properties[compno] |= HAD_COC; + return 0; +} + +/** get common part for QCD and QCC segments */ +static int get_qcx(J2kDecoderContext *s, int n, J2kQuantStyle *q) +{ + int i, x; + + if (s->buf_end - s->buf < 1) + return AVERROR(EINVAL); + + x = bytestream_get_byte(&s->buf); // Sqcd + + q->nguardbits = x >> 5; + q->quantsty = x & 0x1f; + + if (q->quantsty == J2K_QSTY_NONE){ + n -= 3; + if (s->buf_end - s->buf < n) + return AVERROR(EINVAL); + for (i = 0; i < n; i++) + q->expn[i] = bytestream_get_byte(&s->buf) >> 3; + } else if (q->quantsty == J2K_QSTY_SI){ + if (s->buf_end - s->buf < 2) + return AVERROR(EINVAL); + x = bytestream_get_be16(&s->buf); + q->expn[0] = x >> 11; + q->mant[0] = x & 0x7ff; + for (i = 1; i < 32 * 3; i++){ + int curexpn = FFMAX(0, q->expn[0] - (i-1)/3); + q->expn[i] = curexpn; + q->mant[i] = q->mant[0]; + } + } else{ + n = (n - 3) >> 1; + if (s->buf_end - s->buf < n) + return AVERROR(EINVAL); + for (i = 0; i < n; i++){ + x = bytestream_get_be16(&s->buf); + q->expn[i] = x >> 11; + q->mant[i] = x & 0x7ff; + } + } + return 0; +} + +/** get quantization parameters for a particular tile or a whole image */ +static int get_qcd(J2kDecoderContext *s, int n, J2kQuantStyle *q, uint8_t *properties) +{ + J2kQuantStyle tmp; + int compno; + + if (get_qcx(s, n, &tmp)) + return -1; + for (compno = 0; compno < s->ncomponents; compno++) + if (!(properties[compno] & HAD_QCC)) + memcpy(q + compno, &tmp, sizeof(J2kQuantStyle)); + return 0; +} + +/** get quantization parameters for a component in the whole image on in a particular tile */ +static int get_qcc(J2kDecoderContext *s, int n, J2kQuantStyle *q, uint8_t *properties) +{ + int compno; + + if (s->buf_end - s->buf < 1) + return AVERROR(EINVAL); + + compno = bytestream_get_byte(&s->buf); + properties[compno] |= HAD_QCC; + return get_qcx(s, n-1, q+compno); +} + +/** get start of tile segment */ +static uint8_t get_sot(J2kDecoderContext *s) +{ + if (s->buf_end - s->buf < 4) + return AVERROR(EINVAL); + + s->curtileno = bytestream_get_be16(&s->buf); ///< Isot + + s->buf += 4; ///< Psot (ignored) + + if (!bytestream_get_byte(&s->buf)){ ///< TPsot + J2kTile *tile = s->tile + s->curtileno; + + /* copy defaults */ + memcpy(tile->codsty, s->codsty, s->ncomponents * sizeof(J2kCodingStyle)); + memcpy(tile->qntsty, s->qntsty, s->ncomponents * sizeof(J2kQuantStyle)); + } + bytestream_get_byte(&s->buf); ///< TNsot + + return 0; +} + +static int init_tile(J2kDecoderContext *s, int tileno) +{ + int compno, + tilex = tileno % s->numXtiles, + tiley = tileno / s->numXtiles; + J2kTile *tile = s->tile + tileno; + + if (!tile->comp) + return AVERROR(ENOMEM); + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = tile->comp + compno; + J2kCodingStyle *codsty = tile->codsty + compno; + J2kQuantStyle *qntsty = tile->qntsty + compno; + int ret; // global bandno + + comp->coord[0][0] = FFMAX(tilex * s->tile_width + s->tile_offset_x, s->image_offset_x); + comp->coord[0][1] = FFMIN((tilex+1)*s->tile_width + s->tile_offset_x, s->width); + comp->coord[1][0] = FFMAX(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y); + comp->coord[1][1] = FFMIN((tiley+1)*s->tile_height + s->tile_offset_y, s->height); + + if (ret = ff_j2k_init_component(comp, codsty, qntsty, s->cbps[compno], s->cdx[compno], s->cdy[compno])) + return ret; + } + return 0; +} + +/** read the number of coding passes */ +static int getnpasses(J2kDecoderContext *s) +{ + int num; + if (!get_bits(s, 1)) + return 1; + if (!get_bits(s, 1)) + return 2; + if ((num = get_bits(s, 2)) != 3) + return num < 0 ? num : 3 + num; + if ((num = get_bits(s, 5)) != 31) + return num < 0 ? num : 6 + num; + num = get_bits(s, 7); + return num < 0 ? num : 37 + num; +} + +static int getlblockinc(J2kDecoderContext *s) +{ + int res = 0, ret; + while (ret = get_bits(s, 1)){ + if (ret < 0) + return ret; + res++; + } + return res; +} + +static int decode_packet(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kResLevel *rlevel, int precno, + int layno, uint8_t *expn, int numgbits) +{ + int bandno, cblkny, cblknx, cblkno, ret; + + if (!(ret = get_bits(s, 1))){ + j2k_flush(s); + return 0; + } else if (ret < 0) + return ret; + + for (bandno = 0; bandno < rlevel->nbands; bandno++){ + J2kBand *band = rlevel->band + bandno; + J2kPrec *prec = band->prec + precno; + int pos = 0; + + if (band->coord[0][0] == band->coord[0][1] + || band->coord[1][0] == band->coord[1][1]) + continue; + + for (cblkny = prec->yi0; cblkny < prec->yi1; cblkny++) + for(cblknx = prec->xi0, cblkno = cblkny * band->cblknx + cblknx; cblknx < prec->xi1; cblknx++, cblkno++, pos++){ + J2kCblk *cblk = band->cblk + cblkno; + int incl, newpasses, llen; + + if (cblk->npasses) + incl = get_bits(s, 1); + else + incl = tag_tree_decode(s, prec->cblkincl + pos, layno+1) == layno; + if (!incl) + continue; + else if (incl < 0) + return incl; + + if (!cblk->npasses) + cblk->nonzerobits = expn[bandno] + numgbits - 1 - tag_tree_decode(s, prec->zerobits + pos, 100); + if ((newpasses = getnpasses(s)) < 0) + return newpasses; + if ((llen = getlblockinc(s)) < 0) + return llen; + cblk->lblock += llen; + if ((ret = get_bits(s, av_log2(newpasses) + cblk->lblock)) < 0) + return ret; + cblk->lengthinc = ret; + cblk->npasses += newpasses; + } + } + j2k_flush(s); + + if (codsty->csty & J2K_CSTY_EPH) { + if (AV_RB16(s->buf) == J2K_EPH) { + s->buf += 2; + } else { + av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found.\n"); + } + } + + for (bandno = 0; bandno < rlevel->nbands; bandno++){ + J2kBand *band = rlevel->band + bandno; + int yi, cblknw = band->prec[precno].xi1 - band->prec[precno].xi0; + for (yi = band->prec[precno].yi0; yi < band->prec[precno].yi1; yi++){ + int xi; + for (xi = band->prec[precno].xi0; xi < band->prec[precno].xi1; xi++){ + J2kCblk *cblk = band->cblk + yi * cblknw + xi; + if (s->buf_end - s->buf < cblk->lengthinc) + return AVERROR(EINVAL); + bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc); + cblk->length += cblk->lengthinc; + cblk->lengthinc = 0; + } + } + } + return 0; +} + +static int decode_packets(J2kDecoderContext *s, J2kTile *tile) +{ + int layno, reslevelno, compno, precno, ok_reslevel; + s->bit_index = 8; + for (layno = 0; layno < tile->codsty[0].nlayers; layno++){ + ok_reslevel = 1; + for (reslevelno = 0; ok_reslevel; reslevelno++){ + ok_reslevel = 0; + for (compno = 0; compno < s->ncomponents; compno++){ + J2kCodingStyle *codsty = tile->codsty + compno; + J2kQuantStyle *qntsty = tile->qntsty + compno; + if (reslevelno < codsty->nreslevels){ + J2kResLevel *rlevel = tile->comp[compno].reslevel + reslevelno; + ok_reslevel = 1; + for (precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++){ + if (decode_packet(s, codsty, rlevel, precno, layno, qntsty->expn + + (reslevelno ? 3*(reslevelno-1)+1 : 0), qntsty->nguardbits)) + return -1; + } + } + } + } + } + return 0; +} + +/* TIER-1 routines */ +static void decode_sigpass(J2kT1Context *t1, int width, int height, int bpno, int bandno, int bpass_csty_symbol, + int vert_causal_ctx_csty_symbol) +{ + int mask = 3 << (bpno - 1), y0, x, y; + + for (y0 = 0; y0 < height; y0 += 4) + for (x = 0; x < width; x++) + for (y = y0; y < height && y < y0+4; y++){ + if ((t1->flags[y+1][x+1] & J2K_T1_SIG_NB) + && !(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))){ + int vert_causal_ctx_csty_loc_symbol = vert_causal_ctx_csty_symbol && (x == 3 && y == 3); + if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno, + vert_causal_ctx_csty_loc_symbol))){ + int xorbit, ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit); + if (bpass_csty_symbol) + t1->data[y][x] = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? -mask : mask; + else + t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? + -mask : mask; + + ff_j2k_set_significant(t1, x, y, t1->data[y][x] < 0); + } + t1->flags[y+1][x+1] |= J2K_T1_VIS; + } + } +} + +static void decode_refpass(J2kT1Context *t1, int width, int height, int bpno) +{ + int phalf, nhalf; + int y0, x, y; + + phalf = 1 << (bpno - 1); + nhalf = -phalf; + + for (y0 = 0; y0 < height; y0 += 4) + for (x = 0; x < width; x++) + for (y = y0; y < height && y < y0+4; y++){ + if ((t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS)) == J2K_T1_SIG){ + int ctxno = ff_j2k_getrefctxno(t1->flags[y+1][x+1]); + int r = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? phalf : nhalf; + t1->data[y][x] += t1->data[y][x] < 0 ? -r : r; + t1->flags[y+1][x+1] |= J2K_T1_REF; + } + } +} + +static void decode_clnpass(J2kDecoderContext *s, J2kT1Context *t1, int width, int height, + int bpno, int bandno, int seg_symbols) +{ + int mask = 3 << (bpno - 1), y0, x, y, runlen, dec; + + for (y0 = 0; y0 < height; y0 += 4) { + for (x = 0; x < width; x++){ + if (y0 + 3 < height && !( + (t1->flags[y0+1][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) || + (t1->flags[y0+2][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) || + (t1->flags[y0+3][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) || + (t1->flags[y0+4][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)))){ + if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL)) + continue; + runlen = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI); + runlen = (runlen << 1) | ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI); + dec = 1; + } else{ + runlen = 0; + dec = 0; + } + + for (y = y0 + runlen; y < y0 + 4 && y < height; y++){ + if (!dec){ + if (!(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))) + dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], + bandno, 0)); + } + if (dec){ + int xorbit, ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit); + t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? -mask : mask; + ff_j2k_set_significant(t1, x, y, t1->data[y][x] < 0); + } + dec = 0; + t1->flags[y+1][x+1] &= ~J2K_T1_VIS; + } + } + } + if (seg_symbols) { + int val; + val = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI); + val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI); + val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI); + val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI); + if (val != 0xa) { + av_log(s->avctx, AV_LOG_ERROR,"Segmentation symbol value incorrect\n"); + } + } +} + +static int decode_cblk(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kT1Context *t1, J2kCblk *cblk, + int width, int height, int bandpos) +{ + int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y, clnpass_cnt = 0; + int bpass_csty_symbol = J2K_CBLK_BYPASS & codsty->cblk_style; + int vert_causal_ctx_csty_symbol = J2K_CBLK_VSC & codsty->cblk_style; + + for (y = 0; y < height+2; y++) + memset(t1->flags[y], 0, (width+2)*sizeof(int)); + + for (y = 0; y < height; y++) + memset(t1->data[y], 0, width*sizeof(int)); + + ff_mqc_initdec(&t1->mqc, cblk->data); + cblk->data[cblk->length] = 0xff; + cblk->data[cblk->length+1] = 0xff; + + while(passno--){ + switch(pass_t){ + case 0: decode_sigpass(t1, width, height, bpno+1, bandpos, + bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol); + break; + case 1: decode_refpass(t1, width, height, bpno+1); + if (bpass_csty_symbol && clnpass_cnt >= 4) + ff_mqc_initdec(&t1->mqc, cblk->data); + break; + case 2: decode_clnpass(s, t1, width, height, bpno+1, bandpos, + codsty->cblk_style & J2K_CBLK_SEGSYM); + clnpass_cnt = clnpass_cnt + 1; + if (bpass_csty_symbol && clnpass_cnt >= 4) + ff_mqc_initdec(&t1->mqc, cblk->data); + break; + } + + pass_t++; + if (pass_t == 3){ + bpno--; + pass_t = 0; + } + } + return 0; +} + +static void mct_decode(J2kDecoderContext *s, J2kTile *tile) +{ + int i, *src[3], i0, i1, i2, csize = 1; + + for (i = 0; i < 3; i++) + src[i] = tile->comp[i].data; + + for (i = 0; i < 2; i++) + csize *= tile->comp[0].coord[i][1] - tile->comp[0].coord[i][0]; + + if (tile->codsty[0].transform == FF_DWT97){ + for (i = 0; i < csize; i++){ + i0 = *src[0] + (*src[2] * 46802 >> 16); + i1 = *src[0] - (*src[1] * 22553 + *src[2] * 46802 >> 16); + i2 = *src[0] + (116130 * *src[1] >> 16); + *src[0]++ = i0; + *src[1]++ = i1; + *src[2]++ = i2; + } + } else{ + for (i = 0; i < csize; i++){ + i1 = *src[0] - (*src[2] + *src[1] >> 2); + i0 = i1 + *src[2]; + i2 = i1 + *src[1]; + *src[0]++ = i0; + *src[1]++ = i1; + *src[2]++ = i2; + } + } +} + +static int decode_tile(J2kDecoderContext *s, J2kTile *tile) +{ + int compno, reslevelno, bandno; + int x, y, *src[4]; + uint8_t *line; + J2kT1Context t1; + + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = tile->comp + compno; + J2kCodingStyle *codsty = tile->codsty + compno; + + for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + J2kResLevel *rlevel = comp->reslevel + reslevelno; + for (bandno = 0; bandno < rlevel->nbands; bandno++){ + J2kBand *band = rlevel->band + bandno; + int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos; + + bandpos = bandno + (reslevelno > 0); + + yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0]; + y0 = yy0; + yy1 = FFMIN(ff_j2k_ceildiv(band->coord[1][0] + 1, band->codeblock_height) * band->codeblock_height, + band->coord[1][1]) - band->coord[1][0] + yy0; + + if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) + continue; + + for (cblky = 0; cblky < band->cblkny; cblky++){ + if (reslevelno == 0 || bandno == 1) + xx0 = 0; + else + xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0]; + x0 = xx0; + xx1 = FFMIN(ff_j2k_ceildiv(band->coord[0][0] + 1, band->codeblock_width) * band->codeblock_width, + band->coord[0][1]) - band->coord[0][0] + xx0; + + for (cblkx = 0; cblkx < band->cblknx; cblkx++, cblkno++){ + int y, x; + decode_cblk(s, codsty, &t1, band->cblk + cblkno, xx1 - xx0, yy1 - yy0, bandpos); + if (codsty->transform == FF_DWT53){ + for (y = yy0; y < yy1; y+=s->cdy[compno]){ + int *ptr = t1.data[y-yy0]; + for (x = xx0; x < xx1; x+=s->cdx[compno]){ + comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = *ptr++ >> 1; + } + } + } else{ + for (y = yy0; y < yy1; y+=s->cdy[compno]){ + int *ptr = t1.data[y-yy0]; + for (x = xx0; x < xx1; x+=s->cdx[compno]){ + int tmp = ((int64_t)*ptr++) * ((int64_t)band->stepsize) >> 13, tmp2; + tmp2 = FFABS(tmp>>1) + FFABS(tmp&1); + comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = tmp < 0 ? -tmp2 : tmp2; + } + } + } + xx0 = xx1; + xx1 = FFMIN(xx1 + band->codeblock_width, band->coord[0][1] - band->coord[0][0] + x0); + } + yy0 = yy1; + yy1 = FFMIN(yy1 + band->codeblock_height, band->coord[1][1] - band->coord[1][0] + y0); + } + } + } + ff_j2k_dwt_decode(&comp->dwt, comp->data); + src[compno] = comp->data; + } + if (tile->codsty[0].mct) + mct_decode(s, tile); + + if (s->avctx->pix_fmt == PIX_FMT_BGRA) // RGBA -> BGRA + FFSWAP(int *, src[0], src[2]); + + if (s->precision <= 8) { + for (compno = 0; compno < s->ncomponents; compno++){ + y = tile->comp[compno].coord[1][0] - s->image_offset_y; + line = s->picture.data[0] + y * s->picture.linesize[0]; + for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]){ + uint8_t *dst; + + x = tile->comp[compno].coord[0][0] - s->image_offset_x; + dst = line + x * s->ncomponents + compno; + + for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) { + *src[compno] += 1 << (s->cbps[compno]-1); + if (*src[compno] < 0) + *src[compno] = 0; + else if (*src[compno] >= (1 << s->cbps[compno])) + *src[compno] = (1 << s->cbps[compno]) - 1; + *dst = *src[compno]++; + dst += s->ncomponents; + } + line += s->picture.linesize[0]; + } + } + } else { + for (compno = 0; compno < s->ncomponents; compno++) { + y = tile->comp[compno].coord[1][0] - s->image_offset_y; + line = s->picture.data[0] + y * s->picture.linesize[0]; + for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { + uint16_t *dst; + x = tile->comp[compno].coord[0][0] - s->image_offset_x; + dst = line + (x * s->ncomponents + compno) * 2; + for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) { + int32_t val; + val = *src[compno]++ << (16 - s->cbps[compno]); + val += 1 << 15; + val = av_clip(val, 0, (1 << 16) - 1); + *dst = val; + dst += s->ncomponents; + } + line += s->picture.linesize[0]; + } + } + } + return 0; +} + +static void cleanup(J2kDecoderContext *s) +{ + int tileno, compno; + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = s->tile[tileno].comp + compno; + J2kCodingStyle *codsty = s->tile[tileno].codsty + compno; + + ff_j2k_cleanup(comp, codsty); + } + av_freep(&s->tile[tileno].comp); + } + av_freep(&s->tile); +} + +static int decode_codestream(J2kDecoderContext *s) +{ + J2kCodingStyle *codsty = s->codsty; + J2kQuantStyle *qntsty = s->qntsty; + uint8_t *properties = s->properties; + + for (;;){ + int marker, len, ret = 0; + uint8_t *oldbuf; + if (s->buf_end - s->buf < 2){ + av_log(s->avctx, AV_LOG_ERROR, "Missing EOC\n"); + break; + } + + marker = bytestream_get_be16(&s->buf); + oldbuf = s->buf; + + if (marker == J2K_SOD){ + J2kTile *tile = s->tile + s->curtileno; + if (ret = init_tile(s, s->curtileno)) + return ret; + if (ret = decode_packets(s, tile)) + return ret; + continue; + } + if (marker == J2K_EOC) + break; + + if (s->buf_end - s->buf < 2) + return AVERROR(EINVAL); + len = bytestream_get_be16(&s->buf); + switch(marker){ + case J2K_SIZ: + ret = get_siz(s); break; + case J2K_COC: + ret = get_coc(s, codsty, properties); break; + case J2K_COD: + ret = get_cod(s, codsty, properties); break; + case J2K_QCC: + ret = get_qcc(s, len, qntsty, properties); break; + case J2K_QCD: + ret = get_qcd(s, len, qntsty, properties); break; + case J2K_SOT: + if (!(ret = get_sot(s))){ + codsty = s->tile[s->curtileno].codsty; + qntsty = s->tile[s->curtileno].qntsty; + properties = s->tile[s->curtileno].properties; + } + break; + case J2K_COM: + // the comment is ignored + s->buf += len - 2; break; + default: + av_log(s->avctx, AV_LOG_ERROR, "unsupported marker 0x%.4X at pos 0x%x\n", marker, s->buf - s->buf_start - 4); + s->buf += len - 2; break; + } + if (s->buf - oldbuf != len || ret){ + av_log(s->avctx, AV_LOG_ERROR, "error during processing marker segment %.4x\n", marker); + return ret ? ret : -1; + } + } + return 0; +} + +static int jp2_find_codestream(J2kDecoderContext *s) +{ + int32_t atom_size; + int found_codestream = 0, search_range = 10; + + // skip jpeg2k signature atom + s->buf += 12; + + while(!found_codestream && search_range) { + atom_size = AV_RB32(s->buf); + if(AV_RB32(s->buf + 4) == JP2_CODESTREAM) { + found_codestream = 1; + s->buf += 8; + } else { + s->buf += atom_size; + search_range--; + } + } + + if(found_codestream) + return 1; + return 0; +} + +static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, + AVPacket *avpkt) +{ + J2kDecoderContext *s = avctx->priv_data; + AVFrame *picture = data; + int tileno, ret; + + s->avctx = avctx; + av_log(s->avctx, AV_LOG_DEBUG, "start\n"); + + // init + s->buf = s->buf_start = avpkt->data; + s->buf_end = s->buf_start + avpkt->size; + s->curtileno = -1; + + ff_j2k_init_tier1_luts(); + + if (s->buf_end - s->buf < 2) + return AVERROR(EINVAL); + + // check if the image is in jp2 format + if((AV_RB32(s->buf) == 12) && (AV_RB32(s->buf + 4) == JP2_SIG_TYPE) && + (AV_RB32(s->buf + 8) == JP2_SIG_VALUE)) { + if(!jp2_find_codestream(s)) { + av_log(avctx, AV_LOG_ERROR, "couldn't find jpeg2k codestream atom\n"); + return -1; + } + } + + if (bytestream_get_be16(&s->buf) != J2K_SOC){ + av_log(avctx, AV_LOG_ERROR, "SOC marker not present\n"); + return -1; + } + if (ret = decode_codestream(s)) + return ret; + + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) + if (ret = decode_tile(s, s->tile + tileno)) + return ret; + + cleanup(s); + av_log(s->avctx, AV_LOG_DEBUG, "end\n"); + + *data_size = sizeof(AVPicture); + *picture = s->picture; + + return s->buf - s->buf_start; +} + +static av_cold int j2kdec_init(AVCodecContext *avctx) +{ + J2kDecoderContext *s = avctx->priv_data; + + avcodec_get_frame_defaults((AVFrame*)&s->picture); + avctx->coded_frame = (AVFrame*)&s->picture; + return 0; +} + +static av_cold int decode_end(AVCodecContext *avctx) +{ + J2kDecoderContext *s = avctx->priv_data; + + if (s->picture.data[0]) + avctx->release_buffer(avctx, &s->picture); + + return 0; +} + +AVCodec ff_jpeg2000_decoder = { + "j2k", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_JPEG2000, + sizeof(J2kDecoderContext), + j2kdec_init, + NULL, + decode_end, + decode_frame, + .capabilities = CODEC_CAP_EXPERIMENTAL, + .pix_fmts = + (enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_RGB24, -1} +}; diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c new file mode 100644 index 0000000000..123b796a76 --- /dev/null +++ b/libavcodec/j2kenc.c @@ -0,0 +1,1045 @@ +/* + * JPEG2000 image encoder + * Copyright (c) 2007 Kamil Nowosad + * + * 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 + */ + +/** + * JPEG2000 image encoder + * @file + * @author Kamil Nowosad + */ + +#include <float.h> +#include "avcodec.h" +#include "bytestream.h" +#include "j2k.h" +#include "libavutil/common.h" + +#define NMSEDEC_BITS 7 +#define NMSEDEC_FRACBITS (NMSEDEC_BITS-1) +#define WMSEDEC_SHIFT 13 ///< must be >= 13 +#define LAMBDA_SCALE (100000000LL << (WMSEDEC_SHIFT - 13)) + +static int lut_nmsedec_ref [1<<NMSEDEC_BITS], + lut_nmsedec_ref0[1<<NMSEDEC_BITS], + lut_nmsedec_sig [1<<NMSEDEC_BITS], + lut_nmsedec_sig0[1<<NMSEDEC_BITS]; + +static const int dwt_norms[2][4][10] = { // [dwt_type][band][rlevel] (multiplied by 10000) + {{10000, 19650, 41770, 84030, 169000, 338400, 676900, 1353000, 2706000, 5409000}, + {20220, 39890, 83550, 170400, 342700, 686300, 1373000, 2746000, 5490000}, + {20220, 39890, 83550, 170400, 342700, 686300, 1373000, 2746000, 5490000}, + {20800, 38650, 83070, 171800, 347100, 695900, 1393000, 2786000, 5572000}}, + + {{10000, 15000, 27500, 53750, 106800, 213400, 426700, 853300, 1707000, 3413000}, + {10380, 15920, 29190, 57030, 113300, 226400, 452500, 904800, 1809000}, + {10380, 15920, 29190, 57030, 113300, 226400, 452500, 904800, 1809000}, + { 7186, 9218, 15860, 30430, 60190, 120100, 240000, 479700, 959300}} +}; + +typedef struct { + J2kComponent *comp; +} J2kTile; + +typedef struct { + AVCodecContext *avctx; + AVFrame *picture; + + int width, height; ///< image width and height + uint8_t cbps[4]; ///< bits per sample in particular components + int chroma_shift[2]; + uint8_t planar; + int ncomponents; + int tile_width, tile_height; ///< tile size + int numXtiles, numYtiles; + + uint8_t *buf_start; + uint8_t *buf; + uint8_t *buf_end; + int bit_index; + + int64_t lambda; + + J2kCodingStyle codsty; + J2kQuantStyle qntsty; + + J2kTile *tile; +} J2kEncoderContext; + + +/* debug */ +#if 0 +#undef ifprintf +#undef printf + +static void nspaces(FILE *fd, int n) +{ + while(n--) putc(' ', fd); +} + +static void printv(int *tab, int l) +{ + int i; + for (i = 0; i < l; i++) + printf("%.3d ", tab[i]); + printf("\n"); +} + +static void printu(uint8_t *tab, int l) +{ + int i; + for (i = 0; i < l; i++) + printf("%.3hd ", tab[i]); + printf("\n"); +} + +static void printcomp(J2kComponent *comp) +{ + int i; + for (i = 0; i < comp->y1 - comp->y0; i++) + printv(comp->data + i * (comp->x1 - comp->x0), comp->x1 - comp->x0); +} + +static void dump(J2kEncoderContext *s, FILE *fd) +{ + int tileno, compno, reslevelno, bandno, precno; + fprintf(fd, "XSiz = %d, YSiz = %d, tile_width = %d, tile_height = %d\n" + "numXtiles = %d, numYtiles = %d, ncomponents = %d\n" + "tiles:\n", + s->width, s->height, s->tile_width, s->tile_height, + s->numXtiles, s->numYtiles, s->ncomponents); + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ + J2kTile *tile = s->tile + tileno; + nspaces(fd, 2); + fprintf(fd, "tile %d:\n", tileno); + for(compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = tile->comp + compno; + nspaces(fd, 4); + fprintf(fd, "component %d:\n", compno); + nspaces(fd, 4); + fprintf(fd, "x0 = %d, x1 = %d, y0 = %d, y1 = %d\n", + comp->x0, comp->x1, comp->y0, comp->y1); + for(reslevelno = 0; reslevelno < s->nreslevels; reslevelno++){ + J2kResLevel *reslevel = comp->reslevel + reslevelno; + nspaces(fd, 6); + fprintf(fd, "reslevel %d:\n", reslevelno); + nspaces(fd, 6); + fprintf(fd, "x0 = %d, x1 = %d, y0 = %d, y1 = %d, nbands = %d\n", + reslevel->x0, reslevel->x1, reslevel->y0, + reslevel->y1, reslevel->nbands); + for(bandno = 0; bandno < reslevel->nbands; bandno++){ + J2kBand *band = reslevel->band + bandno; + nspaces(fd, 8); + fprintf(fd, "band %d:\n", bandno); + nspaces(fd, 8); + fprintf(fd, "x0 = %d, x1 = %d, y0 = %d, y1 = %d," + "codeblock_width = %d, codeblock_height = %d cblknx = %d cblkny = %d\n", + band->x0, band->x1, + band->y0, band->y1, + band->codeblock_width, band->codeblock_height, + band->cblknx, band->cblkny); + for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){ + J2kPrec *prec = band->prec + precno; + nspaces(fd, 10); + fprintf(fd, "prec %d:\n", precno); + nspaces(fd, 10); + fprintf(fd, "xi0 = %d, xi1 = %d, yi0 = %d, yi1 = %d\n", + prec->xi0, prec->xi1, prec->yi0, prec->yi1); + } + } + } + } + } +} +#endif + +/* bitstream routines */ + +/** put n times val bit */ +static void put_bits(J2kEncoderContext *s, int val, int n) // TODO: optimize +{ + while (n-- > 0){ + if (s->bit_index == 8) + { + s->bit_index = *s->buf == 0xff; + *(++s->buf) = 0; + } + *s->buf |= val << (7 - s->bit_index++); + } +} + +/** put n least significant bits of a number num */ +static void put_num(J2kEncoderContext *s, int num, int n) +{ + while(--n >= 0) + put_bits(s, (num >> n) & 1, 1); +} + +/** flush the bitstream */ +static void j2k_flush(J2kEncoderContext *s) +{ + if (s->bit_index){ + s->bit_index = 0; + s->buf++; + } +} + +/* tag tree routines */ + +/** code the value stored in node */ +static void tag_tree_code(J2kEncoderContext *s, J2kTgtNode *node, int threshold) +{ + J2kTgtNode *stack[30]; + int sp = 1, curval = 0; + stack[0] = node; + + node = node->parent; + while(node){ + if (node->vis){ + curval = node->val; + break; + } + node->vis++; + stack[sp++] = node; + node = node->parent; + } + while(--sp >= 0){ + if (stack[sp]->val >= threshold){ + put_bits(s, 0, threshold - curval); + break; + } + put_bits(s, 0, stack[sp]->val - curval); + put_bits(s, 1, 1); + curval = stack[sp]->val; + } +} + +/** update the value in node */ +static void tag_tree_update(J2kTgtNode *node) +{ + int lev = 0; + while (node->parent){ + if (node->parent->val <= node->val) + break; + node->parent->val = node->val; + node = node->parent; + lev++; + } +} + +static int put_siz(J2kEncoderContext *s) +{ + int i; + + if (s->buf_end - s->buf < 40 + 3 * s->ncomponents) + return -1; + + bytestream_put_be16(&s->buf, J2K_SIZ); + bytestream_put_be16(&s->buf, 38 + 3 * s->ncomponents); // Lsiz + bytestream_put_be16(&s->buf, 0); // Rsiz + bytestream_put_be32(&s->buf, s->width); // width + bytestream_put_be32(&s->buf, s->height); // height + bytestream_put_be32(&s->buf, 0); // X0Siz + bytestream_put_be32(&s->buf, 0); // Y0Siz + + bytestream_put_be32(&s->buf, s->tile_width); // XTSiz + bytestream_put_be32(&s->buf, s->tile_height); // YTSiz + bytestream_put_be32(&s->buf, 0); // XT0Siz + bytestream_put_be32(&s->buf, 0); // YT0Siz + bytestream_put_be16(&s->buf, s->ncomponents); // CSiz + + for (i = 0; i < s->ncomponents; i++){ // Ssiz_i XRsiz_i, YRsiz_i + bytestream_put_byte(&s->buf, 7); + bytestream_put_byte(&s->buf, i?1<<s->chroma_shift[0]:1); + bytestream_put_byte(&s->buf, i?1<<s->chroma_shift[1]:1); + } + return 0; +} + +static int put_cod(J2kEncoderContext *s) +{ + J2kCodingStyle *codsty = &s->codsty; + + if (s->buf_end - s->buf < 14) + return -1; + + bytestream_put_be16(&s->buf, J2K_COD); + bytestream_put_be16(&s->buf, 12); // Lcod + bytestream_put_byte(&s->buf, 0); // Scod + // SGcod + bytestream_put_byte(&s->buf, 0); // progression level + bytestream_put_be16(&s->buf, 1); // num of layers + bytestream_put_byte(&s->buf, 0); // multiple component transformation + // SPcod + bytestream_put_byte(&s->buf, codsty->nreslevels - 1); // num of decomp. levels + bytestream_put_byte(&s->buf, codsty->log2_cblk_width-2); // cblk width + bytestream_put_byte(&s->buf, codsty->log2_cblk_height-2); // cblk height + bytestream_put_byte(&s->buf, 0); // cblk style + bytestream_put_byte(&s->buf, codsty->transform); // transformation + return 0; +} + +static int put_qcd(J2kEncoderContext *s, int compno) +{ + int i, size; + J2kCodingStyle *codsty = &s->codsty; + J2kQuantStyle *qntsty = &s->qntsty; + + if (qntsty->quantsty == J2K_QSTY_NONE) + size = 4 + 3 * (codsty->nreslevels-1); + else // QSTY_SE + size = 5 + 6 * (codsty->nreslevels-1); + + if (s->buf_end - s->buf < size + 2) + return -1; + + bytestream_put_be16(&s->buf, J2K_QCD); + bytestream_put_be16(&s->buf, size); // LQcd + bytestream_put_byte(&s->buf, (qntsty->nguardbits << 5) | qntsty->quantsty); // Sqcd + if (qntsty->quantsty == J2K_QSTY_NONE) + for (i = 0; i < codsty->nreslevels * 3 - 2; i++) + bytestream_put_byte(&s->buf, qntsty->expn[i] << 3); + else // QSTY_SE + for (i = 0; i < codsty->nreslevels * 3 - 2; i++) + bytestream_put_be16(&s->buf, (qntsty->expn[i] << 11) | qntsty->mant[i]); + return 0; +} + +static uint8_t *put_sot(J2kEncoderContext *s, int tileno) +{ + uint8_t *psotptr; + + if (s->buf_end - s->buf < 12) + return -1; + + bytestream_put_be16(&s->buf, J2K_SOT); + bytestream_put_be16(&s->buf, 10); // Lsot + bytestream_put_be16(&s->buf, tileno); // Isot + + psotptr = s->buf; + bytestream_put_be32(&s->buf, 0); // Psot (filled in later) + + bytestream_put_byte(&s->buf, 0); // TPsot + bytestream_put_byte(&s->buf, 1); // TNsot + return psotptr; +} + +/** + * compute the sizes of tiles, resolution levels, bands, etc. + * allocate memory for them + * divide the input image into tile-components + */ +static int init_tiles(J2kEncoderContext *s) +{ + int tileno, tilex, tiley, compno; + J2kCodingStyle *codsty = &s->codsty; + J2kQuantStyle *qntsty = &s->qntsty; + + s->numXtiles = ff_j2k_ceildiv(s->width, s->tile_width); + s->numYtiles = ff_j2k_ceildiv(s->height, s->tile_height); + + s->tile = av_malloc(s->numXtiles * s->numYtiles * sizeof(J2kTile)); + if (!s->tile) + return AVERROR(ENOMEM); + for (tileno = 0, tiley = 0; tiley < s->numYtiles; tiley++) + for (tilex = 0; tilex < s->numXtiles; tilex++, tileno++){ + J2kTile *tile = s->tile + tileno; + + tile->comp = av_malloc(s->ncomponents * sizeof(J2kComponent)); + if (!tile->comp) + return AVERROR(ENOMEM); + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = tile->comp + compno; + int ret, i, j; + + comp->coord[0][0] = tilex * s->tile_width; + comp->coord[0][1] = FFMIN((tilex+1)*s->tile_width, s->width); + comp->coord[1][0] = tiley * s->tile_height; + comp->coord[1][1] = FFMIN((tiley+1)*s->tile_height, s->height); + if (compno > 0) + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + comp->coord[i][j] = ff_j2k_ceildivpow2(comp->coord[i][j], s->chroma_shift[i]); + + if (ret = ff_j2k_init_component(comp, codsty, qntsty, s->cbps[compno])) + return ret; + } + } + return 0; +} + +static void copy_frame(J2kEncoderContext *s) +{ + int tileno, compno, i, y, x; + uint8_t *line; + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ + J2kTile *tile = s->tile + tileno; + if (s->planar){ + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = tile->comp + compno; + int *dst = comp->data; + line = s->picture->data[compno] + + comp->coord[1][0] * s->picture->linesize[compno] + + comp->coord[0][0]; + for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ + uint8_t *ptr = line; + for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) + *dst++ = *ptr++ - (1 << 7); + line += s->picture->linesize[compno]; + } + } + } else{ + line = s->picture->data[0] + tile->comp[0].coord[1][0] * s->picture->linesize[0] + + tile->comp[0].coord[0][0] * s->ncomponents; + + i = 0; + for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; y++){ + uint8_t *ptr = line; + for (x = tile->comp[0].coord[0][0]; x < tile->comp[0].coord[0][1]; x++, i++){ + for (compno = 0; compno < s->ncomponents; compno++){ + tile->comp[compno].data[i] = *ptr++ - (1 << 7); + } + } + line += s->picture->linesize[0]; + } + } + } +} + +static void init_quantization(J2kEncoderContext *s) +{ + int compno, reslevelno, bandno; + J2kQuantStyle *qntsty = &s->qntsty; + J2kCodingStyle *codsty = &s->codsty; + + for (compno = 0; compno < s->ncomponents; compno++){ + int gbandno = 0; + for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + int nbands, lev = codsty->nreslevels - reslevelno - 1; + nbands = reslevelno ? 3 : 1; + for (bandno = 0; bandno < nbands; bandno++, gbandno++){ + int expn, mant; + + if (codsty->transform == FF_DWT97){ + int bandpos = bandno + (reslevelno>0), + ss = 81920000 / dwt_norms[0][bandpos][lev], + log = av_log2(ss); + mant = (11 - log < 0 ? ss >> log - 11 : ss << 11 - log) & 0x7ff; + expn = s->cbps[compno] - log + 13; + } else + expn = ((bandno&2)>>1) + (reslevelno>0) + s->cbps[compno]; + + qntsty->expn[gbandno] = expn; + qntsty->mant[gbandno] = mant; + } + } + } +} + +static void init_luts() +{ + int i, a, + mask = ~((1<<NMSEDEC_FRACBITS)-1); + + for (i = 0; i < (1 << NMSEDEC_BITS); i++){ + lut_nmsedec_sig[i] = FFMAX(6*i - (9<<NMSEDEC_FRACBITS-1) << 12-NMSEDEC_FRACBITS, 0); + lut_nmsedec_sig0[i] = FFMAX((i*i + (1<<NMSEDEC_FRACBITS-1) & mask) << 1, 0); + + a = (i >> (NMSEDEC_BITS-2)&2) + 1; + lut_nmsedec_ref[i] = FFMAX((-2*i + (1<<NMSEDEC_FRACBITS) + a*i - (a*a<<NMSEDEC_FRACBITS-2)) + << 13-NMSEDEC_FRACBITS, 0); + lut_nmsedec_ref0[i] = FFMAX(((i*i + (1-4*i << NMSEDEC_FRACBITS-1) + (1<<2*NMSEDEC_FRACBITS)) & mask) + << 1, 0); + } +} + +/* tier-1 routines */ +static int getnmsedec_sig(int x, int bpno) +{ + if (bpno > NMSEDEC_FRACBITS) + return lut_nmsedec_sig[(x >> (bpno - NMSEDEC_FRACBITS)) & ((1 << NMSEDEC_BITS) - 1)]; + return lut_nmsedec_sig0[x & ((1 << NMSEDEC_BITS) - 1)]; +} + +static int getnmsedec_ref(int x, int bpno) +{ + if (bpno > NMSEDEC_FRACBITS) + return lut_nmsedec_ref[(x >> (bpno - NMSEDEC_FRACBITS)) & ((1 << NMSEDEC_BITS) - 1)]; + return lut_nmsedec_ref0[x & ((1 << NMSEDEC_BITS) - 1)]; +} + +static void encode_sigpass(J2kT1Context *t1, int width, int height, int bandno, int *nmsedec, int bpno) +{ + int y0, x, y, mask = 1 << (bpno + NMSEDEC_FRACBITS); + for (y0 = 0; y0 < height; y0 += 4) + for (x = 0; x < width; x++) + for (y = y0; y < height && y < y0+4; y++){ + if (!(t1->flags[y+1][x+1] & J2K_T1_SIG) && (t1->flags[y+1][x+1] & J2K_T1_SIG_NB)){ + int ctxno = ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno), + bit = t1->data[y][x] & mask ? 1 : 0; + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, bit); + if (bit){ + int xorbit; + int ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit); + *nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS); + ff_j2k_set_significant(t1, x, y, t1->flags[y+1][x+1] >> 15); + } + t1->flags[y+1][x+1] |= J2K_T1_VIS; + } + } +} + +static void encode_refpass(J2kT1Context *t1, int width, int height, int *nmsedec, int bpno) +{ + int y0, x, y, mask = 1 << (bpno + NMSEDEC_FRACBITS); + for (y0 = 0; y0 < height; y0 += 4) + for (x = 0; x < width; x++) + for (y = y0; y < height && y < y0+4; y++) + if ((t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS)) == J2K_T1_SIG){ + int ctxno = ff_j2k_getrefctxno(t1->flags[y+1][x+1]); + *nmsedec += getnmsedec_ref(t1->data[y][x], bpno + NMSEDEC_FRACBITS); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0); + t1->flags[y+1][x+1] |= J2K_T1_REF; + } +} + +static void encode_clnpass(J2kT1Context *t1, int width, int height, int bandno, int *nmsedec, int bpno) +{ + int y0, x, y, mask = 1 << (bpno + NMSEDEC_FRACBITS); + for (y0 = 0; y0 < height; y0 += 4) + for (x = 0; x < width; x++){ + if (y0 + 3 < height && !( + (t1->flags[y0+1][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) || + (t1->flags[y0+2][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) || + (t1->flags[y0+3][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) || + (t1->flags[y0+4][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)))) + { + // aggregation mode + int rlen; + for (rlen = 0; rlen < 4; rlen++) + if (t1->data[y0+rlen][x] & mask) + break; + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL, rlen != 4); + if (rlen == 4) + continue; + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI, rlen >> 1); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI, rlen & 1); + for (y = y0 + rlen; y < y0 + 4; y++){ + if (!(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))){ + int ctxno = ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno); + if (y > y0 + rlen) + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0); + if (t1->data[y][x] & mask){ // newly significant + int xorbit; + int ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit); + *nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit); + ff_j2k_set_significant(t1, x, y, t1->flags[y+1][x+1] >> 15); + } + } + t1->flags[y+1][x+1] &= ~J2K_T1_VIS; + } + } else{ + for (y = y0; y < y0 + 4 && y < height; y++){ + if (!(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))){ + int ctxno = ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0); + if (t1->data[y][x] & mask){ // newly significant + int xorbit; + int ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit); + *nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit); + ff_j2k_set_significant(t1, x, y, t1->flags[y+1][x+1] >> 15); + } + } + t1->flags[y+1][x+1] &= ~J2K_T1_VIS; + } + } + } +} + +static void encode_cblk(J2kEncoderContext *s, J2kT1Context *t1, J2kCblk *cblk, J2kTile *tile, + int width, int height, int bandpos, int lev) +{ + int pass_t = 2, passno, x, y, max=0, nmsedec, bpno; + int64_t wmsedec = 0; + + for (y = 0; y < height+2; y++) + memset(t1->flags[y], 0, (width+2)*sizeof(int)); + + for (y = 0; y < height; y++){ + for (x = 0; x < width; x++){ + if (t1->data[y][x] < 0){ + t1->flags[y+1][x+1] |= J2K_T1_SGN; + t1->data[y][x] = -t1->data[y][x]; + } + max = FFMAX(max, t1->data[y][x]); + } + } + + if (max == 0){ + cblk->nonzerobits = 0; + bpno = 0; + } else{ + cblk->nonzerobits = av_log2(max) + 1 - NMSEDEC_FRACBITS; + bpno = cblk->nonzerobits - 1; + } + + ff_mqc_initenc(&t1->mqc, cblk->data); + + for (passno = 0; bpno >= 0; passno++){ + nmsedec=0; + + switch(pass_t){ + case 0: encode_sigpass(t1, width, height, bandpos, &nmsedec, bpno); + break; + case 1: encode_refpass(t1, width, height, &nmsedec, bpno); + break; + case 2: encode_clnpass(t1, width, height, bandpos, &nmsedec, bpno); + break; + } + + cblk->passes[passno].rate = 3 + ff_mqc_length(&t1->mqc); + wmsedec += (int64_t)nmsedec << (2*bpno); + cblk->passes[passno].disto = wmsedec; + + if (++pass_t == 3){ + pass_t = 0; + bpno--; + } + } + cblk->npasses = passno; + cblk->ninclpasses = passno; + + // TODO: optional flush on each pass + cblk->passes[passno-1].rate = ff_mqc_flush(&t1->mqc); +} + +/* tier-2 routines: */ + +static void putnumpasses(J2kEncoderContext *s, int n) +{ + if (n == 1) + put_num(s, 0, 1); + else if (n == 2) + put_num(s, 2, 2); + else if (n <= 5) + put_num(s, 0xc | (n-3), 4); + else if (n <= 36) + put_num(s, 0x1e0 | (n-6), 9); + else + put_num(s, 0xff80 | (n-37), 16); +} + + +static int encode_packet(J2kEncoderContext *s, J2kResLevel *rlevel, int precno, + uint8_t *expn, int numgbits) +{ + int bandno, empty = 1; + + // init bitstream + *s->buf = 0; + s->bit_index = 0; + + // header + + // is the packet empty? + for (bandno = 0; bandno < rlevel->nbands; bandno++){ + if (rlevel->band[bandno].coord[0][0] < rlevel->band[bandno].coord[0][1] + && rlevel->band[bandno].coord[1][0] < rlevel->band[bandno].coord[1][1]){ + empty = 0; + break; + } + } + + put_bits(s, !empty, 1); + if (empty){ + j2k_flush(s); + return 0; + } + + for (bandno = 0; bandno < rlevel->nbands; bandno++){ + J2kBand *band = rlevel->band + bandno; + J2kPrec *prec = band->prec + precno; + int yi, xi, pos; + int cblknw = prec->xi1 - prec->xi0; + + if (band->coord[0][0] == band->coord[0][1] + || band->coord[1][0] == band->coord[1][1]) + continue; + + for (pos=0, yi = prec->yi0; yi < prec->yi1; yi++){ + for (xi = prec->xi0; xi < prec->xi1; xi++, pos++){ + prec->cblkincl[pos].val = band->cblk[yi * cblknw + xi].ninclpasses == 0; + tag_tree_update(prec->cblkincl + pos); + prec->zerobits[pos].val = expn[bandno] + numgbits - 1 - band->cblk[yi * cblknw + xi].nonzerobits; + tag_tree_update(prec->zerobits + pos); + } + } + + for (pos=0, yi = prec->yi0; yi < prec->yi1; yi++){ + for (xi = prec->xi0; xi < prec->xi1; xi++, pos++){ + int pad = 0, llen, length; + J2kCblk *cblk = band->cblk + yi * cblknw + xi; + + if (s->buf_end - s->buf < 20) // approximately + return -1; + + // inclusion information + tag_tree_code(s, prec->cblkincl + pos, 1); + if (!cblk->ninclpasses) + continue; + // zerobits information + tag_tree_code(s, prec->zerobits + pos, 100); + // number of passes + putnumpasses(s, cblk->ninclpasses); + + length = cblk->passes[cblk->ninclpasses-1].rate; + llen = av_log2(length) - av_log2(cblk->ninclpasses) - 2; + if (llen < 0){ + pad = -llen; + llen = 0; + } + // length of code block + put_bits(s, 1, llen); + put_bits(s, 0, 1); + put_num(s, length, av_log2(length)+1+pad); + } + } + } + j2k_flush(s); + for (bandno = 0; bandno < rlevel->nbands; bandno++){ + J2kBand *band = rlevel->band + bandno; + J2kPrec *prec = band->prec + precno; + int yi, cblknw = prec->xi1 - prec->xi0; + for (yi = prec->yi0; yi < prec->yi1; yi++){ + int xi; + for (xi = prec->xi0; xi < prec->xi1; xi++){ + J2kCblk *cblk = band->cblk + yi * cblknw + xi; + if (cblk->ninclpasses){ + if (s->buf_end - s->buf < cblk->passes[cblk->ninclpasses-1].rate) + return -1; + bytestream_put_buffer(&s->buf, cblk->data, cblk->passes[cblk->ninclpasses-1].rate); + } + } + } + } + return 0; +} + +static int encode_packets(J2kEncoderContext *s, J2kTile *tile, int tileno) +{ + int compno, reslevelno, ret; + J2kCodingStyle *codsty = &s->codsty; + J2kQuantStyle *qntsty = &s->qntsty; + + av_log(s->avctx, AV_LOG_DEBUG, "tier2\n"); + // lay-rlevel-comp-pos progression + for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + for (compno = 0; compno < s->ncomponents; compno++){ + int precno; + J2kResLevel *reslevel = s->tile[tileno].comp[compno].reslevel + reslevelno; + for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){ + if (ret = encode_packet(s, reslevel, precno, qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0), + qntsty->nguardbits)) + return ret; + } + } + } + av_log(s->avctx, AV_LOG_DEBUG, "after tier2\n"); + return 0; +} + +static int getcut(J2kCblk *cblk, int64_t lambda, int dwt_norm) +{ + int passno, res = 0; + for (passno = 0; passno < cblk->npasses; passno++){ + int dr; + int64_t dd; + + dr = cblk->passes[passno].rate + - (res ? cblk->passes[res-1].rate:0); + dd = cblk->passes[passno].disto + - (res ? cblk->passes[res-1].disto:0); + + if (((dd * dwt_norm) >> WMSEDEC_SHIFT) * dwt_norm >= dr * lambda) + res = passno+1; + } + return res; +} + +static void truncpasses(J2kEncoderContext *s, J2kTile *tile) +{ + int compno, reslevelno, bandno, cblkno, lev; + J2kCodingStyle *codsty = &s->codsty; + + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = tile->comp + compno; + + for (reslevelno = 0, lev = codsty->nreslevels-1; reslevelno < codsty->nreslevels; reslevelno++, lev--){ + J2kResLevel *reslevel = comp->reslevel + reslevelno; + + for (bandno = 0; bandno < reslevel->nbands ; bandno++){ + int bandpos = bandno + (reslevelno > 0); + J2kBand *band = reslevel->band + bandno; + + for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){ + J2kCblk *cblk = band->cblk + cblkno; + + cblk->ninclpasses = getcut(cblk, s->lambda, + (int64_t)dwt_norms[codsty->transform][bandpos][lev] * (int64_t)band->stepsize >> 13); + } + } + } + } +} + +static int encode_tile(J2kEncoderContext *s, J2kTile *tile, int tileno) +{ + int compno, reslevelno, bandno, ret; + J2kT1Context t1; + J2kCodingStyle *codsty = &s->codsty; + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = s->tile[tileno].comp + compno; + + av_log(s->avctx, AV_LOG_DEBUG,"dwt\n"); + if (ret = ff_dwt_encode(&comp->dwt, comp->data)) + return ret; + av_log(s->avctx, AV_LOG_DEBUG,"after dwt -> tier1\n"); + + for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ + J2kResLevel *reslevel = comp->reslevel + reslevelno; + + for (bandno = 0; bandno < reslevel->nbands ; bandno++){ + J2kBand *band = reslevel->band + bandno; + int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos; + yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0]; + y0 = yy0; + yy1 = FFMIN(ff_j2k_ceildiv(band->coord[1][0] + 1, band->codeblock_height) * band->codeblock_height, + band->coord[1][1]) - band->coord[1][0] + yy0; + + if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) + continue; + + bandpos = bandno + (reslevelno > 0); + + for (cblky = 0; cblky < band->cblkny; cblky++){ + if (reslevelno == 0 || bandno == 1) + xx0 = 0; + else + xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0]; + x0 = xx0; + xx1 = FFMIN(ff_j2k_ceildiv(band->coord[0][0] + 1, band->codeblock_width) * band->codeblock_width, + band->coord[0][1]) - band->coord[0][0] + xx0; + + for (cblkx = 0; cblkx < band->cblknx; cblkx++, cblkno++){ + int y, x; + if (codsty->transform == FF_DWT53){ + for (y = yy0; y < yy1; y++){ + int *ptr = t1.data[y-yy0]; + for (x = xx0; x < xx1; x++){ + *ptr++ = comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] << NMSEDEC_FRACBITS; + } + } + } else{ + for (y = yy0; y < yy1; y++){ + int *ptr = t1.data[y-yy0]; + for (x = xx0; x < xx1; x++){ + *ptr = (comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x]); + *ptr++ = (int64_t)*ptr * (int64_t)(8192 * 8192 / band->stepsize) >> 13 - NMSEDEC_FRACBITS; + } + } + } + encode_cblk(s, &t1, band->cblk + cblkno, tile, xx1 - xx0, yy1 - yy0, + bandpos, codsty->nreslevels - reslevelno - 1); + xx0 = xx1; + xx1 = FFMIN(xx1 + band->codeblock_width, band->coord[0][1] - band->coord[0][0] + x0); + } + yy0 = yy1; + yy1 = FFMIN(yy1 + band->codeblock_height, band->coord[1][1] - band->coord[1][0] + y0); + } + } + } + av_log(s->avctx, AV_LOG_DEBUG, "after tier1\n"); + } + + av_log(s->avctx, AV_LOG_DEBUG, "rate control\n"); + truncpasses(s, tile); + if (ret = encode_packets(s, tile, tileno)) + return ret; + av_log(s->avctx, AV_LOG_DEBUG, "after rate control\n"); + return 0; +} + +void cleanup(J2kEncoderContext *s) +{ + int tileno, compno; + J2kCodingStyle *codsty = &s->codsty; + + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ + for (compno = 0; compno < s->ncomponents; compno++){ + J2kComponent *comp = s->tile[tileno].comp + compno; + ff_j2k_cleanup(comp, codsty); + } + av_freep(&s->tile[tileno].comp); + } + av_freep(&s->tile); +} + +static void reinit(J2kEncoderContext *s) +{ + int tileno, compno; + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ + J2kTile *tile = s->tile + tileno; + for (compno = 0; compno < s->ncomponents; compno++) + ff_j2k_reinit(tile->comp + compno, &s->codsty); + } +} + +static int encode_frame(AVCodecContext *avctx, + uint8_t *buf, int buf_size, + void *data) +{ + int tileno, ret; + J2kEncoderContext *s = avctx->priv_data; + + // init: + s->buf = s->buf_start = buf; + s->buf_end = buf + buf_size; + + s->picture = data; + + s->lambda = s->picture->quality * LAMBDA_SCALE; + + copy_frame(s); + reinit(s); + + if (s->buf_end - s->buf < 2) + return -1; + bytestream_put_be16(&s->buf, J2K_SOC); + if (ret = put_siz(s)) + return ret; + if (ret = put_cod(s)) + return ret; + if (ret = put_qcd(s, 0)) + return ret; + + for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ + uint8_t *psotptr; + if ((psotptr = put_sot(s, tileno)) < 0) + return psotptr; + if (s->buf_end - s->buf < 2) + return -1; + bytestream_put_be16(&s->buf, J2K_SOD); + if (ret = encode_tile(s, s->tile + tileno, tileno)) + return ret; + bytestream_put_be32(&psotptr, s->buf - psotptr + 6); + } + if (s->buf_end - s->buf < 2) + return -1; + bytestream_put_be16(&s->buf, J2K_EOC); + + av_log(s->avctx, AV_LOG_DEBUG, "end\n"); + return s->buf - s->buf_start; +} + +static av_cold int j2kenc_init(AVCodecContext *avctx) +{ + int i, ret; + J2kEncoderContext *s = avctx->priv_data; + J2kCodingStyle *codsty = &s->codsty; + J2kQuantStyle *qntsty = &s->qntsty; + + s->avctx = avctx; + av_log(s->avctx, AV_LOG_DEBUG, "init\n"); + + // defaults: + // TODO: implement setting non-standard precinct size + codsty->log2_prec_width = 15; + codsty->log2_prec_height = 15; + codsty->nreslevels = 7; + codsty->log2_cblk_width = 4; + codsty->log2_cblk_height = 4; + codsty->transform = 1; + + qntsty->nguardbits = 1; + + s->tile_width = 256; + s->tile_height = 256; + + if (codsty->transform == FF_DWT53) + qntsty->quantsty = J2K_QSTY_NONE; + else + qntsty->quantsty = J2K_QSTY_SE; + + s->width = avctx->width; + s->height = avctx->height; + + for (i = 0; i < 3; i++) + s->cbps[i] = 8; + + if (avctx->pix_fmt == PIX_FMT_RGB24){ + s->ncomponents = 3; + } else if (avctx->pix_fmt == PIX_FMT_GRAY8){ + s->ncomponents = 1; + } else{ // planar YUV + s->planar = 1; + s->ncomponents = 3; + avcodec_get_chroma_sub_sample(avctx->pix_fmt, + s->chroma_shift, s->chroma_shift + 1); + } + + ff_j2k_init_tier1_luts(); + + init_luts(); + + init_quantization(s); + if (ret=init_tiles(s)) + return ret; + + av_log(s->avctx, AV_LOG_DEBUG, "after init\n"); + + return 0; +} + +static int j2kenc_destroy(AVCodecContext *avctx) +{ + J2kEncoderContext *s = avctx->priv_data; + + cleanup(s); + return 0; +} + +AVCodec jpeg2000_encoder = { + "j2k", + CODEC_TYPE_VIDEO, + CODEC_ID_JPEG2000, + sizeof(J2kEncoderContext), + j2kenc_init, + encode_frame, + j2kenc_destroy, + NULL, + 0, + .pix_fmts = + (enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_RGB24, + PIX_FMT_YUV422P, PIX_FMT_YUV444P, + PIX_FMT_YUV410P, PIX_FMT_YUV411P, + -1} +}; diff --git a/libavcodec/jpegls.c b/libavcodec/jpegls.c index ebe6b85e98..c40b929e95 100644 --- a/libavcodec/jpegls.c +++ b/libavcodec/jpegls.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Michael Niedermayer * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/jpegls.h b/libavcodec/jpegls.h index 1c1817e833..28c75248be 100644 --- a/libavcodec/jpegls.h +++ b/libavcodec/jpegls.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Michael Niedermayer * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 69cc1d3266..7278e020da 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Michael Niedermayer * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -40,7 +40,7 @@ * (or test broken JPEG-LS decoder) and slow down ordinary decoding a bit. * * There is no Golomb code with length >= 32 bits possible, so check and -* avoid situation of 32 zeros, Libav Golomb decoder is painfully slow +* avoid situation of 32 zeros, FFmpeg Golomb decoder is painfully slow * on this errors. */ //#define JLS_BROKEN @@ -262,9 +262,9 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor JLSState *state; int off = 0, stride = 1, width, shift; - zero = av_mallocz(s->picture_ptr->linesize[0]); + zero = av_mallocz(s->picture.linesize[0]); last = zero; - cur = s->picture_ptr->data[0]; + cur = s->picture.data[0]; state = av_mallocz(sizeof(JLSState)); /* initialize JPEG-LS state from JPEG parameters */ @@ -299,7 +299,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor t = *((uint16_t*)last); } last = cur; - cur += s->picture_ptr->linesize[0]; + cur += s->picture.linesize[0]; if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); @@ -309,7 +309,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor } else if(ilv == 1) { /* line interleaving */ int j; int Rc[3] = {0, 0, 0}; - memset(cur, 0, s->picture_ptr->linesize[0]); + memset(cur, 0, s->picture.linesize[0]); width = s->width * 3; for(i = 0; i < s->height; i++) { for(j = 0; j < 3; j++) { @@ -322,7 +322,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor } } last = cur; - cur += s->picture_ptr->linesize[0]; + cur += s->picture.linesize[0]; } } else if(ilv == 2) { /* sample interleaving */ av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n"); @@ -337,22 +337,22 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor w = s->width * s->nb_components; if(s->bits <= 8){ - uint8_t *src = s->picture_ptr->data[0]; + uint8_t *src = s->picture.data[0]; for(i = 0; i < s->height; i++){ for(x = off; x < w; x+= stride){ src[x] <<= shift; } - src += s->picture_ptr->linesize[0]; + src += s->picture.linesize[0]; } }else{ - uint16_t *src = (uint16_t*) s->picture_ptr->data[0]; + uint16_t *src = (uint16_t*) s->picture.data[0]; for(i = 0; i < s->height; i++){ for(x = 0; x < w; x++){ src[x] <<= shift; } - src += s->picture_ptr->linesize[0]/2; + src += s->picture.linesize[0]/2; } } } diff --git a/libavcodec/jpeglsdec.h b/libavcodec/jpeglsdec.h index 473282207d..5204ecb205 100644 --- a/libavcodec/jpeglsdec.h +++ b/libavcodec/jpeglsdec.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Michael Niedermayer * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index a825cf9d6b..fef06815ac 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Michael Niedermayer * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index 0c346486f5..f4941992f6 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -2,20 +2,20 @@ * Bitmap Brothers JV video decoder * Copyright (c) 2011 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/kbdwin.c b/libavcodec/kbdwin.c index c2c1c59040..8b33861f71 100644 --- a/libavcodec/kbdwin.c +++ b/libavcodec/kbdwin.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/kbdwin.h b/libavcodec/kbdwin.h index 89b569aa7c..4b939756c1 100644 --- a/libavcodec/kbdwin.h +++ b/libavcodec/kbdwin.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 57684340af..c364cfc593 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -2,20 +2,20 @@ * Kega Game Video (KGV1) decoder * Copyright (c) 2010 Daniel Verkamp * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -150,6 +150,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&c->pic); return 0; } diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 718cdfd932..aa2aaace6c 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -2,20 +2,20 @@ * KMVC decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -375,6 +375,7 @@ static av_cold int decode_init(AVCodecContext * avctx) c->setpal = 1; } + avcodec_get_frame_defaults(&c->pic); avctx->pix_fmt = PIX_FMT_PAL8; return 0; diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index 3d53536d13..02d3533b0c 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -2,20 +2,20 @@ * Lagarith lossless decoder * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lagarithrac.c b/libavcodec/lagarithrac.c index ab7a60011d..56c1d0bcc0 100644 --- a/libavcodec/lagarithrac.c +++ b/libavcodec/lagarithrac.c @@ -3,20 +3,20 @@ * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com> * Copyright (c) 2009 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lagarithrac.h b/libavcodec/lagarithrac.h index 6a8fa95a8e..2cb7323076 100644 --- a/libavcodec/lagarithrac.h +++ b/libavcodec/lagarithrac.h @@ -3,20 +3,20 @@ * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com> * Copyright (c) 2009 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/latm_parser.c b/libavcodec/latm_parser.c index fe39de8e09..8e42c6ace9 100644 --- a/libavcodec/latm_parser.c +++ b/libavcodec/latm_parser.c @@ -1,20 +1,20 @@ /* * copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lcl.h b/libavcodec/lcl.h index 4e7e170138..b60c0e901a 100644 --- a/libavcodec/lcl.h +++ b/libavcodec/lcl.h @@ -2,20 +2,20 @@ * LCL (LossLess Codec Library) Codec * Copyright (c) 2002-2004 Roberto Togni * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 70414d4d55..57735ac6ff 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -2,20 +2,20 @@ * LCL (LossLess Codec Library) Codec * Copyright (c) 2002-2004 Roberto Togni * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -453,6 +453,7 @@ static av_cold int decode_init(AVCodecContext *avctx) unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) + AV_LZO_OUTPUT_PADDING; unsigned int max_decomp_size; + avcodec_get_frame_defaults(&c->pic); if (avctx->extradata_size < 8) { av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n"); return 1; diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c index 3285d1afba..178fe0ae26 100644 --- a/libavcodec/lclenc.c +++ b/libavcodec/lclenc.c @@ -2,20 +2,20 @@ * LCL (LossLess Codec Library) Codec * Copyright (c) 2002-2004 Roberto Togni * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libcelt_dec.c b/libavcodec/libcelt_dec.c new file mode 100644 index 0000000000..6f3965401c --- /dev/null +++ b/libavcodec/libcelt_dec.c @@ -0,0 +1,136 @@ +/* + * Xiph CELT / Opus decoder using libcelt + * Copyright (c) 2011 Nicolas George + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <celt/celt.h> +#include <celt/celt_header.h> +#include "avcodec.h" +#include "libavutil/intreadwrite.h" + +struct libcelt_context { + CELTMode *mode; + CELTDecoder *dec; + int frame_bytes; + int discard; +}; + +static int ff_celt_error_to_averror(int err) +{ + switch(err) { + case CELT_BAD_ARG: return AVERROR(EINVAL); +#ifdef CELT_BUFFER_TOO_SMALL + case CELT_BUFFER_TOO_SMALL: return AVERROR(ENOBUFS); +#endif + case CELT_INTERNAL_ERROR: return AVERROR(EFAULT); + case CELT_CORRUPTED_DATA: return AVERROR_INVALIDDATA; + case CELT_UNIMPLEMENTED: return AVERROR(ENOTSUP); +#ifdef ENOTRECOVERABLE + case CELT_INVALID_STATE: return AVERROR(ENOTRECOVERABLE); +#endif + case CELT_ALLOC_FAIL: return AVERROR(ENOMEM); + default: return AVERROR(EINVAL); + } +} + +static int ff_celt_bitstream_version_hack(CELTMode *mode) +{ + CELTHeader header = { .version_id = 0 }; + celt_header_init(&header, mode, 960, 2); + return header.version_id; +} + +static av_cold int libcelt_dec_init(AVCodecContext *c) +{ + struct libcelt_context *celt = c->priv_data; + int err; + + if (!c->channels || !c->frame_size || + c->frame_size > INT_MAX / sizeof(int16_t) / c->channels) + return AVERROR(EINVAL); + celt->frame_bytes = c->frame_size * c->channels * sizeof(int16_t); + celt->mode = celt_mode_create(c->sample_rate, c->frame_size, &err); + if (!celt->mode) + return ff_celt_error_to_averror(err); + celt->dec = celt_decoder_create_custom(celt->mode, c->channels, &err); + if (!celt->dec) { + celt_mode_destroy(celt->mode); + return ff_celt_error_to_averror(err); + } + if (c->extradata_size >= 4) { + celt->discard = AV_RL32(c->extradata); + if (celt->discard < 0 || celt->discard >= c->frame_size) { + av_log(c, AV_LOG_WARNING, + "Invalid overlap (%d), ignored.\n", celt->discard); + celt->discard = 0; + } + celt->discard *= c->channels * sizeof(int16_t); + } + if(c->extradata_size >= 8) { + unsigned version = AV_RL32(c->extradata + 4); + unsigned lib_version = ff_celt_bitstream_version_hack(celt->mode); + if (version != lib_version) + av_log(c, AV_LOG_WARNING, + "CELT bitstream version 0x%x may be " + "improperly decoded by libcelt for version 0x%x.\n", + version, lib_version); + } + return 0; +} + +static av_cold int libcelt_dec_close(AVCodecContext *c) +{ + struct libcelt_context *celt = c->priv_data; + + celt_decoder_destroy(celt->dec); + celt_mode_destroy(celt->mode); + return 0; +} + +static int libcelt_dec_decode(AVCodecContext *c, void *pcm, int *pcm_size, + AVPacket *pkt) +{ + struct libcelt_context *celt = c->priv_data; + int err; + + if (*pcm_size < celt->frame_bytes) + return AVERROR(ENOBUFS); + err = celt_decode(celt->dec, pkt->data, pkt->size, pcm, c->frame_size); + if (err < 0) + return ff_celt_error_to_averror(err); + *pcm_size = celt->frame_bytes; + if (celt->discard) { + *pcm_size = celt->frame_bytes - celt->discard; + memmove(pcm, (char *)pcm + celt->discard, *pcm_size); + celt->discard = 0; + } + return pkt->size; +} + +AVCodec ff_libcelt_decoder = { + .name = "libcelt", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_CELT, + .priv_data_size = sizeof(struct libcelt_context), + .init = libcelt_dec_init, + .close = libcelt_dec_close, + .decode = libcelt_dec_decode, + .capabilities = 0, + .long_name = NULL_IF_CONFIG_SMALL("Xiph CELT/Opus decoder using libcelt"), +}; diff --git a/libavcodec/libdirac.h b/libavcodec/libdirac.h index 7f7912238d..0dc19ca338 100644 --- a/libavcodec/libdirac.h +++ b/libavcodec/libdirac.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,7 +30,7 @@ #include <libdirac_common/dirac_types.h> /** -* Table providing a Dirac chroma format to Libav pixel format mapping. +* Table providing a Dirac chroma format to FFmpeg pixel format mapping. */ static const struct { enum PixelFormat ff_pix_fmt; diff --git a/libavcodec/libdirac_libschro.c b/libavcodec/libdirac_libschro.c index 525d8663bc..aee185885e 100644 --- a/libavcodec/libdirac_libschro.c +++ b/libavcodec/libdirac_libschro.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libdirac_libschro.h b/libavcodec/libdirac_libschro.h index 9c2e9e7bb7..3d63f977cf 100644 --- a/libavcodec/libdirac_libschro.h +++ b/libavcodec/libdirac_libschro.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libdiracdec.c b/libavcodec/libdiracdec.c index 08fec3dfec..fb6ff45f0a 100644 --- a/libavcodec/libdiracdec.c +++ b/libavcodec/libdiracdec.c @@ -3,20 +3,20 @@ * Copyright (c) 2005 BBC, Andrew Kennedy <dirac at rd dot bbc dot co dot uk> * Copyright (c) 2006-2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -47,7 +47,7 @@ typedef struct FfmpegDiracDecoderParams { /** -* returns Libav chroma format +* returns FFmpeg chroma format */ static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt) { @@ -103,7 +103,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, case STATE_SEQUENCE: { - /* tell Libav about sequence details */ + /* tell FFmpeg about sequence details */ dirac_sourceparams_t *src_params = &p_dirac_params->p_decoder->src_params; if (av_image_check_size(src_params->width, src_params->height, diff --git a/libavcodec/libdiracenc.c b/libavcodec/libdiracenc.c index ff4b92f3c0..a9cc6803b9 100644 --- a/libavcodec/libdiracenc.c +++ b/libavcodec/libdiracenc.c @@ -3,20 +3,20 @@ * Copyright (c) 2005 BBC, Andrew Kennedy <dirac at rd dot bbc dot co dot uk> * Copyright (c) 2006-2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c index 51d965e87a..af85587272 100644 --- a/libavcodec/libfaac.c +++ b/libavcodec/libfaac.c @@ -2,20 +2,20 @@ * Interface to libfaac for aac encoding * Copyright (c) 2002 Gildas Bazin <gbazin@netcourrier.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c index 34f29573db..1f76f82d55 100644 --- a/libavcodec/libgsm.c +++ b/libavcodec/libgsm.c @@ -3,20 +3,20 @@ * Copyright (c) 2005 Alban Bedel <albeu@free.fr> * Copyright (c) 2006, 2007 Michel Bardiaux <mbardiaux@mediaxim.be> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 68f1bc9e2b..05893830c1 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -2,20 +2,20 @@ * Interface to libmp3lame for mp3 encoding * Copyright (c) 2002 Lennert Buytenhek <buytenh@gnu.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -35,6 +35,10 @@ typedef struct Mp3AudioContext { int stereo; uint8_t buffer[BUFFER_SIZE]; int buffer_index; + struct { + int *left; + int *right; + } s32_data; } Mp3AudioContext; static av_cold int MP3lame_encode_init(AVCodecContext *avctx) @@ -70,9 +74,26 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx) avctx->frame_size = lame_get_framesize(s->gfp); - avctx->coded_frame= avcodec_alloc_frame(); + if(!(avctx->coded_frame= avcodec_alloc_frame())) { + lame_close(s->gfp); + + return AVERROR(ENOMEM); + } avctx->coded_frame->key_frame= 1; + if(AV_SAMPLE_FMT_S32 == avctx->sample_fmt && s->stereo) { + int nelem = 2 * avctx->frame_size; + + if(! (s->s32_data.left = av_malloc(nelem * sizeof(int)))) { + av_freep(&avctx->coded_frame); + lame_close(s->gfp); + + return AVERROR(ENOMEM); + } + + s->s32_data.right = s->s32_data.left + avctx->frame_size; + } + return 0; err_close: @@ -147,17 +168,35 @@ static int MP3lame_encode_frame(AVCodecContext *avctx, /* lame 3.91 dies on '1-channel interleaved' data */ - if(data){ + if(!data){ + lame_result= lame_encode_flush( + s->gfp, + s->buffer + s->buffer_index, + BUFFER_SIZE - s->buffer_index + ); +#if 2147483647 == INT_MAX + }else if(AV_SAMPLE_FMT_S32 == avctx->sample_fmt){ if (s->stereo) { - lame_result = lame_encode_buffer_interleaved( + int32_t *rp = data; + int32_t *mp = rp + 2*avctx->frame_size; + int *wpl = s->s32_data.left; + int *wpr = s->s32_data.right; + + while (rp < mp) { + *wpl++ = *rp++; + *wpr++ = *rp++; + } + + lame_result = lame_encode_buffer_int( s->gfp, - data, + s->s32_data.left, + s->s32_data.right, avctx->frame_size, s->buffer + s->buffer_index, BUFFER_SIZE - s->buffer_index ); } else { - lame_result = lame_encode_buffer( + lame_result = lame_encode_buffer_int( s->gfp, data, data, @@ -166,12 +205,26 @@ static int MP3lame_encode_frame(AVCodecContext *avctx, BUFFER_SIZE - s->buffer_index ); } +#endif }else{ - lame_result= lame_encode_flush( + if (s->stereo) { + lame_result = lame_encode_buffer_interleaved( + s->gfp, + data, + avctx->frame_size, + s->buffer + s->buffer_index, + BUFFER_SIZE - s->buffer_index + ); + } else { + lame_result = lame_encode_buffer( s->gfp, + data, + data, + avctx->frame_size, s->buffer + s->buffer_index, BUFFER_SIZE - s->buffer_index ); + } } if(lame_result < 0){ @@ -207,6 +260,7 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx) { Mp3AudioContext *s = avctx->priv_data; + av_freep(&s->s32_data.left); av_freep(&avctx->coded_frame); lame_close(s->gfp); @@ -223,7 +277,11 @@ AVCodec ff_libmp3lame_encoder = { MP3lame_encode_frame, MP3lame_encode_close, .capabilities= CODEC_CAP_DELAY, - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16, +#if 2147483647 == INT_MAX + AV_SAMPLE_FMT_S32, +#endif + AV_SAMPLE_FMT_NONE}, .supported_samplerates= sSampleRates, .long_name= NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"), }; diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index cf8bdbbcb8..73abd758a1 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -2,20 +2,20 @@ * AMR Audio decoder stub * Copyright (c) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libopenjpeg.c b/libavcodec/libopenjpeg.c index 342dcd98ac..39747e78ea 100644 --- a/libavcodec/libopenjpeg.c +++ b/libavcodec/libopenjpeg.c @@ -2,20 +2,20 @@ * JPEG 2000 decoding support via OpenJPEG * Copyright (c) 2009 Jaikrishnan Menon <realityman@gmx.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -53,6 +53,7 @@ static av_cold int libopenjpeg_decode_init(AVCodecContext *avctx) LibOpenJPEGContext *ctx = avctx->priv_data; opj_set_default_decoder_parameters(&ctx->dec_params); + avcodec_get_frame_defaults(&ctx->image); avctx->coded_frame = &ctx->image; return 0; } diff --git a/libavcodec/libschroedinger.c b/libavcodec/libschroedinger.c index 804d652ff7..04c15a2a01 100644 --- a/libavcodec/libschroedinger.c +++ b/libavcodec/libschroedinger.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libschroedinger.h b/libavcodec/libschroedinger.h index c9e2a5ecb0..65a41e642a 100644 --- a/libavcodec/libschroedinger.h +++ b/libavcodec/libschroedinger.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index ee29704d92..7603f7e15f 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -2,20 +2,20 @@ * Dirac decoder support via Schroedinger libraries * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -118,7 +118,7 @@ static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *pa } /** -* Returns Libav chroma format. +* Returns FFmpeg chroma format. */ static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt) { @@ -169,7 +169,7 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) p_schro_params->format = schro_decoder_get_video_format(decoder); - /* Tell Libav about sequence details. */ + /* Tell FFmpeg about sequence details. */ if (av_image_check_size(p_schro_params->format->width, p_schro_params->format->height, 0, avccontext) < 0) { av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n", diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c index d7190d06a4..4f42d28b3b 100644 --- a/libavcodec/libschroedingerenc.c +++ b/libavcodec/libschroedingerenc.c @@ -2,20 +2,20 @@ * Dirac encoder support via Schroedinger libraries * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c index e6626dc88b..1caf738536 100644 --- a/libavcodec/libspeexdec.c +++ b/libavcodec/libspeexdec.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2008 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 86cc09ffa6..87793adc72 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2006 Paul Richards <paul.richards@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,7 +30,7 @@ * and o_ prefixes on variables which are libogg types. */ -/* Libav includes */ +/* FFmpeg includes */ #include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "libavutil/base64.h" diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index 5a75bcbbb4..0efb79b1c1 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -2,20 +2,20 @@ * AAC encoder wrapper * Copyright (c) 2010 Martin Storsjo * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index b3615ede42..ec23aeb7f8 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -2,20 +2,20 @@ * AMR Audio encoder stub * Copyright (c) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c index 88da705a32..bc219ded9b 100644 --- a/libavcodec/libvorbis.c +++ b/libavcodec/libvorbis.c @@ -1,20 +1,20 @@ /* * copyright (c) 2002 Mark Hills <mark@pogo.org.uk> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -96,6 +96,35 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock); } + if (avccontext->channels == 3 && + avccontext->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) || + avccontext->channels == 4 && + avccontext->channel_layout != AV_CH_LAYOUT_2_2 && + avccontext->channel_layout != AV_CH_LAYOUT_QUAD || + avccontext->channels == 5 && + avccontext->channel_layout != AV_CH_LAYOUT_5POINT0 && + avccontext->channel_layout != AV_CH_LAYOUT_5POINT0_BACK || + avccontext->channels == 6 && + avccontext->channel_layout != AV_CH_LAYOUT_5POINT1 && + avccontext->channel_layout != AV_CH_LAYOUT_5POINT1_BACK || + avccontext->channels == 7 && + avccontext->channel_layout != (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) || + avccontext->channels == 8 && + avccontext->channel_layout != AV_CH_LAYOUT_7POINT1) { + if (avccontext->channel_layout) { + char name[32]; + av_get_channel_layout_string(name, sizeof(name), avccontext->channels, + avccontext->channel_layout); + av_log(avccontext, AV_LOG_ERROR, "%s not supported by Vorbis: " + "output stream will have incorrect " + "channel layout.\n", name); + } else { + av_log(avccontext, AV_LOG_WARNING, "No channel layout specified. The encoder " + "will use Vorbis channel layout for " + "%d channels.\n", avccontext->channels); + } + } + return vorbis_encode_setup_init(vi); } diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index 2aa077c07a..29b8eec43e 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2010, Google, Inc. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 02f8135381..f5c942e0fc 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2010, Google, Inc. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,6 +30,7 @@ #include "avcodec.h" #include "libavutil/base64.h" +#include "libavutil/opt.h" /** * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. @@ -47,13 +48,49 @@ struct FrameListData { }; typedef struct VP8EncoderContext { + AVClass *av_class; struct vpx_codec_ctx encoder; struct vpx_image rawimg; struct vpx_fixed_buf twopass_stats; - unsigned long deadline; //i.e., RT/GOOD/BEST + int deadline; //i.e., RT/GOOD/BEST struct FrameListData *coded_frame_list; + + int cpuused; + + /** + * VP8 specific flags, see VP8F_* below. + */ + int flags; +#define VP8F_ERROR_RESILIENT 0x00000001 ///< Enable measures appropriate for streaming over lossy links +#define VP8F_AUTO_ALT_REF 0x00000002 ///< Enable automatic alternate reference frame generation + + int arnr_max_frames; + int arnr_strength; + int arnr_type; } VP8Context; +#define V AV_OPT_FLAG_VIDEO_PARAM +#define E AV_OPT_FLAG_ENCODING_PARAM + +static const AVOption options[]={ +{"speed", "", offsetof(VP8Context, cpuused), FF_OPT_TYPE_INT, 3, -16, 16, V|E}, +{"quality", "", offsetof(VP8Context, deadline), FF_OPT_TYPE_INT, VPX_DL_GOOD_QUALITY, INT_MIN, INT_MAX, V|E, "quality"}, +{"best", NULL, 0, FF_OPT_TYPE_CONST, VPX_DL_BEST_QUALITY, INT_MIN, INT_MAX, V|E, "quality"}, +{"good", NULL, 0, FF_OPT_TYPE_CONST, VPX_DL_GOOD_QUALITY, INT_MIN, INT_MAX, V|E, "quality"}, +{"realtime", NULL, 0, FF_OPT_TYPE_CONST, VPX_DL_REALTIME, INT_MIN, INT_MAX, V|E, "quality"}, +{"vp8flags", "", offsetof(VP8Context, flags), FF_OPT_TYPE_FLAGS, 0, 0, UINT_MAX, V|E, "flags"}, +{"error_resilient", "enable error resilience", 0, FF_OPT_TYPE_CONST, VP8F_ERROR_RESILIENT, INT_MIN, INT_MAX, V|E, "flags"}, +{"altref", "enable use of alternate reference frames (VP8/2-pass only)", 0, FF_OPT_TYPE_CONST, VP8F_AUTO_ALT_REF, INT_MIN, INT_MAX, V|E, "flags"}, +{"arnr_max_frames", "altref noise reduction max frame count", offsetof(VP8Context, arnr_max_frames), FF_OPT_TYPE_INT, 0, 0, 15, V|E}, +{"arnr_strength", "altref noise reduction filter strength", offsetof(VP8Context, arnr_strength), FF_OPT_TYPE_INT, 3, 0, 6, V|E}, +{"arnr_type", "altref noise reduction filter type", offsetof(VP8Context, arnr_type), FF_OPT_TYPE_INT, 3, 1, 3, V|E}, +{NULL} +}; +static const AVClass class = { "libvpx", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; + +#undef V +#undef E + /** String mappings for enum vp8e_enc_control_id */ static const char *ctlidstr[] = { [VP8E_UPD_ENTROPY] = "VP8E_UPD_ENTROPY", @@ -72,6 +109,7 @@ static const char *ctlidstr[] = { [VP8E_SET_ARNR_MAXFRAMES] = "VP8E_SET_ARNR_MAXFRAMES", [VP8E_SET_ARNR_STRENGTH] = "VP8E_SET_ARNR_STRENGTH", [VP8E_SET_ARNR_TYPE] = "VP8E_SET_ARNR_TYPE", + [VP8E_SET_CQ_LEVEL] = "VP8E_SET_CQ_LEVEL", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) @@ -204,7 +242,6 @@ static av_cold int vp8_init(AVCodecContext *avctx) { VP8Context *ctx = avctx->priv_data; const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo; - int cpuused = 3; struct vpx_codec_enc_cfg enccfg; int res; @@ -223,6 +260,7 @@ static av_cold int vp8_init(AVCodecContext *avctx) enccfg.g_timebase.num = avctx->time_base.num; enccfg.g_timebase.den = avctx->time_base.den; enccfg.g_threads = avctx->thread_count; + enccfg.g_lag_in_frames= FFMIN(avctx->rc_lookahead, 25); //0-25, avoids init failure if (avctx->flags & CODEC_FLAG_PASS1) enccfg.g_pass = VPX_RC_FIRST_PASS; @@ -234,6 +272,8 @@ static av_cold int vp8_init(AVCodecContext *avctx) if (avctx->rc_min_rate == avctx->rc_max_rate && avctx->rc_min_rate == avctx->bit_rate) enccfg.rc_end_usage = VPX_CBR; + else if (avctx->crf) + enccfg.rc_end_usage = VPX_CQ; enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000, AV_ROUND_NEAR_INF); @@ -256,6 +296,7 @@ static av_cold int vp8_init(AVCodecContext *avctx) enccfg.rc_buf_initial_sz = avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate; enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6; + enccfg.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100); //_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO if (avctx->keyint_min == avctx->gop_size) @@ -291,13 +332,14 @@ static av_cold int vp8_init(AVCodecContext *avctx) enccfg.rc_twopass_stats_in = ctx->twopass_stats; } - ctx->deadline = VPX_DL_GOOD_QUALITY; /* 0-3: For non-zero values the encoder increasingly optimizes for reduced complexity playback on low powered devices at the expense of encode quality. */ if (avctx->profile != FF_PROFILE_UNKNOWN) enccfg.g_profile = avctx->profile; + enccfg.g_error_resilient = ctx->flags & VP8F_ERROR_RESILIENT; + dump_enc_cfg(avctx, &enccfg); /* Construct Encoder Context */ res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0); @@ -308,10 +350,17 @@ static av_cold int vp8_init(AVCodecContext *avctx) //codec control failures are currently treated only as warnings av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n"); - codecctl_int(avctx, VP8E_SET_CPUUSED, cpuused); + codecctl_int(avctx, VP8E_SET_CPUUSED, ctx->cpuused); codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction); codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices)); codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold); + codecctl_int(avctx, VP8E_SET_CQ_LEVEL, (int)avctx->crf); + codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, !!(ctx->flags & VP8F_AUTO_ALT_REF)); + codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames); + codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength); + codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type); + + av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline); //provide dummy value to initialize wrapper, values will be updated each _encode() vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1, @@ -507,4 +556,5 @@ AVCodec ff_libvpx_encoder = { CODEC_CAP_DELAY, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), + .priv_class= &class, }; diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index e5fac00469..1b6f55f801 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -2,23 +2,24 @@ * H.264 encoding using the x264 library * Copyright (C) 2005 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/opt.h" #include "avcodec.h" #include <x264.h> #include <math.h> @@ -27,12 +28,21 @@ #include <string.h> typedef struct X264Context { + AVClass *class; x264_param_t params; x264_t *enc; x264_picture_t pic; uint8_t *sei; int sei_size; AVFrame out_pic; + char *preset; + char *tune; + char *profile; + char *level; + int fastfirstpass; + char *stats; + char *weightp; + char *x264opts; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -109,6 +119,12 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf, x4->params.b_tff = frame->top_field_first; x264_encoder_reconfig(x4->enc, &x4->params); } + if (x4->params.vui.i_sar_height != ctx->sample_aspect_ratio.den + || x4->params.vui.i_sar_width != ctx->sample_aspect_ratio.num) { + x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den; + x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num; + x264_encoder_reconfig(x4->enc, &x4->params); + } } do { @@ -138,7 +154,8 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf, } x4->out_pic.key_frame = pic_out.b_keyframe; - x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; + if (bufsize) + x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; return bufsize; } @@ -156,6 +173,40 @@ static av_cold int X264_close(AVCodecContext *avctx) return 0; } +/** + * Detect default settings and use default profile to avoid libx264 failure. + */ +static void check_default_settings(AVCodecContext *avctx) +{ + X264Context *x4 = avctx->priv_data; + + int score = 0; + score += x4->params.analyse.i_me_range == 0; + score += x4->params.rc.i_qp_step == 3; + score += x4->params.i_keyint_max == 12; + score += x4->params.rc.i_qp_min == 2; + score += x4->params.rc.i_qp_max == 31; + score += x4->params.rc.f_qcompress == 0.5; + score += fabs(x4->params.rc.f_ip_factor - 1.25) < 0.01; + score += fabs(x4->params.rc.f_pb_factor - 1.25) < 0.01; + score += x4->params.analyse.inter == 0 && x4->params.analyse.i_subpel_refine == 8; + if (score >= 5) { + av_log(avctx, AV_LOG_ERROR, "Default settings detected, using medium profile\n"); + x4->preset = av_strdup("medium"); + if (avctx->bit_rate == 200*1000) + avctx->crf = 23; + } +} + +#define OPT_STR(opt, param) \ + do { \ + if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ + av_log(avctx, AV_LOG_ERROR, \ + "bad value for '%s': '%s'\n", opt, param); \ + return -1; \ + } \ + } while (0); \ + static av_cold int X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; @@ -163,39 +214,13 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->sei_size = 0; x264_param_default(&x4->params); - x4->params.pf_log = X264_log; - x4->params.p_log_private = avctx; - x4->params.i_keyint_max = avctx->gop_size; - x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; - x4->params.rc.i_bitrate = avctx->bit_rate / 1000; - x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; - x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; - x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; - if (avctx->flags & CODEC_FLAG_PASS2) { - x4->params.rc.b_stat_read = 1; - } else { - if (avctx->crf) { - x4->params.rc.i_rc_method = X264_RC_CRF; - x4->params.rc.f_rf_constant = avctx->crf; - x4->params.rc.f_rf_constant_max = avctx->crf_max; - } else if (avctx->cqp > -1) { - x4->params.rc.i_rc_method = X264_RC_CQP; - x4->params.rc.i_qp_constant = avctx->cqp; - } - } - - // if neither crf nor cqp modes are selected we have to enable the RC - // we do it this way because we cannot check if the bitrate has been set - if (!(avctx->crf || (avctx->cqp > -1))) - x4->params.rc.i_rc_method = X264_RC_ABR; x4->params.i_bframe = avctx->max_b_frames; x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC; x4->params.i_bframe_adaptive = avctx->b_frame_strategy; x4->params.i_bframe_bias = avctx->bframebias; x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE; - avctx->has_b_frames = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames; x4->params.i_keyint_min = avctx->keyint_min; if (x4->params.i_keyint_min > x4->params.i_keyint_max) @@ -217,13 +242,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.i_frame_reference = avctx->refs; - x4->params.i_width = avctx->width; - x4->params.i_height = avctx->height; - x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num; - x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den; - x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den; - x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num; - x4->params.analyse.inter = 0; if (avctx->partitions) { if (avctx->partitions & X264_PART_I4X4) @@ -241,7 +259,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_direct_mv_pred = avctx->directpred; x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; - x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred; if (avctx->me_method == ME_EPZS) x4->params.analyse.i_me_method = X264_ME_DIA; @@ -274,8 +291,49 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_noise_reduction = avctx->noise_reduction; - if (avctx->level > 0) - x4->params.i_level_idc = avctx->level; + x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); + x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); + x4->params.rc.f_pb_factor = avctx->b_quant_factor; + x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; + + if (!x4->preset) + check_default_settings(avctx); + + if (x4->preset || x4->tune) { + if (x264_param_default_preset(&x4->params, x4->preset, x4->tune) < 0) + return -1; + } + + x4->params.pf_log = X264_log; + x4->params.p_log_private = avctx; + x4->params.i_log_level = X264_LOG_DEBUG; + + OPT_STR("weightp", x4->weightp); + + x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; + x4->params.rc.i_bitrate = avctx->bit_rate / 1000; + x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; + x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; + x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; + if (avctx->flags & CODEC_FLAG_PASS2) { + x4->params.rc.b_stat_read = 1; + } else { + if (avctx->crf) { + x4->params.rc.i_rc_method = X264_RC_CRF; + x4->params.rc.f_rf_constant = avctx->crf; + x4->params.rc.f_rf_constant_max = avctx->crf_max; + } else if (avctx->cqp > -1) { + x4->params.rc.i_rc_method = X264_RC_CQP; + x4->params.rc.i_qp_constant = avctx->cqp; + } + } + + OPT_STR("stats", x4->stats); + + // if neither crf nor cqp modes are selected we have to enable the RC + // we do it this way because we cannot check if the bitrate has been set + if (!(avctx->crf || (avctx->cqp > -1))) + x4->params.rc.i_rc_method = X264_RC_ABR; if (avctx->rc_buffer_size && avctx->rc_initial_buffer_occupancy && (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) { @@ -283,14 +341,35 @@ static av_cold int X264_init(AVCodecContext *avctx) (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; } - x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); - x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); - x4->params.rc.f_pb_factor = avctx->b_quant_factor; - x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; + OPT_STR("level", x4->level); + + if(x4->x264opts){ + const char *p= x4->x264opts; + while(p){ + char param[256]={0}, val[256]={0}; + sscanf(p, "%255[^:=]=%255[^:]", param, val); + OPT_STR(param, val); + p= strchr(p, ':'); + p+=!!p; + } + } + + if (x4->fastfirstpass) + x264_param_apply_fastfirstpass(&x4->params); + + if (x4->profile) + if (x264_param_apply_profile(&x4->params, x4->profile) < 0) + return -1; + + x4->params.i_width = avctx->width; + x4->params.i_height = avctx->height; + x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num; + x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den; + x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den; + x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num; x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM; - x4->params.i_log_level = X264_LOG_DEBUG; x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; @@ -307,6 +386,12 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; + // update AVCodecContext with x264 parameters + avctx->has_b_frames = x4->params.i_bframe ? + x4->params.i_bframe_pyramid ? 2 : 1 : 0; + avctx->bit_rate = x4->params.rc.i_bitrate*1000; + avctx->crf = x4->params.rc.f_rf_constant; + x4->enc = x264_encoder_open(&x4->params); if (!x4->enc) return -1; @@ -330,6 +415,23 @@ static av_cold int X264_init(AVCodecContext *avctx) return 0; } +#define OFFSET(x) offsetof(X264Context,x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM + +static const AVOption options[] = { + {"preset", "Set the encoding preset", OFFSET(preset), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"tune", "Tune the encoding params", OFFSET(tune), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, {.dbl=1}, 0, 1, VE}, + {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"wpredp", "Weighted prediction for P-frames", OFFSET(weightp), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"x264opts", "x264 options", OFFSET(x264opts), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + { NULL }, +}; + +static const AVClass class = { "libx264", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; + AVCodec ff_libx264_encoder = { .name = "libx264", .type = AVMEDIA_TYPE_VIDEO, @@ -341,4 +443,5 @@ AVCodec ff_libx264_encoder = { .capabilities = CODEC_CAP_DELAY, .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_NONE }, .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), + .priv_class = &class, }; diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index d11c4248e1..4b604bdf99 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -2,20 +2,20 @@ * AVS encoding using the xavs library * Copyright (C) 2010 Amanda, Y.N. Wu <amanda11192003@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libxvid_internal.h b/libavcodec/libxvid_internal.h index a2dc6ef50c..6517f62174 100644 --- a/libavcodec/libxvid_internal.h +++ b/libavcodec/libxvid_internal.h @@ -1,20 +1,20 @@ /* * copyright (C) 2006 Corey Hickey * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c index b4bc715aea..dbf7b0b6c1 100644 --- a/libavcodec/libxvid_rc.c +++ b/libavcodec/libxvid_rc.c @@ -3,20 +3,20 @@ * * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index 1e887a2a8c..9b5c17c59d 100644 --- a/libavcodec/libxvidff.c +++ b/libavcodec/libxvidff.c @@ -2,20 +2,20 @@ * Interface to xvidcore for mpeg4 encoding * Copyright (c) 2004 Adam Thayer <krevnik@comcast.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -453,8 +453,8 @@ static int xvid_encode_frame(AVCodecContext *avctx, XVID_TYPE_AUTO; /* Pixel aspect ratio setting */ - if (avctx->sample_aspect_ratio.num < 1 || avctx->sample_aspect_ratio.num > 255 || - avctx->sample_aspect_ratio.den < 1 || avctx->sample_aspect_ratio.den > 255) { + if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.num > 255 || + avctx->sample_aspect_ratio.den < 0 || avctx->sample_aspect_ratio.den > 255) { av_log(avctx, AV_LOG_ERROR, "Invalid pixel aspect ratio %i/%i\n", avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den); return -1; diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 56a60c913e..e5d19fcaaa 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -8,20 +8,20 @@ * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 32b1bfc9b1..f5807b8f0a 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -2,20 +2,20 @@ * LOCO codec * Copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -272,6 +272,8 @@ static av_cold int decode_init(AVCodecContext *avctx){ if(avctx->debug & FF_DEBUG_PICT_INFO) av_log(avctx, AV_LOG_INFO, "lossy:%i, version:%i, mode: %i\n", l->lossy, version, l->mode); + avcodec_get_frame_defaults(&l->pic); + return 0; } diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index ed985d36ff..d041cafe85 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -2,20 +2,20 @@ * LPC utility code * Copyright (c) 2006 Justin Ruggles <justin.ruggles@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h index 8cc2362e5b..9db5dbac30 100644 --- a/libavcodec/lpc.h +++ b/libavcodec/lpc.h @@ -2,20 +2,20 @@ * LPC utility code * Copyright (c) 2006 Justin Ruggles <justin.ruggles@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index d9ddd7d081..98ca490a76 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -4,20 +4,20 @@ * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder) * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h index 388de514c6..e3af30d300 100644 --- a/libavcodec/lsp.h +++ b/libavcodec/lsp.h @@ -3,20 +3,20 @@ * * Copyright (c) 2008 Vladimir Voroshilov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c index 6129429053..aa886910be 100644 --- a/libavcodec/lzw.c +++ b/libavcodec/lzw.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lzw.h b/libavcodec/lzw.h index d1efdaf131..76a5b6752e 100644 --- a/libavcodec/lzw.h +++ b/libavcodec/lzw.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/lzwenc.c b/libavcodec/lzwenc.c index df38116c0d..23248a6034 100644 --- a/libavcodec/lzwenc.c +++ b/libavcodec/lzwenc.c @@ -2,20 +2,20 @@ * LZW encoder * Copyright (c) 2007 Bartlomiej Wolowiec * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mace.c b/libavcodec/mace.c index 53ec0560dd..1b8c9d0836 100644 --- a/libavcodec/mace.c +++ b/libavcodec/mace.c @@ -2,20 +2,20 @@ * MACE decoder * Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index ec76eaae29..0477cfdce3 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -3,20 +3,20 @@ * Copyright (c) 2001, 2002 Fabrice Bellard * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * 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_MATHOPS_H diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c index 6f64534273..22320240de 100644 --- a/libavcodec/mdct.c +++ b/libavcodec/mdct.c @@ -2,20 +2,20 @@ * MDCT/IMDCT transforms * Copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mdct_fixed.c b/libavcodec/mdct_fixed.c index 94527f9e85..794a3e0bc2 100644 --- a/libavcodec/mdct_fixed.c +++ b/libavcodec/mdct_fixed.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mdct_float.c b/libavcodec/mdct_float.c index e4f5549cb7..ec4f486f19 100644 --- a/libavcodec/mdct_float.c +++ b/libavcodec/mdct_float.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 02b69d045a..5f540f05f2 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -4,20 +4,20 @@ * * based upon code from Sebastian Jedruszkiewicz <elf@frogger.rules.pl> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -219,6 +219,7 @@ static av_cold void mdec_common_init(AVCodecContext *avctx){ a->mb_width = (avctx->coded_width + 15) / 16; a->mb_height = (avctx->coded_height + 15) / 16; + avcodec_get_frame_defaults(&a->picture); avctx->coded_frame= &a->picture; a->avctx= avctx; } @@ -244,14 +245,15 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx){ MDECContext * const a = avctx->priv_data; AVFrame *p = (AVFrame*)&a->picture; - avctx->coded_frame = p; + avctx->coded_frame= p; a->avctx= avctx; - p->qscale_table = av_mallocz( a->mb_width); + p->qscale_table= av_mallocz(a->mb_width); return 0; } + static av_cold int decode_end(AVCodecContext *avctx){ MDECContext * const a = avctx->priv_data; diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 46497ec76c..ee625d0dbf 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -2,20 +2,20 @@ * Copyright (C) 2005 Ole André Vadla Ravnås <oleavr@gmail.com> * Copyright (C) 2008 Ramiro Polla * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -209,7 +209,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale) value = get_bits(&ctx->gb, num_bits); - /* Libav's IDCT behaves somewhat different from the original code, so + /* FFmpeg's IDCT behaves somewhat different from the original code, so * a factor of 4 was added to the input */ coeff = vlcdec_lookup[num_bits][value]; diff --git a/libavcodec/mips/mathops.h b/libavcodec/mips/mathops.h index 573745b291..b58361f74d 100644 --- a/libavcodec/mips/mathops.h +++ b/libavcodec/mips/mathops.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c index 9f2d50fa05..6eba27da0b 100644 --- a/libavcodec/mjpeg.c +++ b/libavcodec/mjpeg.c @@ -8,20 +8,20 @@ * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpeg.h b/libavcodec/mjpeg.h index c3fde4432c..3c88471bab 100644 --- a/libavcodec/mjpeg.h +++ b/libavcodec/mjpeg.h @@ -8,20 +8,20 @@ * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c index 335a73bf54..855f24add3 100644 --- a/libavcodec/mjpeg2jpeg_bsf.c +++ b/libavcodec/mjpeg2jpeg_bsf.c @@ -2,20 +2,20 @@ * MJPEG/AVI1 to JPEG/JFIF bitstream format filter * Copyright (c) 2010 Adrian Daerr and Nicolas George * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpeg_parser.c b/libavcodec/mjpeg_parser.c index b5282f17c4..0cc355db5c 100644 --- a/libavcodec/mjpeg_parser.c +++ b/libavcodec/mjpeg_parser.c @@ -4,20 +4,20 @@ * Copyright (c) 2003 Alex Beregszaszi * Copyright (c) 2003-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c index 2a181fc386..2e86fd4ef3 100644 --- a/libavcodec/mjpega_dump_header_bsf.c +++ b/libavcodec/mjpega_dump_header_bsf.c @@ -2,20 +2,20 @@ * MJPEG A dump header bitstream filter * Copyright (c) 2006 Baptiste Coudurier * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index 837304ea74..5f863433ef 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -2,20 +2,20 @@ * Apple MJPEG-B decoder * Copyright (c) 2002 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 391d58de6b..4e58feffad 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -8,20 +8,20 @@ * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -34,6 +34,7 @@ #include <assert.h> #include "libavutil/imgutils.h" +#include "libavutil/avassert.h" #include "avcodec.h" #include "dsputil.h" #include "mjpeg.h" @@ -83,6 +84,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) if (!s->picture_ptr) s->picture_ptr = &s->picture; + avcodec_get_frame_defaults(&s->picture); s->avctx = avctx; dsputil_init(&s->dsp, avctx); @@ -637,7 +639,7 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point } for(mb_y = 0; mb_y < s->mb_height; mb_y++) { const int modified_predictor= mb_y ? predictor : 1; - uint8_t *ptr = s->picture_ptr->data[0] + (linesize * mb_y); + uint8_t *ptr = s->picture.data[0] + (linesize * mb_y); if (s->interlaced && s->bottom_field) ptr += linesize >> 1; @@ -714,7 +716,7 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point for(j=0; j<n; j++) { int pred; - ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap + ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap if(y==0 && mb_y==0){ if(x==0 && mb_x==0){ pred= 128 << point_transform; @@ -754,7 +756,7 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point for(j=0; j<n; j++) { int pred; - ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap + ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform); if (++x == h) { @@ -879,9 +881,12 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i } } - if (s->restart_interval && !--s->restart_count) { + if (s->restart_interval && show_bits(&s->gb, 8) == 0xFF){/* skip RSTn */ + --s->restart_count; align_get_bits(&s->gb); - skip_bits(&s->gb, 16); /* skip RSTn */ + while(show_bits(&s->gb, 8) == 0xFF) + skip_bits(&s->gb, 8); + skip_bits(&s->gb, 8); for (i=0; i<nb_components; i++) /* reset dc */ s->last_dc[i] = 1024; } @@ -890,43 +895,29 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i return 0; } -static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int se, int Ah, int Al, - const uint8_t *mb_bitmask, const AVFrame *reference){ +static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int se, int Ah, int Al){ int mb_x, mb_y; int EOBRUN = 0; int c = s->comp_index[0]; - uint8_t* data = s->picture_ptr->data[c]; - const uint8_t *reference_data = reference ? reference->data[c] : NULL; + uint8_t* data = s->picture.data[c]; int linesize = s->linesize[c]; int last_scan = 0; int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ]; - GetBitContext mb_bitmask_gb; - - if (mb_bitmask) { - init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height); - } if(!Al) { s->coefs_finished[c] |= (1LL<<(se+1))-(1LL<<ss); last_scan = !~s->coefs_finished[c]; } - if(s->interlaced && s->bottom_field) { - int offset = linesize >> 1; - data += offset; - reference_data += offset; - } + if(s->interlaced && s->bottom_field) + data += linesize >> 1; for(mb_y = 0; mb_y < s->mb_height; mb_y++) { - int block_offset = (mb_y*linesize*8 >> s->avctx->lowres); - uint8_t *ptr = data + block_offset; + uint8_t *ptr = data + (mb_y*linesize*8 >> s->avctx->lowres); int block_idx = mb_y * s->block_stride[c]; DCTELEM (*block)[64] = &s->blocks[c][block_idx]; uint8_t *last_nnz = &s->last_nnz[c][block_idx]; for(mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) { - const int copy_mb = mb_bitmask && !get_bits1(&mb_bitmask_gb); - - if (!copy_mb) { int ret; if(Ah) ret = decode_block_refinement(s, *block, last_nnz, s->ac_index[0], @@ -938,15 +929,9 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int s av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return -1; } - } - if(last_scan) { - if (copy_mb) { - mjpeg_copy_block(ptr, reference_data + block_offset, linesize, s->avctx->lowres); - } else { s->dsp.idct_put(ptr, linesize, *block); ptr += 8 >> s->avctx->lowres; - } } } } @@ -1039,6 +1024,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, skip_bits(&s->gb, 8); if(s->lossless){ + av_assert0(s->picture_ptr == &s->picture); if(CONFIG_JPEGLS_DECODER && s->ls){ // for(){ // reset_ls_coding_parameters(s, 0); @@ -1056,8 +1042,8 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, } }else{ if(s->progressive && predictor) { - if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform, - mb_bitmask, reference) < 0) + av_assert0(s->picture_ptr == &s->picture); + if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0) return -1; } else { if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform, @@ -1299,9 +1285,7 @@ static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end) const uint8_t *buf_ptr; unsigned int v, v2; int val; -#ifdef DEBUG int skipped=0; -#endif buf_ptr = *pbuf_ptr; while (buf_ptr < buf_end) { @@ -1311,9 +1295,7 @@ static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end) val = *buf_ptr++; goto found; } -#ifdef DEBUG skipped++; -#endif } val = -1; found: diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h index 52c256ee2f..beefdb998c 100644 --- a/libavcodec/mjpegdec.h +++ b/libavcodec/mjpegdec.h @@ -4,20 +4,20 @@ * Copyright (c) 2003 Alex Beregszaszi * Copyright (c) 2003-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 169d19e17a..db477a0ab6 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -8,20 +8,20 @@ * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -156,7 +156,7 @@ static void jpeg_put_comments(MpegEncContext *s) int size; uint8_t *ptr; - if (s->aspect_ratio_info /* && !lossless */) + if (s->avctx->sample_aspect_ratio.num /* && !lossless */) { /* JFIF header */ put_marker(p, APP0); diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h index 12ff54055e..49627a3d55 100644 --- a/libavcodec/mjpegenc.h +++ b/libavcodec/mjpegenc.h @@ -8,20 +8,20 @@ * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mlib/dsputil_mlib.c b/libavcodec/mlib/dsputil_mlib.c index c0f2c036c6..1a18a8a223 100644 --- a/libavcodec/mlib/dsputil_mlib.c +++ b/libavcodec/mlib/dsputil_mlib.c @@ -2,20 +2,20 @@ * Sun mediaLib optimized DSP utils * Copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mlp.c b/libavcodec/mlp.c index 9615b66ee1..87f7c77139 100644 --- a/libavcodec/mlp.c +++ b/libavcodec/mlp.c @@ -2,20 +2,20 @@ * MLP codec common code * Copyright (c) 2007-2008 Ian Caulfield * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h index b001ad270d..628b58d318 100644 --- a/libavcodec/mlp.h +++ b/libavcodec/mlp.h @@ -2,20 +2,20 @@ * MLP codec common header file * Copyright (c) 2007-2008 Ian Caulfield * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index e85eb72c38..a6bdc0c0a5 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -2,20 +2,20 @@ * MLP parser * Copyright (c) 2007 Ian Caulfield * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -43,28 +43,28 @@ static const uint8_t mlp_channels[32] = { 5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static const uint64_t mlp_layout[32] = { +const uint64_t ff_mlp_layout[32] = { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_2_1, - AV_CH_LAYOUT_2_2, + AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY, AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY, - AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY, + AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_4POINT0, - AV_CH_LAYOUT_5POINT0, + AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY, AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY, - AV_CH_LAYOUT_5POINT1, + AV_CH_LAYOUT_5POINT1_BACK, AV_CH_LAYOUT_4POINT0, - AV_CH_LAYOUT_5POINT0, + AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY, AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY, - AV_CH_LAYOUT_5POINT1, - AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY, - AV_CH_LAYOUT_5POINT0, - AV_CH_LAYOUT_5POINT1, + AV_CH_LAYOUT_5POINT1_BACK, + AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY, + AV_CH_LAYOUT_5POINT0_BACK, + AV_CH_LAYOUT_5POINT1_BACK, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -107,7 +107,7 @@ static int truehd_channels(int chanmap) return channels; } -static int64_t truehd_layout(int chanmap) +int64_t ff_truehd_layout(int chanmap) { int layout = 0, i; @@ -316,15 +316,15 @@ static int mlp_parse(AVCodecParserContext *s, if (mh.stream_type == 0xbb) { /* MLP stream */ avctx->channels = mlp_channels[mh.channels_mlp]; - avctx->channel_layout = mlp_layout[mh.channels_mlp]; + avctx->channel_layout = ff_mlp_layout[mh.channels_mlp]; } else { /* mh.stream_type == 0xba */ /* TrueHD stream */ if (mh.channels_thd_stream2) { avctx->channels = truehd_channels(mh.channels_thd_stream2); - avctx->channel_layout = truehd_layout(mh.channels_thd_stream2); + avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream2); } else { avctx->channels = truehd_channels(mh.channels_thd_stream1); - avctx->channel_layout = truehd_layout(mh.channels_thd_stream1); + avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream1); } } diff --git a/libavcodec/mlp_parser.h b/libavcodec/mlp_parser.h index 940ba838f3..6e43bc38dc 100644 --- a/libavcodec/mlp_parser.h +++ b/libavcodec/mlp_parser.h @@ -2,20 +2,20 @@ * MLP parser prototypes * Copyright (c) 2007 Ian Caulfield * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -54,6 +54,9 @@ typedef struct MLPHeaderInfo int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb); +int64_t ff_truehd_layout(int chanmap); + +extern const uint64_t ff_mlp_layout[32]; #endif /* AVCODEC_MLP_PARSER_H */ diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 5e50eba75e..b13d0795cd 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -2,20 +2,20 @@ * MLP decoder * Copyright (c) 2007-2008 Ian Caulfield * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -41,7 +41,7 @@ static const char* sample_message = "Please file a bug report following the instructions at " - "http://libav.org/bugreports.html and include " + "http://ffmpeg.org/bugreports.html and include " "a sample of this file."; typedef struct SubStream { @@ -133,6 +133,9 @@ typedef struct MLPDecodeContext { //! Index of the last substream to decode - further substreams are skipped. uint8_t max_decoded_substream; + //! Stream needs channel reordering to comply with FFmpeg's channel order + uint8_t needs_reordering; + //! number of PCM samples contained in each frame int access_unit_size; //! next power of two above the number of samples in each frame @@ -326,6 +329,26 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) for (substr = 0; substr < MAX_SUBSTREAMS; substr++) m->substream[substr].restart_seen = 0; + if (mh.stream_type == 0xbb) { + /* MLP stream */ + m->avctx->channel_layout = ff_mlp_layout[mh.channels_mlp]; + } else { /* mh.stream_type == 0xba */ + /* TrueHD stream */ + if (mh.channels_thd_stream2) { + m->avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream2); + } else { + m->avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream1); + } + if (m->avctx->channels && + !m->avctx->request_channels && !m->avctx->request_channel_layout && + av_get_channel_layout_nb_channels(m->avctx->channel_layout) != m->avctx->channels) { + m->avctx->channel_layout = 0; + av_log_ask_for_sample(m->avctx, "Unknown channel layout."); + } + } + + m->needs_reordering = mh.channels_mlp >= 18 && mh.channels_mlp <= 20; + return 0; } @@ -436,6 +459,24 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, s->ch_assign[ch_assign] = ch; } + if (m->avctx->codec_id == CODEC_ID_MLP && m->needs_reordering) { + if (m->avctx->channel_layout == (AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY) || + m->avctx->channel_layout == AV_CH_LAYOUT_5POINT0_BACK) { + int i = s->ch_assign[4]; + s->ch_assign[4] = s->ch_assign[3]; + s->ch_assign[3] = s->ch_assign[2]; + s->ch_assign[2] = i; + } else if (m->avctx->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) { + FFSWAP(int, s->ch_assign[2], s->ch_assign[4]); + FFSWAP(int, s->ch_assign[3], s->ch_assign[5]); + } + } + if (m->avctx->codec_id == CODEC_ID_TRUEHD && + m->avctx->channel_layout == AV_CH_LAYOUT_7POINT1) { + FFSWAP(int, s->ch_assign[4], s->ch_assign[6]); + FFSWAP(int, s->ch_assign[5], s->ch_assign[7]); + } + checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count); if (checksum != get_bits(gbp, 8)) diff --git a/libavcodec/mlpdsp.c b/libavcodec/mlpdsp.c index 7d01c7586d..7ec8dd24e6 100644 --- a/libavcodec/mlpdsp.c +++ b/libavcodec/mlpdsp.c @@ -2,20 +2,20 @@ * Copyright (c) 2007-2008 Ian Caulfield * 2009 Ramiro Polla * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index b65335e6cb..707ddc5f7e 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -2,20 +2,20 @@ * American Laser Games MM Video Decoder * Copyright (c) 2006,2008 Peter Ross * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -58,6 +58,7 @@ static av_cold int mm_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); s->frame.reference = 1; return 0; diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c index b88917c988..994b262bc0 100644 --- a/libavcodec/motion-test.c +++ b/libavcodec/motion-test.c @@ -1,20 +1,20 @@ /* * (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 5f10456d3b..c12ebf4c7c 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -5,20 +5,20 @@ * * new motion estimation (X1/EPZS) by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 6b807dc6f6..461e85932b 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -2,20 +2,20 @@ * Motion estimation * Copyright (c) 2002-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -158,6 +158,7 @@ static int hpel_motion_search(MpegEncContext * s, const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] + (mv_penalty[bx - pred_x] + mv_penalty[by+2 - pred_y])*c->penalty_factor; +#if 1 int key; int map_generation= c->map_generation; #ifndef NDEBUG @@ -171,6 +172,7 @@ static int hpel_motion_search(MpegEncContext * s, assert(map[(index+1)&(ME_MAP_SIZE-1)] == key); key= ((my)<<ME_MAP_MV_BITS) + (mx-1) + map_generation; assert(map[(index-1)&(ME_MAP_SIZE-1)] == key); +#endif if(t<=b){ CHECK_HALF_MV(0, 1, mx ,my-1) if(l<=r){ diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index ebc4b31201..01558ab95b 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -2,20 +2,20 @@ * Motion Pixels Video Decoder * Copyright (c) 2008 Gregory Montoir (cyx@users.sourceforge.net) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -61,6 +61,7 @@ static av_cold int mp_decode_init(AVCodecContext *avctx) mp->vpt = av_mallocz(avctx->height * sizeof(YuvPixel)); mp->hpt = av_mallocz(avctx->height * avctx->width / 16 * sizeof(YuvPixel)); avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&mp->frame); return 0; } diff --git a/libavcodec/motionpixels_tablegen.c b/libavcodec/motionpixels_tablegen.c index ad8e0d9161..31e5cdf710 100644 --- a/libavcodec/motionpixels_tablegen.c +++ b/libavcodec/motionpixels_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/motionpixels_tablegen.h b/libavcodec/motionpixels_tablegen.h index cbf56c8694..b56dec64a4 100644 --- a/libavcodec/motionpixels_tablegen.h +++ b/libavcodec/motionpixels_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/movsub_bsf.c b/libavcodec/movsub_bsf.c index 423ebebcc6..088c774001 100644 --- a/libavcodec/movsub_bsf.c +++ b/libavcodec/movsub_bsf.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Reimar Döffinger * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mp3_header_compress_bsf.c b/libavcodec/mp3_header_compress_bsf.c index bc3659ef3e..417a2940d5 100644 --- a/libavcodec/mp3_header_compress_bsf.c +++ b/libavcodec/mp3_header_compress_bsf.c @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mp3_header_decompress_bsf.c b/libavcodec/mp3_header_decompress_bsf.c index 3f3074286a..a9c23b17ce 100644 --- a/libavcodec/mp3_header_decompress_bsf.c +++ b/libavcodec/mp3_header_decompress_bsf.c @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c index 4573860525..c2975ec732 100644 --- a/libavcodec/mpc.c +++ b/libavcodec/mpc.c @@ -2,20 +2,20 @@ * Musepack decoder core * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h index 6d0f7b45bb..cd5769234c 100644 --- a/libavcodec/mpc.h +++ b/libavcodec/mpc.h @@ -2,20 +2,20 @@ * Musepack decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index dbfa3c8636..bb21469356 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -2,20 +2,20 @@ * Musepack SV7 decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpc7data.h b/libavcodec/mpc7data.h index f205ffe97f..5609e8fbf3 100644 --- a/libavcodec/mpc7data.h +++ b/libavcodec/mpc7data.h @@ -2,20 +2,20 @@ * Musepack decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 3177faf1c4..2864b1a010 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -2,20 +2,20 @@ * Musepack SV8 decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpc8data.h b/libavcodec/mpc8data.h index 2940b30733..22c2be43bf 100644 --- a/libavcodec/mpc8data.h +++ b/libavcodec/mpc8data.h @@ -2,20 +2,20 @@ * Musepack SV8 decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpc8huff.h b/libavcodec/mpc8huff.h index 6005e214e8..8491037aa4 100644 --- a/libavcodec/mpc8huff.h +++ b/libavcodec/mpc8huff.h @@ -2,20 +2,20 @@ * Musepack SV8 decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpcdata.h b/libavcodec/mpcdata.h index 397dad59d8..03df3da3b5 100644 --- a/libavcodec/mpcdata.h +++ b/libavcodec/mpcdata.h @@ -2,20 +2,20 @@ * Musepack decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 03c95c191d..bd858a59b7 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,6 +30,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "libavutil/avassert.h" #include "mpeg12.h" #include "mpeg12data.h" @@ -67,11 +68,6 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred); static void exchange_uv(MpegEncContext *s); -static const enum PixelFormat pixfmt_xvmc_mpg2_420[] = { - PIX_FMT_XVMC_MPEG2_IDCT, - PIX_FMT_XVMC_MPEG2_MC, - PIX_FMT_NONE}; - uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; @@ -411,6 +407,10 @@ static int mpeg_decode_mb(MpegEncContext *s, } break; case MT_FIELD: + if(s->progressive_sequence){ + av_log(s->avctx, AV_LOG_ERROR, "MT_FIELD in progressive_sequence\n"); + return -1; + } s->mv_type = MV_TYPE_FIELD; if (s->picture_structure == PICT_FRAME) { mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED; @@ -448,6 +448,10 @@ static int mpeg_decode_mb(MpegEncContext *s, } break; case MT_DMV: + if(s->progressive_sequence){ + av_log(s->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n"); + return -1; + } s->mv_type = MV_TYPE_DMV; for(i=0;i<2;i++) { if (USES_LIST(mb_type, i)) { @@ -1195,7 +1199,7 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx, const AVCode if(!ctx->mpeg_enc_ctx_allocated) memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext)); - if(!(s->pict_type == FF_B_TYPE || s->low_delay)) + if(!(s->pict_type == AV_PICTURE_TYPE_B || s->low_delay)) s->picture_number++; return 0; @@ -1213,25 +1217,60 @@ static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, } } +static const enum PixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { +#if CONFIG_MPEG_XVMC_DECODER + PIX_FMT_XVMC_MPEG2_IDCT, + PIX_FMT_XVMC_MPEG2_MC, +#endif +#if CONFIG_MPEG1_VDPAU_HWACCEL + PIX_FMT_VDPAU_MPEG1, +#endif + PIX_FMT_YUV420P, + PIX_FMT_NONE +}; + +static const enum PixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { +#if CONFIG_MPEG_XVMC_DECODER + PIX_FMT_XVMC_MPEG2_IDCT, + PIX_FMT_XVMC_MPEG2_MC, +#endif +#if CONFIG_MPEG2_VDPAU_HWACCEL + PIX_FMT_VDPAU_MPEG2, +#endif +#if CONFIG_MPEG2_DXVA2_HWACCEL + PIX_FMT_DXVA2_VLD, +#endif +#if CONFIG_MPEG2_VAAPI_HWACCEL + PIX_FMT_VAAPI_VLD, +#endif + PIX_FMT_YUV420P, + PIX_FMT_NONE +}; + +static inline int uses_vdpau(AVCodecContext *avctx) { + return avctx->pix_fmt == PIX_FMT_VDPAU_MPEG1 || avctx->pix_fmt == PIX_FMT_VDPAU_MPEG2; +} + static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx){ Mpeg1Context *s1 = avctx->priv_data; MpegEncContext *s = &s1->mpeg_enc_ctx; - if(avctx->xvmc_acceleration) - return avctx->get_format(avctx,pixfmt_xvmc_mpg2_420); - else if(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){ - if(avctx->codec_id == CODEC_ID_MPEG1VIDEO) - return PIX_FMT_VDPAU_MPEG1; - else - return PIX_FMT_VDPAU_MPEG2; - }else{ - if(s->chroma_format < 2) - return avctx->get_format(avctx,ff_hwaccel_pixfmt_list_420); - else if(s->chroma_format == 2) - return PIX_FMT_YUV422P; - else - return PIX_FMT_YUV444P; - } + if(s->chroma_format < 2) { + enum PixelFormat res; + res = avctx->get_format(avctx, + avctx->codec_id == CODEC_ID_MPEG1VIDEO ? + mpeg1_hwaccel_pixfmt_list_420 : + mpeg2_hwaccel_pixfmt_list_420); + if (res != PIX_FMT_XVMC_MPEG2_IDCT && res != PIX_FMT_XVMC_MPEG2_MC) { + avctx->xvmc_acceleration = 0; + } else if (!avctx->xvmc_acceleration) { + avctx->xvmc_acceleration = 2; + } + return res; + } else if(s->chroma_format == 2) + return PIX_FMT_YUV422P; + else + return PIX_FMT_YUV444P; } /* Call this function when we know all parameters. @@ -1332,8 +1371,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){ avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); //until then pix_fmt may be changed right after codec init if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || - avctx->hwaccel || - s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ) + avctx->hwaccel ) if( avctx->idct_algo == FF_IDCT_AUTO ) avctx->idct_algo = FF_IDCT_SIMPLE; @@ -1566,7 +1604,6 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) if(s->progressive_sequence && !s->frame_pred_frame_dct){ av_log(s->avctx, AV_LOG_ERROR, "invalid frame_pred_frame_dct\n"); - s->frame_pred_frame_dct= 1; } if(s->picture_structure == PICT_FRAME){ @@ -2079,8 +2116,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx) avctx->pix_fmt = mpeg_get_pixelformat(avctx); avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); - if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel || - s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ) + if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel ) if( avctx->idct_algo == FF_IDCT_AUTO ) avctx->idct_algo = FF_IDCT_SIMPLE; @@ -2304,13 +2340,14 @@ static int decode_chunks(AVCodecContext *avctx, if(s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT){ if(HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)){ int i; + av_assert0(avctx->thread_count > 1); avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*)); for(i=0; i<s->slice_count; i++) s2->error_count += s2->thread_context[i]->error_count; } - if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) + if (CONFIG_VDPAU && uses_vdpau(avctx)) ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); if (slice_end(avctx, picture)) { @@ -2465,13 +2502,14 @@ static int decode_chunks(AVCodecContext *avctx, return -1; } - if (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) { + if (uses_vdpau(avctx)) { s->slice_count++; break; } if(HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)){ int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count; + av_assert0(avctx->thread_count > 1); if(threshold <= mb_y){ MpegEncContext *thread_context= s2->thread_context[s->slice_count]; diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index 4c55726160..541b66bd94 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -2,20 +2,20 @@ * MPEG1/2 common code * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c index 299215f91e..8b1f563bf4 100644 --- a/libavcodec/mpeg12data.c +++ b/libavcodec/mpeg12data.c @@ -3,20 +3,20 @@ * copyright (c) 2000,2001 Fabrice Bellard * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg12data.h b/libavcodec/mpeg12data.h index 3586a614aa..9695e9d41e 100644 --- a/libavcodec/mpeg12data.h +++ b/libavcodec/mpeg12data.h @@ -3,20 +3,20 @@ * copyright (c) 2000,2001 Fabrice Bellard * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg12decdata.h b/libavcodec/mpeg12decdata.h index 323a902336..66ca5c4971 100644 --- a/libavcodec/mpeg12decdata.h +++ b/libavcodec/mpeg12decdata.h @@ -3,20 +3,20 @@ * copyright (c) 2000,2001 Fabrice Bellard * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index eb07ecfc5e..41344562b2 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index f0399af8fe..f9951b1604 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -3,20 +3,20 @@ * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr> * Copyright (c) 2009 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h index 2d2b4a232e..174624e15d 100644 --- a/libavcodec/mpeg4audio.h +++ b/libavcodec/mpeg4audio.h @@ -2,20 +2,20 @@ * MPEG-4 Audio common header * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4data.h b/libavcodec/mpeg4data.h index 07cbeee18a..1f4e578ca1 100644 --- a/libavcodec/mpeg4data.h +++ b/libavcodec/mpeg4data.h @@ -3,20 +3,20 @@ * H263+ support * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4video.c b/libavcodec/mpeg4video.c index a4dc80a420..f4e9a8a1f8 100644 --- a/libavcodec/mpeg4video.c +++ b/libavcodec/mpeg4video.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index d34e73149c..f1e6a4d172 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index 2e498d100c..5d0f47ec13 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4video_parser.h b/libavcodec/mpeg4video_parser.h index d907dc4d5b..822a24cb99 100644 --- a/libavcodec/mpeg4video_parser.h +++ b/libavcodec/mpeg4video_parser.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 22d7ace789..6b7b4bfbc0 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1491,7 +1491,7 @@ end: if(mpeg4_is_resync(s)){ const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1; - if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta]){ + if(s->pict_type==AV_PICTURE_TYPE_B){ ff_thread_await_progress((AVFrame*)s->next_picture_ptr, (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0); } @@ -1508,18 +1508,22 @@ end: static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){ int hours, minutes, seconds; - unsigned time_code = show_bits(gb, 18); - - if (time_code & 0x40) { /* marker_bit */ - hours = time_code >> 13; - minutes = time_code >> 7 & 0x3f; - seconds = time_code & 0x3f; - s->time_base = seconds + 60*(minutes + 60*hours); - skip_bits(gb, 20); /* time_code, closed_gov, broken_link */ - } else { - av_log(s->avctx, AV_LOG_WARNING, "GOP header missing marker_bit\n"); + + if(!show_bits(gb, 23)){ + av_log(s->avctx, AV_LOG_WARNING, "GOP header invalid\n"); + return -1; } + hours= get_bits(gb, 5); + minutes= get_bits(gb, 6); + skip_bits1(gb); + seconds= get_bits(gb, 6); + + s->time_base= seconds + 60*(minutes + 60*hours); + + skip_bits1(gb); + skip_bits1(gb); + return 0; } diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 8a9bd198df..bdff535a99 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -650,8 +650,6 @@ void mpeg4_encode_mb(MpegEncContext * s, x= s->mb_x*16; y= s->mb_y*16; - if(x+16 > s->width) x= s->width-16; - if(y+16 > s->height) y= s->height-16; offset= x + y*s->linesize; p_pic= s->new_picture.data[0] + offset; @@ -667,7 +665,21 @@ void mpeg4_encode_mb(MpegEncContext * s, b_pic= pic->data[0] + offset; if(pic->type != FF_BUFFER_TYPE_SHARED) b_pic+= INPLACE_OFFSET; - diff= s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16); + + if(x+16 > s->width || y+16 > s->height){ + int x1,y1; + int xe= FFMIN(16, s->width - x); + int ye= FFMIN(16, s->height- y); + diff=0; + for(y1=0; y1<ye; y1++){ + for(x1=0; x1<xe; x1++){ + diff+= FFABS(p_pic[x1+y1*s->linesize] - b_pic[x1+y1*s->linesize]); + } + } + diff= diff*256/(xe*ye); + }else{ + diff= s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16); + } if(diff>s->qscale*70){ //FIXME check that 70 is optimal s->mb_skipped=0; break; @@ -868,7 +880,7 @@ void ff_set_mpeg4_time(MpegEncContext * s){ ff_mpeg4_init_direct_mv(s); }else{ s->last_time_base= s->time_base; - s->time_base= s->time/s->avctx->time_base.den; + s->time_base= FFUDIV(s->time, s->avctx->time_base.den); } } @@ -883,11 +895,12 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){ if(s->reordered_input_picture[1]) time= FFMIN(time, s->reordered_input_picture[1]->pts); time= time*s->avctx->time_base.num; + s->last_time_base= FFUDIV(time, s->avctx->time_base.den); - seconds= time/s->avctx->time_base.den; - minutes= seconds/60; seconds %= 60; - hours= minutes/60; minutes %= 60; - hours%=24; + seconds= FFUDIV(time, s->avctx->time_base.den); + minutes= FFUDIV(seconds, 60); FFUMOD(seconds, 60); + hours = FFUDIV(minutes, 60); FFUMOD(minutes, 60); + hours = FFUMOD(hours , 24); put_bits(&s->pb, 5, hours); put_bits(&s->pb, 6, minutes); @@ -897,8 +910,6 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){ put_bits(&s->pb, 1, !!(s->flags&CODEC_FLAG_CLOSED_GOP)); put_bits(&s->pb, 1, 0); //broken link == NO - s->last_time_base= time / s->avctx->time_base.den; - ff_mpeg4_stuffing(&s->pb); } @@ -1071,9 +1082,8 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number) put_bits(&s->pb, 16, VOP_STARTCODE); /* vop header */ put_bits(&s->pb, 2, s->pict_type - 1); /* pict type: I = 0 , P = 1 */ - assert(s->time>=0); - time_div= s->time/s->avctx->time_base.den; - time_mod= s->time%s->avctx->time_base.den; + time_div= FFUDIV(s->time, s->avctx->time_base.den); + time_mod= FFUMOD(s->time, s->avctx->time_base.den); time_incr= time_div - s->last_time_base; assert(time_incr >= 0); while(time_incr--) diff --git a/libavcodec/mpegaudio.c b/libavcodec/mpegaudio.c index 1a8363540e..cba52992ef 100644 --- a/libavcodec/mpegaudio.c +++ b/libavcodec/mpegaudio.c @@ -2,20 +2,20 @@ * MPEG Audio common code * Copyright (c) 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h index b55680100b..b829cd3f8a 100644 --- a/libavcodec/mpegaudio.h +++ b/libavcodec/mpegaudio.h @@ -1,20 +1,20 @@ /* * copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index f07d34bd29..94a286fb14 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudio_tablegen.c b/libavcodec/mpegaudio_tablegen.c index b4c240bd7c..90c9de430a 100644 --- a/libavcodec/mpegaudio_tablegen.c +++ b/libavcodec/mpegaudio_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h index a222f2c423..291e40b9aa 100644 --- a/libavcodec/mpegaudio_tablegen.h +++ b/libavcodec/mpegaudio_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodata.c b/libavcodec/mpegaudiodata.c index b850d22c9e..c9dabf3185 100644 --- a/libavcodec/mpegaudiodata.c +++ b/libavcodec/mpegaudiodata.c @@ -2,20 +2,20 @@ * MPEG Audio common tables * copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h index 84458836fa..9d65a1e2a6 100644 --- a/libavcodec/mpegaudiodata.h +++ b/libavcodec/mpegaudiodata.h @@ -2,20 +2,20 @@ * MPEG Audio common tables * copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 033d76e049..56a48ce71b 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -2,20 +2,20 @@ * MPEG Audio decoder * Copyright (c) 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1709,7 +1709,6 @@ static int mp_decode_frame(MPADecodeContext *s, if (s->error_protection) skip_bits(&s->gb, 16); - av_dlog(s->avctx, "frame %d:\n", s->frame_count); switch(s->layer) { case 1: s->avctx->frame_size = 384; diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index 0ff866af31..44b38b66d9 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -2,20 +2,20 @@ * Float MPEG Audio decoder * Copyright (c) 2010 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c index be7abc619d..1c3b004bcc 100644 --- a/libavcodec/mpegaudiodecheader.c +++ b/libavcodec/mpegaudiodecheader.c @@ -2,20 +2,20 @@ * MPEG Audio header decoder * Copyright (c) 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodecheader.h b/libavcodec/mpegaudiodecheader.h index 2991595b02..aa77f0122e 100644 --- a/libavcodec/mpegaudiodecheader.h +++ b/libavcodec/mpegaudiodecheader.h @@ -2,20 +2,20 @@ * MPEG Audio header decoder * Copyright (c) 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodectab.h b/libavcodec/mpegaudiodectab.h index 1221657988..accd12b8e2 100644 --- a/libavcodec/mpegaudiodectab.h +++ b/libavcodec/mpegaudiodectab.h @@ -2,20 +2,20 @@ * MPEG Audio decoder * copyright (c) 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodsp.c b/libavcodec/mpegaudiodsp.c index 438b097d06..d98d25bb21 100644 --- a/libavcodec/mpegaudiodsp.c +++ b/libavcodec/mpegaudiodsp.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2011 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudiodsp_template.c b/libavcodec/mpegaudiodsp_template.c index 5561c46135..02a34079c8 100644 --- a/libavcodec/mpegaudiodsp_template.c +++ b/libavcodec/mpegaudiodsp_template.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2001, 2002 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c index ef265c905d..a5859837ef 100644 --- a/libavcodec/mpegaudioenc.c +++ b/libavcodec/mpegaudioenc.c @@ -2,20 +2,20 @@ * The simplest mpeg audio layer 2 encoder * Copyright (c) 2000, 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -400,8 +400,10 @@ static void compute_scale_factors(unsigned char scale_code[SBLIMIT], index = 62; /* value 63 is not allowed */ } - av_dlog(NULL, "%2d:%d in=%x %x %d\n", - j, i, vmax, scale_factor_table[index], index); +#if 0 + printf("%2d:%d in=%x %x %d\n", + j, i, vmax, scale_factor_table[index], index); +#endif /* store the scale factor */ assert(index >=0 && index <= 63); sf[i] = index; @@ -469,8 +471,10 @@ static void compute_scale_factors(unsigned char scale_code[SBLIMIT], code = 0; /* kill warning */ } - av_dlog(NULL, "%d: %2d %2d %2d %d %d -> %d\n", j, - sf[0], sf[1], sf[2], d1, d2, code); +#if 0 + printf("%d: %2d %2d %2d %d %d -> %d\n", j, + sf[0], sf[1], sf[2], d1, d2, code); +#endif scale_code[j] = code; sf += 3; } diff --git a/libavcodec/mpegaudiotab.h b/libavcodec/mpegaudiotab.h index 45afe9bd16..35129e646c 100644 --- a/libavcodec/mpegaudiotab.h +++ b/libavcodec/mpegaudiotab.h @@ -4,20 +4,20 @@ * * Copyright (c) 2000, 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 6a45da8761..8e9a79167d 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -5,20 +5,20 @@ * * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -601,85 +601,83 @@ av_cold int MPV_common_init(MpegEncContext *s) s->flags= s->avctx->flags; s->flags2= s->avctx->flags2; - if (s->width && s->height) { - s->mb_width = (s->width + 15) / 16; - s->mb_stride = s->mb_width + 1; - s->b8_stride = s->mb_width*2 + 1; - s->b4_stride = s->mb_width*4 + 1; - mb_array_size= s->mb_height * s->mb_stride; - mv_table_size= (s->mb_height+2) * s->mb_stride + 1; + s->mb_width = (s->width + 15) / 16; + s->mb_stride = s->mb_width + 1; + s->b8_stride = s->mb_width*2 + 1; + s->b4_stride = s->mb_width*4 + 1; + mb_array_size= s->mb_height * s->mb_stride; + mv_table_size= (s->mb_height+2) * s->mb_stride + 1; - /* set chroma shifts */ - avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,&(s->chroma_x_shift), - &(s->chroma_y_shift) ); + /* set chroma shifts */ + avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,&(s->chroma_x_shift), + &(s->chroma_y_shift) ); - /* set default edge pos, will be overriden in decode_header if needed */ - s->h_edge_pos= s->mb_width*16; - s->v_edge_pos= s->mb_height*16; + /* set default edge pos, will be overriden in decode_header if needed */ + s->h_edge_pos= s->mb_width*16; + s->v_edge_pos= s->mb_height*16; - s->mb_num = s->mb_width * s->mb_height; + s->mb_num = s->mb_width * s->mb_height; - s->block_wrap[0]= - s->block_wrap[1]= - s->block_wrap[2]= - s->block_wrap[3]= s->b8_stride; - s->block_wrap[4]= - s->block_wrap[5]= s->mb_stride; + s->block_wrap[0]= + s->block_wrap[1]= + s->block_wrap[2]= + s->block_wrap[3]= s->b8_stride; + s->block_wrap[4]= + s->block_wrap[5]= s->mb_stride; - y_size = s->b8_stride * (2 * s->mb_height + 1); - c_size = s->mb_stride * (s->mb_height + 1); - yc_size = y_size + 2 * c_size; + y_size = s->b8_stride * (2 * s->mb_height + 1); + c_size = s->mb_stride * (s->mb_height + 1); + yc_size = y_size + 2 * c_size; - /* convert fourcc to upper case */ - s->codec_tag = ff_toupper4(s->avctx->codec_tag); + /* convert fourcc to upper case */ + s->codec_tag = ff_toupper4(s->avctx->codec_tag); - s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag); + s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag); - s->avctx->coded_frame= (AVFrame*)&s->current_picture; + s->avctx->coded_frame= (AVFrame*)&s->current_picture; - FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num+1)*sizeof(int), fail) //error ressilience code looks cleaner with this - for(y=0; y<s->mb_height; y++){ - for(x=0; x<s->mb_width; x++){ - s->mb_index2xy[ x + y*s->mb_width ] = x + y*s->mb_stride; - } + FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num+1)*sizeof(int), fail) //error ressilience code looks cleaner with this + for(y=0; y<s->mb_height; y++){ + for(x=0; x<s->mb_width; x++){ + s->mb_index2xy[ x + y*s->mb_width ] = x + y*s->mb_stride; } - s->mb_index2xy[ s->mb_height*s->mb_width ] = (s->mb_height-1)*s->mb_stride + s->mb_width; //FIXME really needed? - - if (s->encoding) { - /* Allocate MV tables */ - FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) - s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1; - s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; - s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; - s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1; - s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1; - s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1; - - if(s->msmpeg4_version){ - FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int), fail); - } - FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail); - - /* Allocate MB type table */ - FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type , mb_array_size * sizeof(uint16_t), fail) //needed for encoding - - FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail) + } + s->mb_index2xy[ s->mb_height*s->mb_width ] = (s->mb_height-1)*s->mb_stride + s->mb_width; //FIXME really needed? - FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix , 64*32 * sizeof(int), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix , 64*32 * sizeof(int), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail) + if (s->encoding) { + /* Allocate MV tables */ + FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail) + s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1; + s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; + s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; + s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1; + s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1; + s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1; + + if(s->msmpeg4_version){ + FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int), fail); + } + FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail); + + /* Allocate MB type table */ + FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type , mb_array_size * sizeof(uint16_t), fail) //needed for encoding + + FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail) + + FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix , 64*32 * sizeof(int), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix , 64*32 * sizeof(int), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail) - if(s->avctx->noise_reduction){ - FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail) - } + if(s->avctx->noise_reduction){ + FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail) } } @@ -689,11 +687,10 @@ av_cold int MPV_common_init(MpegEncContext *s) avcodec_get_frame_defaults((AVFrame *)&s->picture[i]); } - if (s->width && s->height) { - FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail) - if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){ - /* interlaced direct mode decoding tables */ + if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){ + /* interlaced direct mode decoding tables */ for(i=0; i<2; i++){ int j, k; for(j=0; j<2; j++){ @@ -707,49 +704,47 @@ av_cold int MPV_common_init(MpegEncContext *s) } FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[i], mb_array_size * 2 * sizeof(uint8_t), fail) } - } - if (s->out_format == FMT_H263) { - /* cbp values */ - FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail); - s->coded_block= s->coded_block_base + s->b8_stride + 1; - - /* cbp, ac_pred, pred_dir */ - FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , mb_array_size * sizeof(uint8_t), fail) - FF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, mb_array_size * sizeof(uint8_t), fail) - } + } + if (s->out_format == FMT_H263) { + /* cbp values */ + FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail); + s->coded_block= s->coded_block_base + s->b8_stride + 1; - if (s->h263_pred || s->h263_plus || !s->encoding) { - /* dc values */ - //MN: we need these for error resilience of intra-frames - FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, yc_size * sizeof(int16_t), fail); - s->dc_val[0] = s->dc_val_base + s->b8_stride + 1; - s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1; - s->dc_val[2] = s->dc_val[1] + c_size; - for(i=0;i<yc_size;i++) - s->dc_val_base[i] = 1024; - } + /* cbp, ac_pred, pred_dir */ + FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , mb_array_size * sizeof(uint8_t), fail) + FF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, mb_array_size * sizeof(uint8_t), fail) + } - /* which mb is a intra block */ - FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, mb_array_size, fail); - memset(s->mbintra_table, 1, mb_array_size); + if (s->h263_pred || s->h263_plus || !s->encoding) { + /* dc values */ + //MN: we need these for error resilience of intra-frames + FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, yc_size * sizeof(int16_t), fail); + s->dc_val[0] = s->dc_val_base + s->b8_stride + 1; + s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1; + s->dc_val[2] = s->dc_val[1] + c_size; + for(i=0;i<yc_size;i++) + s->dc_val_base[i] = 1024; + } - /* init macroblock skip table */ - FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size+2, fail); - //Note the +1 is for a quicker mpeg4 slice_end detection - FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail); + /* which mb is a intra block */ + FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, mb_array_size, fail); + memset(s->mbintra_table, 1, mb_array_size); - s->parse_context.state= -1; - if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){ - s->visualization_buffer[0] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); - s->visualization_buffer[1] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); - s->visualization_buffer[2] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); - } + /* init macroblock skip table */ + FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size+2, fail); + //Note the +1 is for a quicker mpeg4 slice_end detection + FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail); + + s->parse_context.state= -1; + if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){ + s->visualization_buffer[0] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); + s->visualization_buffer[1] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); + s->visualization_buffer[2] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); } s->context_initialized = 1; s->thread_context[0]= s; - if (s->width && s->height) { if (s->encoding || (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE)) { threads = s->avctx->thread_count; @@ -768,7 +763,7 @@ av_cold int MPV_common_init(MpegEncContext *s) if(init_duplicate_context(s, s) < 0) goto fail; s->start_mb_y = 0; s->end_mb_y = s->mb_height; - } + } return 0; @@ -1178,22 +1173,19 @@ void MPV_frame_end(MpegEncContext *s) //just to make sure that all data is rendered. if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){ ff_xvmc_field_end(s); - }else if((s->error_count || s->encoding) + }else if((s->error_count || s->encoding || !(s->avctx->codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND)) && !s->avctx->hwaccel && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) && s->unrestricted_mv && s->current_picture.reference && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { - s->dsp.draw_edges(s->current_picture.data[0], s->linesize , - s->h_edge_pos , s->v_edge_pos , - EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM); - s->dsp.draw_edges(s->current_picture.data[1], s->uvlinesize, - s->h_edge_pos>>1, s->v_edge_pos>>1, - EDGE_WIDTH/2, EDGE_TOP | EDGE_BOTTOM); - s->dsp.draw_edges(s->current_picture.data[2], s->uvlinesize, - s->h_edge_pos>>1, s->v_edge_pos>>1, - EDGE_WIDTH/2, EDGE_TOP | EDGE_BOTTOM); + int edges = EDGE_BOTTOM | EDGE_TOP, h = s->v_edge_pos; + + s->dsp.draw_edges(s->current_picture.data[0], s->linesize , s->h_edge_pos , h , EDGE_WIDTH , edges); + s->dsp.draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, h>>1, EDGE_WIDTH/2, edges); + s->dsp.draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, h>>1, EDGE_WIDTH/2, edges); + } emms_c(); @@ -1327,15 +1319,8 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){ if(s->avctx->debug&(FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)){ int x,y; - av_log(s->avctx,AV_LOG_DEBUG,"New frame, type: "); - switch (pict->pict_type) { - case AV_PICTURE_TYPE_I: av_log(s->avctx,AV_LOG_DEBUG,"I\n"); break; - case AV_PICTURE_TYPE_P: av_log(s->avctx,AV_LOG_DEBUG,"P\n"); break; - case AV_PICTURE_TYPE_B: av_log(s->avctx,AV_LOG_DEBUG,"B\n"); break; - case AV_PICTURE_TYPE_S: av_log(s->avctx,AV_LOG_DEBUG,"S\n"); break; - case AV_PICTURE_TYPE_SI: av_log(s->avctx,AV_LOG_DEBUG,"SI\n"); break; - case AV_PICTURE_TYPE_SP: av_log(s->avctx,AV_LOG_DEBUG,"SP\n"); break; - } + av_log(s->avctx, AV_LOG_DEBUG, "New frame, type: %c\n", + av_get_picture_type_char(pict->pict_type)); for(y=0; y<s->mb_height; y++){ for(x=0; x<s->mb_width; x++){ if(s->avctx->debug&FF_DEBUG_SKIP){ @@ -1418,6 +1403,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){ pict->data[i]= s->visualization_buffer[i]; } pict->type= FF_BUFFER_TYPE_COPY; + pict->opaque= NULL; ptr= pict->data[0]; block_height = 16>>v_chroma_shift; @@ -1632,7 +1618,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, uint8_t *ptr_y, *ptr_cb, *ptr_cr; int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy, uvsx, uvsy; const int lowres= s->avctx->lowres; - const int op_index= FFMIN(lowres, 2); + const int op_index= FFMIN(lowres-1+s->chroma_x_shift, 2); const int block_s= 8>>lowres; const int s_mask= (2<<lowres)-1; const int h_edge_pos = s->h_edge_pos >> lowres; @@ -1667,12 +1653,29 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, uvsrc_x = s->mb_x*block_s + (mx >> lowres); uvsrc_y = mb_y*block_s + (my >> lowres); } else { - mx = motion_x / 2; - my = motion_y / 2; - uvsx = mx & s_mask; - uvsy = my & s_mask; - uvsrc_x = s->mb_x*block_s + (mx >> (lowres+1)); - uvsrc_y =( mb_y*block_s>>field_based) + (my >> (lowres+1)); + if(s->chroma_y_shift){ + mx = motion_x / 2; + my = motion_y / 2; + uvsx = mx & s_mask; + uvsy = my & s_mask; + uvsrc_x = s->mb_x*block_s + (mx >> (lowres+1)); + uvsrc_y =( mb_y*block_s>>field_based) + (my >> (lowres+1)); + } else { + if(s->chroma_x_shift){ + //Chroma422 + mx = motion_x / 2; + uvsx = mx & s_mask; + uvsy = motion_y & s_mask; + uvsrc_y = src_y; + uvsrc_x = s->mb_x*block_s + (mx >> (lowres+1)); + } else { + //Chroma444 + uvsx = motion_x & s_mask; + uvsy = motion_y & s_mask; + uvsrc_x = src_x; + uvsrc_y = src_y; + } + } } ptr_y = ref_picture[0] + src_y * linesize + src_x; @@ -1714,8 +1717,10 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ uvsx= (uvsx << 2) >> lowres; uvsy= (uvsy << 2) >> lowres; - pix_op[op_index](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); - pix_op[op_index](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); + if(h >> s->chroma_y_shift){ + pix_op[op_index](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); + pix_op[op_index](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); + } } //FIXME h261 lowres loop filter } @@ -2178,17 +2183,17 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], }else{ //chroma422 dct_linesize = uvlinesize << s->interlaced_dct; - dct_offset =(s->interlaced_dct)? uvlinesize : uvlinesize*8; + dct_offset =(s->interlaced_dct)? uvlinesize : uvlinesize*block_size; add_dct(s, block[4], 4, dest_cb, dct_linesize); add_dct(s, block[5], 5, dest_cr, dct_linesize); add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize); add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize); if(!s->chroma_x_shift){//Chroma444 - add_dct(s, block[8], 8, dest_cb+8, dct_linesize); - add_dct(s, block[9], 9, dest_cr+8, dct_linesize); - add_dct(s, block[10], 10, dest_cb+8+dct_offset, dct_linesize); - add_dct(s, block[11], 11, dest_cr+8+dct_offset, dct_linesize); + add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize); + add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize); + add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize); + add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize); } } }//fi gray @@ -2230,17 +2235,17 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], }else{ dct_linesize = uvlinesize << s->interlaced_dct; - dct_offset =(s->interlaced_dct)? uvlinesize : uvlinesize*8; + dct_offset =(s->interlaced_dct)? uvlinesize : uvlinesize*block_size; s->dsp.idct_put(dest_cb, dct_linesize, block[4]); s->dsp.idct_put(dest_cr, dct_linesize, block[5]); s->dsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]); s->dsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]); if(!s->chroma_x_shift){//Chroma444 - s->dsp.idct_put(dest_cb + 8, dct_linesize, block[8]); - s->dsp.idct_put(dest_cr + 8, dct_linesize, block[9]); - s->dsp.idct_put(dest_cb + 8 + dct_offset, dct_linesize, block[10]); - s->dsp.idct_put(dest_cr + 8 + dct_offset, dct_linesize, block[11]); + s->dsp.idct_put(dest_cb + block_size, dct_linesize, block[8]); + s->dsp.idct_put(dest_cr + block_size, dct_linesize, block[9]); + s->dsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]); + s->dsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]); } } }//gray diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 6ce7faa235..ec9a04a7ae 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h index d0093ce8d2..18e49a63c3 100644 --- a/libavcodec/mpegvideo_common.h +++ b/libavcodec/mpegvideo_common.h @@ -5,20 +5,20 @@ * * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index b5a1872eb1..a6e9c7c7be 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -5,20 +5,20 @@ * * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -352,7 +352,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) } if(avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate){ - av_log(avctx, AV_LOG_INFO, "bitrate above max bitrate\n"); + av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); return -1; } @@ -582,7 +582,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) case CODEC_ID_H263: if (!CONFIG_H263_ENCODER) return -1; if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height) == 8) { - av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height); + av_log(avctx, AV_LOG_ERROR, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height); return -1; } s->out_format = FMT_H263; diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index 9688e18625..cfc950d017 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -151,8 +151,10 @@ static int mpegvideo_parse(AVCodecParserContext *s, to have the full timing information. The time take by this function should be negligible for uncorrupted streams */ mpegvideo_extract_headers(s, avctx, buf, buf_size); - av_dlog(NULL, "pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", - s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict); +#if 0 + printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", + s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict); +#endif *poutbuf = buf; *poutbuf_size = buf_size; diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c index 29d8bbbde6..76794076f9 100644 --- a/libavcodec/mpegvideo_xvmc.c +++ b/libavcodec/mpegvideo_xvmc.c @@ -2,20 +2,20 @@ * XVideo Motion Compensation * Copyright (c) 2003 Ivan Kalvachev * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/mqc.c b/libavcodec/mqc.c new file mode 100644 index 0000000000..700b9574c1 --- /dev/null +++ b/libavcodec/mqc.c @@ -0,0 +1,108 @@ +/* + * MQ-coder encoder and decoder common functions + * Copyright (c) 2007 Kamil Nowosad + * + * 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 + */ + +/** + * MQ-coder ecoder and decoder common functions + * @file + * @author Kamil Nowosad + */ + +#include "mqc.h" + +typedef struct { + uint16_t qe; + uint8_t nmps; + uint8_t nlps; + uint8_t sw; +} MqcCxState; + +const static MqcCxState cx_states[47] = { + {0x5601, 1, 1, 1}, + {0x3401, 2, 6, 0}, + {0x1801, 3, 9, 0}, + {0x0AC1, 4, 12, 0}, + {0x0521, 5, 29, 0}, + {0x0221, 38, 33, 0}, + {0x5601, 7, 6, 1}, + {0x5401, 8, 14, 0}, + {0x4801, 9, 14, 0}, + {0x3801, 10, 14, 0}, + {0x3001, 11, 17, 0}, + {0x2401, 12, 18, 0}, + {0x1C01, 13, 20, 0}, + {0x1601, 29, 21, 0}, + {0x5601, 15, 14, 1}, + {0x5401, 16, 14, 0}, + {0x5101, 17, 15, 0}, + {0x4801, 18, 16, 0}, + {0x3801, 19, 17, 0}, + {0x3401, 20, 18, 0}, + {0x3001, 21, 19, 0}, + {0x2801, 22, 19, 0}, + {0x2401, 23, 20, 0}, + {0x2201, 24, 21, 0}, + {0x1C01, 25, 22, 0}, + {0x1801, 26, 23, 0}, + {0x1601, 27, 24, 0}, + {0x1401, 28, 25, 0}, + {0x1201, 29, 26, 0}, + {0x1101, 30, 27, 0}, + {0x0AC1, 31, 28, 0}, + {0x09C1, 32, 29, 0}, + {0x08A1, 33, 30, 0}, + {0x0521, 34, 31, 0}, + {0x0441, 35, 32, 0}, + {0x02A1, 36, 33, 0}, + {0x0221, 37, 34, 0}, + {0x0141, 38, 35, 0}, + {0x0111, 39, 36, 0}, + {0x0085, 40, 37, 0}, + {0x0049, 41, 38, 0}, + {0x0025, 42, 39, 0}, + {0x0015, 43, 40, 0}, + {0x0009, 44, 41, 0}, + {0x0005, 45, 42, 0}, + {0x0001, 45, 43, 0}, + {0x5601, 46, 46, 0} +}; + +uint16_t ff_mqc_qe [2*47]; +uint8_t ff_mqc_nlps[2*47]; +uint8_t ff_mqc_nmps[2*47]; + +void ff_mqc_init_contexts(MqcState *mqc) +{ + int i; + memset(mqc->cx_states, 0, sizeof(mqc->cx_states)); + mqc->cx_states[MQC_CX_UNI] = 2 * 46; + mqc->cx_states[MQC_CX_RL] = 2 * 3; + mqc->cx_states[0] = 2 * 4; + + for (i = 0; i < 47; i++){ + ff_mqc_qe[2*i ] = + ff_mqc_qe[2*i+1] = cx_states[i].qe; + + ff_mqc_nlps[2*i ] = 2*cx_states[i].nlps + cx_states[i].sw; + ff_mqc_nlps[2*i+1] = 2*cx_states[i].nlps + 1 - cx_states[i].sw; + ff_mqc_nmps[2*i ] = 2*cx_states[i].nmps; + ff_mqc_nmps[2*i+1] = 2*cx_states[i].nmps + 1; + } +} diff --git a/libavcodec/mqc.h b/libavcodec/mqc.h new file mode 100644 index 0000000000..b28c13ec48 --- /dev/null +++ b/libavcodec/mqc.h @@ -0,0 +1,75 @@ +/* + * MQ-coder + * Copyright (c) 2007 Kamil Nowosad + * + * 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_MQC_H +#define AVCODEC_MQC_H + +/** + * MQ-coder + * @file + * @author Kamil Nowosad + */ + +#include "avcodec.h" + +#define MQC_CX_UNI 17 +#define MQC_CX_RL 18 + +extern uint16_t ff_mqc_qe[2*47]; +extern uint8_t ff_mqc_nlps[2*47]; +extern uint8_t ff_mqc_nmps[2*47]; + +typedef struct { + uint8_t *bp, *bpstart; + unsigned int a; + unsigned int c; + unsigned int ct; + uint8_t cx_states[19]; +} MqcState; + +/* encoder */ + +/** initialize the encoder */ +void ff_mqc_initenc(MqcState *mqc, uint8_t *bp); + +/** code bit d with context cx */ +void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d); + +/** number of encoded bytes */ +int ff_mqc_length(MqcState *mqc); + +/** flush the encoder [returns number of bytes encoded] */ +int ff_mqc_flush(MqcState *mqc); + +/* decoder */ + +/** initialize the decoder */ +void ff_mqc_initdec(MqcState *mqc, uint8_t *bp); + +/** returns decoded bit with context cx */ +int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate); + +/* common */ + +/** initialize the contexts */ +void ff_mqc_init_contexts(MqcState *mqc); + +#endif /* AVCODEC_MQC_H */ diff --git a/libavcodec/mqcdec.c b/libavcodec/mqcdec.c new file mode 100644 index 0000000000..56e22f88c7 --- /dev/null +++ b/libavcodec/mqcdec.c @@ -0,0 +1,93 @@ +/* + * MQ-coder decoder + * Copyright (c) 2007 Kamil Nowosad + * + * 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 + */ + +/** + * MQ-coder decoder + * @file + * @author Kamil Nowosad + */ + +#include "mqc.h" + +static void bytein(MqcState *mqc) +{ + if (*mqc->bp == 0xff){ + if (*(mqc->bp+1) > 0x8f) + mqc->c++; + else{ + mqc->bp++; + mqc->c += 2 + 0xfe00 - (*mqc->bp << 9); + } + } else{ + mqc->bp++; + mqc->c += 1 + 0xff00 - (*mqc->bp << 8); + } +} + +static int exchange(MqcState *mqc, uint8_t *cxstate, int lps) +{ + int d; + if ((mqc->a < ff_mqc_qe[*cxstate]) ^ (!lps)){ + if (lps) + mqc->a = ff_mqc_qe[*cxstate]; + d = *cxstate & 1; + *cxstate = ff_mqc_nmps[*cxstate]; + } else{ + if (lps) + mqc->a = ff_mqc_qe[*cxstate]; + d = 1 - (*cxstate & 1); + *cxstate = ff_mqc_nlps[*cxstate]; + } + // renormd: + do{ + if (!(mqc->c & 0xff)){ + mqc->c -= 0x100; + bytein(mqc); + } + mqc->a += mqc->a; + mqc->c += mqc->c; + } while (!(mqc->a & 0x8000)); + return d; +} + +void ff_mqc_initdec(MqcState *mqc, uint8_t *bp) +{ + ff_mqc_init_contexts(mqc); + mqc->bp = bp; + mqc->c = (*mqc->bp ^ 0xff) << 16; + bytein(mqc); + mqc->c = mqc->c << 7; + mqc->a = 0x8000; +} + +int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate) +{ + mqc->a -= ff_mqc_qe[*cxstate]; + if ((mqc->c >> 16) < mqc->a){ + if (mqc->a & 0x8000) + return *cxstate & 1; + else + return exchange(mqc, cxstate, 0); + } else { + mqc->c -= mqc->a << 16; + return exchange(mqc, cxstate, 1); + } +} diff --git a/libavcodec/mqcenc.c b/libavcodec/mqcenc.c new file mode 100644 index 0000000000..97d352be44 --- /dev/null +++ b/libavcodec/mqcenc.c @@ -0,0 +1,119 @@ +/* + * MQ-coder encoder + * Copyright (c) 2007 Kamil Nowosad + * + * 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 + */ + +/** + * MQ-coder encoder + * @file + * @author Kamil Nowosad + */ + +#include "mqc.h" + +static void byteout(MqcState *mqc) +{ +retry: + if (*mqc->bp == 0xff){ + mqc->bp++; + *mqc->bp = mqc->c >> 20; + mqc->c &= 0xfffff; + mqc->ct = 7; + } else if ((mqc->c & 0x8000000)){ + (*mqc->bp)++; + mqc->c &= 0x7ffffff; + goto retry; + } else{ + mqc->bp++; + *mqc->bp = mqc->c >> 19; + mqc->c &= 0x7ffff; + mqc->ct = 8; + } +} + +static void renorme(MqcState *mqc) +{ + do{ + mqc->a += mqc->a; + mqc->c += mqc->c; + if (!--mqc->ct) + byteout(mqc); + } while (!(mqc->a & 0x8000)); +} + +static void setbits(MqcState *mqc) +{ + int tmp = mqc->c + mqc->a; + mqc->c |= 0xffff; + if (mqc->c >= tmp) + mqc->c -= 0x8000; +} + +void ff_mqc_initenc(MqcState *mqc, uint8_t *bp) +{ + ff_mqc_init_contexts(mqc); + mqc->a = 0x8000; + mqc->c = 0; + mqc->bp = bp-1; + mqc->bpstart = bp; + mqc->ct = 12 + (*mqc->bp == 0xff); +} + +void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d) +{ + int qe; + + qe = ff_mqc_qe[*cxstate]; + mqc->a -= qe; + if ((*cxstate & 1) == d){ + if (!(mqc->a & 0x8000)){ + if (mqc->a < qe) + mqc->a = qe; + else + mqc->c += qe; + *cxstate = ff_mqc_nmps[*cxstate]; + renorme(mqc); + } else + mqc->c += qe; + } else{ + if (mqc->a < qe) + mqc->c += qe; + else + mqc->a = qe; + *cxstate = ff_mqc_nlps[*cxstate]; + renorme(mqc); + } +} + +int ff_mqc_length(MqcState *mqc) +{ + return mqc->bp - mqc->bpstart; +} + +int ff_mqc_flush(MqcState *mqc) +{ + setbits(mqc); + mqc->c = mqc->c << mqc->ct; + byteout(mqc); + mqc->c = mqc->c << mqc->ct; + byteout(mqc); + if (*mqc->bp != 0xff) + mqc->bp++; + return mqc->bp - mqc->bpstart; +} diff --git a/libavcodec/msgsmdec.c b/libavcodec/msgsmdec.c index ff9b275b77..e759451c83 100644 --- a/libavcodec/msgsmdec.c +++ b/libavcodec/msgsmdec.c @@ -2,20 +2,20 @@ * gsm 06.10 decoder, Microsoft variant * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/msgsmdec.h b/libavcodec/msgsmdec.h index 76c87f1bd9..3bfd1fd407 100644 --- a/libavcodec/msgsmdec.h +++ b/libavcodec/msgsmdec.h @@ -2,20 +2,20 @@ * gsm 06.10 decoder, Microsoft variant * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index c740cfa0bd..06098b04a1 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -5,20 +5,20 @@ * * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1892,7 +1892,7 @@ AVCodec ff_msmpeg4v1_decoder = { NULL, ff_h263_decode_end, ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_EXPERIMENTAL, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"), .pix_fmts= ff_pixfmt_list_420, diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h index 8a0a066e48..d8e3727a40 100644 --- a/libavcodec/msmpeg4.h +++ b/libavcodec/msmpeg4.h @@ -2,20 +2,20 @@ * MSMPEG4 backend for ffmpeg encoder and decoder * copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/msmpeg4data.c b/libavcodec/msmpeg4data.c index eeb812297d..f72715dea0 100644 --- a/libavcodec/msmpeg4data.c +++ b/libavcodec/msmpeg4data.c @@ -5,20 +5,20 @@ * * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h index bbb802e441..623d9570a7 100644 --- a/libavcodec/msmpeg4data.h +++ b/libavcodec/msmpeg4data.h @@ -5,20 +5,20 @@ * * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index f426b058bd..496eb40916 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -2,20 +2,20 @@ * Micrsoft RLE Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -53,6 +53,9 @@ static av_cold int msrle_decode_init(AVCodecContext *avctx) s->avctx = avctx; switch (avctx->bits_per_coded_sample) { + case 1: + avctx->pix_fmt = PIX_FMT_MONOWHITE; + break; case 4: case 8: avctx->pix_fmt = PIX_FMT_PAL8; @@ -65,6 +68,7 @@ static av_cold int msrle_decode_init(AVCodecContext *avctx) return -1; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; @@ -89,7 +93,7 @@ static int msrle_decode_frame(AVCodecContext *avctx, return -1; } - if (avctx->bits_per_coded_sample <= 8) { + if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) { const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (pal) { diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c index 46cd50dcbc..97510830d5 100644 --- a/libavcodec/msrledec.c +++ b/libavcodec/msrledec.c @@ -2,20 +2,20 @@ * Microsoft RLE decoder * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/msrledec.h b/libavcodec/msrledec.h index 5bde35a1a2..2230162691 100644 --- a/libavcodec/msrledec.h +++ b/libavcodec/msrledec.h @@ -2,20 +2,20 @@ * Microsoft RLE decoder * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index a89ec6ac65..c1c7d48080 100644 --- a/libavcodec/msvideo1.c +++ b/libavcodec/msvideo1.c @@ -2,20 +2,20 @@ * Microsoft Video-1 Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -70,6 +70,7 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_RGB555; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c new file mode 100644 index 0000000000..0b6d474604 --- /dev/null +++ b/libavcodec/msvideo1enc.c @@ -0,0 +1,298 @@ +/* + * Microsoft Video-1 Encoder + * Copyright (c) 2009 Konstantin Shishkov + * + * 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 msvideo1enc.c + * Microsoft Video-1 encoder + */ + +#include "avcodec.h" +#include "bytestream.h" +#include "libavutil/lfg.h" +#include "elbg.h" +#include "libavutil/imgutils.h" +/** + * Encoder context + */ +typedef struct Msvideo1EncContext { + AVCodecContext *avctx; + AVFrame pic; + AVLFG rnd; + uint8_t *prev; + + int block[16*3]; + int block2[16*3]; + int codebook[8*3]; + int codebook2[8*3]; + int output[16*3]; + int output2[16*3]; + int avg[3]; + int bestpos; + int keyint; +} Msvideo1EncContext; + +enum MSV1Mode{ + MODE_SKIP = 0, + MODE_FILL, + MODE_2COL, + MODE_8COL, +}; + +#define SKIP_PREFIX 0x8400 +#define SKIPS_MAX 0x0FFF +#define MKRGB555(in, off) ((in[off] << 10) | (in[off + 1] << 5) | (in[off + 2])) + +static const int remap[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 }; + +static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data) +{ + Msvideo1EncContext * const c = avctx->priv_data; + AVFrame *pict = data; + AVFrame * const p = &c->pic; + uint16_t *src; + uint8_t *prevptr; + uint8_t *dst = buf; + int keyframe = 1; + int no_skips = 1; + int i, j, k, x, y; + int skips = 0; + + *p = *pict; + if(!c->prev) + c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3)); + prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1); + src = (uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1)); + if(c->keyint >= avctx->keyint_min) + keyframe = 1; + + p->quality = 24; + + for(y = 0; y < avctx->height; y += 4){ + for(x = 0; x < avctx->width; x += 4){ + int bestmode = MODE_SKIP; + int bestscore = INT_MAX; + int flags = 0; + int score; + + for(j = 0; j < 4; j++){ + for(i = 0; i < 4; i++){ + uint16_t val = src[x + i - j*p->linesize[0]/2]; + for(k = 0; k < 3; k++){ + c->block[(i + j*4)*3 + k] = + c->block2[remap[i + j*4]*3 + k] = (val >> (10-k*5)) & 0x1F; + } + } + } + if(!keyframe){ + bestscore = 0; + for(j = 0; j < 4; j++){ + for(i = 0; i < 4*3; i++){ + int t = prevptr[x*3 + i + j*p->linesize[0]] - c->block[i + j*4*3]; + bestscore += t*t; + } + } + bestscore /= p->quality; + } + // try to find optimal value to fill whole 4x4 block + score = 0; + ff_init_elbg(c->block, 3, 16, c->avg, 1, 1, c->output, &c->rnd); + ff_do_elbg (c->block, 3, 16, c->avg, 1, 1, c->output, &c->rnd); + if(c->avg[0] == 1) // red component = 1 will be written as skip code + c->avg[0] = 0; + for(j = 0; j < 4; j++){ + for(i = 0; i < 4; i++){ + for(k = 0; k < 3; k++){ + int t = c->avg[k] - c->block[(i+j*4)*3+k]; + score += t*t; + } + } + } + score /= p->quality; + score += 2; + if(score < bestscore){ + bestscore = score; + bestmode = MODE_FILL; + } + // search for optimal filling of 2-color block + score = 0; + ff_init_elbg(c->block, 3, 16, c->codebook, 2, 1, c->output, &c->rnd); + ff_do_elbg (c->block, 3, 16, c->codebook, 2, 1, c->output, &c->rnd); + // last output value should be always 1, swap codebooks if needed + if(!c->output[15]){ + for(i = 0; i < 3; i++) + FFSWAP(uint8_t, c->codebook[i], c->codebook[i+3]); + for(i = 0; i < 16; i++) + c->output[i] ^= 1; + } + for(j = 0; j < 4; j++){ + for(i = 0; i < 4; i++){ + for(k = 0; k < 3; k++){ + int t = c->codebook[c->output[i+j*4]*3 + k] - c->block[i*3+k+j*4*3]; + score += t*t; + } + } + } + score /= p->quality; + score += 6; + if(score < bestscore){ + bestscore = score; + bestmode = MODE_2COL; + } + // search for optimal filling of 2-color 2x2 subblocks + score = 0; + for(i = 0; i < 4; i++){ + ff_init_elbg(c->block2 + i*4*3, 3, 4, c->codebook2 + i*2*3, 2, 1, c->output2 + i*4, &c->rnd); + ff_do_elbg (c->block2 + i*4*3, 3, 4, c->codebook2 + i*2*3, 2, 1, c->output2 + i*4, &c->rnd); + } + // last value should be always 1, swap codebooks if needed + if(!c->output2[15]){ + for(i = 0; i < 3; i++) + FFSWAP(uint8_t, c->codebook2[i+18], c->codebook2[i+21]); + for(i = 12; i < 16; i++) + c->output2[i] ^= 1; + } + for(j = 0; j < 4; j++){ + for(i = 0; i < 4; i++){ + for(k = 0; k < 3; k++){ + int t = c->codebook2[(c->output2[remap[i+j*4]] + (i&2) + (j&2)*2)*3+k] - c->block[i*3+k + j*4*3]; + score += t*t; + } + } + } + score /= p->quality; + score += 18; + if(score < bestscore){ + bestscore = score; + bestmode = MODE_8COL; + } + + if(bestmode == MODE_SKIP){ + skips++; + no_skips = 0; + } + if((bestmode != MODE_SKIP && skips) || skips == SKIPS_MAX){ + bytestream_put_le16(&dst, skips | SKIP_PREFIX); + skips = 0; + } + + switch(bestmode){ + case MODE_FILL: + bytestream_put_le16(&dst, MKRGB555(c->avg,0) | 0x8000); + for(j = 0; j < 4; j++) + for(i = 0; i < 4; i++) + for(k = 0; k < 3; k++) + prevptr[i*3 + k - j*3*avctx->width] = c->avg[k]; + break; + case MODE_2COL: + for(j = 0; j < 4; j++){ + for(i = 0; i < 4; i++){ + flags |= (c->output[i + j*4]^1) << (i + j*4); + for(k = 0; k < 3; k++) + prevptr[i*3 + k - j*3*avctx->width] = c->codebook[c->output[i + j*4]*3 + k]; + } + } + bytestream_put_le16(&dst, flags); + bytestream_put_le16(&dst, MKRGB555(c->codebook, 0)); + bytestream_put_le16(&dst, MKRGB555(c->codebook, 3)); + break; + case MODE_8COL: + for(j = 0; j < 4; j++){ + for(i = 0; i < 4; i++){ + flags |= (c->output2[remap[i + j*4]]^1) << (i + j*4); + for(k = 0; k < 3; k++) + prevptr[i*3 + k - j*3*avctx->width] = c->codebook2[(c->output2[remap[i+j*4]] + (i&2) + (j&2)*2)*3 + k]; + } + } + bytestream_put_le16(&dst, flags); + bytestream_put_le16(&dst, MKRGB555(c->codebook2, 0) | 0x8000); + for(i = 3; i < 24; i += 3) + bytestream_put_le16(&dst, MKRGB555(c->codebook2, i)); + break; + } + } + src -= p->linesize[0] << 1; + prevptr -= avctx->width * 3 * 4; + } + if(skips) + bytestream_put_le16(&dst, skips | SKIP_PREFIX); + //EOF + bytestream_put_byte(&dst, 0); + bytestream_put_byte(&dst, 0); + + if(no_skips) + keyframe = 1; + if(keyframe) + c->keyint = 0; + else + c->keyint++; + p->pict_type= keyframe ? FF_I_TYPE : FF_P_TYPE; + p->key_frame= keyframe; + + return dst - buf; +} + + +/** + * init encoder + */ +static av_cold int encode_init(AVCodecContext *avctx) +{ + Msvideo1EncContext * const c = avctx->priv_data; + + c->avctx = avctx; + if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) { + return -1; + } + + avcodec_get_frame_defaults(&c->pic); + avctx->coded_frame = (AVFrame*)&c->pic; + + c->keyint = avctx->keyint_min; + av_lfg_init(&c->rnd, 1); + + return 0; +} + + + +/** + * Uninit encoder + */ +static av_cold int encode_end(AVCodecContext *avctx) +{ + Msvideo1EncContext * const c = avctx->priv_data; + + av_freep(&c->prev); + + return 0; +} + +AVCodec ff_msvideo1_encoder = { + "msvideo1", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_MSVIDEO1, + sizeof(Msvideo1EncContext), + encode_init, + encode_frame, + encode_end, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB555, PIX_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Microsoft Video-1"), +}; diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c index e710291501..78067c995f 100644 --- a/libavcodec/mxpegdec.c +++ b/libavcodec/mxpegdec.c @@ -2,20 +2,20 @@ * MxPEG decoder * Copyright (c) 2011 Anatoly Nenashev * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -82,6 +82,7 @@ static int mxpeg_decode_mxm(MXpegDecodeContext *s, } if (s->bitmask_size != bitmask_size) { + s->bitmask_size = 0; av_freep(&s->mxm_bitmask); s->mxm_bitmask = av_malloc(bitmask_size); if (!s->mxm_bitmask) { diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 0f94e75c92..1d35cda9a1 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -4,20 +4,20 @@ * * Copyright (c) 2008 Bartlomiej Wolowiec * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -28,7 +28,7 @@ * * Generic codec information: libavcodec/nellymoserdec.c * - * Some information also from: http://samples.libav.org/A-codecs/Nelly_Moser/ASAO/ASAO.zip + * Some information also from: http://samples.mplayerhq.hu/A-codecs/Nelly_Moser/ASAO/ASAO.zip * (Copyright Joseph Artsimovich and UAB "DKD") * * for more information about nellymoser format, visit: diff --git a/libavcodec/noise_bsf.c b/libavcodec/noise_bsf.c index 489e3c7c7c..491fbccc1d 100644 --- a/libavcodec/noise_bsf.c +++ b/libavcodec/noise_bsf.c @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 0c5e42fe78..6eb6de3101 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -2,20 +2,20 @@ * NuppelVideo decoder * Copyright (c) 2006 Reimar Doeffinger * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> diff --git a/libavcodec/options.c b/libavcodec/options.c index 8f9aec4ac2..78a7bc8a40 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -2,20 +2,20 @@ * Copyright (c) 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -351,10 +351,10 @@ static const AVOption options[]={ {"all" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 4, V|E}, {"brd_scale", "downscales frames for dynamic B-frame decision", OFFSET(brd_scale), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 10, V|E}, -{"crf", "enables constant quality mode, and selects the quality (x264)", OFFSET(crf), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E}, +{"crf", "enables constant quality mode, and selects the quality (x264/VP8)", OFFSET(crf), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 63, V|E}, {"cqp", "constant quantization parameter rate control method", OFFSET(cqp), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, -{"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), FF_OPT_TYPE_INT, {.dbl = 25 }, INT_MIN, INT_MAX, V|E}, -{"refs", "reference frames to consider for motion compensation (Snow)", OFFSET(refs), FF_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E}, +{"keyint_min", "minimum interval between IDR-frames", OFFSET(keyint_min), FF_OPT_TYPE_INT, {.dbl = 25 }, INT_MIN, INT_MAX, V|E}, +{"refs", "reference frames to consider for motion compensation", OFFSET(refs), FF_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E}, {"chromaoffset", "chroma qp offset from luma", OFFSET(chromaoffset), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"bframebias", "influences how often B-frames are used", OFFSET(bframebias), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"trellis", "rate-distortion optimal quantization", OFFSET(trellis), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, @@ -441,7 +441,7 @@ static const AVOption options[]={ {"em", "Emergency", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_EMERGENCY }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, {"vo", "Voice Over", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_VOICE_OVER }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, {"ka", "Karaoke", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_KARAOKE }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"request_sample_fmt", NULL, OFFSET(request_sample_fmt), FF_OPT_TYPE_INT, {.dbl = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D, "request_sample_fmt"}, +{"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), FF_OPT_TYPE_INT, {.dbl = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D, "request_sample_fmt"}, {"u8" , "8-bit unsigned integer", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_U8 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, {"s16", "16-bit signed integer", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S16 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, {"s32", "32-bit signed integer", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S32 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index fbf9fd88aa..b6d58dec49 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -2,20 +2,20 @@ * PAM image format * Copyright (c) 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 03f548ef6a..d4a6126611 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -58,12 +58,10 @@ AVCodecParserContext *av_parser_init(int codec_id) if (!s) return NULL; s->parser = parser; - if (parser->priv_data_size) { - s->priv_data = av_mallocz(parser->priv_data_size); - if (!s->priv_data) { - av_free(s); - return NULL; - } + s->priv_data = av_mallocz(parser->priv_data_size); + if (!s->priv_data) { + av_free(s); + return NULL; } if (parser->parser_init) { ret = parser->parser_init(s); @@ -221,11 +219,12 @@ void av_parser_close(AVCodecParserContext *s) */ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size) { +#if 0 if(pc->overread){ - av_dlog(pc, "overread %d, state:%X next:%d index:%d o_index:%d\n", - pc->overread, pc->state, next, pc->index, pc->overread_index); - av_dlog(pc, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]); + printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); + printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); } +#endif /* Copy overread bytes from last frame into buffer. */ for(; pc->overread>0; pc->overread--){ diff --git a/libavcodec/parser.h b/libavcodec/parser.h index 1e85ae4051..6712bfe8b0 100644 --- a/libavcodec/parser.h +++ b/libavcodec/parser.h @@ -3,20 +3,20 @@ * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c index a55d48cb96..030507502d 100644 --- a/libavcodec/pcm-mpeg.c +++ b/libavcodec/pcm-mpeg.c @@ -2,20 +2,20 @@ * LPCM codecs for PCM formats found in MPEG streams * Copyright (c) 2009 Christian Schmidt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 9100646179..111ce6193f 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -2,20 +2,20 @@ * PCM codecs * Copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pcm_tablegen.c b/libavcodec/pcm_tablegen.c index 8a9bcb6fb1..b0fde936c7 100644 --- a/libavcodec/pcm_tablegen.c +++ b/libavcodec/pcm_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pcm_tablegen.h b/libavcodec/pcm_tablegen.h index 79d6561646..1387210a58 100644 --- a/libavcodec/pcm_tablegen.h +++ b/libavcodec/pcm_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index 35f85f94c3..2c9f8c07d5 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -5,20 +5,20 @@ * This decoder does not support CGA palettes. I am unable to find samples * and Netpbm cannot generate them. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 81629d0add..bf7cebbbe2 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -2,20 +2,20 @@ * PC Paintbrush PCX (.pcx) image encoder * Copyright (c) 2009 Daniel Verkamp <daniel at drv.nu> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 9546c38882..315dbbd779 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -2,20 +2,20 @@ * PGS subtitle decoder * Copyright (c) 2009 Stephen Backway * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -355,7 +355,6 @@ static int display_end_segment(AVCodecContext *avctx, void *data, * not been cleared by a subsequent empty display command. */ - memset(sub, 0, sizeof(*sub)); // Blank if last object_number was 0. // Note that this may be wrong for more complex subtitles. if (!ctx->presentation.object_number) diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index 23f299c214..b87c8643d0 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -2,20 +2,20 @@ * Pictor/PC Paint decoder * Copyright (c) 2010 Peter Ross <pross@xvid.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -94,6 +94,14 @@ static const uint8_t cga_mode45_index[6][4] = { [5] = { 0, 11, 12, 15 }, // mode5, high intensity }; +static av_cold int decode_init(AVCodecContext *avctx) +{ + PicContext *s = avctx->priv_data; + + avcodec_get_frame_defaults(&s->frame); + return 0; +} + static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) @@ -242,7 +250,7 @@ AVCodec ff_pictor_decoder = { AVMEDIA_TYPE_VIDEO, CODEC_ID_PICTOR, sizeof(PicContext), - NULL, + decode_init, NULL, decode_end, decode_frame, diff --git a/libavcodec/png.c b/libavcodec/png.c index 70a080e29e..d7898c0a41 100644 --- a/libavcodec/png.c +++ b/libavcodec/png.c @@ -2,20 +2,20 @@ * PNG image format * Copyright (c) 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" diff --git a/libavcodec/png.h b/libavcodec/png.h index b8c72eebc9..d6fac3e673 100644 --- a/libavcodec/png.h +++ b/libavcodec/png.h @@ -2,20 +2,20 @@ * PNG image format * Copyright (c) 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -23,6 +23,9 @@ #define AVCODEC_PNG_H #include <stdint.h> +#include <zlib.h> + +#include "avcodec.h" #define PNG_COLOR_MASK_PALETTE 1 #define PNG_COLOR_MASK_COLOR 2 @@ -69,4 +72,41 @@ int ff_png_pass_row_size(int pass, int bits_per_pixel, int width); void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp); +typedef struct PNGDecContext { + const uint8_t *bytestream; + const uint8_t *bytestream_start; + const uint8_t *bytestream_end; + AVFrame picture1, picture2; + AVFrame *current_picture, *last_picture; + + int state; + int width, height; + int bit_depth; + int color_type; + int compression_type; + int interlace_type; + int filter_type; + int channels; + int bits_per_pixel; + int bpp; + + uint8_t *image_buf; + int image_linesize; + uint32_t palette[256]; + uint8_t *crow_buf; + uint8_t *last_row; + uint8_t *tmp_row; + int pass; + int crow_size; /* compressed row size (include filter type) */ + int row_size; /* decompressed row size */ + int pass_row_size; /* decompress row size of the current pass */ + int y; + z_stream zstream; + + void (*add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w); + void (*add_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp); +} PNGDecContext; + +void ff_png_init_mmx(PNGDecContext *s); + #endif /* AVCODEC_PNG_H */ diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 7477f6746b..05ba027802 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -2,27 +2,29 @@ * PNG image format * Copyright (c) 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +//#define DEBUG + #include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "png.h" -#include "dsputil.h" /* TODO: * - add 2, 4 and 16 bit depth support @@ -30,42 +32,6 @@ #include <zlib.h> -//#define DEBUG - -typedef struct PNGDecContext { - DSPContext dsp; - - const uint8_t *bytestream; - const uint8_t *bytestream_start; - const uint8_t *bytestream_end; - AVFrame picture1, picture2; - AVFrame *current_picture, *last_picture; - - int state; - int width, height; - int bit_depth; - int color_type; - int compression_type; - int interlace_type; - int filter_type; - int channels; - int bits_per_pixel; - int bpp; - - uint8_t *image_buf; - int image_linesize; - uint32_t palette[256]; - uint8_t *crow_buf; - uint8_t *last_row; - uint8_t *tmp_row; - int pass; - int crow_size; /* compressed row size (include filter type) */ - int row_size; /* decompressed row size */ - int pass_row_size; /* decompress row size of the current pass */ - int y; - z_stream zstream; -} PNGDecContext; - /* Mask to determine which y pixels can be written in a pass */ static const uint8_t png_pass_dsp_ymask[NB_PASSES] = { 0xff, 0xff, 0x0f, 0xcc, 0x33, 0xff, 0x55, @@ -134,7 +100,23 @@ static void png_put_interlaced_row(uint8_t *dst, int width, } } -void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp) +// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size +#define pb_7f (~0UL/255 * 0x7f) +#define pb_80 (~0UL/255 * 0x80) + +static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) +{ + long i; + for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ + long a = *(long*)(src1+i); + long b = *(long*)(src2+i); + *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80); + } + for(; i<w; i++) + dst[i] = src1[i]+src2[i]; +} + +static void add_paeth_prediction_c(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp) { int i; for(i = 0; i < w; i++) { @@ -191,7 +173,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w } /* NOTE: 'dst' can be equal to 'last' */ -static void png_filter_row(DSPContext *dsp, uint8_t *dst, int filter_type, +static void png_filter_row(PNGDecContext *s, uint8_t *dst, int filter_type, uint8_t *src, uint8_t *last, int size, int bpp) { int i, p, r, g, b, a; @@ -217,7 +199,7 @@ static void png_filter_row(DSPContext *dsp, uint8_t *dst, int filter_type, } break; case PNG_FILTER_VALUE_UP: - dsp->add_bytes_l2(dst, src, last, size); + s->add_bytes_l2(dst, src, last, size); break; case PNG_FILTER_VALUE_AVG: for(i = 0; i < bpp; i++) { @@ -235,10 +217,10 @@ static void png_filter_row(DSPContext *dsp, uint8_t *dst, int filter_type, if(bpp > 1 && size > 4) { // would write off the end of the array if we let it process the last pixel with bpp=3 int w = bpp==4 ? size : size-3; - dsp->add_png_paeth_prediction(dst+i, src+i, last+i, w-i, bpp); + s->add_paeth_prediction(dst+i, src+i, last+i, w-i, bpp); i = w; } - ff_add_png_paeth_prediction(dst+i, src+i, last+i, size-i, bpp); + add_paeth_prediction_c(dst+i, src+i, last+i, size-i, bpp); break; } } @@ -291,7 +273,7 @@ static void png_handle_row(PNGDecContext *s) ptr = s->image_buf + s->image_linesize * s->y; /* need to swap bytes correctly for RGB_ALPHA */ if (s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1, + png_filter_row(s, s->tmp_row, s->crow_buf[0], s->crow_buf + 1, s->last_row, s->row_size, s->bpp); convert_to_rgb32(ptr, s->tmp_row, s->width, s->filter_type == PNG_FILTER_TYPE_LOCO); FFSWAP(uint8_t*, s->last_row, s->tmp_row); @@ -302,7 +284,7 @@ static void png_handle_row(PNGDecContext *s) else last_row = ptr - s->image_linesize; - png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1, + png_filter_row(s, ptr, s->crow_buf[0], s->crow_buf + 1, last_row, s->row_size, s->bpp); } /* loco lags by 1 row so that it doesn't interfere with top prediction */ @@ -325,7 +307,7 @@ static void png_handle_row(PNGDecContext *s) wait for the next one */ if (got_line) break; - png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1, + png_filter_row(s, s->tmp_row, s->crow_buf[0], s->crow_buf + 1, s->last_row, s->pass_row_size, s->bpp); FFSWAP(uint8_t*, s->last_row, s->tmp_row); got_line = 1; @@ -485,13 +467,12 @@ static int decode_frame(AVCodecContext *avctx, } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_RGB) { avctx->pix_fmt = PIX_FMT_RGB48BE; - } else if (s->bit_depth == 1 && - s->color_type == PNG_COLOR_TYPE_GRAY) { + } else if (s->bit_depth == 1) { avctx->pix_fmt = PIX_FMT_MONOBLACK; } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) { avctx->pix_fmt = PIX_FMT_PAL8; } else if (s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - avctx->pix_fmt = PIX_FMT_Y400A; + avctx->pix_fmt = PIX_FMT_GRAY8A; } else { goto fail; } @@ -522,7 +503,7 @@ static int decode_frame(AVCodecContext *avctx, s->image_buf = p->data[0]; s->image_linesize = p->linesize[0]; /* copy the palette if needed */ - if (s->color_type == PNG_COLOR_TYPE_PALETTE) + if (avctx->pix_fmt == PIX_FMT_PAL8) memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t)); /* empty row is used if differencing to the first row */ s->last_row = av_mallocz(s->row_size); @@ -632,14 +613,23 @@ static int decode_frame(AVCodecContext *avctx, goto the_end; } -static av_cold int png_dec_init(AVCodecContext *avctx){ +static av_cold int png_dec_init(AVCodecContext *avctx) +{ PNGDecContext *s = avctx->priv_data; s->current_picture = &s->picture1; s->last_picture = &s->picture2; avcodec_get_frame_defaults(&s->picture1); avcodec_get_frame_defaults(&s->picture2); - dsputil_init(&s->dsp, avctx); + +#if HAVE_MMX + ff_png_init_mmx(s); +#endif + + if (!s->add_paeth_prediction) + s->add_paeth_prediction = add_paeth_prediction_c; + if (!s->add_bytes_l2) + s->add_bytes_l2 = add_bytes_l2_c; return 0; } @@ -667,6 +657,5 @@ AVCodec ff_png_decoder = { decode_frame, CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, NULL, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PNG image"), }; diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index c2ac4901d7..c4ef2fd945 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -2,20 +2,20 @@ * PNG image format * Copyright (c) 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index 54b55cfa53..dfc18d6013 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -2,20 +2,20 @@ * PNM image format * Copyright (c) 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -135,7 +135,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) return -1; pnm_get(s, buf1, sizeof(buf1)); avctx->height = atoi(buf1); - if(av_image_check_size(avctx->width, avctx->height, 0, avctx)) + if(avctx->height <= 0 || av_image_check_size(avctx->width, avctx->height, 0, avctx)) return -1; if (avctx->pix_fmt != PIX_FMT_MONOWHITE) { pnm_get(s, buf1, sizeof(buf1)); diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h index 702921fbdf..ac4b1084fb 100644 --- a/libavcodec/pnm.h +++ b/libavcodec/pnm.h @@ -2,20 +2,20 @@ * PNM image format * Copyright (c) 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c index 2dc29871c0..17e8082609 100644 --- a/libavcodec/pnm_parser.c +++ b/libavcodec/pnm_parser.c @@ -2,20 +2,20 @@ * PNM image parser * Copyright (c) 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index b9f20c0569..ebecad4006 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -2,20 +2,20 @@ * PNM image format * Copyright (c) 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -33,7 +33,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, PNMContext * const s = avctx->priv_data; AVFrame *picture = data; AVFrame * const p = (AVFrame*)&s->picture; - int i, j, n, linesize, h, upgrade = 0; + int i, j, n, linesize, h, upgrade = 0, is_mono = 0; unsigned char *ptr; int components, sample_len; @@ -88,6 +88,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, n = (avctx->width + 7) >> 3; components=1; sample_len=1; + is_mono = 1; do_read: ptr = p->data[0]; linesize = p->linesize[0]; @@ -104,10 +105,16 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, s->bytestream++; if(s->bytestream >= s->bytestream_end) return -1; - do{ - v= 10*v + c; - c= (*s->bytestream++) - '0'; - }while(c <= 9); + if (is_mono) { + /* read a single digit */ + v = (*s->bytestream++) - '0'; + } else { + /* read a sequence of digits */ + do { + v = 10*v + c; + c = (*s->bytestream++) - '0'; + } while (c <= 9); + } put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval); } flush_put_bits(&pb); @@ -199,7 +206,6 @@ AVCodec ff_pgm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), }; #endif @@ -216,7 +222,6 @@ AVCodec ff_pgmyuv_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), }; #endif @@ -233,7 +238,6 @@ AVCodec ff_ppm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), }; #endif @@ -250,7 +254,6 @@ AVCodec ff_pbm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), }; #endif @@ -267,7 +270,6 @@ AVCodec ff_pam_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), }; #endif diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index 57cb90c868..42c32dc94a 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -2,20 +2,20 @@ * PNM image format * Copyright (c) 2002, 2003 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/asm.S b/libavcodec/ppc/asm.S index 5cbbf97b64..e372d53c60 100644 --- a/libavcodec/ppc/asm.S +++ b/libavcodec/ppc/asm.S @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/dsputil_altivec.c index adce61b277..bd432beb87 100644 --- a/libavcodec/ppc/dsputil_altivec.c +++ b/libavcodec/ppc/dsputil_altivec.c @@ -3,20 +3,20 @@ * Copyright (c) 2002 Dieter Shirley * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/dsputil_altivec.h b/libavcodec/ppc/dsputil_altivec.h index abf2dd3e0a..4147eec823 100644 --- a/libavcodec/ppc/dsputil_altivec.h +++ b/libavcodec/ppc/dsputil_altivec.h @@ -3,20 +3,20 @@ * Copyright (c) 2002 Dieter Shirley * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index 5f131f3196..327fe2c72f 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -3,20 +3,20 @@ * Copyright (c) 2002 Dieter Shirley * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/fdct_altivec.c b/libavcodec/ppc/fdct_altivec.c index 8dbfe33f77..6309a47f32 100644 --- a/libavcodec/ppc/fdct_altivec.c +++ b/libavcodec/ppc/fdct_altivec.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2003 James Klicman <james@klicman.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/fft_altivec.c b/libavcodec/ppc/fft_altivec.c index 435024a0cb..1ea2369f55 100644 --- a/libavcodec/ppc/fft_altivec.c +++ b/libavcodec/ppc/fft_altivec.c @@ -3,20 +3,20 @@ * AltiVec-enabled * Copyright (c) 2009 Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/fft.h" diff --git a/libavcodec/ppc/fft_altivec_s.S b/libavcodec/ppc/fft_altivec_s.S index ab33900582..5d3c5406c3 100644 --- a/libavcodec/ppc/fft_altivec_s.S +++ b/libavcodec/ppc/fft_altivec_s.S @@ -5,20 +5,20 @@ * This algorithm (though not any of the implementation details) is * based on libdjbfft by D. J. Bernstein. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/float_altivec.c b/libavcodec/ppc/float_altivec.c index e4010694a2..ba97cbfd3b 100644 --- a/libavcodec/ppc/float_altivec.c +++ b/libavcodec/ppc/float_altivec.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2006 Luca Barbato <lu_zero@gentoo.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/fmtconvert_altivec.c b/libavcodec/ppc/fmtconvert_altivec.c index b1eaf9b482..30de0e637f 100644 --- a/libavcodec/ppc/fmtconvert_altivec.c +++ b/libavcodec/ppc/fmtconvert_altivec.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2006 Luca Barbato <lu_zero@gentoo.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/gmc_altivec.c b/libavcodec/ppc/gmc_altivec.c index 0ed70ab83b..0e93c337f7 100644 --- a/libavcodec/ppc/gmc_altivec.c +++ b/libavcodec/ppc/gmc_altivec.c @@ -3,20 +3,20 @@ * AltiVec-enabled * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/h264_altivec.c b/libavcodec/ppc/h264_altivec.c index fae0674720..9df18888ad 100644 --- a/libavcodec/ppc/h264_altivec.c +++ b/libavcodec/ppc/h264_altivec.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2004 Romain Dolbeau <romain@dolbeau.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/h264_template_altivec.c b/libavcodec/ppc/h264_template_altivec.c index 2a8f4bf672..2573e9c6f7 100644 --- a/libavcodec/ppc/h264_template_altivec.c +++ b/libavcodec/ppc/h264_template_altivec.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2004 Romain Dolbeau <romain@dolbeau.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/idct_altivec.c b/libavcodec/ppc/idct_altivec.c index cc3adcb526..d65ba24f3a 100644 --- a/libavcodec/ppc/idct_altivec.c +++ b/libavcodec/ppc/idct_altivec.c @@ -1,31 +1,31 @@ /* * Copyright (c) 2001 Michel Lespinasse * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* * NOTE: This code is based on GPL code from the libmpeg2 project. The * author, Michel Lespinasses, has given explicit permission to release - * under LGPL as part of Libav. + * under LGPL as part of FFmpeg. */ /* - * Libav integration by Dieter Shirley + * FFmpeg integration by Dieter Shirley * * This file is a direct copy of the AltiVec IDCT module from the libmpeg2 * project. I've deleted all of the libmpeg2-specific code, renamed the diff --git a/libavcodec/ppc/int_altivec.c b/libavcodec/ppc/int_altivec.c index 25cbb8f771..61c18c8154 100644 --- a/libavcodec/ppc/int_altivec.c +++ b/libavcodec/ppc/int_altivec.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2007 Luca Barbato <lu_zero@gentoo.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/mathops.h b/libavcodec/ppc/mathops.h index 34ddb11800..dbd714fcd4 100644 --- a/libavcodec/ppc/mathops.h +++ b/libavcodec/ppc/mathops.h @@ -3,20 +3,20 @@ * Copyright (c) 2001, 2002 Fabrice Bellard * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/mpegaudiodec_altivec.c b/libavcodec/ppc/mpegaudiodec_altivec.c index 5df0fdafe4..2de5dd133a 100644 --- a/libavcodec/ppc/mpegaudiodec_altivec.c +++ b/libavcodec/ppc/mpegaudiodec_altivec.c @@ -2,20 +2,20 @@ * Altivec optimized MP3 decoding functions * Copyright (c) 2010 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c index e02c094253..64898a10d0 100644 --- a/libavcodec/ppc/mpegvideo_altivec.c +++ b/libavcodec/ppc/mpegvideo_altivec.c @@ -4,20 +4,20 @@ * dct_unquantize_h263_altivec: * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/regs.h b/libavcodec/ppc/regs.h index 2edd639531..63861f28fb 100644 --- a/libavcodec/ppc/regs.h +++ b/libavcodec/ppc/regs.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/types_altivec.h b/libavcodec/ppc/types_altivec.h index defa20e243..36b6e1f388 100644 --- a/libavcodec/ppc/types_altivec.h +++ b/libavcodec/ppc/types_altivec.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2006 Guillaume Poirier <gpoirier@mplayerhq.hu> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/util_altivec.h b/libavcodec/ppc/util_altivec.h index e68e5b593d..cb638dff08 100644 --- a/libavcodec/ppc/util_altivec.h +++ b/libavcodec/ppc/util_altivec.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/vc1dsp_altivec.c b/libavcodec/ppc/vc1dsp_altivec.c index 307e0e9f6b..69670619da 100644 --- a/libavcodec/ppc/vc1dsp_altivec.c +++ b/libavcodec/ppc/vc1dsp_altivec.c @@ -2,20 +2,20 @@ * VC-1 and WMV3 decoder - DSP functions AltiVec-optimized * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/vp3dsp_altivec.c b/libavcodec/ppc/vp3dsp_altivec.c index bbe9170edf..b0509d8b64 100644 --- a/libavcodec/ppc/vp3dsp_altivec.c +++ b/libavcodec/ppc/vp3dsp_altivec.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2009 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ppc/vp8dsp_altivec.c b/libavcodec/ppc/vp8dsp_altivec.c index 06874b8b87..8bb60aae0b 100644 --- a/libavcodec/ppc/vp8dsp_altivec.c +++ b/libavcodec/ppc/vp8dsp_altivec.c @@ -3,20 +3,20 @@ * * Copyright (C) 2010 David Conrad * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c index f4503a9030..349583f1ba 100644 --- a/libavcodec/ps2/dsputil_mmi.c +++ b/libavcodec/ps2/dsputil_mmi.c @@ -5,20 +5,20 @@ * MMI optimization by Leon van Stuivenberg * clear_blocks_mmi() by BroadQ * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ps2/idct_mmi.c b/libavcodec/ps2/idct_mmi.c index 86df092075..bfe362a91d 100644 --- a/libavcodec/ps2/idct_mmi.c +++ b/libavcodec/ps2/idct_mmi.c @@ -8,20 +8,20 @@ * * MMI port and (c) 2002 by Leon van Stuivenberg * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ps2/mmi.h b/libavcodec/ps2/mmi.h index fc8d32819a..0265456108 100644 --- a/libavcodec/ps2/mmi.h +++ b/libavcodec/ps2/mmi.h @@ -1,20 +1,20 @@ /* * copyright (c) 2002 Leon van Stuivenberg * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ps2/mpegvideo_mmi.c b/libavcodec/ps2/mpegvideo_mmi.c index ed56893877..68c3b0d0e7 100644 --- a/libavcodec/ps2/mpegvideo_mmi.c +++ b/libavcodec/ps2/mpegvideo_mmi.c @@ -3,20 +3,20 @@ * * MMI optimization by Leon van Stuivenberg * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index fe9363c7a9..133a85f5c1 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -2,20 +2,20 @@ * audio encoder psychoacoustic model * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/psymodel.h b/libavcodec/psymodel.h index 02dc9c92b1..c65614a151 100644 --- a/libavcodec/psymodel.h +++ b/libavcodec/psymodel.h @@ -2,20 +2,20 @@ * audio encoder psychoacoustic model * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 08ef4ba0c2..e662fb9caf 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -6,20 +6,20 @@ * to Michael Niedermayer <michaelni@gmx.at> for writing initial * implementation. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index c993f6c0f0..3273fd2f8e 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -2,20 +2,20 @@ * V.Flash PTX (.ptx) image decoder * Copyright (c) 2007 Ivo van Poorten * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 3849e6d339..79016912d5 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -1,20 +1,20 @@ /* * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/qcelpdata.h b/libavcodec/qcelpdata.h index df33e9158c..d79cea9f6c 100644 --- a/libavcodec/qcelpdata.h +++ b/libavcodec/qcelpdata.h @@ -2,20 +2,20 @@ * QCELP decoder * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -26,7 +26,7 @@ * @file * Data tables for the QCELP decoder * @author Reynaldo H. Verdejo Pinochet - * @remark Libav merging spearheaded by Kenan Gillet + * @remark FFmpeg merging spearheaded by Kenan Gillet * @remark Development mentored by Benjamin Larson */ diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c index 3095a2464d..3ed821c81e 100644 --- a/libavcodec/qcelpdec.c +++ b/libavcodec/qcelpdec.c @@ -2,20 +2,20 @@ * QCELP decoder * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -23,7 +23,7 @@ * @file * QCELP decoder * @author Reynaldo H. Verdejo Pinochet - * @remark Libav merging spearheaded by Kenan Gillet + * @remark FFmpeg merging spearheaded by Kenan Gillet * @remark Development mentored by Benjamin Larson */ diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 53ee304a28..b9252bab40 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -5,20 +5,20 @@ * Copyright (c) 2005 Alex Beregszaszi * Copyright (c) 2005 Roberto Togni * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/qdm2_tablegen.c b/libavcodec/qdm2_tablegen.c index 59d82df851..a7a9fb6643 100644 --- a/libavcodec/qdm2_tablegen.c +++ b/libavcodec/qdm2_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index b2bb294f58..f215b15ffc 100644 --- a/libavcodec/qdm2_tablegen.h +++ b/libavcodec/qdm2_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/qdm2data.h b/libavcodec/qdm2data.h index ad6ea88ff6..355d61387b 100644 --- a/libavcodec/qdm2data.h +++ b/libavcodec/qdm2data.h @@ -5,20 +5,20 @@ * Copyright (c) 2005 Alex Beregszaszi * Copyright (c) 2005 Roberto Togni * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index 07ac9aa69d..cd3146388e 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -2,20 +2,20 @@ * QuickDraw (qdrw) codec * Copyright (c) 2004 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -133,8 +133,9 @@ static int decode_frame(AVCodecContext *avctx, } static av_cold int decode_init(AVCodecContext *avctx){ -// QdrawContext * const a = avctx->priv_data; + QdrawContext * const a = avctx->priv_data; + avcodec_get_frame_defaults(&a->pic); avctx->pix_fmt= PIX_FMT_PAL8; return 0; diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 5dd2a2d5ca..68232e28e3 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -2,20 +2,20 @@ * QPEG codec * Copyright (c) 2004 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -28,8 +28,7 @@ typedef struct QpegContext{ AVCodecContext *avctx; - AVFrame pic; - uint8_t *refdata; + AVFrame pic, ref; uint32_t pal[256]; } QpegContext; @@ -124,9 +123,12 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, int filled = 0; int orig_height; + if(!refdata) + refdata= dst; + /* copy prev frame */ for(i = 0; i < height; i++) - memcpy(refdata + (i * width), dst + (i * stride), width); + memcpy(dst + (i * stride), refdata + (i * stride), width); orig_height = height; height--; @@ -172,10 +174,10 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, me_x, me_y, me_w, me_h, filled, height); else { /* do motion compensation */ - me_plane = refdata + (filled + me_x) + (height - me_y) * width; + me_plane = refdata + (filled + me_x) + (height - me_y) * stride; for(j = 0; j < me_h; j++) { for(i = 0; i < me_w; i++) - dst[filled + i - (j * stride)] = me_plane[i - (j * width)]; + dst[filled + i - (j * stride)] = me_plane[i - (j * stride)]; } } } @@ -254,14 +256,19 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; QpegContext * const a = avctx->priv_data; - AVFrame * const p= (AVFrame*)&a->pic; + AVFrame * p= (AVFrame*)&a->pic; + AVFrame * ref= (AVFrame*)&a->ref; uint8_t* outdata; int delta; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); - p->reference = 3; - if (avctx->reget_buffer(avctx, p) < 0) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); + if(ref->data[0]) + avctx->release_buffer(avctx, ref); + FFSWAP(AVFrame, *ref, *p); + + p->reference= 3; + if(avctx->get_buffer(avctx, p) < 0){ + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } outdata = a->pic.data[0]; @@ -269,7 +276,7 @@ static int decode_frame(AVCodecContext *avctx, qpeg_decode_intra(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height); } else { delta = buf[0x85]; - qpeg_decode_inter(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height, delta, buf + 4, a->refdata); + qpeg_decode_inter(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height, delta, buf + 4, a->ref.data[0]); } /* make the palette available on the way out */ @@ -288,9 +295,10 @@ static int decode_frame(AVCodecContext *avctx, static av_cold int decode_init(AVCodecContext *avctx){ QpegContext * const a = avctx->priv_data; + avcodec_get_frame_defaults(&a->pic); + avcodec_get_frame_defaults(&a->ref); a->avctx = avctx; avctx->pix_fmt= PIX_FMT_PAL8; - a->refdata = av_malloc(avctx->width * avctx->height); return 0; } @@ -298,11 +306,13 @@ static av_cold int decode_init(AVCodecContext *avctx){ static av_cold int decode_end(AVCodecContext *avctx){ QpegContext * const a = avctx->priv_data; AVFrame * const p= (AVFrame*)&a->pic; + AVFrame * const ref= (AVFrame*)&a->ref; if(p->data[0]) avctx->release_buffer(avctx, p); + if(ref->data[0]) + avctx->release_buffer(avctx, ref); - av_free(a->refdata); return 0; } diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index e14c306c6b..2cc2de2e23 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -2,20 +2,20 @@ * Quicktime Animation (RLE) Video Decoder * Copyright (C) 2004 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -417,6 +417,7 @@ static av_cold int qtrle_decode_init(AVCodecContext *avctx) break; } + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 3cad37fd81..6258b143ad 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -5,20 +5,20 @@ * * This file is based on flashsvenc.c. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -39,6 +39,7 @@ typedef struct QtrleEncContext { int pixel_size; AVPicture previous_frame; unsigned int max_buf_size; + int logical_width; /** * This array will contain at ith position the value of the best RLE code * if the line started at pixel i @@ -67,8 +68,13 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx) return -1; } s->avctx=avctx; + s->logical_width=avctx->width; switch (avctx->pix_fmt) { + case PIX_FMT_GRAY8: + s->logical_width = avctx->width / 4; + s->pixel_size = 4; + break; case PIX_FMT_RGB555BE: s->pixel_size = 2; break; @@ -82,11 +88,11 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Unsupported colorspace.\n"); break; } - avctx->bits_per_coded_sample = s->pixel_size*8; + avctx->bits_per_coded_sample = avctx->pix_fmt == PIX_FMT_GRAY8 ? 40 : s->pixel_size*8; - s->rlecode_table = av_mallocz(s->avctx->width); - s->skip_table = av_mallocz(s->avctx->width); - s->length_table = av_mallocz((s->avctx->width + 1)*sizeof(int)); + s->rlecode_table = av_mallocz(s->logical_width); + s->skip_table = av_mallocz(s->logical_width); + s->length_table = av_mallocz((s->logical_width + 1)*sizeof(int)); if (!s->skip_table || !s->length_table || !s->rlecode_table) { av_log(avctx, AV_LOG_ERROR, "Error allocating memory.\n"); return -1; @@ -96,10 +102,10 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx) return -1; } - s->max_buf_size = s->avctx->width*s->avctx->height*s->pixel_size /* image base material */ - + 15 /* header + footer */ - + s->avctx->height*2 /* skip code+rle end */ - + s->avctx->width/MAX_RLE_BULK + 1 /* rle codes */; + s->max_buf_size = s->logical_width*s->avctx->height*s->pixel_size /* image base material */ + + 15 /* header + footer */ + + s->avctx->height*2 /* skip code+rle end */ + + s->logical_width/MAX_RLE_BULK + 1 /* rle codes */; avctx->coded_frame = &s->frame; return 0; } @@ -109,7 +115,7 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx) */ static void qtrle_encode_line(QtrleEncContext *s, AVFrame *p, int line, uint8_t **buf) { - int width=s->avctx->width; + int width=s->logical_width; int i; signed char rlecode; @@ -224,12 +230,28 @@ static void qtrle_encode_line(QtrleEncContext *s, AVFrame *p, int line, uint8_t } else if (rlecode > 0) { /* bulk copy */ - bytestream_put_buffer(buf, this_line + i*s->pixel_size, rlecode*s->pixel_size); + if (s->avctx->pix_fmt == PIX_FMT_GRAY8) { + int j; + // QT grayscale colorspace has 0=white and 255=black, we will + // ignore the palette that is included in the AVFrame because + // PIX_FMT_GRAY8 has defined color mapping + for (j = 0; j < rlecode*s->pixel_size; ++j) + bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff); + } else { + bytestream_put_buffer(buf, this_line + i*s->pixel_size, rlecode*s->pixel_size); + } i += rlecode; } else { /* repeat the bits */ - bytestream_put_buffer(buf, this_line + i*s->pixel_size, s->pixel_size); + if (s->avctx->pix_fmt == PIX_FMT_GRAY8) { + int j; + // QT grayscale colorspace has 0=white and 255=black, ... + for (j = 0; j < s->pixel_size; ++j) + bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff); + } else { + bytestream_put_buffer(buf, this_line + i*s->pixel_size, s->pixel_size); + } i -= rlecode; } } @@ -245,7 +267,7 @@ static int encode_frame(QtrleEncContext *s, AVFrame *p, uint8_t *buf) uint8_t *orig_buf = buf; if (!s->frame.key_frame) { - unsigned line_size = s->avctx->width * s->pixel_size; + unsigned line_size = s->logical_width * s->pixel_size; for (start_line = 0; start_line < s->avctx->height; start_line++) if (memcmp(p->data[0] + start_line*p->linesize[0], s->previous_frame.data[0] + start_line*s->previous_frame.linesize[0], @@ -329,6 +351,6 @@ AVCodec ff_qtrle_encoder = { qtrle_encode_init, qtrle_encode_frame, qtrle_encode_end, - .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB555BE, PIX_FMT_ARGB, PIX_FMT_NONE}, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB555BE, PIX_FMT_ARGB, PIX_FMT_GRAY8, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"), }; diff --git a/libavcodec/r210dec.c b/libavcodec/r210dec.c index 9d5f7eee9b..293fe654ad 100644 --- a/libavcodec/r210dec.c +++ b/libavcodec/r210dec.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Doeffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c index fd2ed3299d..9baa06850f 100644 --- a/libavcodec/ra144.c +++ b/libavcodec/ra144.c @@ -2,20 +2,20 @@ * Real Audio 1.0 (14.4K) * Copyright (c) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ra144.h b/libavcodec/ra144.h index dcdfbb8ccc..722b42e68a 100644 --- a/libavcodec/ra144.h +++ b/libavcodec/ra144.h @@ -2,20 +2,20 @@ * Real Audio 1.0 (14.4K) * Copyright (c) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ra144dec.c b/libavcodec/ra144dec.c index e64b6c20b4..53f529d6b4 100644 --- a/libavcodec/ra144dec.c +++ b/libavcodec/ra144dec.c @@ -5,20 +5,20 @@ * Copyright (c) 2003 Nick Kurshev * Based on public domain decoder at http://www.honeypot.net/audio * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 6eab6c300f..351ba9e871 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -2,20 +2,20 @@ * Real Audio 1.0 (14.4K) encoder * Copyright (c) 2010 Francesco Lavra <francescolavra@interfree.it> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index 64d765cecd..9445e7088e 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -2,20 +2,20 @@ * RealAudio 2.0 (28.8K) * Copyright (c) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ra288.h b/libavcodec/ra288.h index 8857f40ac8..d7fd4b54f9 100644 --- a/libavcodec/ra288.h +++ b/libavcodec/ra288.h @@ -2,20 +2,20 @@ * RealAudio 2.0 (28.8K) * Copyright (c) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c index 1cd6762cb5..04c2738523 100644 --- a/libavcodec/rangecoder.c +++ b/libavcodec/rangecoder.c @@ -2,20 +2,20 @@ * Range coder * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h index 7ad1bd2e55..47c0362ba3 100644 --- a/libavcodec/rangecoder.h +++ b/libavcodec/rangecoder.h @@ -2,20 +2,20 @@ * Range coder * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 0d7b995476..6874fc7034 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -3,20 +3,20 @@ * * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h index 6cd4a18010..32efe01d24 100644 --- a/libavcodec/ratecontrol.h +++ b/libavcodec/ratecontrol.h @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 7d92aba4a7..0bc04df071 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -2,20 +2,20 @@ * Raw Video Codec * Copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -61,6 +61,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_UYVY422, MKTAG('A', 'V', '1', 'x') }, /* Avid 1:1x */ { PIX_FMT_UYVY422, MKTAG('A', 'V', 'u', 'p') }, { PIX_FMT_UYVY422, MKTAG('V', 'D', 'T', 'Z') }, /* SoftLab-NSK VideoTizer */ + { PIX_FMT_UYVY422, MKTAG('a', 'u', 'v', '2') }, { PIX_FMT_UYYVYY411, MKTAG('Y', '4', '1', '1') }, { PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') }, { PIX_FMT_NV12, MKTAG('N', 'V', '1', '2') }, @@ -113,7 +114,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_YUV444P16LE, MKTAG('Y', '3', 0 , 16 ) }, { PIX_FMT_YUV444P16BE, MKTAG(16 , 0 , '3', 'Y') }, { PIX_FMT_YUVA420P, MKTAG('Y', '4', 11 , 8 ) }, - { PIX_FMT_Y400A, MKTAG('Y', '2', 0 , 8 ) }, + { PIX_FMT_GRAY8A, MKTAG('Y', '2', 0 , 8 ) }, /* quicktime */ { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') }, @@ -121,7 +122,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */ { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', '2') }, { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', 's') }, - { PIX_FMT_PAL8, MKTAG('W', 'R', 'A', 'W') }, + { PIX_FMT_YUYV422, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */ { PIX_FMT_RGB555LE,MKTAG('L', '5', '5', '5') }, { PIX_FMT_RGB565LE,MKTAG('L', '5', '6', '5') }, { PIX_FMT_RGB565BE,MKTAG('B', '5', '6', '5') }, diff --git a/libavcodec/raw.h b/libavcodec/raw.h index 2caa3faff5..4724cd3547 100644 --- a/libavcodec/raw.h +++ b/libavcodec/raw.h @@ -2,20 +2,20 @@ * Raw Video Codec * Copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -35,5 +35,6 @@ typedef struct PixelFormatTag { } PixelFormatTag; extern const PixelFormatTag ff_raw_pix_fmt_tags[]; +enum PixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc); #endif /* AVCODEC_RAW_H */ diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 6b3387f636..503351e68a 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -2,20 +2,20 @@ * Raw Video Decoder * Copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,23 +29,34 @@ #include "raw.h" #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" +#include "libavutil/opt.h" typedef struct RawVideoContext { + AVClass *av_class; uint32_t palette[AVPALETTE_COUNT]; unsigned char * buffer; /* block of memory for holding one frame */ int length; /* number of bytes in buffer */ int flip; AVFrame pic; ///< AVCodecContext.coded_frame + int tff; } RawVideoContext; +static const AVOption options[]={ +{"top", "top field first", offsetof(RawVideoContext, tff), FF_OPT_TYPE_INT, {.dbl = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM}, +{NULL} +}; +static const AVClass class = { "rawdec", NULL, options, LIBAVUTIL_VERSION_INT }; + static const PixelFormatTag pix_fmt_bps_avi[] = { + { PIX_FMT_MONOWHITE, 1 }, + { PIX_FMT_PAL8, 2 }, { PIX_FMT_PAL8, 4 }, { PIX_FMT_PAL8, 8 }, { PIX_FMT_RGB444, 12 }, { PIX_FMT_RGB555, 15 }, { PIX_FMT_RGB555, 16 }, { PIX_FMT_BGR24, 24 }, - { PIX_FMT_RGB32, 32 }, + { PIX_FMT_BGRA, 32 }, { PIX_FMT_NONE, 0 }, }; @@ -59,10 +70,11 @@ static const PixelFormatTag pix_fmt_bps_mov[] = { { PIX_FMT_RGB555BE, 16 }, { PIX_FMT_RGB24, 24 }, { PIX_FMT_ARGB, 32 }, + { PIX_FMT_MONOWHITE,33 }, { PIX_FMT_NONE, 0 }, }; -static enum PixelFormat find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc) +enum PixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc) { while (tags->pix_fmt >= 0) { if (tags->fourcc == fourcc) @@ -77,11 +89,18 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) RawVideoContext *context = avctx->priv_data; if (avctx->codec_tag == MKTAG('r','a','w',' ')) - avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample); + avctx->pix_fmt = ff_find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample); + else if (avctx->codec_tag == MKTAG('W','R','A','W')) + avctx->pix_fmt = ff_find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample); else if (avctx->codec_tag) - avctx->pix_fmt = find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag); + avctx->pix_fmt = ff_find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag); else if (avctx->pix_fmt == PIX_FMT_NONE && avctx->bits_per_coded_sample) - avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample); + avctx->pix_fmt = ff_find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample); + + if (avctx->pix_fmt == PIX_FMT_NONE) { + av_log(avctx, AV_LOG_ERROR, "Pixel format was not specified and cannot be detected\n"); + return AVERROR(EINVAL); + } ff_set_systematic_pal2(context->palette, avctx->pix_fmt); context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); @@ -98,7 +117,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) avctx->coded_frame= &context->pic; if((avctx->extradata_size >= 9 && !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9)) || - avctx->codec_tag == MKTAG( 3 , 0 , 0 , 0 )) + avctx->codec_tag == MKTAG(3, 0, 0, 0) || avctx->codec_tag == MKTAG('W','R','A','W')) context->flip=1; return 0; @@ -120,10 +139,17 @@ static int raw_decode(AVCodecContext *avctx, AVFrame * frame = (AVFrame *) data; AVPicture * picture = (AVPicture *) data; + frame->pict_type = avctx->coded_frame->pict_type; frame->interlaced_frame = avctx->coded_frame->interlaced_frame; frame->top_field_first = avctx->coded_frame->top_field_first; frame->reordered_opaque = avctx->reordered_opaque; frame->pkt_pts = avctx->pkt->pts; + frame->pkt_pos = avctx->pkt->pos; + + if(context->tff>=0){ + frame->interlaced_frame = 1; + frame->top_field_first = context->tff; + } //2bpp and 4bpp raw in avi and mov (yes this is ugly ...) if (context->buffer) { @@ -209,4 +235,5 @@ AVCodec ff_rawvideo_decoder = { raw_close_decoder, raw_decode, .long_name = NULL_IF_CONFIG_SMALL("raw video"), + .priv_class= &class, }; diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c index 926124c54b..772ce94067 100644 --- a/libavcodec/rawenc.c +++ b/libavcodec/rawenc.c @@ -2,20 +2,20 @@ * Raw Video Encoder * Copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rdft.c b/libavcodec/rdft.c index 116cfa4366..ebddd8b56b 100644 --- a/libavcodec/rdft.c +++ b/libavcodec/rdft.c @@ -2,20 +2,20 @@ * (I)RDFT transforms * Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdlib.h> diff --git a/libavcodec/rdft.h b/libavcodec/rdft.h index 8ff620fb59..5fb03232a1 100644 --- a/libavcodec/rdft.h +++ b/libavcodec/rdft.h @@ -2,20 +2,20 @@ * (I)RDFT transforms * Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rectangle.h b/libavcodec/rectangle.h index 5cc81feeaa..cf4a9ccec3 100644 --- a/libavcodec/rectangle.h +++ b/libavcodec/rectangle.h @@ -2,20 +2,20 @@ * rectangle filling function * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/remove_extradata_bsf.c b/libavcodec/remove_extradata_bsf.c index 460482a8ff..f0d9b4513a 100644 --- a/libavcodec/remove_extradata_bsf.c +++ b/libavcodec/remove_extradata_bsf.c @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/resample.c b/libavcodec/resample.c index 0bebe1ab88..82c09fc502 100644 --- a/libavcodec/resample.c +++ b/libavcodec/resample.c @@ -2,20 +2,20 @@ * samplerate conversion for both audio and video * Copyright (c) 2000 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -108,6 +108,39 @@ static void mono_to_stereo(short *output, short *input, int n1) } } +/* +5.1 to stereo input: [fl, fr, c, lfe, rl, rr] +- Left = front_left + rear_gain * rear_left + center_gain * center +- Right = front_right + rear_gain * rear_right + center_gain * center +Where rear_gain is usually around 0.5-1.0 and + center_gain is almost always 0.7 (-3 dB) +*/ +static void surround_to_stereo(short **output, short *input, int channels, int samples) +{ + int i; + short l, r; + + for (i = 0; i < samples; i++) { + int fl,fr,c,rl,rr,lfe; + fl = input[0]; + fr = input[1]; + c = input[2]; + lfe = input[3]; + rl = input[4]; + rr = input[5]; + + l = av_clip_int16(fl + (0.5 * rl) + (0.7 * c)); + r = av_clip_int16(fr + (0.5 * rr) + (0.7 * c)); + + /* output l & r. */ + *output[0]++ = l; + *output[1]++ = r; + + /* increment input. */ + input += channels; + } +} + static void deinterleave(short **output, short *input, int channels, int samples) { int i, j; @@ -147,6 +180,21 @@ static void ac3_5p1_mux(short *output, short *input1, short *input2, int n) } } +#define SUPPORT_RESAMPLE(ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8) \ + ch8<<7 | ch7<<6 | ch6<<5 | ch5<<4 | ch4<<3 | ch3<<2 | ch2<<1 | ch1<<0 + +static const uint8_t supported_resampling[MAX_CHANNELS] = { + //ouput channels:1 2 3 4 5 6 7 8 + SUPPORT_RESAMPLE(1, 1, 0, 0, 0, 0, 0, 0), // 1 input channel + SUPPORT_RESAMPLE(1, 1, 0, 0, 0, 1, 0, 0), // 2 input channels + SUPPORT_RESAMPLE(0, 0, 1, 0, 0, 0, 0, 0), // 3 input channels + SUPPORT_RESAMPLE(0, 0, 0, 1, 0, 0, 0, 0), // 4 input channels + SUPPORT_RESAMPLE(0, 0, 0, 0, 1, 0, 0, 0), // 5 input channels + SUPPORT_RESAMPLE(0, 1, 0, 0, 0, 1, 0, 0), // 6 input channels + SUPPORT_RESAMPLE(0, 0, 0, 0, 0, 0, 1, 0), // 7 input channels + SUPPORT_RESAMPLE(0, 0, 0, 0, 0, 0, 0, 1), // 8 input channels +}; + ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, int output_rate, int input_rate, enum AVSampleFormat sample_fmt_out, @@ -162,11 +210,15 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, MAX_CHANNELS); return NULL; } - if (output_channels > 2 && - !(output_channels == 6 && input_channels == 2) && - output_channels != input_channels) { - av_log(NULL, AV_LOG_ERROR, - "Resampling output channel count must be 1 or 2 for mono input; 1, 2 or 6 for stereo input; or N for N channel input.\n"); + if (!(supported_resampling[input_channels-1] & (1<<(output_channels-1)))) { + int i; + av_log(NULL, AV_LOG_ERROR, "Unsupported audio resampling. Allowed " + "output channels for %d input channel%s", input_channels, + input_channels > 1 ? "s:" : ":"); + for (i = 0; i < MAX_CHANNELS; i++) + if (supported_resampling[input_channels-1] & (1<<i)) + av_log(NULL, AV_LOG_ERROR, " %d", i + 1); + av_log(NULL, AV_LOG_ERROR, "\n"); return NULL; } @@ -269,7 +321,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl input = s->buffer[0]; } - lenout = 4 * nb_samples * s->ratio + 16; + lenout= 2*s->output_channels*nb_samples * s->ratio + 16; if (s->sample_fmt[1] != AV_SAMPLE_FMT_S16) { output_bak = output; @@ -301,6 +353,10 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl } else if (s->output_channels >= 2 && s->input_channels == 1) { buftmp3[0] = bufout[0]; memcpy(buftmp2[0], input, nb_samples * sizeof(short)); + } else if (s->input_channels == 6 && s->output_channels ==2) { + buftmp3[0] = bufout[0]; + buftmp3[1] = bufout[1]; + surround_to_stereo(buftmp2, input, s->input_channels, nb_samples); } else if (s->output_channels >= s->input_channels && s->input_channels >= 2) { for (i = 0; i < s->input_channels; i++) { buftmp3[i] = bufout[i]; @@ -330,7 +386,8 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl mono_to_stereo(output, buftmp3[0], nb_samples1); } else if (s->output_channels == 6 && s->input_channels == 2) { ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1); - } else if (s->output_channels == s->input_channels && s->input_channels >= 2) { + } else if ((s->output_channels == s->input_channels && s->input_channels >= 2) || + (s->output_channels == 2 && s->input_channels == 6)) { interleave(output, buftmp3, s->output_channels, nb_samples1); } diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c index 7560d84bd4..b940059d84 100644 --- a/libavcodec/resample2.c +++ b/libavcodec/resample2.c @@ -2,20 +2,20 @@ * audio resampling * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rl.h b/libavcodec/rl.h index 9c1ad7a642..b2445890e6 100644 --- a/libavcodec/rl.h +++ b/libavcodec/rl.h @@ -2,20 +2,20 @@ * Copyright (c) 2000-2002 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 3d1cea3995..8a553539ab 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -2,20 +2,20 @@ * RL2 Video Decoder * Copyright (C) 2008 Sascha Sommer (saschasommer@freenet.de) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -134,6 +134,7 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx) int i; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); /** parse extra data */ if(!avctx->extradata || avctx->extradata_size < EXTRADATA1_SIZE){ diff --git a/libavcodec/rle.c b/libavcodec/rle.c index 8a009e72bc..6e468f8991 100644 --- a/libavcodec/rle.c +++ b/libavcodec/rle.c @@ -2,20 +2,20 @@ * RLE encoder * Copyright (c) 2007 Bobby Bingham * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" diff --git a/libavcodec/rle.h b/libavcodec/rle.h index 00261d3598..24851321fe 100644 --- a/libavcodec/rle.h +++ b/libavcodec/rle.h @@ -1,20 +1,20 @@ /* * RLE encoder * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 46aefb4bef..f6bd726c4f 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -4,20 +4,20 @@ * Copyright (c) 2005 Eric Lasota * Based on RoQ specs (c)2001 Tim Ferguson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/roqvideo.c b/libavcodec/roqvideo.c index 77df0798db..eb8fc253ad 100644 --- a/libavcodec/roqvideo.c +++ b/libavcodec/roqvideo.c @@ -2,20 +2,20 @@ * Copyright (C) 2003 Mike Melanson * Copyright (C) 2003 Dr. Tim Ferguson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/roqvideo.h b/libavcodec/roqvideo.h index a1ff10af7d..3fe11c670b 100644 --- a/libavcodec/roqvideo.h +++ b/libavcodec/roqvideo.h @@ -2,20 +2,20 @@ * Copyright (C) 2003 Mike Melanson * Copyright (C) 2003 Dr. Tim Ferguson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index 06d1309d65..f0977f6491 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -159,6 +159,8 @@ static av_cold int roq_decode_init(AVCodecContext *avctx) s->avctx = avctx; s->width = avctx->width; s->height = avctx->height; + avcodec_get_frame_defaults(&s->frames[0]); + avcodec_get_frame_defaults(&s->frames[1]); s->last_frame = &s->frames[0]; s->current_frame = &s->frames[1]; avctx->pix_fmt = PIX_FMT_YUV444P; diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 052dcef3de..9030affb31 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -5,27 +5,27 @@ * Copyright (C) 2004-2007 Eric Lasota * Based on RoQ specs (C) 2001 Tim Ferguson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * id RoQ encoder by Vitor. Based on the Switchblade3 library and the - * Switchblade3 Libav glue by Eric Lasota. + * Switchblade3 FFmpeg glue by Eric Lasota. */ /* diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index 958f103865..12558563c6 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -2,20 +2,20 @@ * Quicktime Video (RPZA) Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -233,6 +233,7 @@ static av_cold int rpza_decode_init(AVCodecContext *avctx) s->avctx = avctx; avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/rtjpeg.c b/libavcodec/rtjpeg.c index 616c40258a..4c48f25b2c 100644 --- a/libavcodec/rtjpeg.c +++ b/libavcodec/rtjpeg.c @@ -2,20 +2,20 @@ * RTJpeg decoding functions * Copyright (c) 2006 Reimar Doeffinger * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/common.h" diff --git a/libavcodec/rtjpeg.h b/libavcodec/rtjpeg.h index d537c93ff4..4bcb9f70ca 100644 --- a/libavcodec/rtjpeg.h +++ b/libavcodec/rtjpeg.h @@ -2,20 +2,20 @@ * RTJpeg decoding functions * copyright (c) 2006 Reimar Doeffinger * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 6227dc6f6c..2f822a8ac2 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -293,6 +293,23 @@ static int rv20_decode_picture_header(MpegEncContext *s) { int seq, mb_pos, i; +#if 0 + GetBitContext gb= s->gb; + for(i=0; i<64; i++){ + av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb)); + if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); + } + av_log(s->avctx, AV_LOG_DEBUG, "\n"); +#endif +#if 0 + av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4); + for(i=0; i<s->avctx->extradata_size; i++){ + av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]); + if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); + } + av_log(s->avctx, AV_LOG_DEBUG, "\n"); +#endif + if(s->avctx->sub_id == 0x30202002 || s->avctx->sub_id == 0x30203002){ if (get_bits(&s->gb, 3)){ av_log(s->avctx, AV_LOG_ERROR, "unknown triplet set\n"); @@ -639,6 +656,8 @@ static int rv10_decode_frame(AVCodecContext *avctx, const uint8_t *slices_hdr = NULL; av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size); + s->flags = avctx->flags; + s->flags2 = avctx->flags2; /* no supplementary picture */ if (buf_size == 0) { diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index 1cb36fd223..82b1258799 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 8eba76b1a2..a10998450c 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 62177dda78..b43859b9cb 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -2,20 +2,20 @@ * RV30 decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv30data.h b/libavcodec/rv30data.h index 5ee304802c..9cc48a6a31 100644 --- a/libavcodec/rv30data.h +++ b/libavcodec/rv30data.h @@ -2,20 +2,20 @@ * RealVideo 3 decoder * copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv30dsp.c b/libavcodec/rv30dsp.c index c6e0614827..4700e7868c 100644 --- a/libavcodec/rv30dsp.c +++ b/libavcodec/rv30dsp.c @@ -2,20 +2,20 @@ * RV30 decoder motion compensation functions * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index b5d314cf0f..ae9ae1084f 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -2,20 +2,20 @@ * RV30/40 decoder common data * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv34.h b/libavcodec/rv34.h index c9f4ff7a13..24a27ce482 100644 --- a/libavcodec/rv34.h +++ b/libavcodec/rv34.h @@ -2,20 +2,20 @@ * RV30/40 decoder common data declarations * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv34data.h b/libavcodec/rv34data.h index f8f941d061..2155084d09 100644 --- a/libavcodec/rv34data.h +++ b/libavcodec/rv34data.h @@ -2,20 +2,20 @@ * RealVideo 4 decoder * copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv34vlc.h b/libavcodec/rv34vlc.h index f4670c1625..aa29357c78 100644 --- a/libavcodec/rv34vlc.h +++ b/libavcodec/rv34vlc.h @@ -2,20 +2,20 @@ * RealVideo 3/4 decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 46e77bc240..54d786a3a6 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -2,20 +2,20 @@ * RV40 decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv40data.h b/libavcodec/rv40data.h index 4787075742..7912919ba1 100644 --- a/libavcodec/rv40data.h +++ b/libavcodec/rv40data.h @@ -2,20 +2,20 @@ * RealVideo 4 decoder * copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv40dsp.c b/libavcodec/rv40dsp.c index 2271f5471b..27bc79eec0 100644 --- a/libavcodec/rv40dsp.c +++ b/libavcodec/rv40dsp.c @@ -2,20 +2,20 @@ * RV40 decoder motion compensation functions * Copyright (c) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/rv40vlc2.h b/libavcodec/rv40vlc2.h index 2f63fc27e3..15119a145b 100644 --- a/libavcodec/rv40vlc2.h +++ b/libavcodec/rv40vlc2.h @@ -2,20 +2,20 @@ * RealVideo 4 decoder * copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index 2e261b612e..98a5e73a8c 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -3,20 +3,20 @@ * Copyright (c) 2008 Laurent Aimar <fenrir@videolan.org> * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -63,6 +63,16 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, avctx->sample_fmt = SAMPLE_FMT_S16; avctx->channels = channels; + switch(channels) { + case 2: + avctx->channel_layout = AV_CH_LAYOUT_STEREO; + break; + case 4: + avctx->channel_layout = AV_CH_LAYOUT_QUAD; + break; + case 8: + avctx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK | AV_CH_LAYOUT_STEREO_DOWNMIX; + } avctx->sample_rate = 48000; avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_coded_sample + 4) + 32 * (48000 / (buf_size * 8 / diff --git a/libavcodec/s3tc.c b/libavcodec/s3tc.c index e8ca688270..546ee2156f 100644 --- a/libavcodec/s3tc.c +++ b/libavcodec/s3tc.c @@ -4,20 +4,20 @@ * * see also: http://wiki.multimedia.cx/index.php?title=S3TC * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/s3tc.h b/libavcodec/s3tc.h index 45da6fa8ac..4919c0748a 100644 --- a/libavcodec/s3tc.h +++ b/libavcodec/s3tc.h @@ -2,20 +2,20 @@ * S3 Texture Compression (S3TC) decoding functions * Copyright (c) 2007 by Ivo van Poorten * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index cbf3e23e6b..82a996fdc6 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -3,20 +3,20 @@ * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sgi.h b/libavcodec/sgi.h index ca531f00a1..be17f2e237 100644 --- a/libavcodec/sgi.h +++ b/libavcodec/sgi.h @@ -2,20 +2,20 @@ * SGI image encoder * Xiaohui Sun <tjnksxh@hotmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index 84cff35390..360a25ced2 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -2,20 +2,20 @@ * SGI image decoder * Todd Kirby <doubleshot@pacbell.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c index 202f676fc0..1e2af8e7ae 100644 --- a/libavcodec/sgienc.c +++ b/libavcodec/sgienc.c @@ -2,20 +2,20 @@ * SGI image encoder * Todd Kirby <doubleshot@pacbell.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sh4/dsputil_align.c b/libavcodec/sh4/dsputil_align.c index db40ece670..8be9318cdb 100644 --- a/libavcodec/sh4/dsputil_align.c +++ b/libavcodec/sh4/dsputil_align.c @@ -3,20 +3,20 @@ * * Copyright (c) 2001-2003 BERO <bero@geocities.co.jp> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sh4/dsputil_sh4.c b/libavcodec/sh4/dsputil_sh4.c index 9ea48ad4a1..d254e1db6b 100644 --- a/libavcodec/sh4/dsputil_sh4.c +++ b/libavcodec/sh4/dsputil_sh4.c @@ -3,20 +3,20 @@ * * Copyright (c) 2003 BERO <bero@geocities.co.jp> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sh4/dsputil_sh4.h b/libavcodec/sh4/dsputil_sh4.h index 5abe34557b..2e554e7370 100644 --- a/libavcodec/sh4/dsputil_sh4.h +++ b/libavcodec/sh4/dsputil_sh4.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sh4/idct_sh4.c b/libavcodec/sh4/idct_sh4.c index 0baff396e0..13a85b030e 100644 --- a/libavcodec/sh4/idct_sh4.c +++ b/libavcodec/sh4/idct_sh4.c @@ -3,20 +3,20 @@ * * Copyright (c) 2001-2003 BERO <bero@geocities.co.jp> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sh4/qpel.c b/libavcodec/sh4/qpel.c index 3242872e47..2e30ae1137 100644 --- a/libavcodec/sh4/qpel.c +++ b/libavcodec/sh4/qpel.c @@ -4,20 +4,20 @@ * * copyright (c) 2001-2003 BERO <bero@geocities.co.jp> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sh4/sh4.h b/libavcodec/sh4/sh4.h index acd12e6ff6..5d46540cb6 100644 --- a/libavcodec/sh4/sh4.h +++ b/libavcodec/sh4/sh4.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index a6e00750e9..f593d0a164 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -2,20 +2,20 @@ * Shorten decoder * Copyright (c) 2005 Jeff Muizelaar * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c index 4af11bec51..475be6d2d4 100644 --- a/libavcodec/simple_idct.c +++ b/libavcodec/simple_idct.c @@ -3,20 +3,20 @@ * * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/simple_idct.h b/libavcodec/simple_idct.h index 23bae9c2fe..24f6a6d5db 100644 --- a/libavcodec/simple_idct.h +++ b/libavcodec/simple_idct.h @@ -3,20 +3,20 @@ * * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sinewin.c b/libavcodec/sinewin.c index be38dbc713..1fa0e953f0 100644 --- a/libavcodec/sinewin.c +++ b/libavcodec/sinewin.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h index eefe5bfe7f..61135fd6a2 100644 --- a/libavcodec/sinewin.h +++ b/libavcodec/sinewin.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Robert Swain * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sinewin_tablegen.c b/libavcodec/sinewin_tablegen.c index 2f4d1aa2ae..48eb771e48 100644 --- a/libavcodec/sinewin_tablegen.c +++ b/libavcodec/sinewin_tablegen.c @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h index 720f1ab6b8..f587595c21 100644 --- a/libavcodec/sinewin_tablegen.h +++ b/libavcodec/sinewin_tablegen.h @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c index 17e7e855ed..b96e3b9024 100644 --- a/libavcodec/sipr.c +++ b/libavcodec/sipr.c @@ -4,20 +4,20 @@ * Copyright (c) 2008 Vladimir Voroshilov * Copyright (c) 2009 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sipr.h b/libavcodec/sipr.h index 33984b1baf..66e7696466 100644 --- a/libavcodec/sipr.h +++ b/libavcodec/sipr.h @@ -4,20 +4,20 @@ * Copyright (c) 2008 Vladimir Voroshilov * Copyright (c) 2009 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sipr16k.c b/libavcodec/sipr16k.c index ca10cd9c70..7fb9252927 100644 --- a/libavcodec/sipr16k.c +++ b/libavcodec/sipr16k.c @@ -4,20 +4,20 @@ * Copyright (c) 2008 Vladimir Voroshilov * Copyright (c) 2009 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sipr16kdata.h b/libavcodec/sipr16kdata.h index ec60c29b51..96bf0e96c8 100644 --- a/libavcodec/sipr16kdata.h +++ b/libavcodec/sipr16kdata.h @@ -4,20 +4,20 @@ * Copyright (c) 2008 Vladimir Voroshilov * Copyright (c) 2009 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/siprdata.h b/libavcodec/siprdata.h index 92037a4a87..ed804ee87c 100644 --- a/libavcodec/siprdata.h +++ b/libavcodec/siprdata.h @@ -4,20 +4,20 @@ * Copyright (c) 2008 Vladimir Voroshilov * Copyright (c) 2009 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 8060e1cee7..b8eab837ff 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -2,20 +2,20 @@ * Smacker decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -168,7 +168,7 @@ static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx } /** - * Store large tree as Libav's vlc codes + * Store large tree as FFmpeg's vlc codes */ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size) { @@ -515,6 +515,7 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&c->pic); /* decode huffman trees from extradata */ if(avctx->extradata_size < 16){ diff --git a/libavcodec/smc.c b/libavcodec/smc.c index e75203d7a5..ce5b72a2a3 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -2,20 +2,20 @@ * Quicktime Graphics (SMC) Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -425,6 +425,7 @@ static av_cold int smc_decode_init(AVCodecContext *avctx) s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 6db0b290ba..4ee1722e4c 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1976,15 +1976,9 @@ static int frame_start(SnowContext *s){ int h= s->avctx->height; if(s->current_picture.data[0]){ - s->dsp.draw_edges(s->current_picture.data[0], - s->current_picture.linesize[0], w , h , - EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM); - s->dsp.draw_edges(s->current_picture.data[1], - s->current_picture.linesize[1], w>>1, h>>1, - EDGE_WIDTH/2, EDGE_TOP | EDGE_BOTTOM); - s->dsp.draw_edges(s->current_picture.data[2], - s->current_picture.linesize[2], w>>1, h>>1, - EDGE_WIDTH/2, EDGE_TOP | EDGE_BOTTOM); + s->dsp.draw_edges(s->current_picture.data[0], s->current_picture.linesize[0], w , h , EDGE_WIDTH , EDGE_TOP|EDGE_BOTTOM); + s->dsp.draw_edges(s->current_picture.data[1], s->current_picture.linesize[1], w>>1, h>>1, EDGE_WIDTH/2, EDGE_TOP|EDGE_BOTTOM); + s->dsp.draw_edges(s->current_picture.data[2], s->current_picture.linesize[2], w>>1, h>>1, EDGE_WIDTH/2, EDGE_TOP|EDGE_BOTTOM); } release_buffer(s->avctx); diff --git a/libavcodec/snow.h b/libavcodec/snow.h index db61b875c4..7d847e4b37 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -2,20 +2,20 @@ * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (C) 2006 Robert Edele <yartrebo@earthlink.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c new file mode 100644 index 0000000000..e7cdb3ba81 --- /dev/null +++ b/libavcodec/sonic.c @@ -0,0 +1,977 @@ +/* + * Simple free lossless/lossy audio codec + * Copyright (c) 2004 Alex Beregszaszi + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avcodec.h" +#include "get_bits.h" +#include "golomb.h" + +/** + * @file + * Simple free lossless/lossy audio codec + * Based on Paul Francis Harrison's Bonk (http://www.logarithmic.net/pfh/bonk) + * Written and designed by Alex Beregszaszi + * + * TODO: + * - CABAC put/get_symbol + * - independent quantizer for channels + * - >2 channels support + * - more decorrelation types + * - more tap_quant tests + * - selectable intlist writers/readers (bonk-style, golomb, cabac) + */ + +#define MAX_CHANNELS 2 + +#define MID_SIDE 0 +#define LEFT_SIDE 1 +#define RIGHT_SIDE 2 + +typedef struct SonicContext { + int lossless, decorrelation; + + int num_taps, downsampling; + double quantization; + + int channels, samplerate, block_align, frame_size; + + int *tap_quant; + int *int_samples; + int *coded_samples[MAX_CHANNELS]; + + // for encoding + int *tail; + int tail_size; + int *window; + int window_size; + + // for decoding + int *predictor_k; + int *predictor_state[MAX_CHANNELS]; +} SonicContext; + +#define LATTICE_SHIFT 10 +#define SAMPLE_SHIFT 4 +#define LATTICE_FACTOR (1 << LATTICE_SHIFT) +#define SAMPLE_FACTOR (1 << SAMPLE_SHIFT) + +#define BASE_QUANT 0.6 +#define RATE_VARIATION 3.0 + +static inline int divide(int a, int b) +{ + if (a < 0) + return -( (-a + b/2)/b ); + else + return (a + b/2)/b; +} + +static inline int shift(int a,int b) +{ + return (a+(1<<(b-1))) >> b; +} + +static inline int shift_down(int a,int b) +{ + return (a>>b)+((a<0)?1:0); +} + +#if 1 +static inline int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) +{ + int i; + + for (i = 0; i < entries; i++) + set_se_golomb(pb, buf[i]); + + return 1; +} + +static inline int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) +{ + int i; + + for (i = 0; i < entries; i++) + buf[i] = get_se_golomb(gb); + + return 1; +} + +#else + +#define ADAPT_LEVEL 8 + +static int bits_to_store(uint64_t x) +{ + int res = 0; + + while(x) + { + res++; + x >>= 1; + } + return res; +} + +static void write_uint_max(PutBitContext *pb, unsigned int value, unsigned int max) +{ + int i, bits; + + if (!max) + return; + + bits = bits_to_store(max); + + for (i = 0; i < bits-1; i++) + put_bits(pb, 1, value & (1 << i)); + + if ( (value | (1 << (bits-1))) <= max) + put_bits(pb, 1, value & (1 << (bits-1))); +} + +static unsigned int read_uint_max(GetBitContext *gb, int max) +{ + int i, bits, value = 0; + + if (!max) + return 0; + + bits = bits_to_store(max); + + for (i = 0; i < bits-1; i++) + if (get_bits1(gb)) + value += 1 << i; + + if ( (value | (1<<(bits-1))) <= max) + if (get_bits1(gb)) + value += 1 << (bits-1); + + return value; +} + +static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) +{ + int i, j, x = 0, low_bits = 0, max = 0; + int step = 256, pos = 0, dominant = 0, any = 0; + int *copy, *bits; + + copy = av_mallocz(4* entries); + if (!copy) + return -1; + + if (base_2_part) + { + int energy = 0; + + for (i = 0; i < entries; i++) + energy += abs(buf[i]); + + low_bits = bits_to_store(energy / (entries * 2)); + if (low_bits > 15) + low_bits = 15; + + put_bits(pb, 4, low_bits); + } + + for (i = 0; i < entries; i++) + { + put_bits(pb, low_bits, abs(buf[i])); + copy[i] = abs(buf[i]) >> low_bits; + if (copy[i] > max) + max = abs(copy[i]); + } + + bits = av_mallocz(4* entries*max); + if (!bits) + { +// av_free(copy); + return -1; + } + + for (i = 0; i <= max; i++) + { + for (j = 0; j < entries; j++) + if (copy[j] >= i) + bits[x++] = copy[j] > i; + } + + // store bitstream + while (pos < x) + { + int steplet = step >> 8; + + if (pos + steplet > x) + steplet = x - pos; + + for (i = 0; i < steplet; i++) + if (bits[i+pos] != dominant) + any = 1; + + put_bits(pb, 1, any); + + if (!any) + { + pos += steplet; + step += step / ADAPT_LEVEL; + } + else + { + int interloper = 0; + + while (((pos + interloper) < x) && (bits[pos + interloper] == dominant)) + interloper++; + + // note change + write_uint_max(pb, interloper, (step >> 8) - 1); + + pos += interloper + 1; + step -= step / ADAPT_LEVEL; + } + + if (step < 256) + { + step = 65536 / step; + dominant = !dominant; + } + } + + // store signs + for (i = 0; i < entries; i++) + if (buf[i]) + put_bits(pb, 1, buf[i] < 0); + +// av_free(bits); +// av_free(copy); + + return 0; +} + +static int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) +{ + int i, low_bits = 0, x = 0; + int n_zeros = 0, step = 256, dominant = 0; + int pos = 0, level = 0; + int *bits = av_mallocz(4* entries); + + if (!bits) + return -1; + + if (base_2_part) + { + low_bits = get_bits(gb, 4); + + if (low_bits) + for (i = 0; i < entries; i++) + buf[i] = get_bits(gb, low_bits); + } + +// av_log(NULL, AV_LOG_INFO, "entries: %d, low bits: %d\n", entries, low_bits); + + while (n_zeros < entries) + { + int steplet = step >> 8; + + if (!get_bits1(gb)) + { + for (i = 0; i < steplet; i++) + bits[x++] = dominant; + + if (!dominant) + n_zeros += steplet; + + step += step / ADAPT_LEVEL; + } + else + { + int actual_run = read_uint_max(gb, steplet-1); + +// av_log(NULL, AV_LOG_INFO, "actual run: %d\n", actual_run); + + for (i = 0; i < actual_run; i++) + bits[x++] = dominant; + + bits[x++] = !dominant; + + if (!dominant) + n_zeros += actual_run; + else + n_zeros++; + + step -= step / ADAPT_LEVEL; + } + + if (step < 256) + { + step = 65536 / step; + dominant = !dominant; + } + } + + // reconstruct unsigned values + n_zeros = 0; + for (i = 0; n_zeros < entries; i++) + { + while(1) + { + if (pos >= entries) + { + pos = 0; + level += 1 << low_bits; + } + + if (buf[pos] >= level) + break; + + pos++; + } + + if (bits[i]) + buf[pos] += 1 << low_bits; + else + n_zeros++; + + pos++; + } +// av_free(bits); + + // read signs + for (i = 0; i < entries; i++) + if (buf[i] && get_bits1(gb)) + buf[i] = -buf[i]; + +// av_log(NULL, AV_LOG_INFO, "zeros: %d pos: %d\n", n_zeros, pos); + + return 0; +} +#endif + +static void predictor_init_state(int *k, int *state, int order) +{ + int i; + + for (i = order-2; i >= 0; i--) + { + int j, p, x = state[i]; + + for (j = 0, p = i+1; p < order; j++,p++) + { + int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT); + state[p] += shift_down(k[j]*x, LATTICE_SHIFT); + x = tmp; + } + } +} + +static int predictor_calc_error(int *k, int *state, int order, int error) +{ + int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT); + +#if 1 + int *k_ptr = &(k[order-2]), + *state_ptr = &(state[order-2]); + for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) + { + int k_value = *k_ptr, state_value = *state_ptr; + x -= shift_down(k_value * state_value, LATTICE_SHIFT); + state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT); + } +#else + for (i = order-2; i >= 0; i--) + { + x -= shift_down(k[i] * state[i], LATTICE_SHIFT); + state[i+1] = state[i] + shift_down(k[i] * x, LATTICE_SHIFT); + } +#endif + + // don't drift too far, to avoid overflows + if (x > (SAMPLE_FACTOR<<16)) x = (SAMPLE_FACTOR<<16); + if (x < -(SAMPLE_FACTOR<<16)) x = -(SAMPLE_FACTOR<<16); + + state[0] = x; + + return x; +} + +#if CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER +// Heavily modified Levinson-Durbin algorithm which +// copes better with quantization, and calculates the +// actual whitened result as it goes. + +static void modified_levinson_durbin(int *window, int window_entries, + int *out, int out_entries, int channels, int *tap_quant) +{ + int i; + int *state = av_mallocz(4* window_entries); + + memcpy(state, window, 4* window_entries); + + for (i = 0; i < out_entries; i++) + { + int step = (i+1)*channels, k, j; + double xx = 0.0, xy = 0.0; +#if 1 + int *x_ptr = &(window[step]), *state_ptr = &(state[0]); + j = window_entries - step; + for (;j>=0;j--,x_ptr++,state_ptr++) + { + double x_value = *x_ptr, state_value = *state_ptr; + xx += state_value*state_value; + xy += x_value*state_value; + } +#else + for (j = 0; j <= (window_entries - step); j++); + { + double stepval = window[step+j], stateval = window[j]; +// xx += (double)window[j]*(double)window[j]; +// xy += (double)window[step+j]*(double)window[j]; + xx += stateval*stateval; + xy += stepval*stateval; + } +#endif + if (xx == 0.0) + k = 0; + else + k = (int)(floor(-xy/xx * (double)LATTICE_FACTOR / (double)(tap_quant[i]) + 0.5)); + + if (k > (LATTICE_FACTOR/tap_quant[i])) + k = LATTICE_FACTOR/tap_quant[i]; + if (-k > (LATTICE_FACTOR/tap_quant[i])) + k = -(LATTICE_FACTOR/tap_quant[i]); + + out[i] = k; + k *= tap_quant[i]; + +#if 1 + x_ptr = &(window[step]); + state_ptr = &(state[0]); + j = window_entries - step; + for (;j>=0;j--,x_ptr++,state_ptr++) + { + int x_value = *x_ptr, state_value = *state_ptr; + *x_ptr = x_value + shift_down(k*state_value,LATTICE_SHIFT); + *state_ptr = state_value + shift_down(k*x_value, LATTICE_SHIFT); + } +#else + for (j=0; j <= (window_entries - step); j++) + { + int stepval = window[step+j], stateval=state[j]; + window[step+j] += shift_down(k * stateval, LATTICE_SHIFT); + state[j] += shift_down(k * stepval, LATTICE_SHIFT); + } +#endif + } + + av_free(state); +} + +static inline int code_samplerate(int samplerate) +{ + switch (samplerate) + { + case 44100: return 0; + case 22050: return 1; + case 11025: return 2; + case 96000: return 3; + case 48000: return 4; + case 32000: return 5; + case 24000: return 6; + case 16000: return 7; + case 8000: return 8; + } + return -1; +} + +static av_cold int sonic_encode_init(AVCodecContext *avctx) +{ + SonicContext *s = avctx->priv_data; + PutBitContext pb; + int i, version = 0; + + if (avctx->channels > MAX_CHANNELS) + { + av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n"); + return -1; /* only stereo or mono for now */ + } + + if (avctx->channels == 2) + s->decorrelation = MID_SIDE; + + if (avctx->codec->id == CODEC_ID_SONIC_LS) + { + s->lossless = 1; + s->num_taps = 32; + s->downsampling = 1; + s->quantization = 0.0; + } + else + { + s->num_taps = 128; + s->downsampling = 2; + s->quantization = 1.0; + } + + // max tap 2048 + if ((s->num_taps < 32) || (s->num_taps > 1024) || + ((s->num_taps>>5)<<5 != s->num_taps)) + { + av_log(avctx, AV_LOG_ERROR, "Invalid number of taps\n"); + return -1; + } + + // generate taps + s->tap_quant = av_mallocz(4* s->num_taps); + for (i = 0; i < s->num_taps; i++) + s->tap_quant[i] = (int)(sqrt(i+1)); + + s->channels = avctx->channels; + s->samplerate = avctx->sample_rate; + + s->block_align = (int)(2048.0*s->samplerate/44100)/s->downsampling; + s->frame_size = s->channels*s->block_align*s->downsampling; + + s->tail = av_mallocz(4* s->num_taps*s->channels); + if (!s->tail) + return -1; + s->tail_size = s->num_taps*s->channels; + + s->predictor_k = av_mallocz(4 * s->num_taps); + if (!s->predictor_k) + return -1; + + for (i = 0; i < s->channels; i++) + { + s->coded_samples[i] = av_mallocz(4* s->block_align); + if (!s->coded_samples[i]) + return -1; + } + + s->int_samples = av_mallocz(4* s->frame_size); + + s->window_size = ((2*s->tail_size)+s->frame_size); + s->window = av_mallocz(4* s->window_size); + if (!s->window) + return -1; + + avctx->extradata = av_mallocz(16); + if (!avctx->extradata) + return -1; + init_put_bits(&pb, avctx->extradata, 16*8); + + put_bits(&pb, 2, version); // version + if (version == 1) + { + put_bits(&pb, 2, s->channels); + put_bits(&pb, 4, code_samplerate(s->samplerate)); + } + put_bits(&pb, 1, s->lossless); + if (!s->lossless) + put_bits(&pb, 3, SAMPLE_SHIFT); // XXX FIXME: sample precision + put_bits(&pb, 2, s->decorrelation); + put_bits(&pb, 2, s->downsampling); + put_bits(&pb, 5, (s->num_taps >> 5)-1); // 32..1024 + put_bits(&pb, 1, 0); // XXX FIXME: no custom tap quant table + + flush_put_bits(&pb); + avctx->extradata_size = put_bits_count(&pb)/8; + + av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n", + version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling); + + avctx->coded_frame = avcodec_alloc_frame(); + if (!avctx->coded_frame) + return AVERROR(ENOMEM); + avctx->coded_frame->key_frame = 1; + avctx->frame_size = s->block_align*s->downsampling; + + return 0; +} + +static av_cold int sonic_encode_close(AVCodecContext *avctx) +{ + SonicContext *s = avctx->priv_data; + int i; + + av_freep(&avctx->coded_frame); + + for (i = 0; i < s->channels; i++) + av_free(s->coded_samples[i]); + + av_free(s->predictor_k); + av_free(s->tail); + av_free(s->tap_quant); + av_free(s->window); + av_free(s->int_samples); + + return 0; +} + +static int sonic_encode_frame(AVCodecContext *avctx, + uint8_t *buf, int buf_size, void *data) +{ + SonicContext *s = avctx->priv_data; + PutBitContext pb; + int i, j, ch, quant = 0, x = 0; + short *samples = data; + + init_put_bits(&pb, buf, buf_size*8); + + // short -> internal + for (i = 0; i < s->frame_size; i++) + s->int_samples[i] = samples[i]; + + if (!s->lossless) + for (i = 0; i < s->frame_size; i++) + s->int_samples[i] = s->int_samples[i] << SAMPLE_SHIFT; + + switch(s->decorrelation) + { + case MID_SIDE: + for (i = 0; i < s->frame_size; i += s->channels) + { + s->int_samples[i] += s->int_samples[i+1]; + s->int_samples[i+1] -= shift(s->int_samples[i], 1); + } + break; + case LEFT_SIDE: + for (i = 0; i < s->frame_size; i += s->channels) + s->int_samples[i+1] -= s->int_samples[i]; + break; + case RIGHT_SIDE: + for (i = 0; i < s->frame_size; i += s->channels) + s->int_samples[i] -= s->int_samples[i+1]; + break; + } + + memset(s->window, 0, 4* s->window_size); + + for (i = 0; i < s->tail_size; i++) + s->window[x++] = s->tail[i]; + + for (i = 0; i < s->frame_size; i++) + s->window[x++] = s->int_samples[i]; + + for (i = 0; i < s->tail_size; i++) + s->window[x++] = 0; + + for (i = 0; i < s->tail_size; i++) + s->tail[i] = s->int_samples[s->frame_size - s->tail_size + i]; + + // generate taps + modified_levinson_durbin(s->window, s->window_size, + s->predictor_k, s->num_taps, s->channels, s->tap_quant); + if (intlist_write(&pb, s->predictor_k, s->num_taps, 0) < 0) + return -1; + + for (ch = 0; ch < s->channels; ch++) + { + x = s->tail_size+ch; + for (i = 0; i < s->block_align; i++) + { + int sum = 0; + for (j = 0; j < s->downsampling; j++, x += s->channels) + sum += s->window[x]; + s->coded_samples[ch][i] = sum; + } + } + + // simple rate control code + if (!s->lossless) + { + double energy1 = 0.0, energy2 = 0.0; + for (ch = 0; ch < s->channels; ch++) + { + for (i = 0; i < s->block_align; i++) + { + double sample = s->coded_samples[ch][i]; + energy2 += sample*sample; + energy1 += fabs(sample); + } + } + + energy2 = sqrt(energy2/(s->channels*s->block_align)); + energy1 = sqrt(2.0)*energy1/(s->channels*s->block_align); + + // increase bitrate when samples are like a gaussian distribution + // reduce bitrate when samples are like a two-tailed exponential distribution + + if (energy2 > energy1) + energy2 += (energy2-energy1)*RATE_VARIATION; + + quant = (int)(BASE_QUANT*s->quantization*energy2/SAMPLE_FACTOR); +// av_log(avctx, AV_LOG_DEBUG, "quant: %d energy: %f / %f\n", quant, energy1, energy2); + + if (quant < 1) + quant = 1; + if (quant > 65535) + quant = 65535; + + set_ue_golomb(&pb, quant); + + quant *= SAMPLE_FACTOR; + } + + // write out coded samples + for (ch = 0; ch < s->channels; ch++) + { + if (!s->lossless) + for (i = 0; i < s->block_align; i++) + s->coded_samples[ch][i] = divide(s->coded_samples[ch][i], quant); + + if (intlist_write(&pb, s->coded_samples[ch], s->block_align, 1) < 0) + return -1; + } + +// av_log(avctx, AV_LOG_DEBUG, "used bytes: %d\n", (put_bits_count(&pb)+7)/8); + + flush_put_bits(&pb); + return (put_bits_count(&pb)+7)/8; +} +#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */ + +#if CONFIG_SONIC_DECODER +static const int samplerate_table[] = + { 44100, 22050, 11025, 96000, 48000, 32000, 24000, 16000, 8000 }; + +static av_cold int sonic_decode_init(AVCodecContext *avctx) +{ + SonicContext *s = avctx->priv_data; + GetBitContext gb; + int i, version; + + s->channels = avctx->channels; + s->samplerate = avctx->sample_rate; + + if (!avctx->extradata) + { + av_log(avctx, AV_LOG_ERROR, "No mandatory headers present\n"); + return -1; + } + + init_get_bits(&gb, avctx->extradata, avctx->extradata_size); + + version = get_bits(&gb, 2); + if (version > 1) + { + av_log(avctx, AV_LOG_ERROR, "Unsupported Sonic version, please report\n"); + return -1; + } + + if (version == 1) + { + s->channels = get_bits(&gb, 2); + s->samplerate = samplerate_table[get_bits(&gb, 4)]; + av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n", + s->channels, s->samplerate); + } + + if (s->channels > MAX_CHANNELS) + { + av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n"); + return -1; + } + + s->lossless = get_bits1(&gb); + if (!s->lossless) + skip_bits(&gb, 3); // XXX FIXME + s->decorrelation = get_bits(&gb, 2); + + s->downsampling = get_bits(&gb, 2); + s->num_taps = (get_bits(&gb, 5)+1)<<5; + if (get_bits1(&gb)) // XXX FIXME + av_log(avctx, AV_LOG_INFO, "Custom quant table\n"); + + s->block_align = (int)(2048.0*s->samplerate/44100)/s->downsampling; + s->frame_size = s->channels*s->block_align*s->downsampling; +// avctx->frame_size = s->block_align; + + av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n", + version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling); + + // generate taps + s->tap_quant = av_mallocz(4* s->num_taps); + for (i = 0; i < s->num_taps; i++) + s->tap_quant[i] = (int)(sqrt(i+1)); + + s->predictor_k = av_mallocz(4* s->num_taps); + + for (i = 0; i < s->channels; i++) + { + s->predictor_state[i] = av_mallocz(4* s->num_taps); + if (!s->predictor_state[i]) + return -1; + } + + for (i = 0; i < s->channels; i++) + { + s->coded_samples[i] = av_mallocz(4* s->block_align); + if (!s->coded_samples[i]) + return -1; + } + s->int_samples = av_mallocz(4* s->frame_size); + + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + return 0; +} + +static av_cold int sonic_decode_close(AVCodecContext *avctx) +{ + SonicContext *s = avctx->priv_data; + int i; + + av_free(s->int_samples); + av_free(s->tap_quant); + av_free(s->predictor_k); + + for (i = 0; i < s->channels; i++) + { + av_free(s->predictor_state[i]); + av_free(s->coded_samples[i]); + } + + return 0; +} + +static int sonic_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, + AVPacket *avpkt) +{ + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + SonicContext *s = avctx->priv_data; + GetBitContext gb; + int i, quant, ch, j; + short *samples = data; + + if (buf_size == 0) return 0; + +// av_log(NULL, AV_LOG_INFO, "buf_size: %d\n", buf_size); + + init_get_bits(&gb, buf, buf_size*8); + + intlist_read(&gb, s->predictor_k, s->num_taps, 0); + + // dequantize + for (i = 0; i < s->num_taps; i++) + s->predictor_k[i] *= s->tap_quant[i]; + + if (s->lossless) + quant = 1; + else + quant = get_ue_golomb(&gb) * SAMPLE_FACTOR; + +// av_log(NULL, AV_LOG_INFO, "quant: %d\n", quant); + + for (ch = 0; ch < s->channels; ch++) + { + int x = ch; + + predictor_init_state(s->predictor_k, s->predictor_state[ch], s->num_taps); + + intlist_read(&gb, s->coded_samples[ch], s->block_align, 1); + + for (i = 0; i < s->block_align; i++) + { + for (j = 0; j < s->downsampling - 1; j++) + { + s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, 0); + x += s->channels; + } + + s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, s->coded_samples[ch][i] * quant); + x += s->channels; + } + + for (i = 0; i < s->num_taps; i++) + s->predictor_state[ch][i] = s->int_samples[s->frame_size - s->channels + ch - i*s->channels]; + } + + switch(s->decorrelation) + { + case MID_SIDE: + for (i = 0; i < s->frame_size; i += s->channels) + { + s->int_samples[i+1] += shift(s->int_samples[i], 1); + s->int_samples[i] -= s->int_samples[i+1]; + } + break; + case LEFT_SIDE: + for (i = 0; i < s->frame_size; i += s->channels) + s->int_samples[i+1] += s->int_samples[i]; + break; + case RIGHT_SIDE: + for (i = 0; i < s->frame_size; i += s->channels) + s->int_samples[i] += s->int_samples[i+1]; + break; + } + + if (!s->lossless) + for (i = 0; i < s->frame_size; i++) + s->int_samples[i] = shift(s->int_samples[i], SAMPLE_SHIFT); + + // internal -> short + for (i = 0; i < s->frame_size; i++) + samples[i] = av_clip_int16(s->int_samples[i]); + + align_get_bits(&gb); + + *data_size = s->frame_size * 2; + + return (get_bits_count(&gb)+7)/8; +} + +AVCodec ff_sonic_decoder = { + "sonic", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_SONIC, + sizeof(SonicContext), + sonic_decode_init, + NULL, + sonic_decode_close, + sonic_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("Sonic"), +}; +#endif /* CONFIG_SONIC_DECODER */ + +#if CONFIG_SONIC_ENCODER +AVCodec ff_sonic_encoder = { + "sonic", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_SONIC, + sizeof(SonicContext), + sonic_encode_init, + sonic_encode_frame, + sonic_encode_close, + NULL, + .long_name = NULL_IF_CONFIG_SMALL("Sonic"), +}; +#endif + +#if CONFIG_SONIC_LS_ENCODER +AVCodec ff_sonic_ls_encoder = { + "sonicls", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_SONIC_LS, + sizeof(SonicContext), + sonic_encode_init, + sonic_encode_frame, + sonic_encode_close, + NULL, + .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"), +}; +#endif diff --git a/libavcodec/sp5x.h b/libavcodec/sp5x.h index 23c893be7f..b2c53cc4fe 100644 --- a/libavcodec/sp5x.h +++ b/libavcodec/sp5x.h @@ -2,20 +2,20 @@ * Sunplus JPEG tables * Copyright (c) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 6726c18ca9..0b56c101db 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -2,20 +2,20 @@ * Sunplus JPEG decoder (SP5X) * Copyright (c) 2003 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -104,7 +104,7 @@ AVCodec ff_sp5x_decoder = { sp5x_decode_frame, CODEC_CAP_DR1, NULL, - .max_lowres = 5, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"), }; diff --git a/libavcodec/sparc/dsputil_vis.c b/libavcodec/sparc/dsputil_vis.c index ab9258b2b9..e4236602f6 100644 --- a/libavcodec/sparc/dsputil_vis.c +++ b/libavcodec/sparc/dsputil_vis.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2003 David S. Miller <davem@redhat.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sparc/dsputil_vis.h b/libavcodec/sparc/dsputil_vis.h index 4be86e25e0..e1cbcb49e3 100644 --- a/libavcodec/sparc/dsputil_vis.h +++ b/libavcodec/sparc/dsputil_vis.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sparc/simple_idct_vis.c b/libavcodec/sparc/simple_idct_vis.c index f9fcf809fb..d98bf37651 100644 --- a/libavcodec/sparc/simple_idct_vis.c +++ b/libavcodec/sparc/simple_idct_vis.c @@ -5,20 +5,20 @@ * I did consult the following fine web page about dct * http://www.geocities.com/ssavekar/dct.htm * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/sparc/vis.h b/libavcodec/sparc/vis.h index 505c735cbb..adee91bd6f 100644 --- a/libavcodec/sparc/vis.h +++ b/libavcodec/sparc/vis.h @@ -1,20 +1,20 @@ /* * Copyright (C) 2003 David S. Miller <davem@redhat.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c index 677c5501f8..aa73f4c7bf 100644 --- a/libavcodec/srtdec.c +++ b/libavcodec/srtdec.c @@ -2,20 +2,20 @@ * SubRip subtitle decoder * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -216,8 +216,6 @@ static int srt_decode_frame(AVCodecContext *avctx, if (avpkt->size <= 0) return avpkt->size; - ff_ass_init(sub); - while (ptr < end && *ptr) { ptr = read_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2); if (!ptr) diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c new file mode 100644 index 0000000000..56d3397828 --- /dev/null +++ b/libavcodec/srtenc.c @@ -0,0 +1,301 @@ +/* + * SubRip subtitle encoder + * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdarg.h> +#include "avcodec.h" +#include "libavutil/avstring.h" +#include "ass_split.h" +#include "ass.h" + + +#define SRT_STACK_SIZE 64 + +typedef struct { + AVCodecContext *avctx; + ASSSplitContext *ass_ctx; + char buffer[2048]; + char *ptr; + char *end; + char *dialog_start; + int count; + char stack[SRT_STACK_SIZE]; + int stack_ptr; + int alignment_applied; +} SRTContext; + + +#ifdef __GNUC__ +__attribute__ ((__format__ (__printf__, 2, 3))) +#endif +static void srt_print(SRTContext *s, const char *str, ...) +{ + va_list vargs; + va_start(vargs, str); + s->ptr += vsnprintf(s->ptr, s->end - s->ptr, str, vargs); + va_end(vargs); +} + +static int srt_stack_push(SRTContext *s, const char c) +{ + if (s->stack_ptr >= SRT_STACK_SIZE) + return -1; + s->stack[s->stack_ptr++] = c; + return 0; +} + +static char srt_stack_pop(SRTContext *s) +{ + if (s->stack_ptr <= 0) + return 0; + return s->stack[--s->stack_ptr]; +} + +static int srt_stack_find(SRTContext *s, const char c) +{ + int i; + for (i = s->stack_ptr-1; i >= 0; i--) + if (s->stack[i] == c) + break; + return i; +} + +static void srt_close_tag(SRTContext *s, char tag) +{ + srt_print(s, "</%c%s>", tag, tag == 'f' ? "ont" : ""); +} + +static void srt_stack_push_pop(SRTContext *s, const char c, int close) +{ + if (close) { + int i = c ? srt_stack_find(s, c) : 0; + if (i < 0) + return; + while (s->stack_ptr != i) + srt_close_tag(s, srt_stack_pop(s)); + } else if (srt_stack_push(s, c) < 0) + av_log(s->avctx, AV_LOG_ERROR, "tag stack overflow\n"); +} + +static void srt_style_apply(SRTContext *s, const char *style) +{ + ASSStyle *st = ass_style_get(s->ass_ctx, style); + if (st) { + int c = st->primary_color & 0xFFFFFF; + if (st->font_name && strcmp(st->font_name, ASS_DEFAULT_FONT) || + st->font_size != ASS_DEFAULT_FONT_SIZE || + c != ASS_DEFAULT_COLOR) { + srt_print(s, "<font"); + if (st->font_name && strcmp(st->font_name, ASS_DEFAULT_FONT)) + srt_print(s, " face=\"%s\"", st->font_name); + if (st->font_size != ASS_DEFAULT_FONT_SIZE) + srt_print(s, " size=\"%d\"", st->font_size); + if (c != ASS_DEFAULT_COLOR) + srt_print(s, " color=\"#%06x\"", + (c & 0xFF0000) >> 16 | c & 0xFF00 | (c & 0xFF) << 16); + srt_print(s, ">"); + srt_stack_push(s, 'f'); + } + if (st->bold != ASS_DEFAULT_BOLD) { + srt_print(s, "<b>"); + srt_stack_push(s, 'b'); + } + if (st->italic != ASS_DEFAULT_ITALIC) { + srt_print(s, "<i>"); + srt_stack_push(s, 'i'); + } + if (st->underline != ASS_DEFAULT_UNDERLINE) { + srt_print(s, "<u>"); + srt_stack_push(s, 'u'); + } + if (st->alignment != ASS_DEFAULT_ALIGNMENT) { + srt_print(s, "{\\an%d}", st->alignment); + s->alignment_applied = 1; + } + } +} + + +static av_cold int srt_encode_init(AVCodecContext *avctx) +{ + SRTContext *s = avctx->priv_data; + s->avctx = avctx; + s->ass_ctx = ff_ass_split(avctx->subtitle_header); + return s->ass_ctx ? 0 : AVERROR_INVALIDDATA; +} + +static void srt_text_cb(void *priv, const char *text, int len) +{ + SRTContext *s = priv; + av_strlcpy(s->ptr, text, FFMIN(s->end-s->ptr, len+1)); + s->ptr += len; +} + +static void srt_new_line_cb(void *priv, int forced) +{ + srt_print(priv, "\r\n"); +} + +static void srt_style_cb(void *priv, char style, int close) +{ + srt_stack_push_pop(priv, style, close); + if (!close) + srt_print(priv, "<%c>", style); +} + +static void srt_color_cb(void *priv, unsigned int color, unsigned int color_id) +{ + if (color_id > 1) + return; + srt_stack_push_pop(priv, 'f', color == 0xFFFFFFFF); + if (color != 0xFFFFFFFF) + srt_print(priv, "<font color=\"#%06x\">", + (color & 0xFF0000) >> 16 | color & 0xFF00 | (color & 0xFF) << 16); +} + +static void srt_font_name_cb(void *priv, const char *name) +{ + srt_stack_push_pop(priv, 'f', !name); + if (name) + srt_print(priv, "<font face=\"%s\">", name); +} + +static void srt_font_size_cb(void *priv, int size) +{ + srt_stack_push_pop(priv, 'f', size < 0); + if (size >= 0) + srt_print(priv, "<font size=\"%d\">", size); +} + +static void srt_alignment_cb(void *priv, int alignment) +{ + SRTContext *s = priv; + if (!s->alignment_applied && alignment >= 0) { + srt_print(s, "{\\an%d}", alignment); + s->alignment_applied = 1; + } +} + +static void srt_cancel_overrides_cb(void *priv, const char *style) +{ + srt_stack_push_pop(priv, 0, 1); + srt_style_apply(priv, style); +} + +static void srt_move_cb(void *priv, int x1, int y1, int x2, int y2, + int t1, int t2) +{ + SRTContext *s = priv; + char buffer[32]; + int len = snprintf(buffer, sizeof(buffer), + " X1:%03u X2:%03u Y1:%03u Y2:%03u", x1, x2, y1, y2); + if (s->end - s->ptr > len) { + memmove(s->dialog_start+len, s->dialog_start, s->ptr-s->dialog_start+1); + memcpy(s->dialog_start, buffer, len); + s->ptr += len; + } +} + +static void srt_end_cb(void *priv) +{ + srt_stack_push_pop(priv, 0, 1); + srt_print(priv, "\r\n\r\n"); +} + +static const ASSCodesCallbacks srt_callbacks = { + .text = srt_text_cb, + .new_line = srt_new_line_cb, + .style = srt_style_cb, + .color = srt_color_cb, + .font_name = srt_font_name_cb, + .font_size = srt_font_size_cb, + .alignment = srt_alignment_cb, + .cancel_overrides = srt_cancel_overrides_cb, + .move = srt_move_cb, + .end = srt_end_cb, +}; + +static int srt_encode_frame(AVCodecContext *avctx, + unsigned char *buf, int bufsize, void *data) +{ + SRTContext *s = avctx->priv_data; + AVSubtitle *sub = data; + ASSDialog *dialog; + int i, len, num; + + s->ptr = s->buffer; + s->end = s->ptr + sizeof(s->buffer); + + for (i=0; i<sub->num_rects; i++) { + + if (sub->rects[i]->type != SUBTITLE_ASS) { + av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n"); + return AVERROR(ENOSYS); + } + + dialog = ff_ass_split_dialog(s->ass_ctx, sub->rects[i]->ass, 0, &num); + for (; dialog && num--; dialog++) { + int sh, sm, ss, sc = 10 * dialog->start; + int eh, em, es, ec = 10 * dialog->end; + sh = sc/3600000; sc -= 3600000*sh; + sm = sc/ 60000; sc -= 60000*sm; + ss = sc/ 1000; sc -= 1000*ss; + eh = ec/3600000; ec -= 3600000*eh; + em = ec/ 60000; ec -= 60000*em; + es = ec/ 1000; ec -= 1000*es; + srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n", + ++s->count, sh, sm, ss, sc, eh, em, es, ec); + s->alignment_applied = 0; + s->dialog_start = s->ptr - 2; + srt_style_apply(s, dialog->style); + ff_ass_split_override_codes(&srt_callbacks, s, dialog->text); + } + } + + if (s->ptr == s->buffer) + return 0; + + len = av_strlcpy(buf, s->buffer, bufsize); + + if (len > bufsize-1) { + av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); + return -1; + } + + return len; +} + +static int srt_encode_close(AVCodecContext *avctx) +{ + SRTContext *s = avctx->priv_data; + ff_ass_split_free(s->ass_ctx); + return 0; +} + +AVCodec ff_srt_encoder = { + .name = "srt", + .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_SRT, + .priv_data_size = sizeof(SRTContext), + .init = srt_encode_init, + .encode = srt_encode_frame, + .close = srt_encode_close, +}; diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index cadffdf1b8..558b0edd8f 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -2,20 +2,20 @@ * Sun Rasterfile (.sun/.ras/im{1,8,24}/.sunras) image decoder * Copyright (c) 2007, 2008 Ivo van Poorten * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/svq1.c b/libavcodec/svq1.c index b7e3af0a28..d0e113267b 100644 --- a/libavcodec/svq1.c +++ b/libavcodec/svq1.c @@ -8,20 +8,20 @@ * * SVQ1 Encoder (c) 2004 Mike Melanson <melanson@pcisys.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/svq1.h b/libavcodec/svq1.h index 066ea47fb6..3ade05d848 100644 --- a/libavcodec/svq1.h +++ b/libavcodec/svq1.h @@ -8,20 +8,20 @@ * * SVQ1 Encoder (c) 2004 Mike Melanson <melanson@pcisys.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/svq1_cb.h b/libavcodec/svq1_cb.h index e22cd60e23..7926ce1377 100644 --- a/libavcodec/svq1_cb.h +++ b/libavcodec/svq1_cb.h @@ -6,20 +6,20 @@ * Copyright (C) 2002 the xine project * Copyright (C) 2002 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/svq1_vlc.h b/libavcodec/svq1_vlc.h index 4d03b081ea..272597e1e0 100644 --- a/libavcodec/svq1_vlc.h +++ b/libavcodec/svq1_vlc.h @@ -1,20 +1,20 @@ /* * copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index 2a80374569..f2690fbf33 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -8,20 +8,20 @@ * * SVQ1 Encoder (c) 2004 Mike Melanson <melanson@pcisys.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -141,7 +141,7 @@ static const uint8_t string_table[256] = { break;\ /* add child nodes */\ list[n++] = list[i];\ - list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level / 2) + 1));\ + list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level >> 1) + 1));\ } #define SVQ1_ADD_CODEBOOK()\ @@ -201,7 +201,7 @@ static const uint8_t string_table[256] = { entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);\ }\ mean -= (stages * 128);\ - n4 = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF); + n4 = (mean << 16) + mean; static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch ) { uint32_t bit_cache; diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index fbeca803f0..edd6029209 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -2,20 +2,20 @@ * SVQ1 Encoder * Copyright (C) 2004 Mike Melanson <melanson@pcisys.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/svq1enc_cb.h b/libavcodec/svq1enc_cb.h index 1c86ebeb98..7eff82ee1f 100644 --- a/libavcodec/svq1enc_cb.h +++ b/libavcodec/svq1enc_cb.h @@ -2,20 +2,20 @@ * SVQ1 Encoder * Copyright (C) 2004 Mike Melanson <melanson@pcisys.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 7cde5e5552..9fec0350d2 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -1,20 +1,20 @@ /* - * Copyright (c) 2003 The Libav Project + * Copyright (c) 2003 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -37,7 +37,7 @@ * * You will know you have these parameters passed correctly when the decoder * correctly decodes this file: - * http://samples.libav.org/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov + * http://samples.mplayerhq.hu/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov */ #include "internal.h" #include "dsputil.h" @@ -70,6 +70,8 @@ typedef struct { int unknown_flag; int next_slice_index; uint32_t watermark_key; + uint8_t *buf; + int buf_size; } SVQ3Context; #define FULLPEL_MODE 1 @@ -823,6 +825,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) svq3->thirdpel_flag = 1; svq3->unknown_flag = 0; + /* prowl for the "SEQH" marker in the extradata */ extradata = (unsigned char *)avctx->extradata; for (m = 0; m < avctx->extradata_size; m++) { @@ -928,12 +931,12 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; SVQ3Context *svq3 = avctx->priv_data; H264Context *h = &svq3->h; MpegEncContext *s = &h->s; int buf_size = avpkt->size; - int m, mb_type; + int m, mb_type, left; + uint8_t *buf; /* special case for last picture */ if (buf_size == 0) { @@ -945,10 +948,21 @@ static int svq3_decode_frame(AVCodecContext *avctx, return 0; } - init_get_bits (&s->gb, buf, 8*buf_size); - s->mb_x = s->mb_y = h->mb_xy = 0; + if (svq3->watermark_key) { + av_fast_malloc(&svq3->buf, &svq3->buf_size, + buf_size+FF_INPUT_BUFFER_PADDING_SIZE); + if (!svq3->buf) + return AVERROR(ENOMEM); + memcpy(svq3->buf, avpkt->data, buf_size); + buf = svq3->buf; + } else { + buf = avpkt->data; + } + + init_get_bits(&s->gb, buf, 8*buf_size); + if (svq3_decode_slice_header(avctx)) return -1; @@ -1055,6 +1069,18 @@ static int svq3_decode_frame(AVCodecContext *avctx, ff_draw_horiz_band(s, 16*s->mb_y, 16); } + left = buf_size*8 - get_bits_count(&s->gb); + + if (s->mb_y != s->mb_height || s->mb_x != s->mb_width) { + av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, s->mb_y, s->mb_x, left); + //av_hex_dump(stderr, buf+buf_size-8, 8); + } + + if (left < 0) { + av_log(avctx, AV_LOG_ERROR, "frame num %d left %d\n", avctx->frame_number, left); + return -1; + } + MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { @@ -1081,6 +1107,9 @@ static int svq3_decode_end(AVCodecContext *avctx) MPV_common_end(s); + av_freep(&svq3->buf); + svq3->buf_size = 0; + return 0; } diff --git a/libavcodec/synth_filter.c b/libavcodec/synth_filter.c index 8e6f1202fe..5f10530974 100644 --- a/libavcodec/synth_filter.c +++ b/libavcodec/synth_filter.c @@ -1,20 +1,20 @@ /* * copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/synth_filter.h b/libavcodec/synth_filter.h index 7b73578f68..33edcc437f 100644 --- a/libavcodec/synth_filter.h +++ b/libavcodec/synth_filter.h @@ -1,20 +1,20 @@ /* * copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index ddf2635da0..d81b9a387b 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -3,20 +3,20 @@ * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/targa.c b/libavcodec/targa.c index e57fd8ba65..41741ff9c5 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -2,20 +2,20 @@ * Targa (.tga) image decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -189,10 +189,10 @@ static int decode_frame(AVCodecContext *avctx, int r, g, b, t; int32_t *pal = ((int32_t*)p->data[1]) + first_clr; for(t = 0; t < colors; t++){ - r = *buf++; - g = *buf++; b = *buf++; - *pal++ = (b << 16) | (g << 8) | r; + g = *buf++; + r = *buf++; + *pal++ = (0xff<<24) | (r << 16) | (g << 8) | b; } p->palette_has_changed = 1; } diff --git a/libavcodec/targa.h b/libavcodec/targa.h index f4ef5537b1..158a5ea0f4 100644 --- a/libavcodec/targa.h +++ b/libavcodec/targa.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c index 276bcc83eb..1171f605a2 100644 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@ -2,20 +2,20 @@ * Targa (.tga) image encoder * Copyright (c) 2007 Bobby Bingham * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/thread.h b/libavcodec/thread.h index 401c4d25a8..9cfb31d5a1 100644 --- a/libavcodec/thread.h +++ b/libavcodec/thread.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2008 Alexander Strange <astrange@ithinksw.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index 4468f00df1..f3a044882e 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -2,20 +2,20 @@ * Tiertex Limited SEQ Video Decoder * Copyright (c) 2006 Gregory Montoir (cyx@users.sourceforge.net) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -180,6 +180,7 @@ static av_cold int seqvideo_decode_init(AVCodecContext *avctx) seq->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&seq->frame); seq->frame.data[0] = NULL; return 0; diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 08cd3b0a6f..c54eaee346 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1,28 +1,26 @@ /* - * TIFF image decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** - * TIFF image decoder * @file - * @author Konstantin Shishkov + * TIFF image decoder */ #include "avcodec.h" #if CONFIG_ZLIB @@ -457,7 +455,8 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t * bp = buf + count / 3 * off * 2; off = (type_sizes[type] - 1) << 3; for(i = 0; i < count / 3; i++){ - j = (tget(&rp, type, s->le) >> off) << 16; + j = 0xff << 24; + j |= (tget(&rp, type, s->le) >> off) << 16; j |= (tget(&gp, type, s->le) >> off) << 8; j |= tget(&bp, type, s->le) >> off; pal[i] = j; diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h index cd7ec830e7..e1aca68e35 100644 --- a/libavcodec/tiff.h +++ b/libavcodec/tiff.h @@ -1,31 +1,33 @@ /* - * TIFF tables * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * 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_TIFF_H +#define AVCODEC_TIFF_H + /** - * TIFF tables * @file - * @author Konstantin Shishkov + * TIFF tables + * + * For more information about the TIFF format, check the official docs at: + * http://partners.adobe.com/public/developer/tiff/index.html */ -#ifndef AVCODEC_TIFF_H -#define AVCODEC_TIFF_H #include <stdint.h> diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 5cff13bca0..f7228f128f 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -2,20 +2,20 @@ * TIFF image encoder * Copyright (c) 2007 Bartlomiej Wolowiec * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -210,7 +210,7 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, uint32_t *strip_offsets = NULL; int bytes_per_row; uint32_t res[2] = { 72, 1 }; // image resolution (72/1) - static const uint16_t bpp_tab[] = { 8, 8, 8, 8 }; + uint16_t bpp_tab[] = { 8, 8, 8, 8 }; int ret = -1; int is_yuv = 0; uint8_t *yuv_line = NULL; @@ -255,12 +255,10 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, s->photometric_interpretation = 3; break; case PIX_FMT_MONOBLACK: - s->bpp = 1; - s->photometric_interpretation = 1; - break; case PIX_FMT_MONOWHITE: s->bpp = 1; - s->photometric_interpretation = 0; + s->photometric_interpretation = avctx->pix_fmt == PIX_FMT_MONOBLACK; + bpp_tab[0] = 1; break; case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: @@ -282,7 +280,7 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, return -1; } if (!is_yuv) - s->bpp_tab_size = (s->bpp >> 3); + s->bpp_tab_size = ((s->bpp + 7) >> 3); if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || s->compr == TIFF_LZW) //best choose for DEFLATE diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c index 80f3ac9cbc..b1083fe682 100644 --- a/libavcodec/tmv.c +++ b/libavcodec/tmv.c @@ -2,20 +2,20 @@ * 8088flex TMV video decoder * Copyright (c) 2009 Daniel Verkamp <daniel at drv.nu> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -34,6 +34,14 @@ typedef struct TMVContext { AVFrame pic; } TMVContext; +static av_cold int tmv_decode_init(AVCodecContext *avctx) +{ + TMVContext *tmv = avctx->priv_data; + + avcodec_get_frame_defaults(&tmv->pic); + return 0; +} + static int tmv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { @@ -97,6 +105,7 @@ AVCodec ff_tmv_decoder = { .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_TMV, .priv_data_size = sizeof(TMVContext), + .init = tmv_decode_init, .close = tmv_decode_close, .decode = tmv_decode_frame, .capabilities = CODEC_CAP_DR1, diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 97330d1bb4..284dbd8e12 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -2,20 +2,20 @@ * Duck TrueMotion 1.0 Decoder * Copyright (C) 2003 Alex Beregszaszi & Mike Melanson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -474,6 +474,7 @@ static av_cold int truemotion1_decode_init(AVCodecContext *avctx) // else // avctx->pix_fmt = PIX_FMT_RGB555; + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; /* there is a vertical predictor for each pixel in a line; each vertical diff --git a/libavcodec/truemotion1data.h b/libavcodec/truemotion1data.h index c94e3b5add..6a9822a3cc 100644 --- a/libavcodec/truemotion1data.h +++ b/libavcodec/truemotion1data.h @@ -6,20 +6,20 @@ * GNU LGPL using the common understanding that data tables necessary for * decoding algorithms are not necessarily licensable. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * 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_TRUEMOTION1DATA_H diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index 23abade214..2b9a0cba72 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -2,20 +2,20 @@ * Duck/ON2 TrueMotion 2 Decoder * Copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -64,7 +64,7 @@ typedef struct TM2Context{ * Huffman codes for each of streams */ typedef struct TM2Codes{ - VLC vlc; ///< table for Libav bitstream reader + VLC vlc; ///< table for FFmpeg bitstream reader int bits; int *recode; ///< table for converting from code indexes to values int length; @@ -817,6 +817,7 @@ static av_cold int decode_init(AVCodecContext *avctx){ l->avctx = avctx; l->pic.data[0]=NULL; avctx->pix_fmt = PIX_FMT_BGR24; + avcodec_get_frame_defaults(&l->pic); dsputil_init(&l->dsp, avctx); diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index df9d918fd7..d903a0119e 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -2,20 +2,20 @@ * DSP Group TrueSpeech compatible decoder * Copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/truespeech_data.h b/libavcodec/truespeech_data.h index 6e9806a0b5..73ebda5e85 100644 --- a/libavcodec/truespeech_data.h +++ b/libavcodec/truespeech_data.h @@ -2,20 +2,20 @@ * DSP Group TrueSpeech compatible decoder * copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index 772906aba6..bc57ec74cb 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -2,20 +2,20 @@ * TechSmith Camtasia decoder * Copyright (c) 2004 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -142,6 +142,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->height = avctx->height; + avcodec_get_frame_defaults(&c->pic); // Needed if zlib unused or init aborted before inflateInit memset(&(c->zstream), 0, sizeof(z_stream)); switch(avctx->bits_per_coded_sample){ diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 57f5818d7b..dccca46132 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -2,20 +2,20 @@ * TTA (The Lossless True Audio) decoder * Copyright (c) 2006 Alex Beregszaszi * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -205,6 +205,16 @@ static int tta_get_unary(GetBitContext *gb) return ret; } +static const int64_t tta_channel_layouts[7] = { + AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY, + AV_CH_LAYOUT_QUAD, + 0, + AV_CH_LAYOUT_5POINT1_BACK, + AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER, + AV_CH_LAYOUT_7POINT1_WIDE +}; + static av_cold int tta_decode_init(AVCodecContext * avctx) { TTAContext *s = avctx->priv_data; @@ -234,6 +244,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) } s->is_float = (s->flags == FORMAT_FLOAT); avctx->channels = s->channels = get_bits(&s->gb, 16); + if (s->channels > 1 && s->channels < 9) + avctx->channel_layout = tta_channel_layouts[s->channels-2]; avctx->bits_per_coded_sample = get_bits(&s->gb, 16); s->bps = (avctx->bits_per_coded_sample + 7) / 8; avctx->sample_rate = get_bits_long(&s->gb, 32); @@ -251,9 +263,9 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) return -1; } else switch(s->bps) { -// case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break; + case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break; case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; break; -// case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S24; break; + case 3: avctx->bits_per_coded_sample = 24; case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break; default: av_log_ask_for_sample(s->avctx, @@ -286,6 +298,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) } s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels); + if (!s->decode_buffer) + return AVERROR(ENOMEM); s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx)); if (!s->ch_ctx) return AVERROR(ENOMEM); @@ -311,7 +325,7 @@ static int tta_decode_frame(AVCodecContext *avctx, int cur_chan = 0, framelen = s->frame_length; int32_t *p; - if (*data_size < (framelen * s->channels * 2)) { + if (*data_size < (framelen * s->channels * av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8)) { av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n"); return -1; } @@ -428,6 +442,13 @@ static int tta_decode_frame(AVCodecContext *avctx, // convert to output buffer switch(s->bps) { + case 1: { + uint8_t *samples = data; + for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) + *samples++ = *p + 0x80; + *data_size = samples - (uint8_t *)data; + break; + } case 2: { uint16_t *samples = data; for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { @@ -438,6 +459,13 @@ static int tta_decode_frame(AVCodecContext *avctx, *data_size = (uint8_t *)samples - (uint8_t *)data; break; } + case 3: { + int32_t *samples = data; + for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) + *samples++ = AV_RN32(p) << 8; + *data_size = (uint8_t *)samples - (uint8_t *)data; + break; + } default: av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n"); } diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 985f71c8ca..f8e75bb933 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -2,20 +2,20 @@ * TwinVQ decoder * Copyright (c) 2009 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/twinvq_data.h b/libavcodec/twinvq_data.h index 1f1f33408e..3042cd1beb 100644 --- a/libavcodec/twinvq_data.h +++ b/libavcodec/twinvq_data.h @@ -2,20 +2,20 @@ * TwinVQ decoder * Copyright (c) 2009 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/txd.c b/libavcodec/txd.c index e91b4fbaf3..0e25458c86 100644 --- a/libavcodec/txd.c +++ b/libavcodec/txd.c @@ -4,20 +4,20 @@ * * See also: http://wiki.multimedia.cx/index.php?title=TXD * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index 9a73c627a9..9033cee98f 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -2,20 +2,20 @@ * IBM Ultimotion Video Decoder * Copyright (C) 2004 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -49,6 +49,7 @@ static av_cold int ulti_decode_init(AVCodecContext *avctx) s->height = avctx->height; s->blocks = (s->width / 8) * (s->height / 8); avctx->pix_fmt = PIX_FMT_YUV410P; + avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = (AVFrame*) &s->frame; s->ulti_codebook = ulti_codebook; diff --git a/libavcodec/ulti_cb.h b/libavcodec/ulti_cb.h index 0bd83ffd37..7061d839a8 100644 --- a/libavcodec/ulti_cb.h +++ b/libavcodec/ulti_cb.h @@ -2,20 +2,20 @@ * IBM Ultimotion Video Decoder * copyright (C) 2004 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/unary.h b/libavcodec/unary.h index d14929f797..908dc93507 100644 --- a/libavcodec/unary.h +++ b/libavcodec/unary.h @@ -1,20 +1,20 @@ /* * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1e5886473d..922decf3fb 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -3,20 +3,20 @@ * Copyright (c) 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -343,9 +343,18 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ } s->internal_buffer_count++; - if(s->pkt) pic->pkt_pts= s->pkt->pts; - else pic->pkt_pts= AV_NOPTS_VALUE; + if (s->pkt) { + pic->pkt_pts = s->pkt->pts; + pic->pkt_pos = s->pkt->pos; + } else { + pic->pkt_pts = AV_NOPTS_VALUE; + pic->pkt_pos = -1; + } pic->reordered_opaque= s->reordered_opaque; + pic->sample_aspect_ratio = s->sample_aspect_ratio; + pic->width = s->width; + pic->height = s->height; + pic->format = s->pix_fmt; if(s->debug&FF_DEBUG_BUFFERS) av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); @@ -449,8 +458,11 @@ enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum void avcodec_get_frame_defaults(AVFrame *pic){ memset(pic, 0, sizeof(AVFrame)); - pic->pts= AV_NOPTS_VALUE; + pic->pts = pic->best_effort_timestamp = AV_NOPTS_VALUE; + pic->pkt_pos = -1; pic->key_frame= 1; + pic->sample_aspect_ratio = (AVRational){0, 1}; + pic->format = -1; /* unknown */ } AVFrame *avcodec_alloc_frame(void){ @@ -463,6 +475,12 @@ AVFrame *avcodec_alloc_frame(void){ return pic; } +static void avcodec_get_subtitle_defaults(AVSubtitle *sub) +{ + memset(sub, 0, sizeof(*sub)); + sub->pts = AV_NOPTS_VALUE; +} + int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) { int ret = 0; @@ -545,7 +563,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) } } - if (avctx->codec->max_lowres < avctx->lowres) { + if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) { av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n", avctx->codec->max_lowres); ret = AVERROR(EINVAL); @@ -598,12 +616,19 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) } } + avctx->pts_correction_num_faulty_pts = + avctx->pts_correction_num_faulty_dts = 0; + avctx->pts_correction_last_pts = + avctx->pts_correction_last_dts = INT64_MIN; + if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){ ret = avctx->codec->init(avctx); if (ret < 0) { goto free_and_end; } } + + ret=0; end: entangled_thread_counter--; @@ -660,13 +685,44 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n"); return -1; } - if(sub->num_rects == 0 || !sub->rects) - return -1; + ret = avctx->codec->encode(avctx, buf, buf_size, sub); avctx->frame_number++; return ret; } +/** + * Attempt to guess proper monotonic timestamps for decoded video frames + * which might have incorrect times. Input timestamps may wrap around, in + * which case the output will as well. + * + * @param pts the pts field of the decoded AVPacket, as passed through + * AVFrame.pkt_pts + * @param dts the dts field of the decoded AVPacket + * @return one of the input values, may be AV_NOPTS_VALUE + */ +static int64_t guess_correct_pts(AVCodecContext *ctx, + int64_t reordered_pts, int64_t dts) +{ + int64_t pts = AV_NOPTS_VALUE; + + if (dts != AV_NOPTS_VALUE) { + ctx->pts_correction_num_faulty_dts += dts <= ctx->pts_correction_last_dts; + ctx->pts_correction_last_dts = dts; + } + if (reordered_pts != AV_NOPTS_VALUE) { + ctx->pts_correction_num_faulty_pts += reordered_pts <= ctx->pts_correction_last_pts; + ctx->pts_correction_last_pts = reordered_pts; + } + if ((ctx->pts_correction_num_faulty_pts<=ctx->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE) + && reordered_pts != AV_NOPTS_VALUE) + pts = reordered_pts; + else + pts = dts; + + return pts; +} + int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) @@ -677,9 +733,9 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx)) return -1; - avctx->pkt = avpkt; - if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){ + av_packet_split_side_data(avpkt); + avctx->pkt = avpkt; if (HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr, avpkt); @@ -687,12 +743,30 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi ret = avctx->codec->decode(avctx, picture, got_picture_ptr, avpkt); picture->pkt_dts= avpkt->dts; + + if(!avctx->has_b_frames){ + picture->pkt_pos= avpkt->pos; + } + //FIXME these should be under if(!avctx->has_b_frames) + if (!picture->sample_aspect_ratio.num) + picture->sample_aspect_ratio = avctx->sample_aspect_ratio; + if (!picture->width) + picture->width = avctx->width; + if (!picture->height) + picture->height = avctx->height; + if (picture->format == PIX_FMT_NONE) + picture->format = avctx->pix_fmt; } emms_c(); //needed to avoid an emms_c() call before every return; - if (*got_picture_ptr) + + if (*got_picture_ptr){ avctx->frame_number++; + picture->best_effort_timestamp = guess_correct_pts(avctx, + picture->pkt_pts, + picture->pkt_dts); + } }else ret= 0; @@ -736,6 +810,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, avctx->pkt = avpkt; *got_sub_ptr = 0; + avcodec_get_subtitle_defaults(sub); ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt); if (*got_sub_ptr) avctx->frame_number++; @@ -832,14 +907,18 @@ AVCodec *avcodec_find_encoder_by_name(const char *name) AVCodec *avcodec_find_decoder(enum CodecID id) { - AVCodec *p; + AVCodec *p, *experimental=NULL; p = first_avcodec; while (p) { - if (p->decode != NULL && p->id == id) - return p; + if (p->decode != NULL && p->id == id) { + if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { + experimental = p; + } else + return p; + } p = p->next; } - return NULL; + return experimental; } AVCodec *avcodec_find_decoder_by_name(const char *name) @@ -1030,13 +1109,13 @@ unsigned avcodec_version( void ) const char *avcodec_configuration(void) { - return LIBAV_CONFIGURATION; + return FFMPEG_CONFIGURATION; } const char *avcodec_license(void) { #define LICENSE_PREFIX "libavcodec license: " - return LICENSE_PREFIX LIBAV_LICENSE + sizeof(LICENSE_PREFIX) - 1; + return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; } void avcodec_init(void) @@ -1163,7 +1242,7 @@ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){ void av_log_missing_feature(void *avc, const char *feature, int want_sample) { - av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your Libav " + av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg " "version to the newest one from Git. If the problem still " "occurs, it means that your file has a feature which has not " "been implemented.\n", feature); @@ -1180,8 +1259,8 @@ void av_log_ask_for_sample(void *avc, const char *msg, ...) if (msg) av_vlog(avc, AV_LOG_WARNING, msg, argument_list); av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample " - "of this file to ftp://upload.libav.org/incoming/ " - "and contact the libav-devel mailing list.\n"); + "of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ " + "and contact the ffmpeg-devel mailing list.\n"); va_end(argument_list); } diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index f4ea65cb96..94c5b5bb26 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -4,20 +4,20 @@ * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,7 +30,7 @@ static av_cold int decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n"); return -1; } - avctx->pix_fmt = PIX_FMT_YUV422P16; + avctx->pix_fmt = PIX_FMT_YUV422P10; avctx->bits_per_raw_sample = 10; avctx->coded_frame = avcodec_alloc_frame(); @@ -68,10 +68,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, #define READ_PIXELS(a, b, c) \ do { \ - val = av_le2ne32(*src++); \ - *a++ = val << 6; \ - *b++ = (val >> 4) & 0xFFC0; \ - *c++ = (val >> 14) & 0xFFC0; \ + val = av_le2ne32(*src++); \ + *a++ = val & 0x3FF; \ + *b++ = (val >> 10) & 0x3FF; \ + *c++ = (val >> 20) & 0x3FF; \ } while (0) for (h = 0; h < avctx->height; h++) { @@ -87,15 +87,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, READ_PIXELS(u, y, v); val = av_le2ne32(*src++); - *y++ = val << 6; + *y++ = val & 0x3FF; } if (w < avctx->width - 3) { - *u++ = (val >> 4) & 0xFFC0; - *y++ = (val >> 14) & 0xFFC0; + *u++ = (val >> 10) & 0x3FF; + *y++ = (val >> 20) & 0x3FF; val = av_le2ne32(*src++); - *v++ = val << 6; - *y++ = (val >> 4) & 0xFFC0; + *v++ = val & 0x3FF; + *y++ = (val >> 10) & 0x3FF; } psrc += stride; diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index 8b022fa8f8..fd47d7a5e7 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -4,20 +4,20 @@ * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -31,8 +31,8 @@ static av_cold int encode_init(AVCodecContext *avctx) return -1; } - if (avctx->pix_fmt != PIX_FMT_YUV422P16) { - av_log(avctx, AV_LOG_ERROR, "v210 needs YUV422P16\n"); + if (avctx->pix_fmt != PIX_FMT_YUV422P10) { + av_log(avctx, AV_LOG_ERROR, "v210 needs YUV422P10\n"); return -1; } @@ -66,11 +66,13 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, return -1; } +#define CLIP(v) av_clip(v, 4, 1019) + #define WRITE_PIXELS(a, b, c) \ do { \ - val = (*a++ >> 6) | \ - ((*b++ & 0xFFC0) << 4); \ - val|= (*c++ & 0xFFC0) << 14; \ + val = CLIP(*a++); \ + val |= (CLIP(*b++) << 10) | \ + (CLIP(*c++) << 20); \ bytestream_put_le32(&p, val); \ } while (0) @@ -85,17 +87,15 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, if (w < avctx->width - 1) { WRITE_PIXELS(u, y, v); - val = *y++ >> 6; + val = CLIP(*y++); if (w == avctx->width - 2) bytestream_put_le32(&p, val); } if (w < avctx->width - 3) { - val |=((*u++ & 0xFFC0) << 4) | - ((*y++ & 0xFFC0) << 14); + val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20); bytestream_put_le32(&p, val); - val = (*v++ >> 6) | - (*y++ & 0xFFC0) << 4; + val = CLIP(*v++) | (CLIP(*y++) << 10); bytestream_put_le32(&p, val); } @@ -125,6 +125,6 @@ AVCodec ff_v210_encoder = { encode_init, encode_frame, encode_close, - .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P16, PIX_FMT_NONE}, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P10, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), }; diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c index e3b1a3c684..64954cb6bb 100644 --- a/libavcodec/v210x.c +++ b/libavcodec/v210x.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c index cc2fec365c..de028a0a7e 100644 --- a/libavcodec/vaapi.c +++ b/libavcodec/vaapi.c @@ -4,20 +4,20 @@ * * Copyright (C) 2008-2009 Splitted-Desktop Systems * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vaapi.h b/libavcodec/vaapi.h index 306e164b88..07568a47fc 100644 --- a/libavcodec/vaapi.h +++ b/libavcodec/vaapi.h @@ -1,23 +1,23 @@ /* - * Video Acceleration API (shared data between Libav and the video player) + * Video Acceleration API (shared data between FFmpeg and the video player) * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1 * * Copyright (C) 2008-2009 Splitted-Desktop Systems * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -33,7 +33,7 @@ */ /** - * This structure is used to share data between the Libav library and + * This structure is used to share data between the FFmpeg library and * the client video application. * This shall be zero-allocated and available as * AVCodecContext.hwaccel_context. All user members can be set once diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c index 83bf2907de..922dc86963 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -3,20 +3,20 @@ * * Copyright (C) 2008-2009 Splitted-Desktop Systems * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -24,7 +24,7 @@ #include "h264.h" /** @file - * This file implements the glue code between Libav's and VA API's + * This file implements the glue code between FFmpeg's and VA API's * structures for H.264 decoding. */ @@ -42,10 +42,10 @@ static void init_vaapi_pic(VAPictureH264 *va_pic) } /** - * Translate an Libav Picture into its VA API form. + * Translate an FFmpeg Picture into its VA API form. * * @param[out] va_pic A pointer to VA API's own picture struct - * @param[in] pic A pointer to the Libav picture struct to convert + * @param[in] pic A pointer to the FFmpeg picture struct to convert * @param[in] pic_structure The picture field type (as defined in mpegvideo.h), * supersedes pic's field type if nonzero. */ @@ -146,11 +146,11 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, } /** - * Fill in VA API reference picture lists from the Libav reference + * Fill in VA API reference picture lists from the FFmpeg reference * picture list. * * @param[out] RefPicList VA API internal reference picture list - * @param[in] ref_list A pointer to the Libav reference list + * @param[in] ref_list A pointer to the FFmpeg reference list * @param[in] ref_count The number of reference pictures in ref_list */ static void fill_vaapi_RefPicList(VAPictureH264 RefPicList[32], @@ -258,7 +258,7 @@ static int start_frame(AVCodecContext *avctx, pic_param->seq_fields.bits.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; pic_param->num_slice_groups_minus1 = h->pps.slice_group_count - 1; pic_param->slice_group_map_type = h->pps.mb_slice_group_map_type; - pic_param->slice_group_change_rate_minus1 = 0; /* XXX: unimplemented in Libav */ + pic_param->slice_group_change_rate_minus1 = 0; /* XXX: unimplemented in FFmpeg */ pic_param->pic_init_qp_minus26 = h->pps.init_qp - 26; pic_param->pic_init_qs_minus26 = h->pps.init_qs - 26; pic_param->chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; diff --git a/libavcodec/vaapi_internal.h b/libavcodec/vaapi_internal.h index 3a14a2b969..2c0fdf945e 100644 --- a/libavcodec/vaapi_internal.h +++ b/libavcodec/vaapi_internal.h @@ -4,20 +4,20 @@ * * Copyright (C) 2008-2009 Splitted-Desktop Systems * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c index 561f4bf800..6c92a0ff72 100644 --- a/libavcodec/vaapi_mpeg2.c +++ b/libavcodec/vaapi_mpeg2.c @@ -3,20 +3,20 @@ * * Copyright (C) 2008-2009 Splitted-Desktop Systems * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -109,7 +109,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer MpegEncContext * const s = avctx->priv_data; VASliceParameterBufferMPEG2 *slice_param; GetBitContext gb; - uint32_t start_code, quantiser_scale_code, intra_slice_flag, macroblock_offset; + uint32_t start_code av_unused, quantiser_scale_code, intra_slice_flag, macroblock_offset; av_dlog(avctx, "vaapi_mpeg2_decode_slice(): buffer %p, size %d\n", buffer, size); diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index fcd429086e..cff77740c2 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -3,20 +3,20 @@ * * Copyright (C) 2008-2009 Splitted-Desktop Systems * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -129,7 +129,7 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer /* video_plane_with_short_video_header() contains all GOBs * in-order, and this is what VA API (Intel backend) expects: only - * a single slice param. So fake macroblock_number for Libav so + * a single slice param. So fake macroblock_number for FFmpeg so * that we don't call vaapi_mpeg4_decode_slice() again */ if (avctx->codec->id == CODEC_ID_H263) diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index 19865dc0e8..d4d76c815f 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -3,20 +3,20 @@ * * Copyright (C) 2008-2009 Splitted-Desktop Systems * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -24,7 +24,7 @@ #include "vc1.h" #include "vc1data.h" -/** Translate Libav MV modes to VA API */ +/** Translate FFmpeg MV modes to VA API */ static int get_VAMvModeVC1(enum MVModes mv_mode) { switch (mv_mode) { @@ -116,7 +116,7 @@ static inline VAMvModeVC1 vc1_get_MVMODE2(VC1Context *v) return 0; } -/** Pack Libav bitplanes into a VABitPlaneBuffer element */ +/** Pack FFmpeg bitplanes into a VABitPlaneBuffer element */ static inline void vc1_pack_bitplanes(uint8_t *bitplane, int n, const uint8_t *ff_bp[3], int x, int y, int stride) { const int bitplane_index = n / 2; diff --git a/libavcodec/vb.c b/libavcodec/vb.c index fb37283764..3fb59cf377 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -2,20 +2,20 @@ * Beam Software VB decoder * Copyright (c) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -268,6 +268,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&c->pic); c->frame = av_mallocz(avctx->width * avctx->height); c->prev_frame = av_mallocz(avctx->width * avctx->height); diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 7b878c18d7..e062a35cc1 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -3,20 +3,20 @@ * Copyright (c) 2006-2007 Konstantin Shishkov * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -830,7 +830,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) v->rptfrm = get_bits(gb, 2); } else { v->tff = get_bits1(gb); - v->rptfrm = get_bits1(gb); + v->rff = get_bits1(gb); } } if(v->panscanflag) { diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index 96e5744228..6d4c0aa7a3 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -3,20 +3,20 @@ * Copyright (c) 2006-2007 Konstantin Shishkov * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c index 27ff1bdaa3..4ea9c47076 100644 --- a/libavcodec/vc1_parser.c +++ b/libavcodec/vc1_parser.c @@ -3,20 +3,20 @@ * Copyright (c) 2006-2007 Konstantin Shishkov * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vc1acdata.h b/libavcodec/vc1acdata.h index a7a33ff805..78de0f9a24 100644 --- a/libavcodec/vc1acdata.h +++ b/libavcodec/vc1acdata.h @@ -2,20 +2,20 @@ * VC-1 and WMV3 decoder * copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c index 1cbf93e224..5298079448 100644 --- a/libavcodec/vc1data.c +++ b/libavcodec/vc1data.c @@ -3,20 +3,20 @@ * copyright (c) 2006 Konstantin Shishkov * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h index 1ccc9bbf6e..934627a781 100644 --- a/libavcodec/vc1data.h +++ b/libavcodec/vc1data.h @@ -3,20 +3,20 @@ * copyright (c) 2006 Konstantin Shishkov * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 186610ea95..852c874ee1 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3,20 +3,20 @@ * Copyright (c) 2006-2007 Konstantin Shishkov * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -3699,6 +3699,15 @@ static int vc1_decode_frame(AVCodecContext *avctx, av_log(v->s.avctx, AV_LOG_WARNING, "Sprite decoder: expected I-frame\n"); } + s->current_picture_ptr->repeat_pict = 0; + if (v->rff){ + s->current_picture_ptr->repeat_pict = 1; + }else if (v->rptfrm){ + s->current_picture_ptr->repeat_pict = v->rptfrm * 2; + } + + s->current_picture_ptr->top_field_first = v->tff; + // for skipping the frame s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c index 7d0e406677..2eaa47a05b 100644 --- a/libavcodec/vc1dsp.c +++ b/libavcodec/vc1dsp.c @@ -2,20 +2,20 @@ * VC-1 and WMV3 decoder - DSP functions * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vc1dsp.h b/libavcodec/vc1dsp.h index e1b6ba0aa8..93a9ea3858 100644 --- a/libavcodec/vc1dsp.h +++ b/libavcodec/vc1dsp.h @@ -2,20 +2,20 @@ * VC-1 and WMV3 decoder - DSP functions * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index aaf8eaebef..0d59b7e7ec 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -2,20 +2,20 @@ * ATI VCR1 codec * Copyright (c) 2003 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -146,6 +146,7 @@ static av_cold void common_init(AVCodecContext *avctx){ VCR1Context * const a = avctx->priv_data; avctx->coded_frame= (AVFrame*)&a->picture; + avcodec_get_frame_defaults(&a->picture); a->avctx= avctx; } diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 5f8f09186e..19bd96bc15 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -4,20 +4,20 @@ * * Copyright (c) 2008 NVIDIA * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -369,4 +369,40 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, render->bitstream_buffers_used = 0; } +// Only dummy functions for now +static int vdpau_mpeg2_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ + return 0; +} + +static int vdpau_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ + return 0; +} + +static int vdpau_mpeg2_end_frame(AVCodecContext *avctx) +{ + return 0; +} + +AVHWAccel ff_mpeg1_vdpau_hwaccel = { + .name = "mpeg1_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG1VIDEO, + .pix_fmt = PIX_FMT_VDPAU_MPEG1, + .start_frame = vdpau_mpeg2_start_frame, + .end_frame = vdpau_mpeg2_end_frame, + .decode_slice = vdpau_mpeg2_decode_slice, +}; + +AVHWAccel ff_mpeg2_vdpau_hwaccel = { + .name = "mpeg2_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG2VIDEO, + .pix_fmt = PIX_FMT_VDPAU_MPEG2, + .start_frame = vdpau_mpeg2_start_frame, + .end_frame = vdpau_mpeg2_end_frame, + .decode_slice = vdpau_mpeg2_decode_slice, +}; + /* @}*/ diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h index d06ba634fb..0dc6fb850b 100644 --- a/libavcodec/vdpau.h +++ b/libavcodec/vdpau.h @@ -4,20 +4,20 @@ * * Copyright (C) 2008 NVIDIA * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -31,7 +31,7 @@ * - VDPAU decoding * - VDPAU presentation * - * The VDPAU decoding module parses all headers using Libav + * 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 @@ -56,17 +56,24 @@ #define FF_VDPAU_STATE_USED_FOR_REFERENCE 2 /** - * \brief This structure is used as a callback between the Libav + * \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 Libav decoder and its clients. + * 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. + /** Describe size/location of the compressed video data. + Set to 0 when freeing bitstream_buffers. */ + int bitstream_buffers_allocated; + int bitstream_buffers_used; + /** The user is responsible for freeing this buffer using av_freep(). */ + VdpBitstreamBuffer *bitstream_buffers; + /** picture parameter information for all supported codecs */ union VdpPictureInfo { VdpPictureInfoH264 h264; @@ -74,13 +81,6 @@ struct vdpau_render_state { VdpPictureInfoVC1 vc1; VdpPictureInfoMPEG4Part2 mpeg4; } info; - - /** Describe size/location of the compressed video data. - Set to 0 when freeing bitstream_buffers. */ - int bitstream_buffers_allocated; - int bitstream_buffers_used; - /** The user is responsible for freeing this buffer using av_freep(). */ - VdpBitstreamBuffer *bitstream_buffers; }; /* @}*/ diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h index 673fd3349b..0a8d0b6b55 100644 --- a/libavcodec/vdpau_internal.h +++ b/libavcodec/vdpau_internal.h @@ -4,20 +4,20 @@ * * Copyright (C) 2008 NVIDIA * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/version.h b/libavcodec/version.h index aded68e83e..100c06dfe6 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -1,19 +1,19 @@ /* * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 5 +#define LIBAVCODEC_VERSION_MINOR 7 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index d258252d95..934a52b939 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -2,20 +2,20 @@ * Sierra VMD Audio & Video Decoders * Copyright (C) 2004 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -356,6 +356,9 @@ static av_cold int vmdvideo_decode_init(AVCodecContext *avctx) palette32[i] = (r << 16) | (g << 8) | (b); } + avcodec_get_frame_defaults(&s->frame); + avcodec_get_frame_defaults(&s->prev_frame); + return 0; } diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c index f95bef7e1d..6455d86f77 100644 --- a/libavcodec/vmnc.c +++ b/libavcodec/vmnc.c @@ -2,20 +2,20 @@ * VMware Screen Codec (VMnc) decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -470,6 +470,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->bpp = avctx->bits_per_coded_sample; c->bpp2 = c->bpp/8; + avcodec_get_frame_defaults(&c->pic); switch(c->bpp){ case 8: diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c index f413170b6a..fc830293cc 100644 --- a/libavcodec/vorbis.c +++ b/libavcodec/vorbis.c @@ -3,20 +3,20 @@ * Common code for Vorbis I encoder and decoder * @author Denes Balatoni ( dbalatoni programozo hu ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h index 8501e0a178..15b5d85b36 100644 --- a/libavcodec/vorbis.h +++ b/libavcodec/vorbis.h @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vorbis_data.c b/libavcodec/vorbis_data.c index 4e1fe00863..8fa624168a 100644 --- a/libavcodec/vorbis_data.c +++ b/libavcodec/vorbis_data.c @@ -1,20 +1,20 @@ /* * copyright (c) 2005 Denes Balatoni ( dbalatoni programozo hu ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vorbis_enc_data.h b/libavcodec/vorbis_enc_data.h index a1e743ebe5..affc3d6c86 100644 --- a/libavcodec/vorbis_enc_data.h +++ b/libavcodec/vorbis_enc_data.h @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 017102e777..e012f611a9 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -3,20 +3,20 @@ * Vorbis I decoder * @author Denes Balatoni ( dbalatoni programozo hu ) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1147,7 +1147,7 @@ static int vorbis_floor1_decode(vorbis_context *vc, uint16_t floor1_Y[258]; uint16_t floor1_Y_final[258]; int floor1_flag[258]; - unsigned class, cdim, cbits, csub, cval, offset, i, j; + unsigned partition_class, cdim, cbits, csub, cval, offset, i, j; int book, adx, ady, dy, off, predicted, err; @@ -1163,20 +1163,20 @@ static int vorbis_floor1_decode(vorbis_context *vc, offset = 2; for (i = 0; i < vf->partitions; ++i) { - class = vf->partition_class[i]; - cdim = vf->class_dimensions[class]; - cbits = vf->class_subclasses[class]; + partition_class = vf->partition_class[i]; + cdim = vf->class_dimensions[partition_class]; + cbits = vf->class_subclasses[partition_class]; csub = (1 << cbits) - 1; cval = 0; av_dlog(NULL, "Cbits %u\n", cbits); if (cbits) // this reads all subclasses for this partition's class - cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class]].vlc.table, - vc->codebooks[vf->class_masterbook[class]].nb_bits, 3); + cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[partition_class]].vlc.table, + vc->codebooks[vf->class_masterbook[partition_class]].nb_bits, 3); for (j = 0; j < cdim; ++j) { - book = vf->subclass_books[class][cval & csub]; + book = vf->subclass_books[partition_class][cval & csub]; av_dlog(NULL, "book %d Cbits %u cval %u bits:%d\n", book, cbits, cval, get_bits_count(gb)); diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 67d094b37d..617e2b7cc4 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -1,20 +1,20 @@ /* * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -957,7 +957,7 @@ static av_cold int vorbis_encode_init(AVCodecContext *avccontext) vorbis_enc_context *venc = avccontext->priv_data; if (avccontext->channels != 2) { - av_log(avccontext, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n"); + av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n"); return -1; } diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index c3dff7f89f..148f1179e3 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2003-2004 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp3_parser.c b/libavcodec/vp3_parser.c index cfe6b3f2a3..320f9870f9 100644 --- a/libavcodec/vp3_parser.c +++ b/libavcodec/vp3_parser.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2008 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp3data.h b/libavcodec/vp3data.h index 54d5a6c576..904ec6abf5 100644 --- a/libavcodec/vp3data.h +++ b/libavcodec/vp3data.h @@ -1,20 +1,20 @@ /* * copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp3dsp.c b/libavcodec/vp3dsp.c index baa22a5519..94efa3b1d2 100644 --- a/libavcodec/vp3dsp.c +++ b/libavcodec/vp3dsp.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2004 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index 807309f603..e9de38e6dd 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index a181978334..ad451c251f 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -653,8 +653,10 @@ av_cold void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha) ff_vp56dsp_init(&s->vp56dsp, avctx->codec->id); ff_init_scantable(s->dsp.idct_permutation, &s->scantable,ff_zigzag_direct); - for (i=0; i<4; i++) + for (i=0; i<4; i++) { s->framep[i] = &s->frames[i]; + avcodec_get_frame_defaults(&s->frames[i]); + } s->framep[VP56_FRAME_UNUSED] = s->framep[VP56_FRAME_GOLDEN]; s->framep[VP56_FRAME_UNUSED2] = s->framep[VP56_FRAME_GOLDEN2]; s->edge_emu_buffer_alloc = NULL; diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 5a55f7d6a1..d1735e5609 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp56data.c b/libavcodec/vp56data.c index 7a418761d1..b0515c2410 100644 --- a/libavcodec/vp56data.c +++ b/libavcodec/vp56data.c @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp56data.h b/libavcodec/vp56data.h index 7be5921e9f..57b0968d89 100644 --- a/libavcodec/vp56data.h +++ b/libavcodec/vp56data.h @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp56dsp.c b/libavcodec/vp56dsp.c index 7b4a771676..c629343a8b 100644 --- a/libavcodec/vp56dsp.c +++ b/libavcodec/vp56dsp.c @@ -2,20 +2,20 @@ * Copyright (c) 2006 Aurelien Jacobs <aurel@gnuage.org> * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp56dsp.h b/libavcodec/vp56dsp.h index 3bd6d27068..74a9cb5309 100644 --- a/libavcodec/vp56dsp.h +++ b/libavcodec/vp56dsp.h @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp56rac.c b/libavcodec/vp56rac.c index c009cadb94..f11531de24 100644 --- a/libavcodec/vp56rac.c +++ b/libavcodec/vp56rac.c @@ -2,20 +2,20 @@ * VP5/6/8 decoder * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp5data.h b/libavcodec/vp5data.h index 11144a31ad..5c2d46cde5 100644 --- a/libavcodec/vp5data.h +++ b/libavcodec/vp5data.h @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 4f3f402c70..0a02ce58d6 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -8,20 +8,20 @@ * - upper 4bits: difference between encoded width and visible width * - lower 4bits: difference between encoded height and visible height * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp6data.h b/libavcodec/vp6data.h index 2ba3ef3860..1cfdbe7bea 100644 --- a/libavcodec/vp6data.h +++ b/libavcodec/vp6data.h @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp6dsp.c b/libavcodec/vp6dsp.c index 64282a5b3f..1119b56705 100644 --- a/libavcodec/vp6dsp.c +++ b/libavcodec/vp6dsp.c @@ -4,20 +4,20 @@ * * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 282d2fdb4e..082d8e5829 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -5,20 +5,20 @@ * Copyright (C) 2010 Ronald S. Bultje * Copyright (C) 2010 Jason Garrett-Glaser * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h index 5a96cd436c..468e28e8d5 100644 --- a/libavcodec/vp8.h +++ b/libavcodec/vp8.h @@ -5,20 +5,20 @@ * Copyright (C) 2010 Ronald S. Bultje * Copyright (C) 2010 Jason Garrett-Glaser * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp8_parser.c b/libavcodec/vp8_parser.c index fbdd0ee5ac..aebf667e73 100644 --- a/libavcodec/vp8_parser.c +++ b/libavcodec/vp8_parser.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2008 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp8data.h b/libavcodec/vp8data.h index 4ea4581bc9..9ff21a1a97 100644 --- a/libavcodec/vp8data.h +++ b/libavcodec/vp8data.h @@ -4,20 +4,20 @@ * Copyright (C) 2010 David Conrad * Copyright (C) 2010 Ronald S. Bultje * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp8dsp.c b/libavcodec/vp8dsp.c index 159c070670..4391a7ebc7 100644 --- a/libavcodec/vp8dsp.c +++ b/libavcodec/vp8dsp.c @@ -4,20 +4,20 @@ * Copyright (C) 2010 David Conrad * Copyright (C) 2010 Ronald S. Bultje * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vp8dsp.h b/libavcodec/vp8dsp.h index e2fb8e7cbb..e8757ab7d0 100644 --- a/libavcodec/vp8dsp.h +++ b/libavcodec/vp8dsp.h @@ -4,20 +4,20 @@ * Copyright (C) 2010 David Conrad * Copyright (C) 2010 Ronald S. Bultje * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index caffddbfa4..ca4fd94d75 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -2,20 +2,20 @@ * Westwood Studios VQA Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -179,6 +179,7 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) (s->height / s->vector_height) * 2; s->decode_buffer = av_malloc(s->decode_buffer_size); + avcodec_get_frame_defaults(&s->frame); s->frame.data[0] = NULL; return 0; diff --git a/libavcodec/w32thread.c b/libavcodec/w32thread.c index 023be0e663..7c4c760e6c 100644 --- a/libavcodec/w32thread.c +++ b/libavcodec/w32thread.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ //#define DEBUG diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index e4fe217f59..d5102320fd 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -2,20 +2,20 @@ * WavPack lossless audio decoder * Copyright (c) 2006,2011 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define ALT_BITSTREAM_READER_LE diff --git a/libavcodec/wma.c b/libavcodec/wma.c index bed47ec35b..67599b7eab 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -1,21 +1,21 @@ /* * WMA compatible codec - * Copyright (c) 2002-2007 The Libav Project + * Copyright (c) 2002-2007 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wma.h b/libavcodec/wma.h index f11d5507dc..fd9d5d8d3b 100644 --- a/libavcodec/wma.h +++ b/libavcodec/wma.h @@ -1,21 +1,21 @@ /* * WMA compatible codec - * Copyright (c) 2002-2007 The Libav Project + * Copyright (c) 2002-2007 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmadata.h b/libavcodec/wmadata.h index 07a1afecc8..381f182fa0 100644 --- a/libavcodec/wmadata.h +++ b/libavcodec/wmadata.h @@ -1,21 +1,21 @@ /* * WMA compatible decoder - * copyright (c) 2002 The Libav Project + * copyright (c) 2002 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 479b34c3e0..840025d493 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -1,21 +1,21 @@ /* * WMA compatible decoder - * Copyright (c) 2002 The Libav Project + * Copyright (c) 2002 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -102,6 +102,13 @@ static int wma_decode_init(AVCodecContext * avctx) s->use_bit_reservoir = flags2 & 0x0002; s->use_variable_block_len = flags2 & 0x0004; + if(avctx->codec->id == CODEC_ID_WMAV2 && avctx->extradata_size >= 8){ + if(AV_RL16(extradata+4)==0xd && s->use_variable_block_len){ + av_log(avctx, AV_LOG_WARNING, "Disabling use_variable_block_len, if this fails contact the ffmpeg developers and send us the file\n"); + s->use_variable_block_len= 0; // this fixes issue1503 + } + } + if(ff_wma_init(avctx, flags2)<0) return -1; @@ -480,6 +487,11 @@ static int wma_decode_block(WMACodecContext *s) s->block_len_bits = s->frame_len_bits; } + if (s->frame_len_bits - s->block_len_bits >= s->nb_block_sizes){ + av_log(s->avctx, AV_LOG_ERROR, "block_len_bits not initialized to a valid value\n"); + return -1; + } + /* now check if the block length is coherent with the frame length */ s->block_len = 1 << s->block_len_bits; if ((s->block_pos + s->block_len) > s->frame_len){ @@ -815,7 +827,7 @@ static int wma_decode_superframe(AVCodecContext *avctx, return 0; } if (buf_size < s->block_align) - return 0; + return AVERROR(EINVAL); buf_size = s->block_align; samples = data; diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index 3cdb4a0b9b..0bafe1a64d 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -2,20 +2,20 @@ * WMA compatible encoder * Copyright (c) 2007 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmaprodata.h b/libavcodec/wmaprodata.h index f8a52bf4f4..53824799d5 100644 --- a/libavcodec/wmaprodata.h +++ b/libavcodec/wmaprodata.h @@ -3,20 +3,20 @@ * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion * Copyright (c) 2008 - 2009 Sascha Sommer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 4ba8c455ab..e1d942dca2 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -3,20 +3,20 @@ * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion * Copyright (c) 2008 - 2011 Sascha Sommer, Benjamin Larsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 4e69b83b32..3604eac782 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -2,20 +2,20 @@ * Windows Media Audio Voice decoder. * Copyright (c) 2009 Ronald S. Bultje * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1912,7 +1912,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, *data_size = 0; /* Packets are sometimes a multiple of ctx->block_align, with a packet - * header at each ctx->block_align bytes. However, Libav's ASF demuxer + * header at each ctx->block_align bytes. However, FFmpeg's ASF demuxer * feeds us ASF packets, which may concatenate multiple "codec" packets * in a single "muxer" packet, so we artificially emulate that by * capping the packet size at ctx->block_align. */ diff --git a/libavcodec/wmavoice_data.h b/libavcodec/wmavoice_data.h index 7f14fb8350..cbf65b043e 100644 --- a/libavcodec/wmavoice_data.h +++ b/libavcodec/wmavoice_data.h @@ -2,20 +2,20 @@ * Windows Media Voice (WMAVoice) tables. * Copyright (c) 2009 Ronald S. Bultje * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index 74389ef4db..32aaa8f6df 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -1,20 +1,20 @@ /* - * Copyright (c) 2002 The Libav Project + * Copyright (c) 2002 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h index 80f36ccddb..c69c9f48ee 100644 --- a/libavcodec/wmv2.h +++ b/libavcodec/wmv2.h @@ -1,20 +1,20 @@ /* - * Copyright (c) 2002 The Libav Project + * Copyright (c) 2002 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index ede5236559..21d1eeca3b 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -1,20 +1,20 @@ /* - * Copyright (c) 2002 The Libav Project + * Copyright (c) 2002 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -480,7 +480,6 @@ AVCodec ff_wmv2_decoder = { wmv2_decode_end, ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, - .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), .pix_fmts= ff_pixfmt_list_420, }; diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 9b7890c0f0..4a074e674c 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -1,20 +1,20 @@ /* - * Copyright (c) 2002 The Libav Project + * Copyright (c) 2002 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index 65ad9cdd12..197cf7985d 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -2,20 +2,20 @@ * Winnov WNV1 codec * Copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -136,6 +136,7 @@ static av_cold int decode_init(AVCodecContext *avctx){ l->avctx = avctx; avctx->pix_fmt = PIX_FMT_YUV422P; + avcodec_get_frame_defaults(&l->pic); code_vlc.table = code_table; code_vlc.table_allocated = 1 << CODE_VLC_BITS; diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c index 534be5661b..d6a60d441f 100644 --- a/libavcodec/ws-snd1.c +++ b/libavcodec/ws-snd1.c @@ -2,20 +2,20 @@ * Westwood SNDx codecs * Copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 1c451c8352..9ea330c930 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -26,6 +26,7 @@ MMX-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_mmx.o YASM-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp.o MMX-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp_mmx.o MMX-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodec_mmx.o +MMX-OBJS-$(CONFIG_PNG_DECODER) += x86/png_mmx.o MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o MMX-OBJS-$(CONFIG_GPL) += x86/idct_mmx.o diff --git a/libavcodec/x86/ac3dsp.asm b/libavcodec/x86/ac3dsp.asm index 6892ec2765..99c5df340e 100644 --- a/libavcodec/x86/ac3dsp.asm +++ b/libavcodec/x86/ac3dsp.asm @@ -2,20 +2,20 @@ ;* x86-optimized AC-3 DSP utils ;* Copyright (c) 2011 Justin Ruggles ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/ac3dsp_mmx.c b/libavcodec/x86/ac3dsp_mmx.c index 2664736bb6..e853b8831a 100644 --- a/libavcodec/x86/ac3dsp_mmx.c +++ b/libavcodec/x86/ac3dsp_mmx.c @@ -2,20 +2,20 @@ * x86-optimized AC-3 DSP utils * Copyright (c) 2011 Justin Ruggles * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/cavsdsp_mmx.c b/libavcodec/x86/cavsdsp_mmx.c index 3bc62ea156..0f5fdaa53d 100644 --- a/libavcodec/x86/cavsdsp_mmx.c +++ b/libavcodec/x86/cavsdsp_mmx.c @@ -5,20 +5,20 @@ * MMX-optimized DSP functions, based on H.264 optimizations by * Michael Niedermayer and Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/dct32_sse.asm b/libavcodec/x86/dct32_sse.asm index 46daa43d8c..7f5f815591 100644 --- a/libavcodec/x86/dct32_sse.asm +++ b/libavcodec/x86/dct32_sse.asm @@ -2,20 +2,20 @@ ;* 32 point SSE-optimized DCT transform ;* Copyright (c) 2010 Vitor Sessak ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/deinterlace.asm b/libavcodec/x86/deinterlace.asm index 8613485d5d..2997787beb 100644 --- a/libavcodec/x86/deinterlace.asm +++ b/libavcodec/x86/deinterlace.asm @@ -3,20 +3,20 @@ ;* Copyright (c) 2010 Vitor Sessak ;* Copyright (c) 2002 Michael Niedermayer ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/dnxhd_mmx.c b/libavcodec/x86/dnxhd_mmx.c index f00ce9b188..1256beef7f 100644 --- a/libavcodec/x86/dnxhd_mmx.c +++ b/libavcodec/x86/dnxhd_mmx.c @@ -4,20 +4,20 @@ * * VC-3 encoder funded by the British Broadcasting Corporation * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 1cc6991666..d867dc3e6a 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * MMX optimization by Nick Kurshev <nickols_k@mail.ru> @@ -580,28 +580,6 @@ static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){ dst[i+0] += src[i+0]; } -static void add_bytes_l2_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ - x86_reg i=0; - __asm__ volatile( - "jmp 2f \n\t" - "1: \n\t" - "movq (%2, %0), %%mm0 \n\t" - "movq 8(%2, %0), %%mm1 \n\t" - "paddb (%3, %0), %%mm0 \n\t" - "paddb 8(%3, %0), %%mm1 \n\t" - "movq %%mm0, (%1, %0) \n\t" - "movq %%mm1, 8(%1, %0) \n\t" - "add $16, %0 \n\t" - "2: \n\t" - "cmp %4, %0 \n\t" - " js 1b \n\t" - : "+r" (i) - : "r"(dst), "r"(src1), "r"(src2), "r"((x86_reg)w-15) - ); - for(; i<w; i++) - dst[i] = src1[i] + src2[i]; -} - #if HAVE_7REGS && HAVE_TEN_OPERANDS static void add_hfyu_median_prediction_cmov(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top) { x86_reg w2 = -w; @@ -877,80 +855,6 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w, } } -#define PAETH(cpu, abs3)\ -static void add_png_paeth_prediction_##cpu(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)\ -{\ - x86_reg i = -bpp;\ - x86_reg end = w-3;\ - __asm__ volatile(\ - "pxor %%mm7, %%mm7 \n"\ - "movd (%1,%0), %%mm0 \n"\ - "movd (%2,%0), %%mm1 \n"\ - "punpcklbw %%mm7, %%mm0 \n"\ - "punpcklbw %%mm7, %%mm1 \n"\ - "add %4, %0 \n"\ - "1: \n"\ - "movq %%mm1, %%mm2 \n"\ - "movd (%2,%0), %%mm1 \n"\ - "movq %%mm2, %%mm3 \n"\ - "punpcklbw %%mm7, %%mm1 \n"\ - "movq %%mm2, %%mm4 \n"\ - "psubw %%mm1, %%mm3 \n"\ - "psubw %%mm0, %%mm4 \n"\ - "movq %%mm3, %%mm5 \n"\ - "paddw %%mm4, %%mm5 \n"\ - abs3\ - "movq %%mm4, %%mm6 \n"\ - "pminsw %%mm5, %%mm6 \n"\ - "pcmpgtw %%mm6, %%mm3 \n"\ - "pcmpgtw %%mm5, %%mm4 \n"\ - "movq %%mm4, %%mm6 \n"\ - "pand %%mm3, %%mm4 \n"\ - "pandn %%mm3, %%mm6 \n"\ - "pandn %%mm0, %%mm3 \n"\ - "movd (%3,%0), %%mm0 \n"\ - "pand %%mm1, %%mm6 \n"\ - "pand %%mm4, %%mm2 \n"\ - "punpcklbw %%mm7, %%mm0 \n"\ - "movq %6, %%mm5 \n"\ - "paddw %%mm6, %%mm0 \n"\ - "paddw %%mm2, %%mm3 \n"\ - "paddw %%mm3, %%mm0 \n"\ - "pand %%mm5, %%mm0 \n"\ - "movq %%mm0, %%mm3 \n"\ - "packuswb %%mm3, %%mm3 \n"\ - "movd %%mm3, (%1,%0) \n"\ - "add %4, %0 \n"\ - "cmp %5, %0 \n"\ - "jle 1b \n"\ - :"+r"(i)\ - :"r"(dst), "r"(top), "r"(src), "r"((x86_reg)bpp), "g"(end),\ - "m"(ff_pw_255)\ - :"memory"\ - );\ -} - -#define ABS3_MMX2\ - "psubw %%mm5, %%mm7 \n"\ - "pmaxsw %%mm7, %%mm5 \n"\ - "pxor %%mm6, %%mm6 \n"\ - "pxor %%mm7, %%mm7 \n"\ - "psubw %%mm3, %%mm6 \n"\ - "psubw %%mm4, %%mm7 \n"\ - "pmaxsw %%mm6, %%mm3 \n"\ - "pmaxsw %%mm7, %%mm4 \n"\ - "pxor %%mm7, %%mm7 \n" - -#define ABS3_SSSE3\ - "pabsw %%mm3, %%mm3 \n"\ - "pabsw %%mm4, %%mm4 \n"\ - "pabsw %%mm5, %%mm5 \n" - -PAETH(mmx2, ABS3_MMX2) -#if HAVE_SSSE3 -PAETH(ssse3, ABS3_SSSE3) -#endif - #define QPEL_V_LOW(m3,m4,m5,m6, pw_20, pw_3, rnd, in0, in1, in2, in7, out, OP)\ "paddw " #m4 ", " #m3 " \n\t" /* x1 */\ "movq "MANGLE(ff_pw_20)", %%mm4 \n\t" /* 20 */\ @@ -2538,7 +2442,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) #endif c->add_bytes= add_bytes_mmx; - c->add_bytes_l2= add_bytes_l2_mmx; if (!high_bit_depth) c->draw_edges = draw_edges_mmx; @@ -2659,7 +2562,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov; #endif - c->add_png_paeth_prediction= add_png_paeth_prediction_mmx2; } else if (mm_flags & AV_CPU_FLAG_3DNOW) { c->prefetch = prefetch_3dnow; @@ -2773,7 +2675,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) H264_QPEL_FUNCS(3, 2, ssse3); H264_QPEL_FUNCS(3, 3, ssse3); } - c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3; #if HAVE_YASM if (!high_bit_depth) { c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd; diff --git a/libavcodec/x86/dsputil_mmx.h b/libavcodec/x86/dsputil_mmx.h index 7ab55e7c51..59a9613609 100644 --- a/libavcodec/x86/dsputil_mmx.h +++ b/libavcodec/x86/dsputil_mmx.h @@ -2,20 +2,20 @@ * MMX optimized DSP utils * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/dsputil_mmx_avg_template.c b/libavcodec/x86/dsputil_mmx_avg_template.c index 8b116b74e2..6f768595c0 100644 --- a/libavcodec/x86/dsputil_mmx_avg_template.c +++ b/libavcodec/x86/dsputil_mmx_avg_template.c @@ -7,20 +7,20 @@ * mostly rewritten by Michael Niedermayer <michaelni@gmx.at> * and improved by Zdenek Kabelac <kabi@users.sf.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/dsputil_mmx_qns_template.c b/libavcodec/x86/dsputil_mmx_qns_template.c index 20a40a175e..77a41b9dcb 100644 --- a/libavcodec/x86/dsputil_mmx_qns_template.c +++ b/libavcodec/x86/dsputil_mmx_qns_template.c @@ -5,20 +5,20 @@ * MMX optimization by Michael Niedermayer <michaelni@gmx.at> * 3DNow! and SSSE3 optimization by Zuxy Meng <zuxy.meng@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/dsputil_mmx_rnd_template.c b/libavcodec/x86/dsputil_mmx_rnd_template.c index 34a2c0bca8..e4c91381fa 100644 --- a/libavcodec/x86/dsputil_mmx_rnd_template.c +++ b/libavcodec/x86/dsputil_mmx_rnd_template.c @@ -7,20 +7,20 @@ * mostly rewritten by Michael Niedermayer <michaelni@gmx.at> * and improved by Zdenek Kabelac <kabi@users.sf.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index 8b19cc1441..695aba5ec3 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -2,20 +2,20 @@ ;* MMX optimized DSP utils ;* Copyright (c) 2008 Loren Merritt ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c index 037389137b..bd31205a6b 100644 --- a/libavcodec/x86/dsputilenc_mmx.c +++ b/libavcodec/x86/dsputilenc_mmx.c @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * MMX optimization by Nick Kurshev <nickols_k@mail.ru> diff --git a/libavcodec/x86/dsputilenc_yasm.asm b/libavcodec/x86/dsputilenc_yasm.asm index 6063ff1040..016b354d6c 100644 --- a/libavcodec/x86/dsputilenc_yasm.asm +++ b/libavcodec/x86/dsputilenc_yasm.asm @@ -4,20 +4,20 @@ ;* Copyright (c) 2000, 2001 Fabrice Bellard ;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;***************************************************************************** diff --git a/libavcodec/x86/fdct_mmx.c b/libavcodec/x86/fdct_mmx.c index f35a0591c6..c79a8df04c 100644 --- a/libavcodec/x86/fdct_mmx.c +++ b/libavcodec/x86/fdct_mmx.c @@ -13,20 +13,20 @@ * a page about fdct at http://www.geocities.com/ssavekar/dct.htm * Skal's fdct at http://skal.planet-d.net/coding/dct.html * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/fft.c b/libavcodec/x86/fft.c index 899f0f7ad5..18964d88ca 100644 --- a/libavcodec/x86/fft.c +++ b/libavcodec/x86/fft.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/fft.h b/libavcodec/x86/fft.h index 0ade2b2e7b..79064c27cd 100644 --- a/libavcodec/x86/fft.h +++ b/libavcodec/x86/fft.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/fft_3dn.c b/libavcodec/x86/fft_3dn.c index 5a4d3ad2c8..6f2e2e8353 100644 --- a/libavcodec/x86/fft_3dn.c +++ b/libavcodec/x86/fft_3dn.c @@ -2,20 +2,20 @@ * FFT/MDCT transform with 3DNow! optimizations * Copyright (c) 2008 Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/fft_3dn2.c b/libavcodec/x86/fft_3dn2.c index 05c0467f08..2abb8cfbd7 100644 --- a/libavcodec/x86/fft_3dn2.c +++ b/libavcodec/x86/fft_3dn2.c @@ -2,20 +2,20 @@ * FFT/MDCT transform with Extended 3DNow! optimizations * Copyright (c) 2006-2008 Zuxy MENG Jie, Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/fft_mmx.asm b/libavcodec/x86/fft_mmx.asm index 27276a1a31..15fb67654c 100644 --- a/libavcodec/x86/fft_mmx.asm +++ b/libavcodec/x86/fft_mmx.asm @@ -6,20 +6,20 @@ ;* This algorithm (though not any of the implementation details) is ;* based on libdjbfft by D. J. Bernstein. ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** @@ -388,6 +388,7 @@ fft32_interleave_avx: sub r2d, mmsize/4 jg .deint_loop ret + %endif INIT_XMM diff --git a/libavcodec/x86/fft_sse.c b/libavcodec/x86/fft_sse.c index add20dd5b2..26b933c810 100644 --- a/libavcodec/x86/fft_sse.c +++ b/libavcodec/x86/fft_sse.c @@ -2,20 +2,20 @@ * FFT/MDCT transform with SSE optimizations * Copyright (c) 2008 Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/fmtconvert.asm b/libavcodec/x86/fmtconvert.asm index efab87d570..598e412f73 100644 --- a/libavcodec/x86/fmtconvert.asm +++ b/libavcodec/x86/fmtconvert.asm @@ -2,20 +2,20 @@ ;* x86 optimized Format Conversion Utils ;* Copyright (c) 2008 Loren Merritt ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/fmtconvert_mmx.c b/libavcodec/x86/fmtconvert_mmx.c index 253f60bfc2..ba2c2c9bd5 100644 --- a/libavcodec/x86/fmtconvert_mmx.c +++ b/libavcodec/x86/fmtconvert_mmx.c @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * MMX optimization by Nick Kurshev <nickols_k@mail.ru> diff --git a/libavcodec/x86/h264_chromamc.asm b/libavcodec/x86/h264_chromamc.asm index 0a37994fb9..5dae1cca85 100644 --- a/libavcodec/x86/h264_chromamc.asm +++ b/libavcodec/x86/h264_chromamc.asm @@ -3,20 +3,20 @@ ;* Copyright (c) 2005 Zoltan Hidvegi <hzoli -a- hzoli -d- com>, ;* 2005-2008 Loren Merritt ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/h264_deblock.asm b/libavcodec/x86/h264_deblock.asm index 9831ca2cd6..2a6da0fe90 100644 --- a/libavcodec/x86/h264_deblock.asm +++ b/libavcodec/x86/h264_deblock.asm @@ -7,20 +7,20 @@ ;* Jason Garrett-Glaser <darkshikari@gmail.com> ;* Oskar Arvidsson <oskar@irock.se> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/h264_deblock_10bit.asm b/libavcodec/x86/h264_deblock_10bit.asm index baac725eec..699fc4a687 100644 --- a/libavcodec/x86/h264_deblock_10bit.asm +++ b/libavcodec/x86/h264_deblock_10bit.asm @@ -165,7 +165,7 @@ cglobal deblock_v_luma_10_%1, 5,5,8*(mmsize/16) SUB rsp, pad shl r2d, 2 shl r3d, 2 - LOAD_AB m4, m5, r2, r3 + LOAD_AB m4, m5, r2d, r3d mov r3, 32/mmsize mov r2, r0 sub r0, r1 @@ -222,7 +222,7 @@ cglobal deblock_h_luma_10_%1, 5,6,8*(mmsize/16) SUB rsp, pad shl r2d, 2 shl r3d, 2 - LOAD_AB m4, m5, r2, r3 + LOAD_AB m4, m5, r2d, r3d mov r3, r1 mova am, m4 add r3, r1 @@ -352,7 +352,7 @@ cglobal deblock_v_luma_10_%1, 5,5,15 %define mask2 m11 shl r2d, 2 shl r3d, 2 - LOAD_AB m12, m13, r2, r3 + LOAD_AB m12, m13, r2d, r3d mov r2, r0 sub r0, r1 sub r0, r1 @@ -380,7 +380,7 @@ cglobal deblock_v_luma_10_%1, 5,5,15 cglobal deblock_h_luma_10_%1, 5,7,15 shl r2d, 2 shl r3d, 2 - LOAD_AB m12, m13, r2, r3 + LOAD_AB m12, m13, r2d, r3d mov r2, r1 add r2, r1 add r2, r1 @@ -858,7 +858,7 @@ cglobal deblock_v_chroma_10_%1, 5,7-(mmsize/16),8*(mmsize/16) .loop: %endif CHROMA_V_LOAD r5 - LOAD_AB m4, m5, r2, r3 + LOAD_AB m4, m5, r2d, r3d LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4 pxor m4, m4 CHROMA_V_LOAD_TC m6, r4 @@ -892,7 +892,7 @@ cglobal deblock_v_chroma_intra_10_%1, 4,6-(mmsize/16),8*(mmsize/16) .loop: %endif CHROMA_V_LOAD r4 - LOAD_AB m4, m5, r2, r3 + LOAD_AB m4, m5, r2d, r3d LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4 CHROMA_DEBLOCK_P0_Q0_INTRA m1, m2, m0, m3, m7, m5, m6 CHROMA_V_STORE diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index c850dc2ef3..26c163be3c 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm index f90f41c4bc..87fbbf2fd5 100644 --- a/libavcodec/x86/h264_idct.asm +++ b/libavcodec/x86/h264_idct.asm @@ -9,20 +9,20 @@ ;* Holger Lubitz <hal@duncan.ol.sub.de> ;* Min Chen <chenm001.163.com> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;***************************************************************************** diff --git a/libavcodec/x86/h264_intrapred.asm b/libavcodec/x86/h264_intrapred.asm index cbf3cf7a5c..a9da6a19db 100644 --- a/libavcodec/x86/h264_intrapred.asm +++ b/libavcodec/x86/h264_intrapred.asm @@ -5,20 +5,20 @@ ;* Copyright (c) 2010 Loren Merritt ;* Copyright (c) 2010 Ronald S. Bultje ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index 9d6726c31c..d71f71e861 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Jason Garrett-Glaser * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/h264_qpel_mmx.c b/libavcodec/x86/h264_qpel_mmx.c index 066f794fb6..d8ceca1819 100644 --- a/libavcodec/x86/h264_qpel_mmx.c +++ b/libavcodec/x86/h264_qpel_mmx.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/h264_weight.asm b/libavcodec/x86/h264_weight.asm index d80ca32583..87544ae288 100644 --- a/libavcodec/x86/h264_weight.asm +++ b/libavcodec/x86/h264_weight.asm @@ -4,20 +4,20 @@ ;* Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt ;* Copyright (C) 2010 Eli Friedman <eli.friedman@gmail.com> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c index 3fccd081d5..3bb4384a5f 100644 --- a/libavcodec/x86/h264dsp_mmx.c +++ b/libavcodec/x86/h264dsp_mmx.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/idct_mmx_xvid.c b/libavcodec/x86/idct_mmx_xvid.c index 3055205c81..466cf75bc4 100644 --- a/libavcodec/x86/idct_mmx_xvid.c +++ b/libavcodec/x86/idct_mmx_xvid.c @@ -22,20 +22,20 @@ * * conversion to gcc syntax by Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software Foundation, + * along with FFmpeg; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/idct_sse2_xvid.c b/libavcodec/x86/idct_sse2_xvid.c index 4b6885f4a2..5185d61e54 100644 --- a/libavcodec/x86/idct_sse2_xvid.c +++ b/libavcodec/x86/idct_sse2_xvid.c @@ -9,7 +9,7 @@ * * Originally from dct/x86_asm/fdct_sse2_skal.asm in Xvid. * - * This file is part of Libav. + * This file is part of FFmpeg. * * Vertical pass is an implementation of the scheme: * Loeffler C., Ligtenberg A., and Moschytz C.S.: @@ -23,18 +23,18 @@ * * More details at http://skal.planet-d.net/coding/dct.html * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software Foundation, + * along with FFmpeg; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/idct_xvid.h b/libavcodec/x86/idct_xvid.h index 1ff039d928..5fdc20d3ea 100644 --- a/libavcodec/x86/idct_xvid.h +++ b/libavcodec/x86/idct_xvid.h @@ -1,20 +1,20 @@ /* * XVID MPEG-4 VIDEO CODEC * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/lpc_mmx.c b/libavcodec/x86/lpc_mmx.c index d41c19b443..1c202e2ccc 100644 --- a/libavcodec/x86/lpc_mmx.c +++ b/libavcodec/x86/lpc_mmx.c @@ -2,20 +2,20 @@ * MMX optimized LPC DSP utils * Copyright (c) 2007 Loren Merritt * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 50b0283151..33d9a6c8ff 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -2,20 +2,20 @@ * simple math operations * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/mlpdsp.c b/libavcodec/x86/mlpdsp.c index 333dc561f1..486a927ad7 100644 --- a/libavcodec/x86/mlpdsp.c +++ b/libavcodec/x86/mlpdsp.c @@ -2,20 +2,20 @@ * MLP DSP functions x86-optimized * Copyright (c) 2009 Ramiro Polla * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/motion_est_mmx.c b/libavcodec/x86/motion_est_mmx.c index 948af98ffb..fefef41058 100644 --- a/libavcodec/x86/motion_est_mmx.c +++ b/libavcodec/x86/motion_est_mmx.c @@ -5,20 +5,20 @@ * * mostly by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/mpegaudiodec_mmx.c b/libavcodec/x86/mpegaudiodec_mmx.c index b64461513e..d7f8a0a142 100644 --- a/libavcodec/x86/mpegaudiodec_mmx.c +++ b/libavcodec/x86/mpegaudiodec_mmx.c @@ -2,20 +2,20 @@ * MMX optimized MP3 decoding functions * Copyright (c) 2010 Vitor Sessak * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/mpegvideo_mmx.c b/libavcodec/x86/mpegvideo_mmx.c index 7dd9a66783..3b8513d3f0 100644 --- a/libavcodec/x86/mpegvideo_mmx.c +++ b/libavcodec/x86/mpegvideo_mmx.c @@ -5,20 +5,20 @@ * Optimized for ia32 CPUs by Nick Kurshev <nickols_k@mail.ru> * h263, mpeg1, mpeg2 dequantizer & draw_edges by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/mpegvideo_mmx_template.c b/libavcodec/x86/mpegvideo_mmx_template.c index 0f01cb24b9..fb52159576 100644 --- a/libavcodec/x86/mpegvideo_mmx_template.c +++ b/libavcodec/x86/mpegvideo_mmx_template.c @@ -3,20 +3,20 @@ * * Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/png_mmx.c b/libavcodec/x86/png_mmx.c new file mode 100644 index 0000000000..3b284122ff --- /dev/null +++ b/libavcodec/x86/png_mmx.c @@ -0,0 +1,143 @@ +/* + * MMX optimized PNG utils + * Copyright (c) 2008 Loren Merritt + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "libavutil/cpu.h" +#include "libavutil/x86_cpu.h" +#include "libavcodec/dsputil.h" +#include "libavcodec/png.h" +#include "dsputil_mmx.h" + +//#undef NDEBUG +//#include <assert.h> + +static void add_bytes_l2_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) +{ + x86_reg i=0; + __asm__ volatile( + "jmp 2f \n\t" + "1: \n\t" + "movq (%2, %0), %%mm0 \n\t" + "movq 8(%2, %0), %%mm1 \n\t" + "paddb (%3, %0), %%mm0 \n\t" + "paddb 8(%3, %0), %%mm1 \n\t" + "movq %%mm0, (%1, %0) \n\t" + "movq %%mm1, 8(%1, %0) \n\t" + "add $16, %0 \n\t" + "2: \n\t" + "cmp %4, %0 \n\t" + " js 1b \n\t" + : "+r" (i) + : "r"(dst), "r"(src1), "r"(src2), "r"((x86_reg)w-15) + ); + for(; i<w; i++) + dst[i] = src1[i] + src2[i]; +} + +#define PAETH(cpu, abs3)\ +static void add_paeth_prediction_##cpu(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)\ +{\ + x86_reg i, end;\ + if(bpp>4) add_paeth_prediction_##cpu(dst+bpp/2, src+bpp/2, top+bpp/2, w-bpp/2, -bpp);\ + if(bpp<0) bpp=-bpp;\ + i= -bpp;\ + end = w-3;\ + __asm__ volatile(\ + "pxor %%mm7, %%mm7 \n"\ + "movd (%1,%0), %%mm0 \n"\ + "movd (%2,%0), %%mm1 \n"\ + "punpcklbw %%mm7, %%mm0 \n"\ + "punpcklbw %%mm7, %%mm1 \n"\ + "add %4, %0 \n"\ + "1: \n"\ + "movq %%mm1, %%mm2 \n"\ + "movd (%2,%0), %%mm1 \n"\ + "movq %%mm2, %%mm3 \n"\ + "punpcklbw %%mm7, %%mm1 \n"\ + "movq %%mm2, %%mm4 \n"\ + "psubw %%mm1, %%mm3 \n"\ + "psubw %%mm0, %%mm4 \n"\ + "movq %%mm3, %%mm5 \n"\ + "paddw %%mm4, %%mm5 \n"\ + abs3\ + "movq %%mm4, %%mm6 \n"\ + "pminsw %%mm5, %%mm6 \n"\ + "pcmpgtw %%mm6, %%mm3 \n"\ + "pcmpgtw %%mm5, %%mm4 \n"\ + "movq %%mm4, %%mm6 \n"\ + "pand %%mm3, %%mm4 \n"\ + "pandn %%mm3, %%mm6 \n"\ + "pandn %%mm0, %%mm3 \n"\ + "movd (%3,%0), %%mm0 \n"\ + "pand %%mm1, %%mm6 \n"\ + "pand %%mm4, %%mm2 \n"\ + "punpcklbw %%mm7, %%mm0 \n"\ + "paddw %%mm6, %%mm0 \n"\ + "paddw %%mm2, %%mm3 \n"\ + "paddw %%mm3, %%mm0 \n"\ + "pand %6 , %%mm0 \n"\ + "movq %%mm0, %%mm3 \n"\ + "packuswb %%mm3, %%mm3 \n"\ + "movd %%mm3, (%1,%0) \n"\ + "add %4, %0 \n"\ + "cmp %5, %0 \n"\ + "jle 1b \n"\ + :"+r"(i)\ + :"r"(dst), "r"(top), "r"(src), "r"((x86_reg)bpp), "g"(end),\ + "m"(ff_pw_255)\ + :"memory"\ + );\ +} + +#define ABS3_MMX2\ + "psubw %%mm5, %%mm7 \n"\ + "pmaxsw %%mm7, %%mm5 \n"\ + "pxor %%mm6, %%mm6 \n"\ + "pxor %%mm7, %%mm7 \n"\ + "psubw %%mm3, %%mm6 \n"\ + "psubw %%mm4, %%mm7 \n"\ + "pmaxsw %%mm6, %%mm3 \n"\ + "pmaxsw %%mm7, %%mm4 \n"\ + "pxor %%mm7, %%mm7 \n" + +#define ABS3_SSSE3\ + "pabsw %%mm3, %%mm3 \n"\ + "pabsw %%mm4, %%mm4 \n"\ + "pabsw %%mm5, %%mm5 \n" + +PAETH(mmx2, ABS3_MMX2) +#if HAVE_SSSE3 +PAETH(ssse3, ABS3_SSSE3) +#endif + +void ff_png_init_mmx(PNGDecContext *s) +{ + int mm_flags = av_get_cpu_flags(); + + if (mm_flags & AV_CPU_FLAG_MMX2) { + s->add_bytes_l2 = add_bytes_l2_mmx; + s->add_paeth_prediction = add_paeth_prediction_mmx2; +#if HAVE_SSSE3 + if (mm_flags & AV_CPU_FLAG_SSSE3) + s->add_paeth_prediction = add_paeth_prediction_ssse3; +#endif + } +} diff --git a/libavcodec/x86/simple_idct_mmx.c b/libavcodec/x86/simple_idct_mmx.c index d78ae6b508..92cc18465c 100644 --- a/libavcodec/x86/simple_idct_mmx.c +++ b/libavcodec/x86/simple_idct_mmx.c @@ -3,20 +3,20 @@ * * Copyright (c) 2001, 2002 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/dsputil.h" diff --git a/libavcodec/x86/snowdsp_mmx.c b/libavcodec/x86/snowdsp_mmx.c index 3e6bc99796..9c1fa429a8 100644 --- a/libavcodec/x86/snowdsp_mmx.c +++ b/libavcodec/x86/snowdsp_mmx.c @@ -2,20 +2,20 @@ * MMX and SSE2 optimized snow DSP utils * Copyright (c) 2005-2006 Robert Edele <yartrebo@earthlink.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/vc1dsp_yasm.asm b/libavcodec/x86/vc1dsp_yasm.asm index 220cc03da3..a353c5f9ed 100644 --- a/libavcodec/x86/vc1dsp_yasm.asm +++ b/libavcodec/x86/vc1dsp_yasm.asm @@ -2,20 +2,20 @@ ;* VC1 deblocking optimizations ;* Copyright (c) 2009 David Conrad ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/vp3dsp.asm b/libavcodec/x86/vp3dsp.asm index 23574383a1..328f94ca60 100644 --- a/libavcodec/x86/vp3dsp.asm +++ b/libavcodec/x86/vp3dsp.asm @@ -2,20 +2,20 @@ ;* MMX/SSE2-optimized functions for the VP3 decoder ;* Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/vp56_arith.h b/libavcodec/x86/vp56_arith.h index be2dd30b8d..ddbf38b1a9 100644 --- a/libavcodec/x86/vp56_arith.h +++ b/libavcodec/x86/vp56_arith.h @@ -4,20 +4,20 @@ * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * Copyright (C) 2010 Eli Friedman * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/vp56dsp.asm b/libavcodec/x86/vp56dsp.asm index c70ed60d76..6da3ce30e3 100644 --- a/libavcodec/x86/vp56dsp.asm +++ b/libavcodec/x86/vp56dsp.asm @@ -3,20 +3,20 @@ ;* Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com> ;* Copyright (C) 2009 Zuxy Meng <zuxy.meng@gmail.com> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/vp56dsp_init.c b/libavcodec/x86/vp56dsp_init.c index 29892812ac..87fc935315 100644 --- a/libavcodec/x86/vp56dsp_init.c +++ b/libavcodec/x86/vp56dsp_init.c @@ -3,20 +3,20 @@ * Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com> * Copyright (C) 2009 Zuxy Meng <zuxy.meng@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/vp8dsp-init.c b/libavcodec/x86/vp8dsp-init.c index 8b27b0dadc..201b34e243 100644 --- a/libavcodec/x86/vp8dsp-init.c +++ b/libavcodec/x86/vp8dsp-init.c @@ -3,20 +3,20 @@ * Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com> * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/x86/vp8dsp.asm b/libavcodec/x86/vp8dsp.asm index 7d9ebc9463..14b49705dc 100644 --- a/libavcodec/x86/vp8dsp.asm +++ b/libavcodec/x86/vp8dsp.asm @@ -3,20 +3,20 @@ ;* Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com> ;* Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/x86/x86util.asm b/libavcodec/x86/x86util.asm index 141e96000c..b8ca348b68 100644 --- a/libavcodec/x86/x86util.asm +++ b/libavcodec/x86/x86util.asm @@ -6,20 +6,20 @@ ;* Authors: Loren Merritt <lorenm@u.washington.edu> ;* Holger Lubitz <holger@lubitz.org> ;* -;* This file is part of Libav. +;* This file is part of FFmpeg. ;* -;* Libav is free software; you can redistribute it and/or +;* 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. ;* -;* Libav is distributed in the hope that it will be useful, +;* 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 Libav; if not, write to the Free Software +;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 876a9a5558..f5d1812aec 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -2,20 +2,20 @@ * Wing Commander/Xan Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -91,6 +91,8 @@ static av_cold int xan_decode_init(AVCodecContext *avctx) av_freep(&s->buffer1); return AVERROR(ENOMEM); } + avcodec_get_frame_defaults(&s->last_frame); + avcodec_get_frame_defaults(&s->current_frame); return 0; } diff --git a/libavcodec/xiph.c b/libavcodec/xiph.c index 0bcfd45eea..2f4f25c929 100644 --- a/libavcodec/xiph.c +++ b/libavcodec/xiph.c @@ -1,20 +1,20 @@ /* - * Copyright (C) 2007 Libav Project + * Copyright (C) 2007 FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/xiph.h b/libavcodec/xiph.h index da18c9c094..0cbb870355 100644 --- a/libavcodec/xiph.h +++ b/libavcodec/xiph.h @@ -1,20 +1,20 @@ /* - * Copyright (C) 2007 Libav Project + * Copyright (C) 2007 FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/xl.c b/libavcodec/xl.c index 4f17ae54f2..7f3b0775c0 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -2,20 +2,20 @@ * Miro VideoXL codec * Copyright (c) 2004 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -121,8 +121,9 @@ static int decode_frame(AVCodecContext *avctx, } static av_cold int decode_init(AVCodecContext *avctx){ -// VideoXLContext * const a = avctx->priv_data; + VideoXLContext * const a = avctx->priv_data; + avcodec_get_frame_defaults(&a->pic); avctx->pix_fmt= PIX_FMT_YUV411P; return 0; diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 097cbc6c1d..9289a2554e 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -2,20 +2,20 @@ * XSUB subtitle decoder * Copyright (c) 2007 Reimar Döffinger * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/imgutils.h" @@ -51,11 +51,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVSubtitle *sub = data; const uint8_t *buf_end = buf + buf_size; uint8_t *bitmap; - int w, h, x, y, rlelen, i; + int w, h, x, y, i; int64_t packet_time = 0; GetBitContext gb; - - memset(sub, 0, sizeof(*sub)); + int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A'); // check that at least header fits if (buf_size < 27 + 7 * 2 + 4 * 3) { @@ -84,7 +83,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, // skip bottom right position, it gives no new information bytestream_get_le16(&buf); bytestream_get_le16(&buf); - rlelen = bytestream_get_le16(&buf); + // The following value is supposed to indicate the start offset + // (relative to the palette) of the data for the second field, + // however there are files where it has a bogus value and thus + // we just ignore it + bytestream_get_le16(&buf); // allocate sub and set values sub->rects = av_mallocz(sizeof(*sub->rects)); @@ -102,12 +105,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, for (i = 0; i < sub->rects[0]->nb_colors; i++) ((uint32_t*)sub->rects[0]->pict.data[1])[i] = bytestream_get_be24(&buf); // make all except background (first entry) non-transparent - for (i = 1; i < sub->rects[0]->nb_colors; i++) - ((uint32_t*)sub->rects[0]->pict.data[1])[i] |= 0xff000000; + for (i = 0; i < sub->rects[0]->nb_colors; i++) + ((uint32_t*)sub->rects[0]->pict.data[1])[i] |= (has_alpha ? *buf++ : (i ? 0xff : 0)) << 24; // process RLE-compressed data - rlelen = FFMIN(rlelen, buf_end - buf); - init_get_bits(&gb, buf, rlelen * 8); + init_get_bits(&gb, buf, (buf_end - buf) * 8); bitmap = sub->rects[0]->pict.data[0]; for (y = 0; y < h; y++) { // interlaced: do odd lines diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index 87dc75c22d..a7e3a891d4 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -3,20 +3,20 @@ * Copyright (c) 2005 DivX, Inc. * Copyright (c) 2009 Bjorn Axelsson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -129,7 +129,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, } // TODO: support multiple rects - if (h->num_rects > 1) + if (h->num_rects != 1) av_log(avctx, AV_LOG_WARNING, "Only single rects supported (%d in subtitle.)\n", h->num_rects); // TODO: render text-based subtitles into bitmaps diff --git a/libavcodec/xvmc.h b/libavcodec/xvmc.h index 1239015fcd..93ad8bb9a5 100644 --- a/libavcodec/xvmc.h +++ b/libavcodec/xvmc.h @@ -1,20 +1,20 @@ /* * Copyright (C) 2003 Ivan Kalvachev * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/xvmc_internal.h b/libavcodec/xvmc_internal.h index 3c6aed8361..04197cefae 100644 --- a/libavcodec/xvmc_internal.h +++ b/libavcodec/xvmc_internal.h @@ -1,20 +1,20 @@ /* * XVideo Motion Compensation internal functions * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c index 28c868d5ba..10ec53f467 100644 --- a/libavcodec/xxan.c +++ b/libavcodec/xxan.c @@ -3,20 +3,20 @@ * Copyright (C) 2011 Konstantin Shishkov * based on work by Mike Melanson * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 1f1314b6a7..45a3344b9e 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -6,20 +6,20 @@ * derived from the code by * Copyright (C) 2009 Thomas P. Higdon <thomas.p.higdon@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -92,6 +92,7 @@ static av_cold int yop_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_PAL8; + avcodec_get_frame_defaults(&s->frame); s->num_pal_colors = avctx->extradata[0]; s->first_color[0] = avctx->extradata[1]; s->first_color[1] = avctx->extradata[2]; diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index deae580d20..4bd159cc44 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -2,20 +2,20 @@ * Zip Motion Blocks Video (ZMBV) decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -599,6 +599,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->width = avctx->width; c->height = avctx->height; + avcodec_get_frame_defaults(&c->pic); c->bpp = avctx->bits_per_coded_sample; diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index e4f4860ea0..4c98987fea 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -2,20 +2,20 @@ * Zip Motion Blocks Video (ZMBV) encoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ |