OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at> | 2 * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at> |
3 * | 3 * |
4 * This file is part of FFmpeg. | 4 * This file is part of FFmpeg. |
5 * | 5 * |
6 * FFmpeg is free software; you can redistribute it and/or modify | 6 * FFmpeg is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2 of the License, or | 8 * the Free Software Foundation; either version 2 of the License, or |
9 * (at your option) any later version. | 9 * (at your option) any later version. |
10 * | 10 * |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 || (x)==PIX_FMT_GRAY8 \ | 85 || (x)==PIX_FMT_GRAY8 \ |
86 || (x)==PIX_FMT_YUV410P \ | 86 || (x)==PIX_FMT_YUV410P \ |
87 || (x)==PIX_FMT_YUV440P \ | 87 || (x)==PIX_FMT_YUV440P \ |
88 || (x)==PIX_FMT_NV12 \ | 88 || (x)==PIX_FMT_NV12 \ |
89 || (x)==PIX_FMT_NV21 \ | 89 || (x)==PIX_FMT_NV21 \ |
90 || (x)==PIX_FMT_GRAY16BE \ | 90 || (x)==PIX_FMT_GRAY16BE \ |
91 || (x)==PIX_FMT_GRAY16LE \ | 91 || (x)==PIX_FMT_GRAY16LE \ |
92 || (x)==PIX_FMT_YUV444P \ | 92 || (x)==PIX_FMT_YUV444P \ |
93 || (x)==PIX_FMT_YUV422P \ | 93 || (x)==PIX_FMT_YUV422P \ |
94 || (x)==PIX_FMT_YUV411P \ | 94 || (x)==PIX_FMT_YUV411P \ |
| 95 || (x)==PIX_FMT_YUVJ420P \ |
| 96 || (x)==PIX_FMT_YUVJ422P \ |
| 97 || (x)==PIX_FMT_YUVJ440P \ |
| 98 || (x)==PIX_FMT_YUVJ444P \ |
95 || (x)==PIX_FMT_PAL8 \ | 99 || (x)==PIX_FMT_PAL8 \ |
96 || (x)==PIX_FMT_BGR8 \ | 100 || (x)==PIX_FMT_BGR8 \ |
97 || (x)==PIX_FMT_RGB8 \ | 101 || (x)==PIX_FMT_RGB8 \ |
98 || (x)==PIX_FMT_BGR4_BYTE \ | 102 || (x)==PIX_FMT_BGR4_BYTE \ |
99 || (x)==PIX_FMT_RGB4_BYTE \ | 103 || (x)==PIX_FMT_RGB4_BYTE \ |
100 || (x)==PIX_FMT_YUV440P \ | 104 || (x)==PIX_FMT_YUV440P \ |
101 || (x)==PIX_FMT_MONOWHITE \ | 105 || (x)==PIX_FMT_MONOWHITE \ |
102 || (x)==PIX_FMT_MONOBLACK \ | 106 || (x)==PIX_FMT_MONOBLACK \ |
103 || (x)==PIX_FMT_YUV420P16LE \ | 107 || (x)==PIX_FMT_YUV420P16LE \ |
104 || (x)==PIX_FMT_YUV422P16LE \ | 108 || (x)==PIX_FMT_YUV422P16LE \ |
105 || (x)==PIX_FMT_YUV444P16LE \ | 109 || (x)==PIX_FMT_YUV444P16LE \ |
106 || (x)==PIX_FMT_YUV420P16BE \ | 110 || (x)==PIX_FMT_YUV420P16BE \ |
107 || (x)==PIX_FMT_YUV422P16BE \ | 111 || (x)==PIX_FMT_YUV422P16BE \ |
108 || (x)==PIX_FMT_YUV444P16BE \ | 112 || (x)==PIX_FMT_YUV444P16BE \ |
109 ) | 113 ) |
110 | 114 |
111 int sws_isSupportedInput(enum PixelFormat pix_fmt) | 115 int sws_isSupportedInput(enum PixelFormat pix_fmt) |
112 { | 116 { |
113 return isSupportedIn(pix_fmt); | 117 return isSupportedIn(pix_fmt); |
114 } | 118 } |
115 | 119 |
116 #define isSupportedOut(x) ( \ | 120 #define isSupportedOut(x) ( \ |
117 (x)==PIX_FMT_YUV420P \ | 121 (x)==PIX_FMT_YUV420P \ |
118 || (x)==PIX_FMT_YUVA420P \ | 122 || (x)==PIX_FMT_YUVA420P \ |
119 || (x)==PIX_FMT_YUYV422 \ | 123 || (x)==PIX_FMT_YUYV422 \ |
120 || (x)==PIX_FMT_UYVY422 \ | 124 || (x)==PIX_FMT_UYVY422 \ |
121 || (x)==PIX_FMT_YUV444P \ | 125 || (x)==PIX_FMT_YUV444P \ |
122 || (x)==PIX_FMT_YUV422P \ | 126 || (x)==PIX_FMT_YUV422P \ |
123 || (x)==PIX_FMT_YUV411P \ | 127 || (x)==PIX_FMT_YUV411P \ |
124 || isRGB(x) \ | 128 || (x)==PIX_FMT_YUVJ420P \ |
125 || isBGR(x) \ | 129 || (x)==PIX_FMT_YUVJ422P \ |
| 130 || (x)==PIX_FMT_YUVJ440P \ |
| 131 || (x)==PIX_FMT_YUVJ444P \ |
| 132 || isAnyRGB(x) \ |
126 || (x)==PIX_FMT_NV12 \ | 133 || (x)==PIX_FMT_NV12 \ |
127 || (x)==PIX_FMT_NV21 \ | 134 || (x)==PIX_FMT_NV21 \ |
128 || (x)==PIX_FMT_GRAY16BE \ | 135 || (x)==PIX_FMT_GRAY16BE \ |
129 || (x)==PIX_FMT_GRAY16LE \ | 136 || (x)==PIX_FMT_GRAY16LE \ |
130 || (x)==PIX_FMT_GRAY8 \ | 137 || (x)==PIX_FMT_GRAY8 \ |
131 || (x)==PIX_FMT_YUV410P \ | 138 || (x)==PIX_FMT_YUV410P \ |
132 || (x)==PIX_FMT_YUV440P \ | 139 || (x)==PIX_FMT_YUV440P \ |
133 || (x)==PIX_FMT_YUV420P16LE \ | 140 || (x)==PIX_FMT_YUV420P16LE \ |
134 || (x)==PIX_FMT_YUV422P16LE \ | 141 || (x)==PIX_FMT_YUV422P16LE \ |
135 || (x)==PIX_FMT_YUV444P16LE \ | 142 || (x)==PIX_FMT_YUV444P16LE \ |
136 || (x)==PIX_FMT_YUV420P16BE \ | 143 || (x)==PIX_FMT_YUV420P16BE \ |
137 || (x)==PIX_FMT_YUV422P16BE \ | 144 || (x)==PIX_FMT_YUV422P16BE \ |
138 || (x)==PIX_FMT_YUV444P16BE \ | 145 || (x)==PIX_FMT_YUV444P16BE \ |
139 ) | 146 ) |
140 | 147 |
141 int sws_isSupportedOutput(enum PixelFormat pix_fmt) | 148 int sws_isSupportedOutput(enum PixelFormat pix_fmt) |
142 { | 149 { |
143 return isSupportedOut(pix_fmt); | 150 return isSupportedOut(pix_fmt); |
144 } | 151 } |
145 | 152 |
146 #define usePal(x) (av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) | |
147 | |
148 extern const int32_t ff_yuv2rgb_coeffs[8][4]; | 153 extern const int32_t ff_yuv2rgb_coeffs[8][4]; |
149 | 154 |
150 const char *sws_format_name(enum PixelFormat format) | 155 const char *sws_format_name(enum PixelFormat format) |
151 { | 156 { |
152 if ((unsigned)format < PIX_FMT_NB && av_pix_fmt_descriptors[format].name) | 157 if ((unsigned)format < PIX_FMT_NB && av_pix_fmt_descriptors[format].name) |
153 return av_pix_fmt_descriptors[format].name; | 158 return av_pix_fmt_descriptors[format].name; |
154 else | 159 else |
155 return "Unknown format"; | 160 return "Unknown format"; |
156 } | 161 } |
157 | 162 |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 return 1; | 778 return 1; |
774 default: | 779 default: |
775 return 0; | 780 return 0; |
776 } | 781 } |
777 } | 782 } |
778 | 783 |
779 SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, | 784 SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, |
780 int dstW, int dstH, enum PixelFormat dstFormat, int f
lags, | 785 int dstW, int dstH, enum PixelFormat dstFormat, int f
lags, |
781 SwsFilter *srcFilter, SwsFilter *dstFilter, const dou
ble *param) | 786 SwsFilter *srcFilter, SwsFilter *dstFilter, const dou
ble *param) |
782 { | 787 { |
783 | |
784 SwsContext *c; | 788 SwsContext *c; |
785 int i; | 789 int i; |
786 int usesVFilter, usesHFilter; | 790 int usesVFilter, usesHFilter; |
787 int unscaled; | 791 int unscaled; |
788 int srcRange, dstRange; | 792 int srcRange, dstRange; |
789 SwsFilter dummyFilter= {NULL, NULL, NULL, NULL}; | 793 SwsFilter dummyFilter= {NULL, NULL, NULL, NULL}; |
790 #if ARCH_X86 | 794 #if ARCH_X86 |
791 if (flags & SWS_CPU_CAPS_MMX) | 795 if (flags & SWS_CPU_CAPS_MMX) |
792 __asm__ volatile("emms\n\t"::: "memory"); | 796 __asm__ volatile("emms\n\t"::: "memory"); |
793 #endif | 797 #endif |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 c->dstH= dstH; | 855 c->dstH= dstH; |
852 c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW; | 856 c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW; |
853 c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH; | 857 c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH; |
854 c->flags= flags; | 858 c->flags= flags; |
855 c->dstFormat= dstFormat; | 859 c->dstFormat= dstFormat; |
856 c->srcFormat= srcFormat; | 860 c->srcFormat= srcFormat; |
857 c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]); | 861 c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]); |
858 c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]); | 862 c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]); |
859 c->vRounder= 4* 0x0001000100010001ULL; | 863 c->vRounder= 4* 0x0001000100010001ULL; |
860 | 864 |
861 usesHFilter= usesVFilter= 0; | 865 usesVFilter = (srcFilter->lumV && srcFilter->lumV->length>1) || |
862 if (dstFilter->lumV && dstFilter->lumV->length>1) usesVFilter=1; | 866 (srcFilter->chrV && srcFilter->chrV->length>1) || |
863 if (dstFilter->lumH && dstFilter->lumH->length>1) usesHFilter=1; | 867 (dstFilter->lumV && dstFilter->lumV->length>1) || |
864 if (dstFilter->chrV && dstFilter->chrV->length>1) usesVFilter=1; | 868 (dstFilter->chrV && dstFilter->chrV->length>1); |
865 if (dstFilter->chrH && dstFilter->chrH->length>1) usesHFilter=1; | 869 usesHFilter = (srcFilter->lumH && srcFilter->lumH->length>1) || |
866 if (srcFilter->lumV && srcFilter->lumV->length>1) usesVFilter=1; | 870 (srcFilter->chrH && srcFilter->chrH->length>1) || |
867 if (srcFilter->lumH && srcFilter->lumH->length>1) usesHFilter=1; | 871 (dstFilter->lumH && dstFilter->lumH->length>1) || |
868 if (srcFilter->chrV && srcFilter->chrV->length>1) usesVFilter=1; | 872 (dstFilter->chrH && dstFilter->chrH->length>1); |
869 if (srcFilter->chrH && srcFilter->chrH->length>1) usesHFilter=1; | |
870 | 873 |
871 getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat); | 874 getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat); |
872 getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat); | 875 getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat); |
873 | 876 |
874 // reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpola
tion | 877 // reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpola
tion |
875 if ((isBGR(dstFormat) || isRGB(dstFormat)) && !(flags&SWS_FULL_CHR_H_INT)) c
->chrDstHSubSample=1; | 878 if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=
1; |
876 | 879 |
877 // drop some chroma lines if the user wants it | 880 // drop some chroma lines if the user wants it |
878 c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT; | 881 c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT; |
879 c->chrSrcVSubSample+= c->vChrDrop; | 882 c->chrSrcVSubSample+= c->vChrDrop; |
880 | 883 |
881 // drop every other pixel for chroma calculation unless user wants full chro
ma | 884 // drop every other pixel for chroma calculation unless user wants full chro
ma |
882 if ((isBGR(srcFormat) || isRGB(srcFormat)) && !(flags&SWS_FULL_CHR_H_INP) | 885 if (isAnyRGB(srcFormat) && !(flags&SWS_FULL_CHR_H_INP) |
883 && srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8 | 886 && srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8 |
884 && srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4 | 887 && srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4 |
885 && srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE | 888 && srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE |
886 && ((dstW>>c->chrDstHSubSample) <= (srcW>>1) || (flags&(SWS_FAST_BILINEAR|
SWS_POINT)))) | 889 && ((dstW>>c->chrDstHSubSample) <= (srcW>>1) || (flags&(SWS_FAST_BILINEAR|
SWS_POINT)))) |
887 c->chrSrcHSubSample=1; | 890 c->chrSrcHSubSample=1; |
888 | 891 |
889 if (param) { | 892 if (param) { |
890 c->param[0] = param[0]; | 893 c->param[0] = param[0]; |
891 c->param[1] = param[1]; | 894 c->param[1] = param[1]; |
892 } else { | 895 } else { |
893 c->param[0] = | 896 c->param[0] = |
894 c->param[1] = SWS_PARAM_DEFAULT; | 897 c->param[1] = SWS_PARAM_DEFAULT; |
895 } | 898 } |
896 | 899 |
897 // Note the -((-x)>>y) is so that we always round toward +inf. | 900 // Note the -((-x)>>y) is so that we always round toward +inf. |
898 c->chrSrcW= -((-srcW) >> c->chrSrcHSubSample); | 901 c->chrSrcW= -((-srcW) >> c->chrSrcHSubSample); |
899 c->chrSrcH= -((-srcH) >> c->chrSrcVSubSample); | 902 c->chrSrcH= -((-srcH) >> c->chrSrcVSubSample); |
900 c->chrDstW= -((-dstW) >> c->chrDstHSubSample); | 903 c->chrDstW= -((-dstW) >> c->chrDstHSubSample); |
901 c->chrDstH= -((-dstH) >> c->chrDstVSubSample); | 904 c->chrDstH= -((-dstH) >> c->chrDstVSubSample); |
902 | 905 |
903 sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], srcRange, ff_
yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16); | 906 sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], srcRange, ff_
yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16); |
904 | 907 |
905 /* unscaled special cases */ | 908 /* unscaled special cases */ |
906 if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isB
GR(dstFormat) || isRGB(dstFormat))) { | 909 if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isA
nyRGB(dstFormat))) { |
907 ff_get_unscaled_swscale(c); | 910 ff_get_unscaled_swscale(c); |
908 | 911 |
909 if (c->swScale) { | 912 if (c->swScale) { |
910 if (flags&SWS_PRINT_INFO) | 913 if (flags&SWS_PRINT_INFO) |
911 av_log(c, AV_LOG_INFO, "using unscaled %s -> %s special converte
r\n", | 914 av_log(c, AV_LOG_INFO, "using unscaled %s -> %s special converte
r\n", |
912 sws_format_name(srcFormat), sws_format_name(dstFormat)); | 915 sws_format_name(srcFormat), sws_format_name(dstFormat)); |
913 return c; | 916 return c; |
914 } | 917 } |
915 } | 918 } |
916 | 919 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_REA
D | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); | 961 c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_REA
D | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); |
959 c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_REA
D | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); | 962 c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_REA
D | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); |
960 #elif HAVE_VIRTUALALLOC | 963 #elif HAVE_VIRTUALALLOC |
961 c->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize,
MEM_COMMIT, PAGE_EXECUTE_READWRITE); | 964 c->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize,
MEM_COMMIT, PAGE_EXECUTE_READWRITE); |
962 c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize,
MEM_COMMIT, PAGE_EXECUTE_READWRITE); | 965 c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize,
MEM_COMMIT, PAGE_EXECUTE_READWRITE); |
963 #else | 966 #else |
964 c->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize); | 967 c->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize); |
965 c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize); | 968 c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize); |
966 #endif | 969 #endif |
967 | 970 |
| 971 if (!c->lumMmx2FilterCode || !c->chrMmx2FilterCode) |
| 972 goto fail; |
968 FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int
16_t), fail); | 973 FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int
16_t), fail); |
969 FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int
16_t), fail); | 974 FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int
16_t), fail); |
970 FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW /2/8+8)*sizeof(int
32_t), fail); | 975 FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW /2/8+8)*sizeof(int
32_t), fail); |
971 FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW/2/4+8)*sizeof(int
32_t), fail); | 976 FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW/2/4+8)*sizeof(int
32_t), fail); |
972 | 977 |
973 initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->hLu
mFilter, c->hLumFilterPos, 8); | 978 initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->hLu
mFilter, c->hLumFilterPos, 8); |
974 initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hCh
rFilter, c->hChrFilterPos, 4); | 979 initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hCh
rFilter, c->hChrFilterPos, 4); |
975 | 980 |
976 #ifdef MAP_ANONYMOUS | 981 #ifdef MAP_ANONYMOUS |
977 mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC |
PROT_READ); | 982 mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC |
PROT_READ); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 if (flags & SWS_CPU_CAPS_MMX2) | 1124 if (flags & SWS_CPU_CAPS_MMX2) |
1120 av_log(c, AV_LOG_INFO, "using MMX2\n"); | 1125 av_log(c, AV_LOG_INFO, "using MMX2\n"); |
1121 else if (flags & SWS_CPU_CAPS_3DNOW) | 1126 else if (flags & SWS_CPU_CAPS_3DNOW) |
1122 av_log(c, AV_LOG_INFO, "using 3DNOW\n"); | 1127 av_log(c, AV_LOG_INFO, "using 3DNOW\n"); |
1123 else if (flags & SWS_CPU_CAPS_MMX) | 1128 else if (flags & SWS_CPU_CAPS_MMX) |
1124 av_log(c, AV_LOG_INFO, "using MMX\n"); | 1129 av_log(c, AV_LOG_INFO, "using MMX\n"); |
1125 else if (flags & SWS_CPU_CAPS_ALTIVEC) | 1130 else if (flags & SWS_CPU_CAPS_ALTIVEC) |
1126 av_log(c, AV_LOG_INFO, "using AltiVec\n"); | 1131 av_log(c, AV_LOG_INFO, "using AltiVec\n"); |
1127 else | 1132 else |
1128 av_log(c, AV_LOG_INFO, "using C\n"); | 1133 av_log(c, AV_LOG_INFO, "using C\n"); |
1129 } | |
1130 | 1134 |
1131 if (flags & SWS_PRINT_INFO) { | |
1132 if (flags & SWS_CPU_CAPS_MMX) { | 1135 if (flags & SWS_CPU_CAPS_MMX) { |
1133 if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR)) | 1136 if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR)) |
1134 av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for h
orizontal scaling\n"); | 1137 av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for h
orizontal scaling\n"); |
1135 else { | 1138 else { |
1136 if (c->hLumFilterSize==4) | 1139 if (c->hLumFilterSize==4) |
1137 av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizo
ntal luminance scaling\n"); | 1140 av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizo
ntal luminance scaling\n"); |
1138 else if (c->hLumFilterSize==8) | 1141 else if (c->hLumFilterSize==8) |
1139 av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizo
ntal luminance scaling\n"); | 1142 av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizo
ntal luminance scaling\n"); |
1140 else | 1143 else |
1141 av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizo
ntal luminance scaling\n"); | 1144 av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizo
ntal luminance scaling\n"); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 vec->coeff[i]= c; | 1304 vec->coeff[i]= c; |
1302 | 1305 |
1303 return vec; | 1306 return vec; |
1304 } | 1307 } |
1305 | 1308 |
1306 SwsVector *sws_getIdentityVec(void) | 1309 SwsVector *sws_getIdentityVec(void) |
1307 { | 1310 { |
1308 return sws_getConstVec(1.0, 1); | 1311 return sws_getConstVec(1.0, 1); |
1309 } | 1312 } |
1310 | 1313 |
1311 double sws_dcVec(SwsVector *a) | 1314 static double sws_dcVec(SwsVector *a) |
1312 { | 1315 { |
1313 int i; | 1316 int i; |
1314 double sum=0; | 1317 double sum=0; |
1315 | 1318 |
1316 for (i=0; i<a->length; i++) | 1319 for (i=0; i<a->length; i++) |
1317 sum+= a->coeff[i]; | 1320 sum+= a->coeff[i]; |
1318 | 1321 |
1319 return sum; | 1322 return sum; |
1320 } | 1323 } |
1321 | 1324 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 av_freep(&c->vLumFilterPos); | 1533 av_freep(&c->vLumFilterPos); |
1531 av_freep(&c->vChrFilterPos); | 1534 av_freep(&c->vChrFilterPos); |
1532 av_freep(&c->hLumFilterPos); | 1535 av_freep(&c->hLumFilterPos); |
1533 av_freep(&c->hChrFilterPos); | 1536 av_freep(&c->hChrFilterPos); |
1534 | 1537 |
1535 #if ARCH_X86 && CONFIG_GPL | 1538 #if ARCH_X86 && CONFIG_GPL |
1536 #ifdef MAP_ANONYMOUS | 1539 #ifdef MAP_ANONYMOUS |
1537 if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, c->lumMmx2FilterCodeS
ize); | 1540 if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, c->lumMmx2FilterCodeS
ize); |
1538 if (c->chrMmx2FilterCode) munmap(c->chrMmx2FilterCode, c->chrMmx2FilterCodeS
ize); | 1541 if (c->chrMmx2FilterCode) munmap(c->chrMmx2FilterCode, c->chrMmx2FilterCodeS
ize); |
1539 #elif HAVE_VIRTUALALLOC | 1542 #elif HAVE_VIRTUALALLOC |
1540 if (c->lumMmx2FilterCode) VirtualFree(c->lumMmx2FilterCode, c->lumMmx2Filter
CodeSize, MEM_RELEASE); | 1543 if (c->lumMmx2FilterCode) VirtualFree(c->lumMmx2FilterCode, 0, MEM_RELEASE); |
1541 if (c->chrMmx2FilterCode) VirtualFree(c->chrMmx2FilterCode, c->chrMmx2Filter
CodeSize, MEM_RELEASE); | 1544 if (c->chrMmx2FilterCode) VirtualFree(c->chrMmx2FilterCode, 0, MEM_RELEASE); |
1542 #else | 1545 #else |
1543 av_free(c->lumMmx2FilterCode); | 1546 av_free(c->lumMmx2FilterCode); |
1544 av_free(c->chrMmx2FilterCode); | 1547 av_free(c->chrMmx2FilterCode); |
1545 #endif | 1548 #endif |
1546 c->lumMmx2FilterCode=NULL; | 1549 c->lumMmx2FilterCode=NULL; |
1547 c->chrMmx2FilterCode=NULL; | 1550 c->chrMmx2FilterCode=NULL; |
1548 #endif /* ARCH_X86 && CONFIG_GPL */ | 1551 #endif /* ARCH_X86 && CONFIG_GPL */ |
1549 | 1552 |
1550 av_freep(&c->yuvTable); | 1553 av_freep(&c->yuvTable); |
1551 | 1554 |
1552 av_free(c); | 1555 av_free(c); |
1553 } | 1556 } |
1554 | 1557 |
1555 struct SwsContext *sws_getCachedContext(struct SwsContext *context, | 1558 struct SwsContext *sws_getCachedContext(struct SwsContext *context, |
1556 int srcW, int srcH, enum PixelFormat src
Format, | 1559 int srcW, int srcH, enum PixelFormat src
Format, |
1557 int dstW, int dstH, enum PixelFormat dst
Format, int flags, | 1560 int dstW, int dstH, enum PixelFormat dst
Format, int flags, |
1558 SwsFilter *srcFilter, SwsFilter *dstFilt
er, const double *param) | 1561 SwsFilter *srcFilter, SwsFilter *dstFilt
er, const double *param) |
1559 { | 1562 { |
1560 static const double default_param[2] = {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT
}; | 1563 static const double default_param[2] = {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT
}; |
1561 | 1564 |
1562 if (!param) | 1565 if (!param) |
1563 param = default_param; | 1566 param = default_param; |
1564 | 1567 |
1565 if (context) { | 1568 if (context && |
1566 if (context->srcW != srcW || context->srcH != srcH || | 1569 (context->srcW != srcW || |
1567 context->srcFormat != srcFormat || | 1570 context->srcH != srcH || |
1568 context->dstW != dstW || context->dstH != dstH || | 1571 context->srcFormat != srcFormat || |
1569 context->dstFormat != dstFormat || context->flags != flags || | 1572 context->dstW != dstW || |
1570 context->param[0] != param[0] || context->param[1] != param[1]) | 1573 context->dstH != dstH || |
1571 { | 1574 context->dstFormat != dstFormat || |
1572 sws_freeContext(context); | 1575 context->flags != flags || |
1573 context = NULL; | 1576 context->param[0] != param[0] || |
1574 } | 1577 context->param[1] != param[1])) { |
| 1578 sws_freeContext(context); |
| 1579 context = NULL; |
1575 } | 1580 } |
| 1581 |
1576 if (!context) { | 1582 if (!context) { |
1577 return sws_getContext(srcW, srcH, srcFormat, | 1583 return sws_getContext(srcW, srcH, srcFormat, |
1578 dstW, dstH, dstFormat, flags, | 1584 dstW, dstH, dstFormat, flags, |
1579 srcFilter, dstFilter, param); | 1585 srcFilter, dstFilter, param); |
1580 } | 1586 } |
1581 return context; | 1587 return context; |
1582 } | 1588 } |
1583 | 1589 |
OLD | NEW |