Lines Matching refs:avctx

71 static av_cold int raw_init_decoder(AVCodecContext *avctx)
73 RawVideoContext *context = avctx->priv_data;
78 if ( avctx->codec_tag == MKTAG('r','a','w',' ')
79 || avctx->codec_tag == MKTAG('N','O','1','6'))
80 avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
81 avctx->bits_per_coded_sample);
82 else if (avctx->codec_tag == MKTAG('W', 'R', 'A', 'W'))
83 avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
84 avctx->bits_per_coded_sample);
85 else if (avctx->codec_tag && (avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0))
86 avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, avctx->codec_tag);
87 else if (avctx->pix_fmt == AV_PIX_FMT_NONE && avctx->bits_per_coded_sample)
88 avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
89 avctx->bits_per_coded_sample);
91 desc = av_pix_fmt_desc_get(avctx->pix_fmt);
93 av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
102 if (avctx->bits_per_coded_sample == 1)
106 if ((avctx->extradata_size >= 9 &&
107 !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9)) ||
108 avctx->codec_tag == MKTAG('c','y','u','v') ||
109 avctx->codec_tag == MKTAG(3, 0, 0, 0) ||
110 avctx->codec_tag == MKTAG('W','R','A','W'))
113 if (avctx->pix_fmt == AV_PIX_FMT_MONOWHITE ||
114 avctx->pix_fmt == AV_PIX_FMT_MONOBLACK)
116 else if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
119 if (avctx->codec_tag == MKTAG('B','1','W','0') ||
120 avctx->codec_tag == MKTAG('B','0','W','1'))
122 else if (avctx->codec_tag == MKTAG('P','A','L',8))
125 if (avctx->codec_tag == AV_RL32("yuv2") &&
126 avctx->pix_fmt == AV_PIX_FMT_YUYV422)
132 static void flip(AVCodecContext *avctx, AVFrame *frame)
134 frame->data[0] += frame->linesize[0] * (avctx->height - 1);
147 static void name(AVCodecContext *avctx, uint8_t * dst, const uint8_t *buf, int buf_size, int packed) \
152 w16(dst + i, SCALE16(r16(buf + i), avctx->bits_per_coded_sample)); \
156 for (i = 0; i < avctx->width * avctx->height; i++) { \
157 int sample = get_bits(&gb, avctx->bits_per_coded_sample); \
158 w16(dst + i*2, SCALE16(sample, avctx->bits_per_coded_sample)); \
166 static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
170 RawVideoContext *context = avctx->priv_data;
178 if (avctx->width <= 0) {
179 av_log(avctx, AV_LOG_ERROR, "width is not set\n");
182 if (avctx->height <= 0) {
183 av_log(avctx, AV_LOG_ERROR, "height is not set\n");
188 stride = avctx->width / 8 + (avctx->width & 7 ? 1 : 0);
190 stride = avctx->width;
192 stride = avpkt->size / avctx->height;
194 av_log(avctx, AV_LOG_DEBUG, "PACKET SIZE: %d, STRIDE: %d\n", avpkt->size, stride);
196 if (stride == 0 || avpkt->size < stride * avctx->height) {
197 av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
201 desc = av_pix_fmt_desc_get(avctx->pix_fmt);
203 if ((avctx->bits_per_coded_sample == 8 || avctx->bits_per_coded_sample == 4 ||
204 avctx->bits_per_coded_sample == 2 || avctx->bits_per_coded_sample == 1 ||
205 (avctx->bits_per_coded_sample == 0 && (context->is_nut_pal8 || context->is_mono)) ) &&
207 (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' ') ||
211 int row_bytes = avctx->width / 8 + (avctx->width & 7 ? 1 : 0);
212 context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
214 avctx->height, 1);
216 context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
217 FFALIGN(avctx->width, 16),
218 avctx->height, 1);
220 context->is_lt_16bpp = av_get_bits_per_pixel(desc) == 16 && avctx->bits_per_coded_sample > 8 && avctx->bits_per_coded_sample < 16;
221 context->frame_size = av_image_get_buffer_size(avctx->pix_fmt, avctx->width,
222 avctx->height, 1);
232 res = ff_decode_frame_props(avctx, frame);
236 frame->pkt_pos = avctx->internal->last_pkt_props->pos;
237 frame->pkt_duration = avctx->internal->last_pkt_props->duration;
244 if ((res = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
259 if (avctx->bits_per_coded_sample == 8 || context->is_nut_pal8 || context->is_mono) {
264 if (row_pix >= avctx->width) {
270 } else if (avctx->bits_per_coded_sample == 4) {
275 if (row_pix >= avctx->width) {
281 } else if (avctx->bits_per_coded_sample == 2) {
288 if (row_pix >= avctx->width) {
295 av_assert0(avctx->bits_per_coded_sample == 1);
306 if (row_pix >= avctx->width) {
317 int packed = (avctx->codec_tag & 0xFFFFFF) == MKTAG('B','I','T', 0);
318 int swap = avctx->codec_tag >> 24;
334 scale16be(avctx, dst, buf, buf_size, packed);
336 scale16le(avctx, dst, buf, buf_size, packed);
344 if (avctx->codec_tag == MKTAG('A', 'V', '1', 'x') ||
345 avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
348 len = context->frame_size - (avctx->pix_fmt==AV_PIX_FMT_PAL8 ? AVPALETTE_SIZE : 0);
349 if (buf_size < len && ((avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0) || !need_copy)) {
350 av_log(avctx, AV_LOG_ERROR, "Invalid buffer size, packet size %d < expected frame_size %d\n", buf_size, len);
356 buf, avctx->pix_fmt,
357 avctx->width, avctx->height, 1)) < 0) {
362 if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
377 if (ff_copy_palette(context->palette->data, avpkt, avctx)) {
380 int vid_size = avctx->width * avctx->height;
391 if ((avctx->pix_fmt==AV_PIX_FMT_RGB24 ||
392 avctx->pix_fmt==AV_PIX_FMT_BGR24 ||
393 avctx->pix_fmt==AV_PIX_FMT_GRAY8 ||
394 avctx->pix_fmt==AV_PIX_FMT_RGB555LE ||
395 avctx->pix_fmt==AV_PIX_FMT_RGB555BE ||
396 avctx->pix_fmt==AV_PIX_FMT_RGB565LE ||
397 avctx->pix_fmt==AV_PIX_FMT_MONOWHITE ||
398 avctx->pix_fmt==AV_PIX_FMT_MONOBLACK ||
399 avctx->pix_fmt==AV_PIX_FMT_PAL8) &&
400 FFALIGN(frame->linesize[0], linesize_align) * avctx->height <= buf_size)
403 if (avctx->pix_fmt == AV_PIX_FMT_NV12 && avctx->codec_tag == MKTAG('N', 'V', '1', '2') &&
404 FFALIGN(frame->linesize[0], linesize_align) * avctx->height +
405 FFALIGN(frame->linesize[1], linesize_align) * ((avctx->height + 1) / 2) <= buf_size) {
407 frame->data[1] += (la0 - frame->linesize[0]) * avctx->height;
412 if (avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) {
421 if (avctx->pix_fmt == AV_PIX_FMT_BGR24 &&
422 ((frame->linesize[0] + 3) & ~3) * avctx->height <= buf_size)
426 flip(avctx, frame);
428 if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2') ||
429 avctx->codec_tag == MKTAG('Y', 'V', '1', '6') ||
430 avctx->codec_tag == MKTAG('Y', 'V', '2', '4') ||
431 avctx->codec_tag == MKTAG('Y', 'V', 'U', '9'))
434 if (avctx->codec_tag == AV_RL32("I420") && (avctx->width+1)*(avctx->height+1) * 3/2 == buf_size) {
435 frame->data[1] = frame->data[1] + (avctx->width+1)*(avctx->height+1) -avctx->width*avctx->height;
436 frame->data[2] = frame->data[2] + ((avctx->width+1)*(avctx->height+1) -avctx->width*avctx->height)*5/4;
439 if (avctx->codec_tag == AV_RL32("yuv2") &&
440 avctx->pix_fmt == AV_PIX_FMT_YUYV422) {
443 for (y = 0; y < avctx->height; y++) {
444 for (x = 0; x < avctx->width; x++)
450 if (avctx->codec_tag == AV_RL32("b64a") &&
451 avctx->pix_fmt == AV_PIX_FMT_RGBA64BE) {
455 for (y = 0; y < avctx->height; y++) {
456 for (x = 0; x >> 3 < avctx->width; x += 8) {
464 if (avctx->field_order > AV_FIELD_PROGRESSIVE) { /* we have interlaced material flagged in container */
466 if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB)
474 static av_cold int raw_close_decoder(AVCodecContext *avctx)
476 RawVideoContext *context = avctx->priv_data;