Revision cf087595 libavcodec/utils.c

View differences:

libavcodec/utils.c
174 174
    return NULL;
175 175
}
176 176

  
177
const char *pix_fmt_str[] = {
178
    "yuv420p",
179
    "yuv422",
180
    "rgb24",
181
    "bgr24",
182
    "yuv422p",
183
    "yuv444p",
184
};
185
    
177 186
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
178 187
{
179 188
    const char *codec_name;
......
208 217
        snprintf(buf, buf_size,
209 218
                 "Video: %s%s",
210 219
                 codec_name, enc->flags & CODEC_FLAG_HQ ? " (hq)" : "");
220
        if (enc->codec_id == CODEC_ID_RAWVIDEO) {
221
            snprintf(buf + strlen(buf), buf_size - strlen(buf),
222
                     ", %s",
223
                     pix_fmt_str[enc->pix_fmt]);
224
        }
211 225
        if (enc->width) {
212 226
            snprintf(buf + strlen(buf), buf_size - strlen(buf),
213 227
                     ", %dx%d, %0.2f fps",
......
235 249
    }
236 250
}
237 251

  
252
/* Picture field are filled with 'ptr' addresses */
253
void avpicture_fill(AVPicture *picture, UINT8 *ptr,
254
                    int pix_fmt, int width, int height)
255
{
256
    int size;
257

  
258
    size = width * height;
259
    switch(pix_fmt) {
260
    case PIX_FMT_YUV420P:
261
        picture->data[0] = ptr;
262
        picture->data[1] = picture->data[0] + size;
263
        picture->data[2] = picture->data[1] + size / 4;
264
        picture->linesize[0] = width;
265
        picture->linesize[1] = width / 2;
266
        picture->linesize[2] = width / 2;
267
        break;
268
    case PIX_FMT_YUV422P:
269
        picture->data[0] = ptr;
270
        picture->data[1] = picture->data[0] + size;
271
        picture->data[2] = picture->data[1] + size / 2;
272
        picture->linesize[0] = width;
273
        picture->linesize[1] = width / 2;
274
        picture->linesize[2] = width / 2;
275
        break;
276
    case PIX_FMT_YUV444P:
277
        picture->data[0] = ptr;
278
        picture->data[1] = picture->data[0] + size;
279
        picture->data[2] = picture->data[1] + size;
280
        picture->linesize[0] = width;
281
        picture->linesize[1] = width;
282
        picture->linesize[2] = width;
283
        break;
284
    case PIX_FMT_RGB24:
285
    case PIX_FMT_BGR24:
286
        picture->data[0] = ptr;
287
        picture->data[1] = NULL;
288
        picture->data[2] = NULL;
289
        picture->linesize[0] = width * 3;
290
        break;
291
    case PIX_FMT_YUV422:
292
        picture->data[0] = ptr;
293
        picture->data[1] = NULL;
294
        picture->data[2] = NULL;
295
        picture->linesize[0] = width * 2;
296
        break;
297
    default:
298
        picture->data[0] = NULL;
299
        picture->data[1] = NULL;
300
        picture->data[2] = NULL;
301
        break;
302
    }
303
}
304

  
305
int avpicture_get_size(int pix_fmt, int width, int height)
306
{
307
    int size;
308

  
309
    size = width * height;
310
    switch(pix_fmt) {
311
    case PIX_FMT_YUV420P:
312
        size = (size * 3) / 2;
313
        break;
314
    case PIX_FMT_YUV422P:
315
        size = (size * 2);
316
        break;
317
    case PIX_FMT_YUV444P:
318
        size = (size * 3);
319
        break;
320
    case PIX_FMT_RGB24:
321
    case PIX_FMT_BGR24:
322
        size = (size * 3);
323
        break;
324
    case PIX_FMT_YUV422:
325
        size = (size * 2);
326
        break;
327
    default:
328
        size = -1;
329
        break;
330
    }
331
    return size;
332
}
333

  
334

  
238 335
/* must be called before any other functions */
239 336
void avcodec_init(void)
240 337
{

Also available in: Unified diff