comparison vp8.c @ 11974:356b20a6566d libavcodec

VP8 bilinear filter
author conrad
date Sun, 27 Jun 2010 01:46:29 +0000
parents c7953ee47af4
children 176c5deb6756
comparison
equal deleted inserted replaced
11973:7ca225db75e8 11974:356b20a6566d
43 typedef struct { 43 typedef struct {
44 AVCodecContext *avctx; 44 AVCodecContext *avctx;
45 DSPContext dsp; 45 DSPContext dsp;
46 VP8DSPContext vp8dsp; 46 VP8DSPContext vp8dsp;
47 H264PredContext hpc; 47 H264PredContext hpc;
48 vp8_mc_func put_pixels_tab[3][3][3];
48 AVFrame frames[4]; 49 AVFrame frames[4];
49 AVFrame *framep[4]; 50 AVFrame *framep[4];
50 uint8_t *edge_emu_buffer; 51 uint8_t *edge_emu_buffer;
51 VP56RangeCoder c; ///< header context, includes mb modes and motion vectors 52 VP56RangeCoder c; ///< header context, includes mb modes and motion vectors
52 int profile; 53 int profile;
377 s->invisible = !(buf[0] & 0x10); 378 s->invisible = !(buf[0] & 0x10);
378 header_size = RL24(buf) >> 5; 379 header_size = RL24(buf) >> 5;
379 buf += 3; 380 buf += 3;
380 buf_size -= 3; 381 buf_size -= 3;
381 382
382 if (s->profile) 383 if (s->profile > 3)
383 av_log(s->avctx, AV_LOG_WARNING, "Profile %d not fully handled\n", s->profile); 384 av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile);
385
386 if (!s->profile)
387 memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab));
388 else // profile 1-3 use bilinear, 4+ aren't defined so whatever
389 memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab, sizeof(s->put_pixels_tab));
384 390
385 if (header_size > buf_size - 7*s->keyframe) { 391 if (header_size > buf_size - 7*s->keyframe) {
386 av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n"); 392 av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n");
387 return AVERROR_INVALIDDATA; 393 return AVERROR_INVALIDDATA;
388 } 394 }
949 955
950 if (mb->mode < VP8_MVMODE_SPLIT) { 956 if (mb->mode < VP8_MVMODE_SPLIT) {
951 /* Y */ 957 /* Y */
952 vp8_mc(s, 1, dst[0], s->framep[mb->ref_frame]->data[0], &mb->mv, 958 vp8_mc(s, 1, dst[0], s->framep[mb->ref_frame]->data[0], &mb->mv,
953 x_off, y_off, 16, 16, width, height, s->linesize, 959 x_off, y_off, 16, 16, width, height, s->linesize,
954 s->vp8dsp.put_vp8_epel_pixels_tab[0]); 960 s->put_pixels_tab[0]);
955 961
956 /* U/V */ 962 /* U/V */
957 uvmv = mb->mv; 963 uvmv = mb->mv;
958 if (s->profile == 3) { 964 if (s->profile == 3) {
959 uvmv.x &= ~7; 965 uvmv.x &= ~7;
960 uvmv.y &= ~7; 966 uvmv.y &= ~7;
961 } 967 }
962 x_off >>= 1; y_off >>= 1; width >>= 1; height >>= 1; 968 x_off >>= 1; y_off >>= 1; width >>= 1; height >>= 1;
963 vp8_mc(s, 0, dst[1], s->framep[mb->ref_frame]->data[1], &uvmv, 969 vp8_mc(s, 0, dst[1], s->framep[mb->ref_frame]->data[1], &uvmv,
964 x_off, y_off, 8, 8, width, height, s->uvlinesize, 970 x_off, y_off, 8, 8, width, height, s->uvlinesize,
965 s->vp8dsp.put_vp8_epel_pixels_tab[1]); 971 s->put_pixels_tab[1]);
966 vp8_mc(s, 0, dst[2], s->framep[mb->ref_frame]->data[2], &uvmv, 972 vp8_mc(s, 0, dst[2], s->framep[mb->ref_frame]->data[2], &uvmv,
967 x_off, y_off, 8, 8, width, height, s->uvlinesize, 973 x_off, y_off, 8, 8, width, height, s->uvlinesize,
968 s->vp8dsp.put_vp8_epel_pixels_tab[1]); 974 s->put_pixels_tab[1]);
969 } else { 975 } else {
970 int x, y; 976 int x, y;
971 977
972 /* Y */ 978 /* Y */
973 for (y = 0; y < 4; y++) { 979 for (y = 0; y < 4; y++) {
974 for (x = 0; x < 4; x++) { 980 for (x = 0; x < 4; x++) {
975 vp8_mc(s, 1, dst[0] + 4*y*s->linesize + x*4, 981 vp8_mc(s, 1, dst[0] + 4*y*s->linesize + x*4,
976 s->framep[mb->ref_frame]->data[0], &mb->bmv[4*y + x], 982 s->framep[mb->ref_frame]->data[0], &mb->bmv[4*y + x],
977 4*x + x_off, 4*y + y_off, 4, 4, 983 4*x + x_off, 4*y + y_off, 4, 4,
978 width, height, s->linesize, 984 width, height, s->linesize,
979 s->vp8dsp.put_vp8_epel_pixels_tab[2]); 985 s->put_pixels_tab[2]);
980 } 986 }
981 } 987 }
982 988
983 /* U/V */ 989 /* U/V */
984 x_off >>= 1; y_off >>= 1; width >>= 1; height >>= 1; 990 x_off >>= 1; y_off >>= 1; width >>= 1; height >>= 1;
1000 } 1006 }
1001 vp8_mc(s, 0, dst[1] + 4*y*s->uvlinesize + x*4, 1007 vp8_mc(s, 0, dst[1] + 4*y*s->uvlinesize + x*4,
1002 s->framep[mb->ref_frame]->data[1], &uvmv, 1008 s->framep[mb->ref_frame]->data[1], &uvmv,
1003 4*x + x_off, 4*y + y_off, 4, 4, 1009 4*x + x_off, 4*y + y_off, 4, 4,
1004 width, height, s->uvlinesize, 1010 width, height, s->uvlinesize,
1005 s->vp8dsp.put_vp8_epel_pixels_tab[2]); 1011 s->put_pixels_tab[2]);
1006 vp8_mc(s, 0, dst[2] + 4*y*s->uvlinesize + x*4, 1012 vp8_mc(s, 0, dst[2] + 4*y*s->uvlinesize + x*4,
1007 s->framep[mb->ref_frame]->data[2], &uvmv, 1013 s->framep[mb->ref_frame]->data[2], &uvmv,
1008 4*x + x_off, 4*y + y_off, 4, 4, 1014 4*x + x_off, 4*y + y_off, 4, 4,
1009 width, height, s->uvlinesize, 1015 width, height, s->uvlinesize,
1010 s->vp8dsp.put_vp8_epel_pixels_tab[2]); 1016 s->put_pixels_tab[2]);
1011 } 1017 }
1012 } 1018 }
1013 } 1019 }
1014 } 1020 }
1015 1021