aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2009-03-31 22:52:30 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2009-03-31 22:52:30 +0000
commitc95dd8d38256a57bc54ede07baa86cfdf50b0c4a (patch)
tree5216e2e3b2515a6fb008f7a83a75b4eacafb612a /libavcodec
parent21010f6b2ad9f065e565eac443c21c538622e276 (diff)
downloadffmpeg-c95dd8d38256a57bc54ede07baa86cfdf50b0c4a.tar.gz
Add/fix support for bitstream formats reading in read_line().
Originally committed as revision 18291 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/pixdesc.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/libavcodec/pixdesc.h b/libavcodec/pixdesc.h
index 28695e6674..6ff07fb342 100644
--- a/libavcodec/pixdesc.h
+++ b/libavcodec/pixdesc.h
@@ -22,6 +22,7 @@
#include <inttypes.h>
#include "libavutil/intreadwrite.h"
+#include "libavcodec/bitstream.h"
typedef struct AVComponentDescriptor{
uint16_t plane :2; ///< which of the 4 planes contains the component
@@ -103,9 +104,21 @@ static inline void read_line(uint16_t *dst, const uint8_t *data[4], const int li
int shift= comp.shift;
int step = comp.step_minus1+1;
int flags= desc->flags;
- const uint8_t *p= data[plane]+y*linesize[plane] + x * step + comp.offset_plus1 - 1;
- //FIXME initial x in case of PIX_FMT_BITSTREAM is wrong
+ if (flags & PIX_FMT_BITSTREAM){
+ GetBitContext gb;
+ init_get_bits(&gb, data[plane] + y*linesize[plane], linesize[plane]*8);
+ skip_bits_long(&gb, x*step + comp.offset_plus1-1);
+
+ while(w--){
+ int val = show_bits(&gb, depth);
+ if(flags & PIX_FMT_PAL)
+ val= data[1][4*val + c];
+ skip_bits(&gb, step);
+ *dst++= val;
+ }
+ } else {
+ const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
while(w--){
int val;
@@ -114,14 +127,8 @@ static inline void read_line(uint16_t *dst, const uint8_t *data[4], const int li
val = (val>>shift) & mask;
if(flags & PIX_FMT_PAL)
val= data[1][4*val + c];
- if(flags & PIX_FMT_BITSTREAM){
- shift-=depth;
- while(shift<0){
- shift+=8;
- p++;
- }
- }else
p+= step;
*dst++= val;
}
+ }
}