@@ -742,6 +742,77 @@ static void packed16togbra16(const uint8_t *src, int srcStride,
742
742
}
743
743
}
744
744
745
+ static void packed30togbra10 (const uint8_t * src , int srcStride ,
746
+ uint16_t * dst [], const int dstStride [], int srcSliceH ,
747
+ int swap , int bpc , int width )
748
+ {
749
+ int x , h , i ;
750
+ int dst_alpha = dst [3 ] != NULL ;
751
+ int scale_high = bpc - 10 , scale_low = 10 - scale_high ;
752
+ for (h = 0 ; h < srcSliceH ; h ++ ) {
753
+ uint32_t * src_line = (uint32_t * )(src + srcStride * h );
754
+ unsigned component ;
755
+
756
+ switch (swap ) {
757
+ case 3 :
758
+ case 2 :
759
+ if (dst_alpha ) {
760
+ for (x = 0 ; x < width ; x ++ ) {
761
+ unsigned p = AV_RL32 (src_line );
762
+ component = (p >> 20 ) & 0x3FF ;
763
+ dst [0 ][x ] = av_bswap16 (component << scale_high | component >> scale_low );
764
+ component = (p >> 10 ) & 0x3FF ;
765
+ dst [1 ][x ] = av_bswap16 (component << scale_high | component >> scale_low );
766
+ component = p & 0x3FF ;
767
+ dst [2 ][x ] = av_bswap16 (component << scale_high | component >> scale_low );
768
+ dst [3 ][x ] = 0xFFFF ;
769
+ src_line ++ ;
770
+ }
771
+ } else {
772
+ for (x = 0 ; x < width ; x ++ ) {
773
+ unsigned p = AV_RL32 (src_line );
774
+ component = (p >> 20 ) & 0x3FF ;
775
+ dst [0 ][x ] = av_bswap16 (component << scale_high | component >> scale_low );
776
+ component = (p >> 10 ) & 0x3FF ;
777
+ dst [1 ][x ] = av_bswap16 (component << scale_high | component >> scale_low );
778
+ component = p & 0x3FF ;
779
+ dst [2 ][x ] = av_bswap16 (component << scale_high | component >> scale_low );
780
+ src_line ++ ;
781
+ }
782
+ }
783
+ break ;
784
+ default :
785
+ if (dst_alpha ) {
786
+ for (x = 0 ; x < width ; x ++ ) {
787
+ unsigned p = AV_RL32 (src_line );
788
+ component = (p >> 20 ) & 0x3FF ;
789
+ dst [0 ][x ] = component << scale_high | component >> scale_low ;
790
+ component = (p >> 10 ) & 0x3FF ;
791
+ dst [1 ][x ] = component << scale_high | component >> scale_low ;
792
+ component = p & 0x3FF ;
793
+ dst [2 ][x ] = component << scale_high | component >> scale_low ;
794
+ dst [3 ][x ] = 0xFFFF ;
795
+ src_line ++ ;
796
+ }
797
+ } else {
798
+ for (x = 0 ; x < width ; x ++ ) {
799
+ unsigned p = AV_RL32 (src_line );
800
+ component = (p >> 20 ) & 0x3FF ;
801
+ dst [0 ][x ] = component << scale_high | component >> scale_low ;
802
+ component = (p >> 10 ) & 0x3FF ;
803
+ dst [1 ][x ] = component << scale_high | component >> scale_low ;
804
+ component = p & 0x3FF ;
805
+ dst [2 ][x ] = component << scale_high | component >> scale_low ;
806
+ src_line ++ ;
807
+ }
808
+ }
809
+ break ;
810
+ }
811
+ for (i = 0 ; i < 4 ; i ++ )
812
+ dst [i ] += dstStride [i ] >> 1 ;
813
+ }
814
+ }
815
+
745
816
static int Rgb16ToPlanarRgb16Wrapper (SwsInternal * c , const uint8_t * const src [],
746
817
const int srcStride [], int srcSliceY , int srcSliceH ,
747
818
uint8_t * const dst [], const int dstStride [])
@@ -785,6 +856,12 @@ static int Rgb16ToPlanarRgb16Wrapper(SwsInternal *c, const uint8_t *const src[],
785
856
dst2013 , stride2013 , srcSliceH , alpha , swap ,
786
857
16 - bpc , c -> srcW );
787
858
break ;
859
+ case AV_PIX_FMT_X2RGB10LE :
860
+ av_assert0 (bpc >= 10 );
861
+ packed30togbra10 (src [0 ], srcStride [0 ],
862
+ dst2013 , stride2013 , srcSliceH , swap ,
863
+ bpc , c -> srcW );
864
+ break ;
788
865
case AV_PIX_FMT_BGR48LE :
789
866
case AV_PIX_FMT_BGR48BE :
790
867
case AV_PIX_FMT_BGRA64LE :
@@ -793,6 +870,12 @@ static int Rgb16ToPlanarRgb16Wrapper(SwsInternal *c, const uint8_t *const src[],
793
870
dst1023 , stride1023 , srcSliceH , alpha , swap ,
794
871
16 - bpc , c -> srcW );
795
872
break ;
873
+ case AV_PIX_FMT_X2BGR10LE :
874
+ av_assert0 (bpc >= 10 );
875
+ packed30togbra10 (src [0 ], srcStride [0 ],
876
+ dst1023 , stride1023 , srcSliceH , swap ,
877
+ bpc , c -> srcW );
878
+ break ;
796
879
default :
797
880
av_log (c , AV_LOG_ERROR ,
798
881
"unsupported conversion to planar RGB %s -> %s\n" ,
@@ -2301,6 +2384,11 @@ void ff_get_unscaled_swscale(SwsInternal *c)
2301
2384
dstFormat == AV_PIX_FMT_GBRAP16LE || dstFormat == AV_PIX_FMT_GBRAP16BE ))
2302
2385
c -> convert_unscaled = Rgb16ToPlanarRgb16Wrapper ;
2303
2386
2387
+ if (av_pix_fmt_desc_get (dstFormat )-> comp [0 ].depth >= 10 &&
2388
+ isPlanarRGB (dstFormat ) && !isFloat (dstFormat ) &&
2389
+ (srcFormat == AV_PIX_FMT_X2RGB10LE || srcFormat == AV_PIX_FMT_X2BGR10LE ))
2390
+ c -> convert_unscaled = Rgb16ToPlanarRgb16Wrapper ;
2391
+
2304
2392
if ((srcFormat == AV_PIX_FMT_GBRP9LE || srcFormat == AV_PIX_FMT_GBRP9BE ||
2305
2393
srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE ||
2306
2394
srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
0 commit comments