Mercurial > mplayer.hg
comparison libmpcodecs/vd_ffmpeg.c @ 5592:b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
author | arpi |
---|---|
date | Sat, 13 Apr 2002 13:40:26 +0000 |
parents | a3337d7b853f |
children | 481592004427 |
comparison
equal
deleted
inserted
replaced
5591:9243e8988e0f | 5592:b545d56314d2 |
---|---|
21 "native codecs" | 21 "native codecs" |
22 }; | 22 }; |
23 | 23 |
24 LIBVD_EXTERN(ffmpeg) | 24 LIBVD_EXTERN(ffmpeg) |
25 | 25 |
26 #include "../postproc/rgb2rgb.h" | |
27 | |
28 | |
26 #ifdef USE_LIBAVCODEC_SO | 29 #ifdef USE_LIBAVCODEC_SO |
27 #include <libffmpeg/avcodec.h> | 30 #include <libffmpeg/avcodec.h> |
28 #else | 31 #else |
29 #include "libavcodec/avcodec.h" | 32 #include "libavcodec/avcodec.h" |
30 #endif | 33 #endif |
38 typedef struct { | 41 typedef struct { |
39 AVCodecContext *avctx; | 42 AVCodecContext *avctx; |
40 int last_aspect; | 43 int last_aspect; |
41 int do_slices; | 44 int do_slices; |
42 int vo_inited; | 45 int vo_inited; |
46 int convert; | |
47 int yuy2_support; | |
43 } vd_ffmpeg_ctx; | 48 } vd_ffmpeg_ctx; |
44 | 49 |
45 //#ifdef FF_POSTPROCESS | 50 //#ifdef FF_POSTPROCESS |
46 //unsigned int lavc_pp=0; | 51 //unsigned int lavc_pp=0; |
47 //#endif | 52 //#endif |
48 | 53 |
49 // to set/get/query special features/parameters | 54 // to set/get/query special features/parameters |
50 static int control(sh_video_t *sh,int cmd,void* arg,...){ | 55 static int control(sh_video_t *sh,int cmd,void* arg,...){ |
56 vd_ffmpeg_ctx *ctx = sh->context; | |
57 switch(cmd){ | |
58 case VDCTRL_QUERY_FORMAT: | |
59 if( (*((int*)arg)) == IMGFMT_YV12 ) return CONTROL_TRUE; | |
60 if( (*((int*)arg)) == IMGFMT_YUY2 && ctx->yuy2_support ) return CONTROL_TRUE; | |
61 return CONTROL_FALSE; | |
62 } | |
51 return CONTROL_UNKNOWN; | 63 return CONTROL_UNKNOWN; |
52 } | 64 } |
53 | 65 |
54 // init driver | 66 // init driver |
55 static int init(sh_video_t *sh){ | 67 static int init(sh_video_t *sh){ |
133 AVCodecContext *avctx = ctx->avctx; | 145 AVCodecContext *avctx = ctx->avctx; |
134 mp_image_t* mpi=NULL; | 146 mp_image_t* mpi=NULL; |
135 | 147 |
136 if(len<=0) return NULL; // skipped frame | 148 if(len<=0) return NULL; // skipped frame |
137 | 149 |
138 if(ctx->vo_inited){ | 150 if(ctx->vo_inited && !ctx->convert){ |
139 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE | | 151 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE | |
140 (ctx->do_slices?MP_IMGFLAG_DRAW_CALLBACK:0), | 152 (ctx->do_slices?MP_IMGFLAG_DRAW_CALLBACK:0), |
141 sh->disp_w, sh->disp_h); | 153 sh->disp_w, sh->disp_h); |
142 if(mpi && mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ | 154 if(mpi && mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ |
143 // vd core likes slices! | 155 // vd core likes slices! |
175 break; | 187 break; |
176 } | 188 } |
177 sh->disp_w = avctx->width; | 189 sh->disp_w = avctx->width; |
178 sh->disp_h = avctx->height; | 190 sh->disp_h = avctx->height; |
179 ctx->vo_inited=1; | 191 ctx->vo_inited=1; |
180 if (mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12)) | 192 ctx->yuy2_support=(avctx->pix_fmt==PIX_FMT_YUV422P); |
193 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h, | |
194 ctx->yuy2_support ? IMGFMT_YUY2 : IMGFMT_YV12)) | |
181 return NULL; | 195 return NULL; |
196 ctx->convert=(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_YUY2); | |
197 } | |
198 | |
199 if(!mpi && ctx->convert){ | |
200 // do yuv422p -> yuy2 conversion: | |
201 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
202 avctx->width, avctx->height); | |
203 if(!mpi) return NULL; | |
204 yuv422ptoyuy2(lavc_picture.data[0],lavc_picture.data[1],lavc_picture.data[2], | |
205 mpi->planes[0],avctx->width,avctx->height, | |
206 lavc_picture.linesize[0],lavc_picture.linesize[1],mpi->stride[0]); | |
207 return mpi; | |
182 } | 208 } |
183 | 209 |
184 if(!mpi) | 210 if(!mpi) |
185 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, | 211 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, |
186 avctx->width, avctx->height); | 212 avctx->width, avctx->height); |
195 mpi->stride[0]=lavc_picture.linesize[0]; | 221 mpi->stride[0]=lavc_picture.linesize[0]; |
196 mpi->stride[1]=lavc_picture.linesize[1]; | 222 mpi->stride[1]=lavc_picture.linesize[1]; |
197 mpi->stride[2]=lavc_picture.linesize[2]; | 223 mpi->stride[2]=lavc_picture.linesize[2]; |
198 | 224 |
199 if(avctx->pix_fmt==PIX_FMT_YUV422P){ | 225 if(avctx->pix_fmt==PIX_FMT_YUV422P){ |
226 // we have 422p but user wants yv12 (420p) | |
200 mpi->stride[1]*=2; | 227 mpi->stride[1]*=2; |
201 mpi->stride[2]*=2; | 228 mpi->stride[2]*=2; |
202 } | 229 } |
203 | 230 |
204 #ifdef FF_POSTPROCESS | 231 #ifdef FF_POSTPROCESS |