Skip to content

Commit

Permalink
submodule update
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Dec 26, 2014
1 parent d15a487 commit 8ffe501
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 206 deletions.
2 changes: 1 addition & 1 deletion contrib/capi
4 changes: 2 additions & 2 deletions src/AudioResamplerTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace QtAV {

AudioResamplerId AudioResamplerId_FF = mkid32base36_6<'F', 'F', 'm', 'p', 'e', 'g'>::value;
AudioResamplerId AudioResamplerId_Libav = mkid32base36_5<'L', 'i', 'b', 'a', 'v'>::value;
AudioResamplerId AudioResamplerId_FF = mkid::id32base36_6<'F', 'F', 'm', 'p', 'e', 'g'>::value;
AudioResamplerId AudioResamplerId_Libav = mkid::id32base36_5<'L', 'i', 'b', 'a', 'v'>::value;

}
2 changes: 1 addition & 1 deletion src/ImageConverterFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ImageConverterFF : public ImageConverter //Q_AV_EXPORT is not needed
};


ImageConverterId ImageConverterId_FF = mkid32base36_6<'F', 'F', 'm', 'p', 'e', 'g'>::value;
ImageConverterId ImageConverterId_FF = mkid::id32base36_6<'F', 'F', 'm', 'p', 'e', 'g'>::value;
FACTORY_REGISTER_ID_AUTO(ImageConverter, FF, "FFmpeg")

void RegisterImageConverterFF_Man()
Expand Down
2 changes: 1 addition & 1 deletion src/ImageConverterIPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ImageConverterIPP : public ImageConverter //Q_AV_EXPORT is not needed
virtual bool prepareData(); //Allocate memory for out data
};

ImageConverterId ImageConverterId_IPP = mkid32base36_3<'I', 'P', 'P'>::value;
ImageConverterId ImageConverterId_IPP = mkid::id32base36_3<'I', 'P', 'P'>::value;
FACTORY_REGISTER_ID_AUTO(ImageConverter, IPP, "IPP")

void RegisterImageConverterIPP_Man()
Expand Down
148 changes: 85 additions & 63 deletions src/QtAV/private/mkid.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
mkid: map 5 chars to int
mkid: map chars to int at build time. Template based. A replacement of FourCC
Copyright (C) 2012-2014 Wang Bin <[email protected]>
This library is free software; you can redistribute it and/or
Expand All @@ -20,33 +20,79 @@
#ifndef MKID_H
#define MKID_H

