Skip to content

Commit

Permalink
make function calls to H264 compress functions take context pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
bsobhani committed Apr 1, 2024
1 parent 560dda6 commit 5b4623e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ADApp/pluginSrc/NDPluginCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ NDArray *decompressBSLZ4(NDArray *input, NDCodecStatus_t *status, char *errorMes
#ifdef HAVE_VC
#include <video_compression.h>
//extern int H264_compress_default(const char*, char*, int, int, int);
NDArray *compressH264(NDArray *input, NDCodecStatus_t *status, char *errorMessage)
NDArray *compressH264(void** vc_context, NDArray *input, NDCodecStatus_t *status, char *errorMessage)
{
//printf("inside compressH264\n");
if (!input->codec.empty()) {
Expand Down Expand Up @@ -679,7 +679,8 @@ NDArray *compressH264(NDArray *input, NDCodecStatus_t *status, char *errorMessag
//printf("x_size %d y_size %d\n", x_size, y_size);
//printf("before H264 compress default\n");
//int compSize = H264_compress_default((const char*)input->pData, (char*)output->pData, (int)x_size, (int)y_size, outputSize);
int compSize = H264_compress((const char*)input->pData, (char*)output->pData, (int)x_size, (int)y_size);
//int compSize = H264_compress((const char*)input->pData, (char*)output->pData, (int)x_size, (int)y_size);
int compSize = H264_compress(vc_context, (const char*)input->pData, (char*)output->pData, (int)x_size, (int)y_size);

if (compSize <= 0) {
output->release();
Expand All @@ -697,7 +698,7 @@ NDArray *compressH264(NDArray *input, NDCodecStatus_t *status, char *errorMessag

#else

NDArray *compressH264(NDArray *input, NDCodecStatus_t *status, char *errorMessage)
NDArray *compressH264(void** vc_context, NDArray *input, NDCodecStatus_t *status, char *errorMessage)
{
sprintf(errorMessage, "No H264 support");
*status = NDCODEC_ERROR;
Expand Down Expand Up @@ -808,7 +809,7 @@ void NDPluginCodec::processCallbacks(NDArray *pArray)

case NDCODEC_H264: {
unlock();
result = compressH264(pArray, &codecStatus, errorMessage);
result = compressH264(&vc_context, pArray, &codecStatus, errorMessage);
lock();
break;
}
Expand Down Expand Up @@ -905,11 +906,11 @@ asynStatus NDPluginCodec::writeInt32(asynUser *pasynUser, epicsInt32 value)
status = NDPluginDriver::writeInt32(pasynUser, value);
} else if (function == NDCodecGOPSize) {
printf("setting GOP Size...\n");
set_gop_size(value);
set_gop_size(vc_context, value);
} else if (function == NDCodecQMinMax) {
//lock();
printf("setting qmin and qmax...\n");
set_q_min_max(value);
set_q_min_max(vc_context, value);
//unlock();
}

Expand Down Expand Up @@ -1001,6 +1002,8 @@ NDPluginCodec::NDPluginCodec(const char *portName, int queueSize, int blockingCa
// This plugin currently ignores this setting and always does callbacks, so make the setting reflect the behavior
setIntegerParam(NDArrayCallbacks, 1);

void* vc_context=0;

/* Try to connect to the array port */
connectToArrayPort();
}
Expand Down
1 change: 1 addition & 0 deletions ADApp/pluginSrc/NDPluginCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class NDPLUGIN_API NDPluginCodec : public NDPluginDriver {
/* These methods override the virtual methods in the base class */
void processCallbacks(NDArray *pArray);
asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
void* vc_context;

protected:
int NDCodecMode;
Expand Down

0 comments on commit 5b4623e

Please sign in to comment.