• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/bytestream.h

Go to the documentation of this file.
00001 /*
00002  * Bytestream functions
00003  * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #ifndef AVCODEC_BYTESTREAM_H
00023 #define AVCODEC_BYTESTREAM_H
00024 
00025 #include <string.h>
00026 #include "libavutil/common.h"
00027 #include "libavutil/intreadwrite.h"
00028 
00029 #define DEF_T(type, name, bytes, read, write)                             \
00030 static av_always_inline type bytestream_get_ ## name(const uint8_t **b){\
00031     (*b) += bytes;\
00032     return read(*b - bytes);\
00033 }\
00034 static av_always_inline void bytestream_put_ ##name(uint8_t **b, const type value){\
00035     write(*b, value);\
00036     (*b) += bytes;\
00037 }
00038 
00039 #define DEF(name, bytes, read, write) \
00040     DEF_T(unsigned int, name, bytes, read, write)
00041 #define DEF64(name, bytes, read, write) \
00042     DEF_T(uint64_t, name, bytes, read, write)
00043 
00044 DEF64(le64, 8, AV_RL64, AV_WL64)
00045 DEF  (le32, 4, AV_RL32, AV_WL32)
00046 DEF  (le24, 3, AV_RL24, AV_WL24)
00047 DEF  (le16, 2, AV_RL16, AV_WL16)
00048 DEF64(be64, 8, AV_RB64, AV_WB64)
00049 DEF  (be32, 4, AV_RB32, AV_WB32)
00050 DEF  (be24, 3, AV_RB24, AV_WB24)
00051 DEF  (be16, 2, AV_RB16, AV_WB16)
00052 DEF  (byte, 1, AV_RB8 , AV_WB8 )
00053 
00054 #undef DEF
00055 #undef DEF64
00056 #undef DEF_T
00057 
00058 static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)
00059 {
00060     memcpy(dst, *b, size);
00061     (*b) += size;
00062     return size;
00063 }
00064 
00065 static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
00066 {
00067     memcpy(*b, src, size);
00068     (*b) += size;
00069 }
00070 
00071 #endif /* AVCODEC_BYTESTREAM_H */

Generated on Fri Sep 16 2011 17:17:34 for FFmpeg by  doxygen 1.7.1