@@ -720,28 +720,89 @@ static void decode_gray_bitstream(HYuvContext *s, int count)
720
720
CLOSE_READER (re , & s -> gb );
721
721
}
722
722
723
+ #define GET_VLC_DUAL (dst0 , dst1 , name , gb , dtable , table1 , table2 , \
724
+ bits , max_depth , rsvd ) \
725
+ do { \
726
+ unsigned int index = SHOW_UBITS(name, gb, bits); \
727
+ int code = dtable[index][0]; \
728
+ int n = dtable[index][1]; \
729
+ \
730
+ if (code != rsvd && n>0) { \
731
+ dst0 = code>>8; \
732
+ dst1 = code; \
733
+ LAST_SKIP_BITS(name, gb, n); \
734
+ } else { \
735
+ int nb_bits; \
736
+ DUAL_INTERN(dst0, table1, gb, name, bits, max_depth); \
737
+ \
738
+ UPDATE_CACHE(re, gb); \
739
+ index = SHOW_UBITS(name, gb, bits); \
740
+ DUAL_INTERN(dst1, table2, gb, name, bits, max_depth); \
741
+ } \
742
+ } while (0)
743
+
744
+ #define READ_2PIX (dst0 , dst1 , plane1 )\
745
+ UPDATE_CACHE(re, &s->gb); \
746
+ GET_VLC_DUAL(dst0, dst1, re, &s->gb, s->vlc[4+plane1].table, \
747
+ s->vlc[0].table, s->vlc[plane1].table, \
748
+ VLC_BITS, 3, 0xffff)
749
+
723
750
static av_always_inline void decode_bgr_1 (HYuvContext * s , int count ,
724
751
int decorrelate , int alpha )
725
752
{
726
753
int i ;
754
+ OPEN_READER (re , & s -> gb );
755
+
727
756
for (i = 0 ; i < count ; i ++ ) {
728
- int code = get_vlc2 (& s -> gb , s -> vlc [4 ].table , VLC_BITS , 1 );
757
+ unsigned int index ;
758
+ int code , n ;
759
+
760
+ UPDATE_CACHE (re , & s -> gb );
761
+ index = SHOW_UBITS (re , & s -> gb , VLC_BITS );
762
+ code = s -> vlc [4 ].table [index ][0 ];
763
+ n = s -> vlc [4 ].table [index ][1 ];
764
+
729
765
if (code != -1 ) {
730
766
* (uint32_t * )& s -> temp [0 ][4 * i ] = s -> pix_bgr_map [code ];
731
- } else if (decorrelate ) {
732
- s -> temp [0 ][4 * i + G ] = get_vlc2 (& s -> gb , s -> vlc [1 ].table , VLC_BITS , 3 );
733
- s -> temp [0 ][4 * i + B ] = get_vlc2 (& s -> gb , s -> vlc [0 ].table , VLC_BITS , 3 ) +
734
- s -> temp [0 ][4 * i + G ];
735
- s -> temp [0 ][4 * i + R ] = get_vlc2 (& s -> gb , s -> vlc [2 ].table , VLC_BITS , 3 ) +
736
- s -> temp [0 ][4 * i + G ];
767
+ LAST_SKIP_BITS (re , & s -> gb , n );
737
768
} else {
738
- s -> temp [0 ][4 * i + B ] = get_vlc2 (& s -> gb , s -> vlc [0 ].table , VLC_BITS , 3 );
739
- s -> temp [0 ][4 * i + G ] = get_vlc2 (& s -> gb , s -> vlc [1 ].table , VLC_BITS , 3 );
740
- s -> temp [0 ][4 * i + R ] = get_vlc2 (& s -> gb , s -> vlc [2 ].table , VLC_BITS , 3 );
769
+ int nb_bits ;
770
+ if (decorrelate ) {
771
+ DUAL_INTERN (s -> temp [0 ][4 * i + G ], s -> vlc [1 ].table ,
772
+ & s -> gb , re , VLC_BITS , 3 );
773
+
774
+ UPDATE_CACHE (re , & s -> gb );
775
+ index = SHOW_UBITS (re , & s -> gb , VLC_BITS );
776
+ DUAL_INTERN (code , s -> vlc [0 ].table , & s -> gb , re , VLC_BITS , 3 );
777
+ s -> temp [0 ][4 * i + B ] = code + s -> temp [0 ][4 * i + G ];
778
+
779
+ UPDATE_CACHE (re , & s -> gb );
780
+ index = SHOW_UBITS (re , & s -> gb , VLC_BITS );
781
+ DUAL_INTERN (code , s -> vlc [2 ].table , & s -> gb , re , VLC_BITS , 3 );
782
+ s -> temp [0 ][4 * i + R ] = code + s -> temp [0 ][4 * i + G ];
783
+ } else {
784
+ DUAL_INTERN (s -> temp [0 ][4 * i + B ], s -> vlc [0 ].table ,
785
+ & s -> gb , re , VLC_BITS , 3 );
786
+
787
+ UPDATE_CACHE (re , & s -> gb );
788
+ index = SHOW_UBITS (re , & s -> gb , VLC_BITS );
789
+ DUAL_INTERN (s -> temp [0 ][4 * i + G ], s -> vlc [1 ].table ,
790
+ & s -> gb , re , VLC_BITS , 3 );
791
+
792
+ UPDATE_CACHE (re , & s -> gb );
793
+ index = SHOW_UBITS (re , & s -> gb , VLC_BITS );
794
+ DUAL_INTERN (s -> temp [0 ][4 * i + R ], s -> vlc [2 ].table ,
795
+ & s -> gb , re , VLC_BITS , 3 );
796
+ }
797
+ if (alpha ) {
798
+ UPDATE_CACHE (re , & s -> gb );
799
+ index = SHOW_UBITS (re , & s -> gb , VLC_BITS );
800
+ DUAL_INTERN (s -> temp [0 ][4 * i + A ], s -> vlc [2 ].table ,
801
+ & s -> gb , re , VLC_BITS , 3 );
802
+ }
741
803
}
742
- if (alpha )
743
- s -> temp [0 ][4 * i + A ] = get_vlc2 (& s -> gb , s -> vlc [2 ].table , VLC_BITS , 3 );
744
804
}
805
+ CLOSE_READER (re , & s -> gb );
745
806
}
746
807
747
808
static void decode_bgr_bitstream (HYuvContext * s , int count )
0 commit comments