aasc.c
Go to the documentation of this file.
1 /*
2  * Autodesk RLE Decoder
3  * Copyright (C) 2005 the ffmpeg project
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 
31 #include "avcodec.h"
32 #include "dsputil.h"
33 #include "msrledec.h"
34 
35 typedef struct AascContext {
39 } AascContext;
40 
42 {
43  AascContext *s = avctx->priv_data;
44 
45  s->avctx = avctx;
46 
47  avctx->pix_fmt = AV_PIX_FMT_BGR24;
48 
49  return 0;
50 }
51 
53  void *data, int *got_frame,
54  AVPacket *avpkt)
55 {
56  const uint8_t *buf = avpkt->data;
57  int buf_size = avpkt->size;
58  AascContext *s = avctx->priv_data;
59  int compr, i, stride;
60 
61  s->frame.reference = 1;
63  if (avctx->reget_buffer(avctx, &s->frame)) {
64  av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
65  return -1;
66  }
67 
68  compr = AV_RL32(buf);
69  buf += 4;
70  buf_size -= 4;
71  switch (compr) {
72  case 0:
73  stride = (avctx->width * 3 + 3) & ~3;
74  for (i = avctx->height - 1; i >= 0; i--) {
75  memcpy(s->frame.data[0] + i * s->frame.linesize[0], buf, avctx->width * 3);
76  buf += stride;
77  }
78  break;
79  case 1:
80  bytestream2_init(&s->gb, buf, buf_size);
81  ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb);
82  break;
83  default:
84  av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
85  return -1;
86  }
87 
88  *got_frame = 1;
89  *(AVFrame*)data = s->frame;
90 
91  /* report that the buffer was completely consumed */
92  return buf_size;
93 }
94 
96 {
97  AascContext *s = avctx->priv_data;
98 
99  /* release the last frame */
100  if (s->frame.data[0])
101  avctx->release_buffer(avctx, &s->frame);
102 
103  return 0;
104 }
105 
107  .name = "aasc",
108  .type = AVMEDIA_TYPE_VIDEO,
109  .id = AV_CODEC_ID_AASC,
110  .priv_data_size = sizeof(AascContext),
114  .capabilities = CODEC_CAP_DR1,
115  .long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"),
116 };
This structure describes decoded (raw) audio or video data.
Definition: avcodec.h:989
int buffer_hints
codec suggestion on buffer type if != 0
Definition: avcodec.h:1253
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
Definition: avcodec.h:2259
int size
Definition: avcodec.h:916
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1533
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:130
four components are given, that's all.
Definition: avcodec.h:3153
int stride
Definition: mace.c:144
AVCodec.
Definition: avcodec.h:2960
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
Definition: avcodec.h:2273
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
Definition: mimic.c:228
uint8_t
const char data[16]
Definition: mxf.c:66
uint8_t * data
Definition: avcodec.h:915
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:335
static av_cold int aasc_decode_end(AVCodecContext *avctx)
Definition: aasc.c:95
struct AascContext AascContext
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
Definition: avcodec.h:1132
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:88
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:146
const char * name
Name of the codec implementation.
Definition: avcodec.h:2967
GetByteContext gb
Definition: aasc.c:37
int width
picture width / height.
Definition: avcodec.h:1508
static av_cold int aasc_decode_init(AVCodecContext *avctx)
Definition: aasc.c:41
#define AV_RL32
Definition: intreadwrite.h:146
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:68
static int aasc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: aasc.c:52
AVFrame frame
Definition: aasc.c:38
external API header
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
Definition: avcodec.h:1008
main external API structure.
Definition: avcodec.h:1339
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:326
AVCodec ff_aasc_decoder
Definition: aasc.c:106
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: avcodec.h:997
DSP utils.
void * priv_data
Definition: avcodec.h:1382
int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic, int depth, GetByteContext *gb)
Decode stream in MS RLE format into frame.
Definition: msrledec.c:246
AVCodecContext * avctx
Definition: aasc.c:36
This structure stores compressed data.
Definition: avcodec.h:898