Ticket #4877: scaling_r.c

File scaling_r.c, 1.1 KB (added by rxt, 11 years ago)
Line 
1#include <libavutil/imgutils.h>
2#include <libswscale/swscale.h>
3
4int main()
5{
6 uint8_t *src_data[4], *dst_data[4];
7 int src_linesize[4], dst_linesize[4];
8 int src_w, src_h, dst_w, dst_h;
9 struct SwsContext *sws_ctx;
10 int i;
11
12 src_w = 720;
13 src_h = 480;
14 dst_w = 720;
15 dst_h = 540;
16
17 sws_ctx = sws_getContext(src_w, src_h, AV_PIX_FMT_YUV420P,
18 dst_w, dst_h, AV_PIX_FMT_RGB24,
19 SWS_PRINT_INFO|SWS_BICUBIC, NULL, NULL, NULL);
20
21 src_linesize[0] = FFALIGN(src_w,16);
22 src_data[0] = av_malloc(src_linesize[0]*src_h+16);
23 src_linesize[1] = src_linesize[2]=FFALIGN(src_w/2,16);
24 src_data[1] = av_malloc(src_linesize[1]*src_h+16);
25 src_data[2] = av_malloc(src_linesize[2]*src_h+16);
26
27 dst_linesize[0] = FFALIGN(dst_w*3,16);
28 dst_data[0] = av_malloc(dst_linesize[0]*dst_h+16);
29
30
31 for (i = 0; i < src_h; i+=16) {
32 fprintf(stderr, "pos %d\n", i);
33 sws_scale(sws_ctx, (const uint8_t * const*)src_data,
34 src_linesize, i, 16, dst_data, dst_linesize);
35
36 }
37
38 return 0;
39}