00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #include "avcodec.h"
00028 #include "raw.h"
00029 #include "libavutil/pixdesc.h"
00030 #include "libavutil/intreadwrite.h"
00031
00032 static av_cold int raw_init_encoder(AVCodecContext *avctx)
00033 {
00034 avctx->coded_frame = (AVFrame *)avctx->priv_data;
00035 avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
00036 avctx->coded_frame->key_frame = 1;
00037 avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
00038 if(!avctx->codec_tag)
00039 avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
00040 return 0;
00041 }
00042
00043 static int raw_encode(AVCodecContext *avctx,
00044 unsigned char *frame, int buf_size, void *data)
00045 {
00046 int ret = avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width,
00047 avctx->height, frame, buf_size);
00048
00049 if(avctx->codec_tag == AV_RL32("yuv2") && ret > 0 &&
00050 avctx->pix_fmt == PIX_FMT_YUYV422) {
00051 int x;
00052 for(x = 1; x < avctx->height*avctx->width*2; x += 2)
00053 frame[x] ^= 0x80;
00054 }
00055 return ret;
00056 }
00057
00058 AVCodec ff_rawvideo_encoder = {
00059 "rawvideo",
00060 AVMEDIA_TYPE_VIDEO,
00061 CODEC_ID_RAWVIDEO,
00062 sizeof(AVFrame),
00063 raw_init_encoder,
00064 raw_encode,
00065 .long_name = NULL_IF_CONFIG_SMALL("raw video"),
00066 };