MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / raw_decode

Function raw_decode

libavcodec/rawdec.c:165–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163MKSCALE16(scale16le, AV_RL16, AV_WL16)
164
165static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
166 int *got_frame, AVPacket *avpkt)
167{
168 const AVPixFmtDescriptor *desc;
169 RawVideoContext *context = avctx->priv_data;
170 const uint8_t *buf = avpkt->data;
171 int buf_size = avpkt->size;
172 int linesize_align = 4;
173 int stride;
174 int res, len;
175 int need_copy;
176
177 if (avctx->width <= 0) {
178 av_log(avctx, AV_LOG_ERROR, "width is not set\n");
179 return AVERROR_INVALIDDATA;
180 }
181 if (avctx->height <= 0) {
182 av_log(avctx, AV_LOG_ERROR, "height is not set\n");
183 return AVERROR_INVALIDDATA;
184 }
185
186 if (context->is_nut_mono)
187 stride = avctx->width / 8 + (avctx->width & 7 ? 1 : 0);
188 else if (context->is_nut_pal8)
189 stride = avctx->width;
190 else
191 stride = avpkt->size / avctx->height;
192
193 av_log(avctx, AV_LOG_DEBUG, "PACKET SIZE: %d, STRIDE: %d\n", avpkt->size, stride);
194
195 if (stride == 0 || avpkt->size < stride * avctx->height) {
196 av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
197 return AVERROR_INVALIDDATA;
198 }
199
200 desc = av_pix_fmt_desc_get(avctx->pix_fmt);
201
202 if ((avctx->bits_per_coded_sample == 8 || avctx->bits_per_coded_sample == 4 ||
203 avctx->bits_per_coded_sample == 2 || avctx->bits_per_coded_sample == 1 ||
204 (avctx->bits_per_coded_sample == 0 && (context->is_nut_pal8 || context->is_mono)) ) &&
205 (context->is_mono || context->is_pal8) &&
206 (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' ') ||
207 context->is_nut_mono || context->is_nut_pal8)) {
208 context->is_1_2_4_8_bpp = 1;
209 if (context->is_mono) {
210 int row_bytes = avctx->width / 8 + (avctx->width & 7 ? 1 : 0);
211 context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
212 FFALIGN(row_bytes, 16) * 8,
213 avctx->height, 1);
214 } else
215 context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
216 FFALIGN(avctx->width, 16),
217 avctx->height, 1);
218 } else {
219 context->is_lt_16bpp = av_get_bits_per_pixel(desc) == 16 && avctx->bits_per_coded_sample > 8 && avctx->bits_per_coded_sample < 16;
220 context->frame_size = av_image_get_buffer_size(avctx->pix_fmt, avctx->width,
221 avctx->height, 1);
222 }

Callers

nothing calls this directly

Calls 14

av_logFunction · 0.85
av_pix_fmt_desc_getFunction · 0.85
av_image_get_buffer_sizeFunction · 0.85
av_get_bits_per_pixelFunction · 0.85
ff_decode_frame_propsFunction · 0.85
av_image_check_sizeFunction · 0.85
av_buffer_allocFunction · 0.85
av_buffer_refFunction · 0.85
av_fast_padded_mallocFunction · 0.85
av_buffer_unrefFunction · 0.85
av_image_fill_arraysFunction · 0.85
av_buffer_make_writableFunction · 0.85

Tested by

no test coverage detected