struct lower_letter_t;
struct upper_letter_t;
struct number_t;
struct underline_t;
struct dot_t;
template<int x, typename T> struct map64_helper {};
/*!
* Example:
* int id1 = mkid::fourcc<'H', 'E', 'V', 'C'>::value;
* int id2 = mkid::id32base64_5<'H', 'e', 'l', 'l', 'o'>::value;
* int id3 = mkid::id32base36_6<'M', 'r', 'W', 'a', 'n', 'g'>::value;
* For (u)int32 result, base 64 accepts at most 5 characters, while base 36 accepts at most 6 characters.
*/
namespace mkid {
namespace detail {
template<int base, int x> struct map_base;
} // namespace internal

template<int base, int a0>
struct id32_1 { enum { value = detail::map_base<base, a0>::value};};
template<int base, int a0, int a1>
struct id32_2 { enum { value = id32_1<base, a0>::value*base + detail::map_base<base, a1>::value};};
template<int base, int a0, int a1, int a2>
struct id32_3 { enum { value = id32_2<base, a0, a1>::value*base + detail::map_base<base, a2>::value};};
template<int base, int a0, int a1, int a2, int a3>
struct id32_4 { enum { value = id32_3<base, a0, a1, a2>::value*base + detail::map_base<base, a3>::value};};
template<int base, int a0, int a1, int a2, int a3, int a4>
struct id32_5 { enum { value = id32_4<base, a0, a1, a2, a3>::value*base + detail::map_base<base, a4>::value};};
template<int base, int a0, int a1, int a2, int a3, int a4, int a5>
struct id32_6 { enum { value = id32_5<base, a0, a1, a2, a3, a4>::value*base + detail::map_base<base, a5>::value};};

// template based FourCC
template<int a0, int a1, int a2, int a3>
struct fourcc : public id32_4<256, a0, a1, a2, a3>{};

// a0~a4: '0'~'9', 'A'~'Z', 'a'~'z', '_', '.' ==>> [0,63]
template<int a0>
struct id32base64_1 : public id32_1<64, a0>{};
template<int a0, int a1>
struct id32base64_2 : public id32_2<64, a0, a1>{};
template<int a0, int a1, int a2>
struct id32base64_3 : public id32_3<64, a0, a1, a2>{};
template<int a0, int a1, int a2, int a3>
struct id32base64_4 : public id32_4<64, a0, a1, a2, a3>{};
template<int a0, int a1, int a2, int a3, int a4>
struct id32base64_5 : public id32_5<64, a0, a1, a2, a3, a4>{};

// a0~a5: '0'~'9', 'A'~'Z', 'a'~'z' ==>> [0,63], upper and lower letters are equal
template<int a0>
struct id32base36_1 : public id32_1<36, a0>{};
template<int a0, int a1>
struct id32base36_2 : public id32_2<36, a0, a1>{};
template<int a0, int a1, int a2>
struct id32base36_3 : public id32_3<36, a0, a1, a2>{};
template<int a0, int a1, int a2, int a3>
struct id32base36_4 : public id32_4<36, a0, a1, a2, a3>{};
template<int a0, int a1, int a2, int a3, int a4>
struct id32base36_5 : public id32_5<36, a0, a1, a2, a3, a4>{};
template<int a0, int a1, int a2, int a3, int a4, int a5>
struct id32base36_6 : public id32_6<36, a0, a1, a2, a3, a4, a5>{};

namespace detail {
////////////////////////////Details////////////////////////////
template<bool b, typename T1, typename T2> struct if_then_else;
template<typename T1, typename T2> struct if_then_else<true, T1, T2> { typedef T1 Type;};
template<typename T1, typename T2> struct if_then_else<false, T1, T2> { typedef T2 Type;};
template<int c> struct is_lower_letter { enum { value = c >= 97 && c <= 122 };};
template<int c> struct is_upper_letter { enum { value = c >= 65 && c <= 90 };};
template<int c> struct is_num { enum { value = c >= 48 && c <= 57 };};
template<int c> struct is_underline { enum { value = c == 95 }; };
template<int c> struct is_dot { enum { value = c == 46 };};
struct lower_letter_t; struct upper_letter_t; struct number_t; struct underline_t; struct dot_t;
template<int x, typename T> struct map64_helper;
template<int x> struct map64_helper<x, number_t> { enum { value = x-48}; };
template<int x> struct map64_helper<x, upper_letter_t> { enum { value = x-65+10}; };
template<int x> struct map64_helper<x, lower_letter_t> { enum { value = x-97+10+26}; };
template<int x> struct map64_helper<x, underline_t> { enum { value = 62}; };
template<int x> struct map64_helper<x, dot_t> { enum { value = 63}; };

template<bool b, typename T1, typename T2> struct if_then_else;
template<typename T1, typename T2> struct if_then_else<true, T1, T2> { typedef T1 Type;};
template<typename T1, typename T2> struct if_then_else<false, T1, T2> { typedef T2 Type;};
template<int c>
struct is_lower_letter { enum { value = c >= 97 && c <= 122 };};
template<int c>
struct is_upper_letter { enum { value = c >= 65 && c <= 90 };};
template<int c>
struct is_num { enum { value = c >= 48 && c <= 57 };};
template<int c>
struct is_underline { enum { value = c == 95 }; };
template<int c>
struct is_dot { enum { value = c == 46 };};
struct invalid_char_must_be_number_26letters_underline_dot;
template<int base, int x> struct map_base;
template<int x> struct map_base<64, x> {
enum {
value = map64_helper<x,
Expand All @@ -58,7 +104,7 @@ template<int x> struct map_base<64, x> {
invalid_char_must_be_number_26letters_underline_dot>::Type>::Type>::Type>::Type>::Type>::value
};
};
template<int x, typename T> struct map36_helper {};
template<int x, typename T> struct map36_helper;
template<int x> struct map36_helper<x, number_t> { enum { value = x-48}; };
template<int x> struct map36_helper<x, upper_letter_t> { enum { value = x-65+10}; };
template<int x> struct map36_helper<x, lower_letter_t> { enum { value = x-97+10}; };
Expand All @@ -72,44 +118,20 @@ template<int x> struct map_base<36, x> {
invalid_char_must_be_number_26letters>::Type>::Type>::Type>::value
};
};

template<int base, int a0>
struct mkid32_1 { enum { value = map_base<base, a0>::value};};
template<int base, int a0, int a1>
struct mkid32_2 { enum { value = mkid32_1<base, a0>::value*base + map_base<base, a1>::value};};
template<int base, int a0, int a1, int a2>
struct mkid32_3 { enum { value = mkid32_2<base, a0, a1>::value*base + map_base<base, a2>::value};};
template<int base, int a0, int a1, int a2, int a3>
struct mkid32_4 { enum { value = mkid32_3<base, a0, a1, a2>::value*base + map_base<base, a3>::value};};
template<int base, int a0, int a1, int a2, int a3, int a4>
struct mkid32_5 { enum { value = mkid32_4<base, a0, a1, a2, a3>::value*base + map_base<base, a4>::value};};
template<int base, int a0, int a1, int a2, int a3, int a4, int a5>
struct mkid32_6 { enum { value = mkid32_5<base, a0, a1, a2, a3, a4>::value*base + map_base<base, a5>::value};};

// a0~a4: '0'~'9', 'A'~'Z', 'a'~'z', '_', '.' ==>> [0,63]
template<int a0>
struct mkid32base64_1 : public mkid32_1<64, a0>{};
template<int a0, int a1>
struct mkid32base64_2 : public mkid32_2<64, a0, a1>{};
template<int a0, int a1, int a2>
struct mkid32base64_3 : public mkid32_3<64, a0, a1, a2>{};
template<int a0, int a1, int a2, int a3>
struct mkid32base64_4 : public mkid32_4<64, a0, a1, a2, a3>{};
template<int a0, int a1, int a2, int a3, int a4>
struct mkid32base64_5 : public mkid32_5<64, a0, a1, a2, a3, a4>{};

// a0~a5: '0'~'9', 'A'~'Z', 'a'~'z' ==>> [0,63], upper and lower letters are equal
template<int a0>
struct mkid32base36_1 : public mkid32_1<36, a0>{};
template<int a0, int a1>
struct mkid32base36_2 : public mkid32_2<36, a0, a1>{};
template<int a0, int a1, int a2>
struct mkid32base36_3 : public mkid32_3<36, a0, a1, a2>{};
template<int a0, int a1, int a2, int a3>
struct mkid32base36_4 : public mkid32_4<36, a0, a1, a2, a3>{};
template<int a0, int a1, int a2, int a3, int a4>
struct mkid32base36_5 : public mkid32_5<36, a0, a1, a2, a3, a4>{};
template<int a0, int a1, int a2, int a3, int a4, int a5>
struct mkid32base36_6 : public mkid32_6<36, a0, a1, a2, a3, a4, a5>{};

// for FourCC
template<int> struct out_of_lower_bound {};
template<int> struct out_of_upper_bound {};
struct map_identical_t;
template<int x, typename T> struct map_identical_helper;
template<int x> struct map_identical_helper<x,map_identical_t>{enum{value=x};};
template<int x> struct map_base<256, x> {
enum {
value = map_identical_helper<x,
typename if_then_else<(x<0), out_of_lower_bound<0>,
typename if_then_else<(x>255), out_of_upper_bound<255>,
map_identical_t>::Type>::Type>::value
};
};
} // namespace detail
} // namespace mkid
#endif // MKID_H
12 changes: 6 additions & 6 deletions src/codec/video/VideoDecoderTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace QtAV {

VideoDecoderId VideoDecoderId_FFmpeg = mkid32base36_6<'F', 'F', 'm', 'p', 'e', 'g'>::value;
VideoDecoderId VideoDecoderId_CUDA = mkid32base36_4<'C', 'U', 'D', 'A'>::value;
VideoDecoderId VideoDecoderId_DXVA = mkid32base36_4<'D', 'X', 'V', 'A'>::value;
VideoDecoderId VideoDecoderId_VAAPI = mkid32base36_5<'V', 'A', 'A', 'P', 'I'>::value;
VideoDecoderId VideoDecoderId_Cedarv = mkid32base36_6<'C', 'e', 'd', 'a', 'r', 'V'>::value;
VideoDecoderId VideoDecoderId_VDA = mkid32base36_3<'V', 'D', 'A'>::value;
VideoDecoderId VideoDecoderId_FFmpeg = mkid::id32base36_6<'F', 'F', 'm', 'p', 'e', 'g'>::value;
VideoDecoderId VideoDecoderId_CUDA = mkid::id32base36_4<'C', 'U', 'D', 'A'>::value;
VideoDecoderId VideoDecoderId_DXVA = mkid::id32base36_4<'D', 'X', 'V', 'A'>::value;
VideoDecoderId VideoDecoderId_VAAPI = mkid::id32base36_5<'V', 'A', 'A', 'P', 'I'>::value;
VideoDecoderId VideoDecoderId_Cedarv = mkid::id32base36_6<'C', 'e', 'd', 'a', 'r', 'V'>::value;
VideoDecoderId VideoDecoderId_VDA = mkid::id32base36_3<'V', 'D', 'A'>::value;

QVector<VideoDecoderId> GetRegistedVideoDecoderIds()
{
Expand Down
4 changes: 2 additions & 2 deletions src/input/QIODeviceInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif
namespace QtAV {

static const AVInputId AVInputId_QIODevice = mkid32base36_6<'Q','I','O','D','e','v'>::value;
static const AVInputId AVInputId_QIODevice = mkid::id32base36_6<'Q','I','O','D','e','v'>::value;
static const char kQIODevName[] = "QIODevice";
FACTORY_REGISTER_ID_TYPE(AVInput, AVInputId_QIODevice, QIODeviceInput, kQIODevName)

Expand Down Expand Up @@ -122,7 +122,7 @@ class QFileInput : public QIODeviceInput
using QIODeviceInput::setIODevice;
};

static const AVInputId AVInputId_QFile = mkid32base36_5<'Q','F','i','l','e'>::value;
static const AVInputId AVInputId_QFile = mkid::id32base36_5<'Q','F','i','l','e'>::value;
FACTORY_REGISTER_ID_TYPE(AVInput, AVInputId_QFile, QFileInput, kQFileName)

class QFileInputPrivate : public QIODeviceInputPrivate
Expand Down
8 changes: 4 additions & 4 deletions src/output/audio/AudioOutputTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#include "QtAV/private/mkid.h"
namespace QtAV {

AudioOutputId AudioOutputId_PortAudio = mkid32base36_5<'P', 'o', 'r', 't', 'A'>::value;
AudioOutputId AudioOutputId_OpenAL = mkid32base36_6<'O', 'p', 'e', 'n', 'A', 'L'>::value;
AudioOutputId AudioOutputId_OpenSL = mkid32base36_6<'O', 'p', 'e', 'n', 'S', 'L'>::value;
AudioOutputId AudioOutputId_DSound = mkid32base36_6<'D', 'S', 'o', 'u', 'n', 'd'>::value;
AudioOutputId AudioOutputId_PortAudio = mkid::id32base36_5<'P', 'o', 'r', 't', 'A'>::value;
AudioOutputId AudioOutputId_OpenAL = mkid::id32base36_6<'O', 'p', 'e', 'n', 'A', 'L'>::value;
AudioOutputId AudioOutputId_OpenSL = mkid::id32base36_6<'O', 'p', 'e', 'n', 'S', 'L'>::value;
AudioOutputId AudioOutputId_DSound = mkid::id32base36_6<'D', 'S', 'o', 'u', 'n', 'd'>::value;

QVector<AudioOutputId> GetRegistedAudioOutputIds()
{
Expand Down
18 changes: 9 additions & 9 deletions src/output/video/VideoRendererTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ namespace QtAV {

FACTORY_DEFINE(VideoRenderer)

VideoRendererId VideoRendererId_Widget = mkid32base36_6<'W', 'i', 'd', 'g', 'e', 't'>::value;
VideoRendererId VideoRendererId_GraphicsItem = mkid32base36_6<'Q', 'G', 'r', 'a', 'p', 'h'>::value;
VideoRendererId VideoRendererId_GLWidget = mkid32base36_6<'Q', 'G', 'L', 'W', 't', '1'>::value;
VideoRendererId VideoRendererId_GDI = mkid32base36_3<'G', 'D', 'I'>::value;
VideoRendererId VideoRendererId_Direct2D = mkid32base36_3<'D', '2', 'D'>::value;
VideoRendererId VideoRendererId_XV = mkid32base36_6<'X', 'V', 'i', 'd', 'e', 'o'>::value;
VideoRendererId VideoRendererId_GLWidget2 = mkid32base36_6<'Q', 'G', 'L', 'W', 't', '2'>::value;
VideoRendererId VideoRendererId_OpenGLWindow = mkid32base36_6<'Q', 'O', 'G', 'L', 'W', 'w'>::value;
VideoRendererId VideoRendererId_OpenGLWidget = mkid32base36_6<'Q', 'O', 'G', 'L', 'W', 't'>::value;
VideoRendererId VideoRendererId_Widget = mkid::id32base36_6<'W', 'i', 'd', 'g', 'e', 't'>::value;
VideoRendererId VideoRendererId_GraphicsItem = mkid::id32base36_6<'Q', 'G', 'r', 'a', 'p', 'h'>::value;
VideoRendererId VideoRendererId_GLWidget = mkid::id32base36_6<'Q', 'G', 'L', 'W', 't', '1'>::value;
VideoRendererId VideoRendererId_GDI = mkid::id32base36_3<'G', 'D', 'I'>::value;
VideoRendererId VideoRendererId_Direct2D = mkid::id32base36_3<'D', '2', 'D'>::value;
VideoRendererId VideoRendererId_XV = mkid::id32base36_6<'X', 'V', 'i', 'd', 'e', 'o'>::value;
VideoRendererId VideoRendererId_GLWidget2 = mkid::id32base36_6<'Q', 'G', 'L', 'W', 't', '2'>::value;
VideoRendererId VideoRendererId_OpenGLWindow = mkid::id32base36_6<'Q', 'O', 'G', 'L', 'W', 'w'>::value;
VideoRendererId VideoRendererId_OpenGLWidget = mkid::id32base36_6<'Q', 'O', 'G', 'L', 'W', 't'>::value;

#if QTAV_HAVE(WIDGETS)
//QPainterRenderer is abstract. So can not register(operator new will needed)
Expand Down
Loading

0 comments on commit 8ffe501

Please sign in to comment.