#include <stdio.h>#include <stdlib.h>#include <string.h>#include "avcodec.h"#include "dsputil.h"Go to the source code of this file.
Data Structures | |
| struct | AascContext |
Defines | |
| #define | FETCH_NEXT_STREAM_BYTE() |
Functions | |
| static av_cold int | aasc_decode_init (AVCodecContext *avctx) |
| static int | aasc_decode_frame (AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) |
| static av_cold int | aasc_decode_end (AVCodecContext *avctx) |
Variables | |
| AVCodec | aasc_decoder |
Definition in file aasc.c.
| #define FETCH_NEXT_STREAM_BYTE | ( | ) |
Value:
if (stream_ptr >= buf_size) \ { \ av_log(s->avctx, AV_LOG_ERROR, " AASC: stream ptr just went out of bounds (fetch)\n"); \ break; \ } \ stream_byte = buf[stream_ptr++];
Definition at line 39 of file aasc.c.
Referenced by aasc_decode_frame(), msrle_decode_pal4(), and msrle_decode_pal8().
| static av_cold int aasc_decode_end | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 153 of file aasc.c.
References AascContext::frame, AVCodecContext::priv_data, and AVCodecContext::release_buffer.
00154 { 00155 AascContext *s = avctx->priv_data; 00156 00157 /* release the last frame */ 00158 if (s->frame.data[0]) 00159 avctx->release_buffer(avctx, &s->frame); 00160 00161 return 0; 00162 }
| static int aasc_decode_frame | ( | AVCodecContext * | avctx, | |
| void * | data, | |||
| int * | data_size, | |||
| const uint8_t * | buf, | |||
| int | buf_size | |||
| ) | [static] |
Definition at line 59 of file aasc.c.
References av_log(), AV_LOG_ERROR, AascContext::avctx, FETCH_NEXT_STREAM_BYTE, FF_BUFFER_HINTS_PRESERVE, FF_BUFFER_HINTS_REUSABLE, FF_BUFFER_HINTS_VALID, AascContext::frame, AVCodecContext::height, AVCodecContext::priv_data, AVCodecContext::reget_buffer, and AVCodecContext::width.
00062 { 00063 AascContext *s = avctx->priv_data; 00064 int stream_ptr = 4; 00065 unsigned char rle_code; 00066 unsigned char stream_byte; 00067 int pixel_ptr = 0; 00068 int row_dec, row_ptr; 00069 int frame_size; 00070 int i; 00071 00072 s->frame.reference = 1; 00073 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; 00074 if (avctx->reget_buffer(avctx, &s->frame)) { 00075 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); 00076 return -1; 00077 } 00078 00079 row_dec = s->frame.linesize[0]; 00080 row_ptr = (s->avctx->height - 1) * row_dec; 00081 frame_size = row_dec * s->avctx->height; 00082 00083 while (row_ptr >= 0) { 00084 FETCH_NEXT_STREAM_BYTE(); 00085 rle_code = stream_byte; 00086 if (rle_code == 0) { 00087 /* fetch the next byte to see how to handle escape code */ 00088 FETCH_NEXT_STREAM_BYTE(); 00089 if (stream_byte == 0) { 00090 /* line is done, goto the next one */ 00091 row_ptr -= row_dec; 00092 pixel_ptr = 0; 00093 } else if (stream_byte == 1) { 00094 /* decode is done */ 00095 break; 00096 } else if (stream_byte == 2) { 00097 /* reposition frame decode coordinates */ 00098 FETCH_NEXT_STREAM_BYTE(); 00099 pixel_ptr += stream_byte; 00100 FETCH_NEXT_STREAM_BYTE(); 00101 row_ptr -= stream_byte * row_dec; 00102 } else { 00103 /* copy pixels from encoded stream */ 00104 if ((pixel_ptr + stream_byte > avctx->width * 3) || 00105 (row_ptr < 0)) { 00106 av_log(s->avctx, AV_LOG_ERROR, " AASC: frame ptr just went out of bounds (copy1)\n"); 00107 break; 00108 } 00109 00110 rle_code = stream_byte; 00111 if (stream_ptr + rle_code > buf_size) { 00112 av_log(s->avctx, AV_LOG_ERROR, " AASC: stream ptr just went out of bounds (copy2)\n"); 00113 break; 00114 } 00115 00116 for (i = 0; i < rle_code; i++) { 00117 FETCH_NEXT_STREAM_BYTE(); 00118 s->frame.data[0][row_ptr + pixel_ptr] = stream_byte; 00119 pixel_ptr++; 00120 } 00121 if (rle_code & 1) 00122 stream_ptr++; 00123 } 00124 } else { 00125 /* decode a run of data */ 00126 if ((pixel_ptr + rle_code > avctx->width * 3) || 00127 (row_ptr < 0)) { 00128 av_log(s->avctx, AV_LOG_ERROR, " AASC: frame ptr just went out of bounds (run1)\n"); 00129 break; 00130 } 00131 00132 FETCH_NEXT_STREAM_BYTE(); 00133 00134 while(rle_code--) { 00135 s->frame.data[0][row_ptr + pixel_ptr] = stream_byte; 00136 pixel_ptr++; 00137 } 00138 } 00139 } 00140 00141 /* one last sanity check on the way out */ 00142 if (stream_ptr < buf_size) 00143 av_log(s->avctx, AV_LOG_ERROR, " AASC: ended frame decode with bytes left over (%d < %d)\n", 00144 stream_ptr, buf_size); 00145 00146 *data_size = sizeof(AVFrame); 00147 *(AVFrame*)data = s->frame; 00148 00149 /* report that the buffer was completely consumed */ 00150 return buf_size; 00151 }
| static av_cold int aasc_decode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 47 of file aasc.c.
References AascContext::avctx, AascContext::frame, NULL, AVCodecContext::pix_fmt, PIX_FMT_BGR24, and AVCodecContext::priv_data.
00048 { 00049 AascContext *s = avctx->priv_data; 00050 00051 s->avctx = avctx; 00052 00053 avctx->pix_fmt = PIX_FMT_BGR24; 00054 s->frame.data[0] = NULL; 00055 00056 return 0; 00057 }
Initial value:
{
"aasc",
CODEC_TYPE_VIDEO,
CODEC_ID_AASC,
sizeof(AascContext),
aasc_decode_init,
NULL,
aasc_decode_end,
aasc_decode_frame,
CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"),
}
1.5.1