annotate libmpcodecs/vd_ffmpeg.c @ 5634:cc24d5e2573f

removed unused XP stuff
author alex
date Mon, 15 Apr 2002 17:08:02 +0000
parents 481592004427
children d0308affc401
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
1 #include <stdio.h>
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
2 #include <stdlib.h>
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
3 #include <assert.h>
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
4
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
5 #include "config.h"
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
6 #include "mp_msg.h"
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
7 #include "help_mp.h"
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
8
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
9 #ifdef USE_LIBAVCODEC
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
10
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
11 #include "bswap.h"
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
12
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
13 #include "vd_internal.h"
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
14
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
15 static vd_info_t info = {
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
16 "FFmpeg's libavcodec codec family",
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
17 "ffmpeg",
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
18 VFM_FFMPEG,
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
19 "A'rpi",
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
20 "http://ffmpeg.sf.net",
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
21 "native codecs"
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
22 };
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
23
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
24 LIBVD_EXTERN(ffmpeg)
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
25
5592
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
26 #include "../postproc/rgb2rgb.h"
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
27
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
28
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
29 #ifdef USE_LIBAVCODEC_SO
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
30 #include <libffmpeg/avcodec.h>
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
31 #else
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
32 #include "libavcodec/avcodec.h"
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
33 #endif
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
34
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
35 int avcodec_inited=0;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
36
5517
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
37 #ifdef FF_POSTPROCESS
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
38 int quant_store[MBR+1][MBC+1];
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
39 #endif
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
40
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
41 typedef struct {
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
42 AVCodecContext *avctx;
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
43 int last_aspect;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
44 int do_slices;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
45 int vo_inited;
5592
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
46 int convert;
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
47 int yuy2_support;
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
48 } vd_ffmpeg_ctx;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
49
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
50 //#ifdef FF_POSTPROCESS
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
51 //unsigned int lavc_pp=0;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
52 //#endif
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
53
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
54 // to set/get/query special features/parameters
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
55 static int control(sh_video_t *sh,int cmd,void* arg,...){
5592
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
56 vd_ffmpeg_ctx *ctx = sh->context;
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
57 switch(cmd){
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
58 case VDCTRL_QUERY_FORMAT:
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
59 if( (*((int*)arg)) == IMGFMT_YV12 ) return CONTROL_TRUE;
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
60 if( (*((int*)arg)) == IMGFMT_YUY2 && ctx->yuy2_support ) return CONTROL_TRUE;
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
61 return CONTROL_FALSE;
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
62 }
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
63 return CONTROL_UNKNOWN;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
64 }
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
65
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
66 // init driver
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
67 static int init(sh_video_t *sh){
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
68 AVCodecContext *avctx;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
69 vd_ffmpeg_ctx *ctx;
5457
f248c9e86423 config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents: 5331
diff changeset
70 AVCodec *lavc_codec;
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
71
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
72 if(!avcodec_inited){
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
73 avcodec_init();
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
74 avcodec_register_all();
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
75 avcodec_inited=1;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
76 }
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
77
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
78 ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx));
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
79 if (!ctx)
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
80 return(0);
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
81 memset(ctx, 0, sizeof(vd_ffmpeg_ctx));
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
82
5457
f248c9e86423 config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents: 5331
diff changeset
83 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll);
f248c9e86423 config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents: 5331
diff changeset
84 if(!lavc_codec){
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
85 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh->codec->dll);
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
86 return 0;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
87 }
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
88
5494
1c45b1484ffb i just fixed b-frames & slices in libavcodec :) ... iam too tired for benchmarks now ...
michael
parents: 5482
diff changeset
89 if(vd_use_slices && lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND)
1c45b1484ffb i just fixed b-frames & slices in libavcodec :) ... iam too tired for benchmarks now ...
michael
parents: 5482
diff changeset
90 ctx->do_slices=1;
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
91
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
92 ctx->avctx = malloc(sizeof(AVCodecContext));
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
93 memset(ctx->avctx, 0, sizeof(AVCodecContext));
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
94 avctx = ctx->avctx;
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
95
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
96 avctx->width = sh->disp_w;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
97 avctx->height= sh->disp_h;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
98 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",avctx->width,avctx->height);
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
99 if (sh->format == mmioFOURCC('R', 'V', '1', '3'))
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
100 avctx->sub_id = 3;
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
101 /* open it */
5457
f248c9e86423 config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents: 5331
diff changeset
102 if (avcodec_open(avctx, lavc_codec) < 0) {
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
103 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec);
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
104 return 0;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
105 }
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
106 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n");
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
107 ctx->last_aspect=-3;
5510
f2c4cace6450 don't config twice
arpi
parents: 5495
diff changeset
108 return 1; //mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12);
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
109 }
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
110
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
111 // uninit driver
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
112 static void uninit(sh_video_t *sh){
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
113 vd_ffmpeg_ctx *ctx = sh->context;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
114 AVCodecContext *avctx = ctx->avctx;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
115
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
116 if (avcodec_close(avctx) < 0)
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
117 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec);
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
118 if (avctx)
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
119 free(avctx);
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
120 if (ctx)
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
121 free(ctx);
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
122 }
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
123
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
124 #include "libvo/video_out.h" // FIXME!!!
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
125
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
126 static void draw_slice(struct AVCodecContext *s,
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
127 UINT8 **src, int linesize,
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
128 int y, int width, int height){
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
129 vo_functions_t * output = s->opaque;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
130 int stride[3];
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
131
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
132 stride[0]=linesize;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
133 stride[1]=stride[2]=stride[0]/2;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
134
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
135 output->draw_slice (src, stride, width, height, 0, y);
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
136
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
137 }
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
138
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
139 // decode a frame
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
140 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
141 int got_picture=0;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
142 int ret;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
143 AVPicture lavc_picture;
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
144 vd_ffmpeg_ctx *ctx = sh->context;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
145 AVCodecContext *avctx = ctx->avctx;
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
146 mp_image_t* mpi=NULL;
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
147
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
148 if(len<=0) return NULL; // skipped frame
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
149
5613
481592004427 draw_slices with framedrop fixed
arpi
parents: 5592
diff changeset
150 avctx->draw_horiz_band=NULL;
481592004427 draw_slices with framedrop fixed
arpi
parents: 5592
diff changeset
151 if(ctx->vo_inited && !ctx->convert && !(flags&3)){
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
152 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE |
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
153 (ctx->do_slices?MP_IMGFLAG_DRAW_CALLBACK:0),
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
154 sh->disp_w, sh->disp_h);
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
155 if(mpi && mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
156 // vd core likes slices!
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
157 avctx->draw_horiz_band=draw_slice;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
158 avctx->opaque=sh->video_out;
5613
481592004427 draw_slices with framedrop fixed
arpi
parents: 5592
diff changeset
159 }
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
160 }
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
161
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
162 ret = avcodec_decode_video(avctx, &lavc_picture,
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
163 &got_picture, data, len);
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
164
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
165 if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n");
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
166 if(!got_picture) return NULL; // skipped image
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
167
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
168 if (avctx->aspect_ratio_info != ctx->last_aspect ||
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
169 avctx->width != sh->disp_w ||
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
170 avctx->height != sh->disp_h ||
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
171 !ctx->vo_inited)
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
172 {
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
173 ctx->last_aspect = avctx->aspect_ratio_info;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
174 switch(avctx->aspect_ratio_info)
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
175 {
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
176 case FF_ASPECT_4_3_625:
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
177 case FF_ASPECT_4_3_525:
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
178 sh->aspect = 4.0/3.0;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
179 break;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
180 case FF_ASPECT_16_9_625:
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
181 case FF_ASPECT_16_9_525:
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
182 sh->aspect = 16.0/9.0;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
183 break;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
184 case FF_ASPECT_SQUARE:
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
185 default:
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
186 sh->aspect = 0.0;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
187 break;
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
188 }
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
189 sh->disp_w = avctx->width;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
190 sh->disp_h = avctx->height;
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
191 ctx->vo_inited=1;
5592
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
192 ctx->yuy2_support=(avctx->pix_fmt==PIX_FMT_YUV422P);
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
193 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
194 ctx->yuy2_support ? IMGFMT_YUY2 : IMGFMT_YV12))
5457
f248c9e86423 config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents: 5331
diff changeset
195 return NULL;
5592
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
196 ctx->convert=(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_YUY2);
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
197 }
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
198
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
199 if(!mpi && ctx->convert){
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
200 // do yuv422p -> yuy2 conversion:
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
201 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
202 avctx->width, avctx->height);
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
203 if(!mpi) return NULL;
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
204 yuv422ptoyuy2(lavc_picture.data[0],lavc_picture.data[1],lavc_picture.data[2],
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
205 mpi->planes[0],avctx->width,avctx->height,
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
206 lavc_picture.linesize[0],lavc_picture.linesize[1],mpi->stride[0]);
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
207 return mpi;
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
208 }
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
209
5482
cd97c8313300 libavcodec slices support
arpi
parents: 5457
diff changeset
210 if(!mpi)
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
211 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
212 avctx->width, avctx->height);
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
213 if(!mpi){ // temporary!
5207
d337cc4ab0ee config vo if resolution changed (after decoded image read the dimensions out of lavc context)
alex
parents: 5124
diff changeset
214 printf("couldn't allocate image for codec\n");
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
215 return NULL;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
216 }
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
217
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
218 mpi->planes[0]=lavc_picture.data[0];
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
219 mpi->planes[1]=lavc_picture.data[1];
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
220 mpi->planes[2]=lavc_picture.data[2];
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
221 mpi->stride[0]=lavc_picture.linesize[0];
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
222 mpi->stride[1]=lavc_picture.linesize[1];
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
223 mpi->stride[2]=lavc_picture.linesize[2];
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
224
5280
ea8f3e8f39c1 added aspect ratio support and local ctx
alex
parents: 5219
diff changeset
225 if(avctx->pix_fmt==PIX_FMT_YUV422P){
5592
b545d56314d2 yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents: 5517
diff changeset
226 // we have 422p but user wants yv12 (420p)
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
227 mpi->stride[1]*=2;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
228 mpi->stride[2]*=2;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
229 }
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
230
5517
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
231 #ifdef FF_POSTPROCESS
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
232 mpi->qscale=&quant_store[0][0];
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
233 mpi->qstride=MBC+1;
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
234 #endif
a3337d7b853f export qscale for postproc
arpi
parents: 5510
diff changeset
235
4952
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
236 return mpi;
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
237 }
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
238
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
239 #endif
ffeba1050226 vd_ffmpeg added
arpi
parents:
diff changeset
240