~ubuntu-branches/debian/squeeze/gstreamer0.10-ffmpeg/squeeze

« back to all changes in this revision

Viewing changes to gst-libs/ext/ffmpeg/libavcodec/smacker.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-02-19 18:14:59 UTC
  • mfrom: (4.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20100219181459-mect96st3px2jfsi
Tags: 0.10.9.2-1
* New upstream pre-release:
  + debian/patches/03_restricted-caps.patch,
    debian/patches/04_ignore-vdpau.patch:
    - Dropped, merged upstream.
* debian/patches/03_too-new-codec-ids.patch:
  + Disable some ffmpeg codec IDs because Debian's
    ffmpeg is once again too old...

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "avcodec.h"
35
35
 
36
36
#define ALT_BITSTREAM_READER_LE
37
 
#include "bitstream.h"
 
37
#include "get_bits.h"
38
38
#include "bytestream.h"
39
39
 
40
40
#define SMKTREE_BITS 9
345
345
    return v;
346
346
}
347
347
 
348
 
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
 
348
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
349
349
{
 
350
    const uint8_t *buf = avpkt->data;
 
351
    int buf_size = avpkt->size;
350
352
    SmackVContext * const smk = avctx->priv_data;
351
353
    uint8_t *out;
352
354
    uint32_t *pal;
512
514
 
513
515
    c->avctx = avctx;
514
516
 
515
 
    c->pic.data[0] = NULL;
516
 
 
517
 
    if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
518
 
        return 1;
519
 
    }
520
 
 
521
517
    avctx->pix_fmt = PIX_FMT_PAL8;
522
518
 
523
519
 
558
554
 
559
555
static av_cold int smka_decode_init(AVCodecContext *avctx)
560
556
{
561
 
    avctx->sample_fmt = SAMPLE_FMT_S16;
562
557
    avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
 
558
    avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? SAMPLE_FMT_U8 : SAMPLE_FMT_S16;
563
559
    return 0;
564
560
}
565
561
 
566
562
/**
567
563
 * Decode Smacker audio data
568
564
 */
569
 
static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
 
565
static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
570
566
{
 
567
    const uint8_t *buf = avpkt->data;
 
568
    int buf_size = avpkt->size;
571
569
    GetBitContext gb;
572
570
    HuffContext h[4];
573
571
    VLC vlc[4];
574
572
    int16_t *samples = data;
 
573
    int8_t *samples8 = data;
575
574
    int val;
576
575
    int i, res;
577
576
    int unp_size;
589
588
    }
590
589
    stereo = get_bits1(&gb);
591
590
    bits = get_bits1(&gb);
592
 
    if (unp_size & 0xC0000000 || (unp_size << !bits) > *data_size) {
 
591
    if (unp_size & 0xC0000000 || unp_size > *data_size) {
593
592
        av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
594
593
        return -1;
595
594
    }
655
654
        for(i = stereo; i >= 0; i--)
656
655
            pred[i] = get_bits(&gb, 8);
657
656
        for(i = 0; i < stereo; i++)
658
 
            *samples++ = (pred[i] - 0x80) << 8;
 
657
            *samples8++ = pred[i];
659
658
        for(i = 0; i < unp_size; i++) {
660
659
            if(i & stereo){
661
660
                if(vlc[1].table)
663
662
                else
664
663
                    res = 0;
665
664
                pred[1] += (int8_t)h[1].values[res];
666
 
                *samples++ = (pred[1] - 0x80) << 8;
 
665
                *samples8++ = pred[1];
667
666
            } else {
668
667
                if(vlc[0].table)
669
668
                    res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
670
669
                else
671
670
                    res = 0;
672
671
                pred[0] += (int8_t)h[0].values[res];
673
 
                *samples++ = (pred[0] - 0x80) << 8;
 
672
                *samples8++ = pred[0];
674
673
            }
675
674
        }
676
 
        unp_size *= 2;
677
675
    }
678
676
 
679
677
    for(i = 0; i < 4; i++) {
700
698
    NULL,
701
699
    decode_end,
702
700
    decode_frame,
 
701
    CODEC_CAP_DR1,
703
702
    .long_name = NULL_IF_CONFIG_SMALL("Smacker video"),
704
703
};
705
704