📄 encode.h
字号:
/* * encode.h * * ============================================================================ * Copyright (c) Texas Instruments Inc 2005 * * Use of this software is controlled by the terms and conditions found in the * license agreement under which this software has been supplied or provided. * ============================================================================ */#ifndef _ENCODE_H#define _ENCODE_H/* Standard Linux headers */#include <stdio.h>#include <pthread.h>/* Enables or disables debug output */#ifdef __DEBUG#define DBG(fmt, args...) fprintf(stderr, "Encode Debug: " fmt, ## args)#else#define DBG(fmt, args...)#endif#define ERR(fmt, args...) fprintf(stderr, "Encode Error: " fmt, ## args)/* Function error codes */#define SUCCESS 0#define FAILURE -1/* Thread error codes */#define THREAD_SUCCESS (void *) 0#define THREAD_FAILURE (void *) -1/* The codec engine to use in this application */#define ENGINE_NAME "encode"/* Device parameters */#define V4L2_DEVICE "/dev/video0"#define OSD_DEVICE "/dev/fb/0"#define ATTR_DEVICE "/dev/fb/2"#define FBVID_DEVICE "/dev/fb/3"#define SOUND_DEVICE "/dev/dsp"#define MIXER_DEVICE "/dev/mixer"/* True of false enumeration */#define TRUE 1#define FALSE 0/* Scaling factors for the video standards */#define NOSTD 0#define PALSTD 12#define NTSCSTD 10/* Number of microseconds to pause if the demo is 'paused' */#define PAUSE 100/* Screen dimensions */#define SCREEN_BPP 16#define D1_WIDTH 720#define D1_HEIGHT yScale(480)#define D1_LINE_WIDTH D1_WIDTH * SCREEN_BPP / 8#define D1_FRAME_SIZE D1_LINE_WIDTH * D1_HEIGHTtypedef enum SpeechEncoder { G711_SPEECH_ENCODER, NUM_SPEECH_ENCODERS} SpeechEncoder;typedef enum VideoEncoder { MPEG4_VIDEO_ENCODER, H264_VIDEO_ENCODER, NUM_VIDEO_ENCODERS} VideoEncoder;typedef enum SoundInput { MIC_SOUND_INPUT, LINEIN_SOUND_INPUT} SoundInput;/* Global data structure */typedef struct GlobalData { int quit; /* Global quit flag */ int record; /* Whether to record or pause */ int frames; /* Video frame counter */ int videoBytesEncoded; /* Video bytes encoded counter */ int soundBytesEncoded; /* Sound bytes encoded counter */ int yFactor; /* Vertical scaling (PAL vs. NTSC) */ pthread_mutex_t mutex; /* Mutex to protect the global data */} GlobalData;/* Global data */extern GlobalData gbl;/* Functions to protect the global data */static inline int gblGetQuit(void){ int quit; pthread_mutex_lock(&gbl.mutex); quit = gbl.quit; pthread_mutex_unlock(&gbl.mutex); return quit;}static inline void gblSetQuit(void){ pthread_mutex_lock(&gbl.mutex); gbl.quit = TRUE; pthread_mutex_unlock(&gbl.mutex);}static inline int gblGetRecord(void){ int record; pthread_mutex_lock(&gbl.mutex); record = gbl.record; pthread_mutex_unlock(&gbl.mutex); return record;}static inline void gblSetRecord(int record){ pthread_mutex_lock(&gbl.mutex); gbl.record = record; pthread_mutex_unlock(&gbl.mutex);}static inline int gblGetAndResetFrames(void){ int frames; pthread_mutex_lock(&gbl.mutex); frames = gbl.frames; gbl.frames = 0; pthread_mutex_unlock(&gbl.mutex); return frames;}static inline void gblIncFrames(void){ pthread_mutex_lock(&gbl.mutex); gbl.frames++; pthread_mutex_unlock(&gbl.mutex);}static inline int gblGetAndResetVideoBytesEncoded(void){ int videoBytesEncoded; pthread_mutex_lock(&gbl.mutex); videoBytesEncoded = gbl.videoBytesEncoded; gbl.videoBytesEncoded = 0; pthread_mutex_unlock(&gbl.mutex); return videoBytesEncoded;}static inline void gblIncVideoBytesEncoded(int videoBytesEncoded){ pthread_mutex_lock(&gbl.mutex); gbl.videoBytesEncoded += videoBytesEncoded; pthread_mutex_unlock(&gbl.mutex);}static inline int gblGetAndResetSoundBytesEncoded(void){ int soundBytesEncoded; pthread_mutex_lock(&gbl.mutex); soundBytesEncoded = gbl.soundBytesEncoded; gbl.soundBytesEncoded = 0; pthread_mutex_unlock(&gbl.mutex); return soundBytesEncoded;}static inline void gblIncSoundBytesEncoded(int soundBytesEncoded){ pthread_mutex_lock(&gbl.mutex); gbl.soundBytesEncoded += soundBytesEncoded; pthread_mutex_unlock(&gbl.mutex);}static inline int gblGetYFactor(void){ int yFactor; pthread_mutex_lock(&gbl.mutex); yFactor = gbl.yFactor; pthread_mutex_unlock(&gbl.mutex); return yFactor;}static inline void gblSetYFactor(int yFactor){ pthread_mutex_lock(&gbl.mutex); gbl.yFactor = yFactor; pthread_mutex_unlock(&gbl.mutex);}/* Scale vertically depending on video standard */#define yScale(x) (((x) * gblGetYFactor()) / 10)/* Cleans up cleanly after a failure */#define cleanup(x) \ status = (x); \ gblSetQuit(); \ goto cleanup/* Breaks a processing loop for a clean exit */#define breakLoop(x) \ status = (x); \ gblSetQuit(); \ break#endif /* _ENCODE_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -