FFmpeg: libavcodec/avs.c Source File
Go to the documentation of this file. 1 /*
2 * AVS video decoder.
3 * Copyright (c) 2006 Aurelien Jacobs <aurel@gnuage.org>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg 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 * FFmpeg 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 FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
25
29
36
43
44
45 static int
48 {
49 const uint8_t *buf = avpkt->
data;
50 const uint8_t *buf_end = avpkt->
data + avpkt->
size;
51 int buf_size = avpkt->
size;
55 const uint8_t *
table, *vect;
57 int i, j, x, y,
stride,
ret, vect_w = 3, vect_h = 3;
61
66
69
70 if (buf_end - buf < 4)
72 sub_type = buf[0];
74 buf += 4;
75
78 uint32_t *pal = (uint32_t *) p->
data[1];
79
82 if (
first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last -
first))
84 buf += 4;
86 pal[
i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2);
87 pal[
i] |= 0xFF
U << 24 | (pal[
i] >> 6) & 0x30303;
88 }
89
90 sub_type = buf[0];
92 buf += 4;
93 }
94
97
98 switch (sub_type) {
103 vect_w = 3;
104 vect_h = 3;
105 break;
106
108 vect_w = 2;
109 vect_h = 2;
110 break;
111
113 vect_w = 2;
114 vect_h = 3;
115 break;
116
117 default:
119 }
120
121 if (buf_end - buf < 256 * vect_w * vect_h)
123 table = buf + (256 * vect_w * vect_h);
125 int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h);
126 if (buf_end -
table < map_size)
130 }
131
132 for (y=0; y<198; y+=vect_h) {
133 for (x=0; x<318; x+=vect_w) {
135 if (buf_end -
table < 1)
137 vect = &buf[*
table++ * (vect_w * vect_h)];
138 for (j=0; j<vect_w; j++) {
139 out[(y + 0) *
stride + x + j] = vect[(0 * vect_w) + j];
140 out[(y + 1) *
stride + x + j] = vect[(1 * vect_w) + j];
141 if (vect_h == 3)
143 vect[(2 * vect_w) + j];
144 }
145 }
146 }
149 }
150
153 *got_frame = 1;
154
155 return buf_size;
156 }
157
159 {
161
165
167
169 }
170
172 {
175 return 0;
176 }
177
178
190 };
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static av_cold int avs_decode_end(AVCodecContext *avctx)
static const uint16_t table[]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const AVCodec ff_avs_decoder
int key_frame
1 -> keyframe, 0-> not
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static av_cold int avs_decode_init(AVCodecContext *avctx)
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static unsigned int get_bits1(GetBitContext *s)
@ AV_PICTURE_TYPE_I
Intra.
enum AVPictureType pict_type
Picture type of the frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define i(width, name, range_min, range_max)
static int avs_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
static const uint8_t * align_get_bits(GetBitContext *s)
main external API structure.
@ AV_PICTURE_TYPE_P
Predicted.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
This structure stores compressed data.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Generated on Wed Aug 24 2022 21:37:27 for FFmpeg by
doxygen
1.8.17