~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/flacdec.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * @file
24
24
 * FLAC (Free Lossless Audio Codec) decoder
25
25
 * @author Alex Beregszaszi
26
 
 *
27
 
 * For more information on the FLAC format, visit:
28
 
 *  http://flac.sourceforge.net/
 
26
 * @see http://flac.sourceforge.net/
29
27
 *
30
28
 * This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed
31
29
 * through, starting from the initial 'fLaC' signature; or by passing the
51
49
    FLACSTREAMINFO
52
50
 
53
51
    AVCodecContext *avctx;                  ///< parent AVCodecContext
 
52
    AVFrame frame;
54
53
    GetBitContext gb;                       ///< GetBitContext initialized to start at the current frame
55
54
 
56
55
    int blocksize;                          ///< number of samples in the current frame
65
64
 
66
65
static void allocate_buffers(FLACContext *s);
67
66
 
68
 
int ff_flac_is_extradata_valid(AVCodecContext *avctx,
 
67
int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
69
68
                               enum FLACExtradataFormat *format,
70
69
                               uint8_t **streaminfo_start)
71
70
{
106
105
    if (!avctx->extradata)
107
106
        return 0;
108
107
 
109
 
    if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo))
 
108
    if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo))
110
109
        return -1;
111
110
 
112
111
    /* initialize based on the demuxer-supplied streamdata header */
113
 
    ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
 
112
    avpriv_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
114
113
    if (s->bps > 16)
115
114
        avctx->sample_fmt = AV_SAMPLE_FMT_S32;
116
115
    else
118
117
    allocate_buffers(s);
119
118
    s->got_streaminfo = 1;
120
119
 
 
120
    avcodec_get_frame_defaults(&s->frame);
 
121
    avctx->coded_frame = &s->frame;
 
122
 
121
123
    return 0;
122
124
}
123
125
 
142
144
    }
143
145
}
144
146
 
145
 
void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
 
147
void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
146
148
                              const uint8_t *buffer)
147
149
{
148
150
    GetBitContext gb;
176
178
    dump_headers(avctx, s);
177
179
}
178
180
 
179
 
void ff_flac_parse_block_header(const uint8_t *block_header,
 
181
void avpriv_flac_parse_block_header(const uint8_t *block_header,
180
182
                                int *last, int *type, int *size)
181
183
{
182
184
    int tmp = bytestream_get_byte(&block_header);
203
205
        /* need more data */
204
206
        return 0;
205
207
    }
206
 
    ff_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size);
 
208
    avpriv_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size);
207
209
    if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO ||
208
210
        metadata_size != FLAC_STREAMINFO_SIZE) {
209
211
        return AVERROR_INVALIDDATA;
210
212
    }
211
 
    ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]);
 
213
    avpriv_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]);
212
214
    allocate_buffers(s);
213
215
    s->got_streaminfo = 1;
214
216
 
228
230
 
229
231
    buf += 4;
230
232
    do {
231
 
        ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
 
233
        if (buf_end - buf < 4)
 
234
            return 0;
 
235
        avpriv_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
232
236
        buf += 4;
233
 
        if (buf + metadata_size > buf_end) {
 
237
        if (buf_end - buf < metadata_size) {
234
238
            /* need more data in order to read the complete header */
235
239
            return 0;
236
240
        }
542
546
    return 0;
543
547
}
544
548
 
545
 
static int flac_decode_frame(AVCodecContext *avctx,
546
 
                            void *data, int *data_size,
547
 
                            AVPacket *avpkt)
 
549
static int flac_decode_frame(AVCodecContext *avctx, void *data,
 
550
                             int *got_frame_ptr, AVPacket *avpkt)
548
551
{
549
552
    const uint8_t *buf = avpkt->data;
550
553
    int buf_size = avpkt->size;
551
554
    FLACContext *s = avctx->priv_data;
552
555
    int i, j = 0, bytes_read = 0;
553
 
    int16_t *samples_16 = data;
554
 
    int32_t *samples_32 = data;
555
 
    int alloc_data_size= *data_size;
556
 
    int output_size;
 
556
    int16_t *samples_16;
 
557
    int32_t *samples_32;
 
558
    int ret;
557
559
 
558
 
    *data_size=0;
 
560
    *got_frame_ptr = 0;
559
561
 
560
562
    if (s->max_framesize == 0) {
561
563
        s->max_framesize =
586
588
    }
587
589
    bytes_read = (get_bits_count(&s->gb)+7)/8;
588
590
 
589
 
    /* check if allocated data size is large enough for output */
590
 
    output_size = s->blocksize * s->channels * (s->is32 ? 4 : 2);
591
 
    if (output_size > alloc_data_size) {
592
 
        av_log(s->avctx, AV_LOG_ERROR, "output data size is larger than "
593
 
                                       "allocated data size\n");
594
 
        return -1;
 
591
    /* get output buffer */
 
592
    s->frame.nb_samples = s->blocksize;
 
593
    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
 
594
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 
595
        return ret;
595
596
    }
596
 
    *data_size = output_size;
 
597
    samples_16 = (int16_t *)s->frame.data[0];
 
598
    samples_32 = (int32_t *)s->frame.data[0];
597
599
 
598
600
#define DECORRELATE(left, right)\
599
601
            assert(s->channels == 2);\
638
640
               buf_size - bytes_read, buf_size);
639
641
    }
640
642
 
 
643
    *got_frame_ptr   = 1;
 
644
    *(AVFrame *)data = s->frame;
 
645
 
641
646
    return bytes_read;
642
647
}
643
648
 
654
659
}
655
660
 
656
661
AVCodec ff_flac_decoder = {
657
 
    "flac",
658
 
    AVMEDIA_TYPE_AUDIO,
659
 
    CODEC_ID_FLAC,
660
 
    sizeof(FLACContext),
661
 
    flac_decode_init,
662
 
    NULL,
663
 
    flac_decode_close,
664
 
    flac_decode_frame,
 
662
    .name           = "flac",
 
663
    .type           = AVMEDIA_TYPE_AUDIO,
 
664
    .id             = CODEC_ID_FLAC,
 
665
    .priv_data_size = sizeof(FLACContext),
 
666
    .init           = flac_decode_init,
 
667
    .close          = flac_decode_close,
 
668
    .decode         = flac_decode_frame,
 
669
    .capabilities   = CODEC_CAP_DR1,
665
670
    .long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
666
671
};