~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/flicvideo.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * You should have received a copy of the GNU Lesser General Public
18
18
 * License along with FFmpeg; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 
 *
21
20
 */
22
21
 
23
22
/**
41
40
#include <string.h>
42
41
#include <unistd.h>
43
42
 
44
 
#include "common.h"
45
43
#include "avcodec.h"
46
44
#include "bswap.h"
47
45
 
78
76
    int fli_type;  /* either 0xAF11 or 0xAF12, affects palette resolution */
79
77
} FlicDecodeContext;
80
78
 
81
 
static int flic_decode_init(AVCodecContext *avctx)
 
79
static av_cold int flic_decode_init(AVCodecContext *avctx)
82
80
{
83
 
    FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data;
 
81
    FlicDecodeContext *s = avctx->priv_data;
84
82
    unsigned char *fli_header = (unsigned char *)avctx->extradata;
85
83
    int depth;
86
84
 
87
85
    s->avctx = avctx;
88
 
    avctx->has_b_frames = 0;
89
86
 
90
87
    s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
91
 
    depth       = AV_RL16(&fli_header[12]);
92
 
 
93
 
    if (depth == 0) {
94
 
      depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
95
 
    }
96
 
 
 
88
 
 
89
    depth = 0;
97
90
    if (s->avctx->extradata_size == 12) {
98
91
        /* special case for magic carpet FLIs */
99
92
        s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE;
 
93
        depth = 8;
100
94
    } else if (s->avctx->extradata_size != 128) {
101
95
        av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n");
102
96
        return -1;
 
97
    } else {
 
98
        depth = AV_RL16(&fli_header[12]);
 
99
    }
 
100
 
 
101
    if (depth == 0) {
 
102
        depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
103
103
    }
104
104
 
105
105
    if ((s->fli_type == FLC_FLX_TYPE_CODE) && (depth == 16)) {
115
115
                  return -1;
116
116
                  break;
117
117
        default :
118
 
                  av_log(avctx, AV_LOG_ERROR, "Unkown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
 
118
                  av_log(avctx, AV_LOG_ERROR, "Unknown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
119
119
                  return -1;
120
120
    }
121
121
 
127
127
 
128
128
static int flic_decode_frame_8BPP(AVCodecContext *avctx,
129
129
                                  void *data, int *data_size,
130
 
                                  uint8_t *buf, int buf_size)
 
130
                                  const uint8_t *buf, int buf_size)
131
131
{
132
 
    FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data;
 
132
    FlicDecodeContext *s = avctx->priv_data;
133
133
 
134
134
    int stream_ptr = 0;
135
135
    int stream_ptr_after_color_chunk;
427
427
 
428
428
static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
429
429
                                      void *data, int *data_size,
430
 
                                      uint8_t *buf, int buf_size)
 
430
                                      const uint8_t *buf, int buf_size)
431
431
{
432
432
    /* Note, the only difference between the 15Bpp and 16Bpp */
433
433
    /* Format is the pixel format, the packets are processed the same. */
434
 
    FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data;
 
434
    FlicDecodeContext *s = avctx->priv_data;
435
435
 
436
436
    int stream_ptr = 0;
437
437
    int pixel_ptr;
483
483
        switch (chunk_type) {
484
484
        case FLI_256_COLOR:
485
485
        case FLI_COLOR:
486
 
            /* For some reason, it seems that non-paletised flics do include one of these */
487
 
            /* chunks in their first frame.  Why i do not know, it seems rather extraneous */
 
486
            /* For some reason, it seems that non-palettized flics do
 
487
             * include one of these chunks in their first frame.
 
488
             * Why I do not know, it seems rather extraneous. */
488
489
/*            av_log(avctx, AV_LOG_ERROR, "Unexpected Palette chunk %d in non-paletised FLC\n",chunk_type);*/
489
490
            stream_ptr = stream_ptr + chunk_size - 6;
490
491
            break;
581
582
                }
582
583
 
583
584
                /* Now FLX is strange, in that it is "byte" as opposed to "pixel" run length compressed.
584
 
                 * This doesnt give us any good oportunity to perform word endian conversion
585
 
                 * during decompression. So if its requried (ie, this isnt a LE target, we do
 
585
                 * This does not give us any good oportunity to perform word endian conversion
 
586
                 * during decompression. So if it is required (i.e., this is not a LE target, we do
586
587
                 * a second pass over the line here, swapping the bytes.
587
588
                 */
588
 
                pixel = 0xFF00;
589
 
                if (0xFF00 != AV_RL16(&pixel)) /* Check if its not an LE Target */
590
 
                {
591
 
                  pixel_ptr = y_ptr;
592
 
                  pixel_countdown = s->avctx->width;
593
 
                  while (pixel_countdown > 0) {
 
589
#ifdef WORDS_BIGENDIAN
 
590
                pixel_ptr = y_ptr;
 
591
                pixel_countdown = s->avctx->width;
 
592
                while (pixel_countdown > 0) {
594
593
                    *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[pixel_ptr]);
595
594
                    pixel_ptr += 2;
596
 
                  }
597
595
                }
 
596
#endif
598
597
                y_ptr += s->frame.linesize[0];
599
598
            }
600
599
            break;
694
693
 
695
694
static int flic_decode_frame_24BPP(AVCodecContext *avctx,
696
695
                                   void *data, int *data_size,
697
 
                                   uint8_t *buf, int buf_size)
 
696
                                   const uint8_t *buf, int buf_size)
698
697
{
699
698
  av_log(avctx, AV_LOG_ERROR, "24Bpp FLC Unsupported due to lack of test files.\n");
700
699
  return -1;
702
701
 
703
702
static int flic_decode_frame(AVCodecContext *avctx,
704
703
                             void *data, int *data_size,
705
 
                             uint8_t *buf, int buf_size)
 
704
                             const uint8_t *buf, int buf_size)
706
705
{
707
706
    if (avctx->pix_fmt == PIX_FMT_PAL8) {
708
707
      return flic_decode_frame_8BPP(avctx, data, data_size,
718
717
                                     buf, buf_size);
719
718
    }
720
719
 
721
 
    /* Shouldnt get  here, ever as the pix_fmt is processed */
 
720
    /* Should not get  here, ever as the pix_fmt is processed */
722
721
    /* in flic_decode_init and the above if should deal with */
723
722
    /* the finite set of possibilites allowable by here. */
724
 
    /* but in case we do, just error out. */
725
 
    av_log(avctx, AV_LOG_ERROR, "Unknown Format of FLC. My Science cant explain how this happened\n");
 
723
    /* But in case we do, just error out. */
 
724
    av_log(avctx, AV_LOG_ERROR, "Unknown FLC format, my science cannot explain how this happened.\n");
726
725
    return -1;
727
726
}
728
727
 
729
728
 
730
 
static int flic_decode_end(AVCodecContext *avctx)
 
729
static av_cold int flic_decode_end(AVCodecContext *avctx)
731
730
{
732
731
    FlicDecodeContext *s = avctx->priv_data;
733
732
 
750
749
    NULL,
751
750
    NULL,
752
751
    NULL,
753
 
    NULL
 
752
    NULL,
 
753
    .long_name = "Autodesk Animator Flic video",
754
754
};