]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pixdesc.h
add casts to silence gcc warnings
[ffmpeg] / libavcodec / pixdesc.h
index 5c2718dba7b788cd98f9f69e392e07c2f75cf428..0a2acab7199488b3afa147d58c0245b1332bdb7b 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#ifndef AVCODEC_PIXDESC_H
+#define AVCODEC_PIXDESC_H
+
 #include <inttypes.h>
 
 #include "libavutil/intreadwrite.h"
-#include "get_bits.h"
 
 typedef struct AVComponentDescriptor{
     uint16_t plane        :2;            ///< which of the 4 planes contains the component
@@ -111,15 +113,17 @@ static inline void read_line(uint16_t *dst, const uint8_t *data[4], const int li
     int flags= desc->flags;
 
     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);
+        int skip = x*step + comp.offset_plus1-1;
+        const uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3);
+        int shift = 8 - depth - (skip&7);
 
         while(w--){
-            int val = show_bits(&gb, depth);
+            int val = (*p >> shift) & mask;
             if(read_pal_component)
                 val= data[1][4*val + c];
-            skip_bits(&gb, step);
+            shift -= step;
+            p -= shift>>3;
+            shift &= 7;
             *dst++= val;
         }
     } else {
@@ -188,3 +192,15 @@ static inline void write_line(const uint16_t *src, uint8_t *data[4], const int l
         }
     }
 }
+
+/**
+ * Returns the number of bits per pixel used by the pixel format
+ * described by pixdesc.
+ *
+ * The returned number of bits refers to the number of bits actually
+ * used for storing the pixel information, that is padding bits are
+ * not counted.
+ */
+int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
+
+#endif /* AVCODEC_PIXDESC_H */