ithewei 5 سال پیش
والد
کامیت
3e5e3c9368
3فایلهای تغییر یافته به همراه0 افزوده شده و 190 حذف شده
  1. 0 74
      utils/hframe.cpp
  2. 0 89
      utils/hframe.h
  3. 0 27
      utils/hgl.h

+ 0 - 74
utils/hframe.cpp

@@ -1,74 +0,0 @@
-#include "hframe.h"
-
-#include "hlog.h"
-
-int HFrameBuf::push(HFrame* pFrame) {
-    if (pFrame->isNull())
-        return -10;
-
-    frame_stats.push_cnt++;
-
-    std::lock_guard<std::mutex> locker(mutex);
-
-    if (frames.size() >= (size_t)cache_num) {
-        hlogd("frame cache full!");
-        if (policy == HFrameBuf::DISCARD) {
-            return -20;     // note: cache full, discard frame
-        }
-
-        HFrame& frame = frames.front();
-        frames.pop_front();
-        free(frame.buf.len);
-        if (frame.userdata) {
-            hlogd("free userdata");
-            ::free(frame.userdata);
-            frame.userdata = NULL;
-        }
-    }
-
-    int ret = 0;
-    if (isNull()) {
-        resize(pFrame->buf.len * cache_num);
-        ret = 1;    // note: first push
-
-        frame_info.w = pFrame->w;
-        frame_info.h = pFrame->h;
-        frame_info.type = pFrame->type;
-        frame_info.bpp  = pFrame->bpp;
-    }
-
-    HFrame frame;
-    frame.buf.base = alloc(pFrame->buf.len);
-    frame.buf.len  = pFrame->buf.len;
-    frame.copy(*pFrame);
-    frames.push_back(frame);
-    frame_stats.push_ok_cnt++;
-
-    return ret;
-}
-
-int HFrameBuf::pop(HFrame* pFrame) {
-    frame_stats.pop_cnt++;
-
-    std::lock_guard<std::mutex> locker(mutex);
-
-    if (isNull())
-        return -10;
-
-    if (frames.size() == 0) {
-        hlogd("frame cache empty!");
-        return -20;
-    }
-
-    HFrame& frame = frames.front();
-    frames.pop_front();
-    free(frame.buf.len);
-
-    if (frame.isNull())
-        return -30;
-
-    pFrame->copy(frame);
-    frame_stats.pop_ok_cnt++;
-
-    return 0;
-}

+ 0 - 89
utils/hframe.h

@@ -1,89 +0,0 @@
-#ifndef HV_FRAME_H_
-#define HV_FRAME_H_
-
-#include <deque>
-#include <mutex>
-
-#include "hbuf.h"
-
-class HFrame {
-public:
-    HBuf buf;
-    int w;
-    int h;
-    int bpp;
-    int type;
-    uint64_t ts;
-    int64_t useridx;
-    void* userdata;
-
-    HFrame() {
-        w = h = bpp = type = 0;
-        ts = 0;
-        useridx = -1;
-        userdata = NULL;
-    }
-
-    bool isNull() {
-        return w == 0 || h == 0 || buf.isNull();
-    }
-
-    void copy(const HFrame& rhs) {
-        w = rhs.w;
-        h = rhs.h;
-        bpp = rhs.bpp;
-        type = rhs.type;
-        ts = rhs.ts;
-        useridx = rhs.useridx;
-        userdata = rhs.userdata;
-        buf.copy(rhs.buf.base, rhs.buf.len);
-    }
-};
-
-typedef struct frame_info_s {
-    int w;
-    int h;
-    int type;
-    int bpp;
-} FrameInfo;
-
-typedef struct frame_stats_s {
-    int push_cnt;
-    int pop_cnt;
-
-    int push_ok_cnt;
-    int pop_ok_cnt;
-
-    frame_stats_s() {
-        push_cnt = pop_cnt = push_ok_cnt = pop_ok_cnt = 0;
-    }
-} FrameStats;
-
-#define DEFAULT_FRAME_CACHENUM  10
-
-class HFrameBuf : public HRingBuf {
- public:
-    enum CacheFullPolicy {
-        SQUEEZE,
-        DISCARD,
-    } policy;
-
-    HFrameBuf() : HRingBuf() {
-        cache_num = DEFAULT_FRAME_CACHENUM;
-        policy = SQUEEZE;
-    }
-
-    void setCache(int num) {cache_num = num;}
-    void setPolicy(CacheFullPolicy policy) {this->policy = policy;}
-
-    int push(HFrame* pFrame);
-    int pop(HFrame* pFrame);
-
-    int         cache_num;
-    FrameStats  frame_stats;
-    FrameInfo   frame_info;
-    std::deque<HFrame> frames;
-    std::mutex         mutex;
-};
-
-#endif // HV_FRAME_H_

+ 0 - 27
utils/hgl.h

@@ -1,27 +0,0 @@
-#ifndef HV_GL_H_
-#define HV_GL_H_
-
-#include <GL/glew.h>
-
-#include "hframe.h"
-
-// GL PixelFormat extend
-#define GL_I420             0x1910  // YYYYYYYYUUVV
-#define GL_YV12             0x1911  // YYYYYYYYVVUU
-#define GL_NV12             0x1912  // YYYYYYYYUVUV
-#define GL_NV21             0x1913  // YYYYYYYYVUVU
-
-/*
-#define GL_RGB      0x1907      // RGBRGB
-#define GL_RGBA     0x1908      // RGBARGBA
-
-#define GL_BGR      0x80E0      // BGRBGR       .bmp
-#define GL_BGRA     0x80E1      // BGRABGRA
-*/
-
-typedef struct GLTexture_s {
-    GLuint id;  // for glGenTextures
-    HFrame frame;
-} GLTexture;
-
-#endif // HV_GL_H_