Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: patched-ffmpeg-mt/libavcodec/imgconvert.c

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Misc image conversion routines 2 * Misc image conversion routines
3 * Copyright (c) 2001, 2002, 2003 Fabrice Bellard 3 * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 15 matching lines...) Expand all
26 26
27 /* TODO: 27 /* TODO:
28 * - write 'ffimg' program to test all the image related stuff 28 * - write 'ffimg' program to test all the image related stuff
29 * - move all api to slice based system 29 * - move all api to slice based system
30 * - integrate deinterlacing, postprocessing and scaling in the conversion proce ss 30 * - integrate deinterlacing, postprocessing and scaling in the conversion proce ss
31 */ 31 */
32 32
33 #include "avcodec.h" 33 #include "avcodec.h"
34 #include "dsputil.h" 34 #include "dsputil.h"
35 #include "colorspace.h" 35 #include "colorspace.h"
36 #include "internal.h"
37 #include "imgconvert.h"
36 #include "libavutil/pixdesc.h" 38 #include "libavutil/pixdesc.h"
37 39
38 #if HAVE_MMX 40 #if HAVE_MMX
39 #include "x86/mmx.h" 41 #include "x86/mmx.h"
40 #include "x86/dsputil_mmx.h" 42 #include "x86/dsputil_mmx.h"
41 #endif 43 #endif
42 44
43 #define xglue(x, y) x ## y 45 #define xglue(x, y) x ## y
44 #define glue(x, y) xglue(x, y) 46 #define glue(x, y) xglue(x, y)
45 47
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 .color_type = FF_COLOR_RGB, 233 .color_type = FF_COLOR_RGB,
232 .pixel_type = FF_PIXEL_PACKED, 234 .pixel_type = FF_PIXEL_PACKED,
233 .depth = 5, 235 .depth = 5,
234 }, 236 },
235 [PIX_FMT_RGB555LE] = { 237 [PIX_FMT_RGB555LE] = {
236 .nb_channels = 3, 238 .nb_channels = 3,
237 .color_type = FF_COLOR_RGB, 239 .color_type = FF_COLOR_RGB,
238 .pixel_type = FF_PIXEL_PACKED, 240 .pixel_type = FF_PIXEL_PACKED,
239 .depth = 5, 241 .depth = 5,
240 }, 242 },
243 [PIX_FMT_RGB444BE] = {
244 .nb_channels = 3,
245 .color_type = FF_COLOR_RGB,
246 .pixel_type = FF_PIXEL_PACKED,
247 .depth = 4,
248 },
249 [PIX_FMT_RGB444LE] = {
250 .nb_channels = 3,
251 .color_type = FF_COLOR_RGB,
252 .pixel_type = FF_PIXEL_PACKED,
253 .depth = 4,
254 },
241 255
242 /* gray / mono formats */ 256 /* gray / mono formats */
243 [PIX_FMT_GRAY16BE] = { 257 [PIX_FMT_GRAY16BE] = {
244 .nb_channels = 1, 258 .nb_channels = 1,
245 .color_type = FF_COLOR_GRAY, 259 .color_type = FF_COLOR_GRAY,
246 .pixel_type = FF_PIXEL_PLANAR, 260 .pixel_type = FF_PIXEL_PLANAR,
247 .depth = 16, 261 .depth = 16,
248 }, 262 },
249 [PIX_FMT_GRAY16LE] = { 263 [PIX_FMT_GRAY16LE] = {
250 .nb_channels = 1, 264 .nb_channels = 1,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 .color_type = FF_COLOR_RGB, 321 .color_type = FF_COLOR_RGB,
308 .pixel_type = FF_PIXEL_PACKED, 322 .pixel_type = FF_PIXEL_PACKED,
309 .depth = 5, 323 .depth = 5,
310 }, 324 },
311 [PIX_FMT_BGR555LE] = { 325 [PIX_FMT_BGR555LE] = {
312 .nb_channels = 3, 326 .nb_channels = 3,
313 .color_type = FF_COLOR_RGB, 327 .color_type = FF_COLOR_RGB,
314 .pixel_type = FF_PIXEL_PACKED, 328 .pixel_type = FF_PIXEL_PACKED,
315 .depth = 5, 329 .depth = 5,
316 }, 330 },
331 [PIX_FMT_BGR444BE] = {
332 .nb_channels = 3,
333 .color_type = FF_COLOR_RGB,
334 .pixel_type = FF_PIXEL_PACKED,
335 .depth = 4,
336 },
337 [PIX_FMT_BGR444LE] = {
338 .nb_channels = 3,
339 .color_type = FF_COLOR_RGB,
340 .pixel_type = FF_PIXEL_PACKED,
341 .depth = 4,
342 },
317 [PIX_FMT_RGB8] = { 343 [PIX_FMT_RGB8] = {
318 .nb_channels = 1, 344 .nb_channels = 1,
319 .color_type = FF_COLOR_RGB, 345 .color_type = FF_COLOR_RGB,
320 .pixel_type = FF_PIXEL_PACKED, 346 .pixel_type = FF_PIXEL_PACKED,
321 .depth = 8, 347 .depth = 8,
322 }, 348 },
323 [PIX_FMT_RGB4] = { 349 [PIX_FMT_RGB4] = {
324 .nb_channels = 1, 350 .nb_channels = 1,
325 .color_type = FF_COLOR_RGB, 351 .color_type = FF_COLOR_RGB,
326 .pixel_type = FF_PIXEL_PACKED, 352 .pixel_type = FF_PIXEL_PACKED,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 case PIX_FMT_RGBA: 546 case PIX_FMT_RGBA:
521 case PIX_FMT_BGRA: 547 case PIX_FMT_BGRA:
522 picture->linesize[0] = width * 4; 548 picture->linesize[0] = width * 4;
523 break; 549 break;
524 case PIX_FMT_RGB48BE: 550 case PIX_FMT_RGB48BE:
525 case PIX_FMT_RGB48LE: 551 case PIX_FMT_RGB48LE:
526 picture->linesize[0] = width * 6; 552 picture->linesize[0] = width * 6;
527 break; 553 break;
528 case PIX_FMT_GRAY16BE: 554 case PIX_FMT_GRAY16BE:
529 case PIX_FMT_GRAY16LE: 555 case PIX_FMT_GRAY16LE:
556 case PIX_FMT_BGR444BE:
557 case PIX_FMT_BGR444LE:
530 case PIX_FMT_BGR555BE: 558 case PIX_FMT_BGR555BE:
531 case PIX_FMT_BGR555LE: 559 case PIX_FMT_BGR555LE:
532 case PIX_FMT_BGR565BE: 560 case PIX_FMT_BGR565BE:
533 case PIX_FMT_BGR565LE: 561 case PIX_FMT_BGR565LE:
562 case PIX_FMT_RGB444BE:
563 case PIX_FMT_RGB444LE:
534 case PIX_FMT_RGB555BE: 564 case PIX_FMT_RGB555BE:
535 case PIX_FMT_RGB555LE: 565 case PIX_FMT_RGB555LE:
536 case PIX_FMT_RGB565BE: 566 case PIX_FMT_RGB565BE:
537 case PIX_FMT_RGB565LE: 567 case PIX_FMT_RGB565LE:
538 case PIX_FMT_YUYV422: 568 case PIX_FMT_YUYV422:
539 picture->linesize[0] = width * 2; 569 picture->linesize[0] = width * 2;
540 break; 570 break;
541 case PIX_FMT_UYVY422: 571 case PIX_FMT_UYVY422:
542 picture->linesize[0] = width * 2; 572 picture->linesize[0] = width * 2;
543 break; 573 break;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 case PIX_FMT_RGB24: 647 case PIX_FMT_RGB24:
618 case PIX_FMT_BGR24: 648 case PIX_FMT_BGR24:
619 case PIX_FMT_ARGB: 649 case PIX_FMT_ARGB:
620 case PIX_FMT_ABGR: 650 case PIX_FMT_ABGR:
621 case PIX_FMT_RGBA: 651 case PIX_FMT_RGBA:
622 case PIX_FMT_BGRA: 652 case PIX_FMT_BGRA:
623 case PIX_FMT_RGB48BE: 653 case PIX_FMT_RGB48BE:
624 case PIX_FMT_RGB48LE: 654 case PIX_FMT_RGB48LE:
625 case PIX_FMT_GRAY16BE: 655 case PIX_FMT_GRAY16BE:
626 case PIX_FMT_GRAY16LE: 656 case PIX_FMT_GRAY16LE:
657 case PIX_FMT_BGR444BE:
658 case PIX_FMT_BGR444LE:
627 case PIX_FMT_BGR555BE: 659 case PIX_FMT_BGR555BE:
628 case PIX_FMT_BGR555LE: 660 case PIX_FMT_BGR555LE:
629 case PIX_FMT_BGR565BE: 661 case PIX_FMT_BGR565BE:
630 case PIX_FMT_BGR565LE: 662 case PIX_FMT_BGR565LE:
663 case PIX_FMT_RGB444BE:
664 case PIX_FMT_RGB444LE:
631 case PIX_FMT_RGB555BE: 665 case PIX_FMT_RGB555BE:
632 case PIX_FMT_RGB555LE: 666 case PIX_FMT_RGB555LE:
633 case PIX_FMT_RGB565BE: 667 case PIX_FMT_RGB565BE:
634 case PIX_FMT_RGB565LE: 668 case PIX_FMT_RGB565LE:
635 case PIX_FMT_YUYV422: 669 case PIX_FMT_YUYV422:
636 case PIX_FMT_UYVY422: 670 case PIX_FMT_UYVY422:
637 case PIX_FMT_UYYVYY411: 671 case PIX_FMT_UYYVYY411:
638 case PIX_FMT_RGB4: 672 case PIX_FMT_RGB4:
639 case PIX_FMT_BGR4: 673 case PIX_FMT_BGR4:
640 case PIX_FMT_MONOWHITE: 674 case PIX_FMT_MONOWHITE:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 if (size > dest_size || size < 0) 724 if (size > dest_size || size < 0)
691 return -1; 725 return -1;
692 726
693 if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) { 727 if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
694 if (pix_fmt == PIX_FMT_YUYV422 || 728 if (pix_fmt == PIX_FMT_YUYV422 ||
695 pix_fmt == PIX_FMT_UYVY422 || 729 pix_fmt == PIX_FMT_UYVY422 ||
696 pix_fmt == PIX_FMT_BGR565BE || 730 pix_fmt == PIX_FMT_BGR565BE ||
697 pix_fmt == PIX_FMT_BGR565LE || 731 pix_fmt == PIX_FMT_BGR565LE ||
698 pix_fmt == PIX_FMT_BGR555BE || 732 pix_fmt == PIX_FMT_BGR555BE ||
699 pix_fmt == PIX_FMT_BGR555LE || 733 pix_fmt == PIX_FMT_BGR555LE ||
734 pix_fmt == PIX_FMT_BGR444BE ||
735 pix_fmt == PIX_FMT_BGR444LE ||
700 pix_fmt == PIX_FMT_RGB565BE || 736 pix_fmt == PIX_FMT_RGB565BE ||
701 pix_fmt == PIX_FMT_RGB565LE || 737 pix_fmt == PIX_FMT_RGB565LE ||
702 pix_fmt == PIX_FMT_RGB555BE || 738 pix_fmt == PIX_FMT_RGB555BE ||
703 pix_fmt == PIX_FMT_RGB555LE) 739 pix_fmt == PIX_FMT_RGB555LE ||
740 pix_fmt == PIX_FMT_RGB444BE ||
741 pix_fmt == PIX_FMT_RGB444LE)
704 w = width * 2; 742 w = width * 2;
705 else if (pix_fmt == PIX_FMT_UYYVYY411) 743 else if (pix_fmt == PIX_FMT_UYYVYY411)
706 w = width + width/2; 744 w = width + width/2;
707 else if (pix_fmt == PIX_FMT_PAL8) 745 else if (pix_fmt == PIX_FMT_PAL8)
708 w = width; 746 w = width;
709 else 747 else
710 w = width * (pf->depth * pf->nb_channels / 8); 748 w = width * (pf->depth * pf->nb_channels / 8);
711 749
712 data_planes = 1; 750 data_planes = 1;
713 h = height; 751 h = height;
714 } else { 752 } else {
715 data_planes = pf->nb_channels; 753 data_planes = pf->nb_channels;
716 w = (width*pf->depth + 7)/8; 754 w = (width*pf->depth + 7)/8;
717 h = height; 755 h = height;
718 } 756 }
719 757
720 ow = w; 758 ow = w;
721 oh = h; 759 oh = h;
722 760
723 for (i=0; i<data_planes; i++) { 761 for (i=0; i<data_planes; i++) {
724 if (i == 1) { 762 if (i == 1) {
725 w = ((width >> desc->log2_chroma_w) * pf->depth + 7) / 8; 763 w = (- ((-width) >> desc->log2_chroma_w) * pf->depth + 7) / 8;
726 h = height >> desc->log2_chroma_h; 764 h = -((-height) >> desc->log2_chroma_h);
727 if (pix_fmt == PIX_FMT_NV12 || pix_fmt == PIX_FMT_NV21) 765 if (pix_fmt == PIX_FMT_NV12 || pix_fmt == PIX_FMT_NV21)
728 w <<= 1; 766 w <<= 1;
729 } else if (i == 3) { 767 } else if (i == 3) {
730 w = ow; 768 w = ow;
731 h = oh; 769 h = oh;
732 } 770 }
733 s = src->data[i]; 771 s = src->data[i];
734 for(j=0; j<h; j++) { 772 for(j=0; j<h; j++) {
735 memcpy(dest, s, w); 773 memcpy(dest, s, w);
736 dest += w; 774 dest += w;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt]; 806 const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt];
769 const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt]; 807 const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];
770 int loss; 808 int loss;
771 809
772 ps = &pix_fmt_info[src_pix_fmt]; 810 ps = &pix_fmt_info[src_pix_fmt];
773 811
774 /* compute loss */ 812 /* compute loss */
775 loss = 0; 813 loss = 0;
776 pf = &pix_fmt_info[dst_pix_fmt]; 814 pf = &pix_fmt_info[dst_pix_fmt];
777 if (pf->depth < ps->depth || 815 if (pf->depth < ps->depth ||
778 ((dst_pix_fmt == PIX_FMT_RGB555BE || dst_pix_fmt == PIX_FMT_RGB555LE) && 816 ((dst_pix_fmt == PIX_FMT_RGB555BE || dst_pix_fmt == PIX_FMT_RGB555LE ||
779 (src_pix_fmt == PIX_FMT_RGB565BE || src_pix_fmt == PIX_FMT_RGB565LE))) 817 dst_pix_fmt == PIX_FMT_BGR555BE || dst_pix_fmt == PIX_FMT_BGR555LE) &&
818 (src_pix_fmt == PIX_FMT_RGB565BE || src_pix_fmt == PIX_FMT_RGB565LE ||
819 src_pix_fmt == PIX_FMT_BGR565BE || src_pix_fmt == PIX_FMT_BGR565LE)))
780 loss |= FF_LOSS_DEPTH; 820 loss |= FF_LOSS_DEPTH;
781 if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w || 821 if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w ||
782 dst_desc->log2_chroma_h > src_desc->log2_chroma_h) 822 dst_desc->log2_chroma_h > src_desc->log2_chroma_h)
783 loss |= FF_LOSS_RESOLUTION; 823 loss |= FF_LOSS_RESOLUTION;
784 switch(pf->color_type) { 824 switch(pf->color_type) {
785 case FF_COLOR_RGB: 825 case FF_COLOR_RGB:
786 if (ps->color_type != FF_COLOR_RGB && 826 if (ps->color_type != FF_COLOR_RGB &&
787 ps->color_type != FF_COLOR_GRAY) 827 ps->color_type != FF_COLOR_GRAY)
788 loss |= FF_LOSS_COLORSPACE; 828 loss |= FF_LOSS_COLORSPACE;
789 break; 829 break;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 pf = &pix_fmt_info[pix_fmt]; 867 pf = &pix_fmt_info[pix_fmt];
828 switch(pf->pixel_type) { 868 switch(pf->pixel_type) {
829 case FF_PIXEL_PACKED: 869 case FF_PIXEL_PACKED:
830 switch(pix_fmt) { 870 switch(pix_fmt) {
831 case PIX_FMT_YUYV422: 871 case PIX_FMT_YUYV422:
832 case PIX_FMT_UYVY422: 872 case PIX_FMT_UYVY422:
833 case PIX_FMT_RGB565BE: 873 case PIX_FMT_RGB565BE:
834 case PIX_FMT_RGB565LE: 874 case PIX_FMT_RGB565LE:
835 case PIX_FMT_RGB555BE: 875 case PIX_FMT_RGB555BE:
836 case PIX_FMT_RGB555LE: 876 case PIX_FMT_RGB555LE:
877 case PIX_FMT_RGB444BE:
878 case PIX_FMT_RGB444LE:
837 case PIX_FMT_BGR565BE: 879 case PIX_FMT_BGR565BE:
838 case PIX_FMT_BGR565LE: 880 case PIX_FMT_BGR565LE:
839 case PIX_FMT_BGR555BE: 881 case PIX_FMT_BGR555BE:
840 case PIX_FMT_BGR555LE: 882 case PIX_FMT_BGR555LE:
883 case PIX_FMT_BGR444BE:
884 case PIX_FMT_BGR444LE:
841 bits = 16; 885 bits = 16;
842 break; 886 break;
843 case PIX_FMT_UYYVYY411: 887 case PIX_FMT_UYYVYY411:
844 bits = 12; 888 bits = 12;
845 break; 889 break;
846 default: 890 default:
847 bits = pf->depth * pf->nb_channels; 891 bits = pf->depth * pf->nb_channels;
848 break; 892 break;
849 } 893 }
850 break; 894 break;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 pf = &pix_fmt_info[pix_fmt]; 991 pf = &pix_fmt_info[pix_fmt];
948 switch(pf->pixel_type) { 992 switch(pf->pixel_type) {
949 case FF_PIXEL_PACKED: 993 case FF_PIXEL_PACKED:
950 switch(pix_fmt) { 994 switch(pix_fmt) {
951 case PIX_FMT_YUYV422: 995 case PIX_FMT_YUYV422:
952 case PIX_FMT_UYVY422: 996 case PIX_FMT_UYVY422:
953 case PIX_FMT_RGB565BE: 997 case PIX_FMT_RGB565BE:
954 case PIX_FMT_RGB565LE: 998 case PIX_FMT_RGB565LE:
955 case PIX_FMT_RGB555BE: 999 case PIX_FMT_RGB555BE:
956 case PIX_FMT_RGB555LE: 1000 case PIX_FMT_RGB555LE:
1001 case PIX_FMT_RGB444BE:
1002 case PIX_FMT_RGB444LE:
957 case PIX_FMT_BGR565BE: 1003 case PIX_FMT_BGR565BE:
958 case PIX_FMT_BGR565LE: 1004 case PIX_FMT_BGR565LE:
959 case PIX_FMT_BGR555BE: 1005 case PIX_FMT_BGR555BE:
960 case PIX_FMT_BGR555LE: 1006 case PIX_FMT_BGR555LE:
1007 case PIX_FMT_BGR444BE:
1008 case PIX_FMT_BGR444LE:
961 bits = 16; 1009 bits = 16;
962 break; 1010 break;
963 case PIX_FMT_UYYVYY411: 1011 case PIX_FMT_UYYVYY411:
964 bits = 12; 1012 bits = 12;
965 break; 1013 break;
966 default: 1014 default:
967 bits = pf->depth * pf->nb_channels; 1015 bits = pf->depth * pf->nb_channels;
968 break; 1016 break;
969 } 1017 }
970 return (width * bits + 7) >> 3; 1018 return (width * bits + 7) >> 3;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 } else { 1539 } else {
1492 deinterlace_bottom_field(dst->data[i],dst->linesize[i], 1540 deinterlace_bottom_field(dst->data[i],dst->linesize[i],
1493 src->data[i], src->linesize[i], 1541 src->data[i], src->linesize[i],
1494 width, height); 1542 width, height);
1495 } 1543 }
1496 } 1544 }
1497 emms_c(); 1545 emms_c();
1498 return 0; 1546 return 0;
1499 } 1547 }
1500 1548
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698