Skip to content

Commit

Permalink
Replace bzero() with the standard and portable memset()
Browse files Browse the repository at this point in the history
 cherry-pick: #b7ae7a6151091b7fa42c3698d6fa77a5915570c6
  • Loading branch information
stuartm authored and jyavenard committed Jun 16, 2011
1 parent b7ae7a6 commit 57328b4
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 75 deletions.
14 changes: 7 additions & 7 deletions mythtv/filters/denoise3d/filter_denoise3d.c
Expand Up @@ -132,7 +132,7 @@ static void denoiseMMX(uint8_t *Frame,
movq_r2r (mm2, mm3);
movq_r2r (mm4, mm5);
movq_r2r (mm6, mm7);

punpcklbw_m2r(mz, mm0);
punpckhbw_m2r(mz, mm1);
punpcklbw_m2r(mz, mm2);
Expand All @@ -154,7 +154,7 @@ static void denoiseMMX(uint8_t *Frame,

movq_m2r (Line[X], mm4);
movq_m2r (Line[X+8], mm6);

for (i = 0; i < 16; i++)
cbuf[i] = Temporal[wbuf[i]];

Expand Down Expand Up @@ -186,7 +186,7 @@ static void denoiseMMX(uint8_t *Frame,
movq_r2r (mm2, mm3);
movq_r2r (mm4, mm5);
movq_r2r (mm6, mm7);

punpcklbw_m2r(mz, mm0);
punpckhbw_m2r(mz, mm1);
punpcklbw_m2r(mz, mm2);
Expand Down Expand Up @@ -223,7 +223,7 @@ static void denoiseMMX(uint8_t *Frame,
movq_r2r (mm2, mm3);
movq_r2r (mm4, mm5);
movq_r2r (mm6, mm7);

punpcklbw_m2r(mz, mm0);
punpckhbw_m2r(mz, mm1);
punpcklbw_m2r(mz, mm2);
Expand Down Expand Up @@ -411,7 +411,7 @@ static VideoFilter *NewDenoise3DFilter(VideoFrameType inpixfmt,
return NULL;
}

memset(filter, 0, sizeof(ThisFilter)); /*MS Windows doesn't like bzero()*/
memset(filter, 0, sizeof(ThisFilter));

filter->vf.filter = &denoise3DFilter;
filter->vf.cleanup = &Denoise3DFilterCleanup;
Expand Down Expand Up @@ -464,13 +464,13 @@ static VideoFilter *NewDenoise3DFilter(VideoFrameType inpixfmt,
return (VideoFilter*) filter;
}

static FmtConv FmtList[] =
static FmtConv FmtList[] =
{
{ FMT_YV12, FMT_YV12 },
FMT_NULL
};

ConstFilterInfo filter_table[] =
ConstFilterInfo filter_table[] =
{
{
filter_init: &NewDenoise3DFilter,
Expand Down
34 changes: 17 additions & 17 deletions mythtv/filters/ivtc/filter_ivtc.c
Expand Up @@ -38,7 +38,7 @@ static inline void * memcpy_pic(void * dst, const void * src, int height, int ds
if (dstStride == srcStride)
{
memcpy(dst, src, srcStride*height);
}
}

return retval;
}
Expand All @@ -47,19 +47,19 @@ static int
IvtcFilter (VideoFilter *vf, VideoFrame *frame, int field)
{
(void)field;
ThisFilter *filter = (ThisFilter *) vf;
ThisFilter *filter = (ThisFilter *) vf;

if (!frame->interlaced_frame)
{
filter->progressive_frame_seen = 1;
}

if (filter->progressive_frame_seen &&
frame->interlaced_frame)
{
filter->interlaced_frame_seen = 1;
}

if (!frame->interlaced_frame &&
!filter->apply_filter &&
filter->interlaced_frame_seen &&
Expand All @@ -68,10 +68,10 @@ IvtcFilter (VideoFilter *vf, VideoFrame *frame, int field)
fprintf(stderr,"turning on inverse telecine filter");
filter->apply_filter = 1;
}

if (!filter->apply_filter)
return 1;

SetupFilter(filter, frame->width, frame->height, (int*)frame->pitches);

struct pullup_buffer *b;
Expand All @@ -85,15 +85,15 @@ IvtcFilter (VideoFilter *vf, VideoFrame *frame, int field)
struct pullup_context *c = filter->context;
if (c->bpp[0] == 0)
c->bpp[0] = c->bpp[1] = c->bpp[2] = frame->bpp;

b = pullup_get_buffer(c,2);
if (!b)
{
f = pullup_get_frame(c);
pullup_release_frame(f);
return 0;
return 0;
}

memcpy_pic(b->planes[0], frame->buf + frame->offsets[0],
height, ypitch, ypitch);
memcpy_pic(b->planes[1], frame->buf + frame->offsets[1],
Expand All @@ -112,8 +112,8 @@ IvtcFilter (VideoFilter *vf, VideoFrame *frame, int field)

if (!f)
return 0;


if (f->length < 2)
{
pullup_release_frame(f);
Expand Down Expand Up @@ -150,7 +150,7 @@ IvtcFilter (VideoFilter *vf, VideoFrame *frame, int field)
cheight, cpitch, cpitch);
memcpy_pic(frame->buf + frame->offsets[2], f->buffer->planes[2],
cheight, cpitch, cpitch);

pullup_release_frame(f);

return 1;
Expand All @@ -159,20 +159,20 @@ IvtcFilter (VideoFilter *vf, VideoFrame *frame, int field)
static void
IvtcFilterCleanup( VideoFilter * filter)
{
pullup_free_context((((ThisFilter *)filter)->context));
pullup_free_context((((ThisFilter *)filter)->context));
}

static void SetupFilter(ThisFilter *vf, int width, int height, int *pitches)
{
if (vf->width == width &&
vf->height == height &&
vf->context->stride[0] == pitches[0] &&
vf->context->stride[0] == pitches[0] &&
vf->context->stride[1] == pitches[1] &&
vf->context->stride[2] == pitches[2])
{
return;
}

vf->width = width;
vf->height = height;

Expand Down Expand Up @@ -213,7 +213,7 @@ static VideoFilter *NewIvtcFilter(VideoFrameType inpixfmt,
return NULL;
}

memset(filter, 0, sizeof(ThisFilter)); /*MS Windows doesn't like bzero()*/
memset(filter, 0, sizeof(ThisFilter));
filter->progressive_frame_seen = 0;
filter->interlaced_frame_seen = 0;
filter->apply_filter = 0;
Expand Down Expand Up @@ -256,7 +256,7 @@ ConstFilterInfo filter_table[] =
name: "ivtc",
descript: "inverse telecine filter",
formats: FmtList,
libname: NULL
libname: NULL
},
FILT_NULL
};
Expand Down
32 changes: 16 additions & 16 deletions mythtv/filters/quickdnr/filter_quickdnr.c
Expand Up @@ -2,12 +2,12 @@
* Quick DNR 0.8
* (C)opyright 2003, Debabrata Banerjee
* GNU GPL 2 or later
*
*
* Pass options as:
* quickdnr=quality (0-255 scale adjusted)
* quickdnr=Luma_threshold:Chroma_threshold (0-255) for single threshold
* quickdnr=Luma_threshold1:Luma_threshold2:Chroma_threshold1:Chroma_threshold2 for double
*
*
*/

#include <stdio.h>
Expand Down Expand Up @@ -86,7 +86,7 @@ static int init_avg(ThisFilter *filter, VideoFrame *frame)
{
if (!alloc_avg(filter, frame->size))
return 0;

if ((filter->offsets[0] != frame->offsets[0]) ||
(filter->offsets[1] != frame->offsets[1]) ||
(filter->offsets[2] != frame->offsets[2]) ||
Expand Down Expand Up @@ -130,7 +130,7 @@ static void init_vars(ThisFilter *tf, VideoFrame *frame,
static int quickdnr(VideoFilter *f, VideoFrame *frame, int field)
{
(void)field;
ThisFilter *tf = (ThisFilter *)f;
ThisFilter *tf = (ThisFilter *)f;
int thr1[3], thr2[3], height[3];
uint8_t *avg[3], *buf[3];
int i, y;
Expand All @@ -157,20 +157,20 @@ static int quickdnr(VideoFilter *f, VideoFrame *frame, int field)
}

TF_END(tf, "QuickDNR: ");

return 0;
}

static int quickdnr2(VideoFilter *f, VideoFrame *frame, int field)
{
(void)field;
ThisFilter *tf = (ThisFilter *)f;
ThisFilter *tf = (ThisFilter *)f;
int thr1[3], thr2[3], height[3];
uint8_t *avg[3], *buf[3];
int i, y;

TF_VARS;

TF_START;

if (!init_avg(tf, frame))
Expand Down Expand Up @@ -198,7 +198,7 @@ static int quickdnr2(VideoFilter *f, VideoFrame *frame, int field)
}

TF_END(tf, "QuickDNR2: ");

return 0;
}

Expand Down Expand Up @@ -228,7 +228,7 @@ static int quickdnrMMX(VideoFilter *f, VideoFrame *frame, int field)
processor automatically does a prefetchT0 in these cases. The
instruction is meant to be used to specify a different prefetch
cache level, or to prefetch non-sequental data.
These prefetches are not available on all MMX processors so if
we wanted to use them we would need to test for a prefetch
capable processor before using them. -- dtk
Expand Down Expand Up @@ -321,9 +321,9 @@ static int quickdnr2MMX(VideoFilter *f, VideoFrame *frame, int field)
int i, y;

TF_VARS;

TF_START;

if (!init_avg(tf, frame))
return 0;

Expand Down Expand Up @@ -364,7 +364,7 @@ static int quickdnr2MMX(VideoFilter *f, VideoFrame *frame, int field)

"paddb %%mm4, %%mm3 \n\t" // hack! No proper unsigned mmx compares!
"pcmpgtb %%mm5, %%mm3 \n\t" // compare diff with mask

"movq %%mm2, %%mm0 \n\t" // reload registers
"movq %%mm7, %%mm1 \n\t"

Expand Down Expand Up @@ -477,7 +477,7 @@ static VideoFilter *new_filter(VideoFrameType inpixfmt,
return NULL;
}

memset(filter, 0, sizeof(ThisFilter)); /*MS Windows doesn't like bzero()*/
memset(filter, 0, sizeof(ThisFilter));
filter->vf.cleanup = &cleanup;
filter->Luma_threshold1 = LUMA_THRESHOLD1_DEFAULT;
filter->Chroma_threshold1 = CHROMA_THRESHOLD1_DEFAULT;
Expand Down Expand Up @@ -556,7 +556,7 @@ static VideoFilter *new_filter(VideoFrameType inpixfmt,
#endif

TF_INIT(filter);

#ifdef QUICKDNR_DEBUG
fprintf(stderr, "DNR Loaded: 0x%X Params: %u %u \n"
"Luma1: %3d 0x%X%X Luma2: 0x%X%X\n"
Expand All @@ -581,13 +581,13 @@ static VideoFilter *new_filter(VideoFrameType inpixfmt,
return (VideoFilter*) filter;
}

static FmtConv FmtList[] =
static FmtConv FmtList[] =
{
{ FMT_YV12, FMT_YV12 },
FMT_NULL
};

ConstFilterInfo filter_table[] =
ConstFilterInfo filter_table[] =
{
{
filter_init: &new_filter,
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmyth/audiooutputbase.cpp
Expand Up @@ -102,7 +102,6 @@ AudioOutputBase::AudioOutputBase(const AudioSettings &settings) :
m_spdifenc(NULL)
{
src_in = (float *)AOALIGN(src_in_buf);
// The following are not bzero() because MS Windows doesn't like it.
memset(&src_data, 0, sizeof(SRC_DATA));
memset(src_in, 0, sizeof(float) * kAudioSRCInputSize);
memset(audiobuffer, 0, sizeof(char) * kAudioRingBufferSize);
Expand Down
12 changes: 6 additions & 6 deletions mythtv/libs/libmyth/audiooutputca.cpp
Expand Up @@ -194,7 +194,7 @@ bool CoreAudioData::OpenAnalog()

// Set up the audio output unit
AudioStreamBasicDescription conv_in_desc;
bzero(&conv_in_desc, sizeof(AudioStreamBasicDescription));
memset(&conv_in_desc, 0, sizeof(AudioStreamBasicDescription));
conv_in_desc.mSampleRate = mCA->samplerate;
conv_in_desc.mFormatID = kAudioFormatLinearPCM;
conv_in_desc.mFormatFlags = formatFlags;
Expand Down Expand Up @@ -392,7 +392,7 @@ bool AudioOutputCA::RenderAudio(unsigned char *aubuf,
if (written_size && (size > written_size))
{
// play silence on buffer underrun
bzero(aubuf + written_size, size - written_size);
memset(aubuf + written_size, 0, size - written_size);
}

//Audio received is in SMPTE channel order, reorder to CA unless passthru
Expand Down Expand Up @@ -458,7 +458,7 @@ OSStatus RenderCallbackAnalog(void *inRefCon,
inTimeStamp->mHostTime))
{
// play silence if RenderAudio returns false
bzero(ioData->mBuffers[0].mData, ioData->mBuffers[0].mDataByteSize);
memset(ioData->mBuffers[0].mData, 0, ioData->mBuffers[0].mDataByteSize);
*ioActionFlags = kAudioUnitRenderAction_OutputIsSilence;
}
return noErr;
Expand Down Expand Up @@ -508,7 +508,7 @@ static OSStatus RenderCallbackSPDIF(AudioDeviceID inDevice,
outOutputData->mBuffers[index].mDataByteSize,
inOutputTime->mHostTime))
// play silence if RenderAudio returns false
bzero(outOutputData->mBuffers[index].mData,
memset(outOutputData->mBuffers[index].mData, 0,
outOutputData->mBuffers[index].mDataByteSize);

return noErr;
Expand Down Expand Up @@ -833,7 +833,7 @@ bool *CoreAudioData::ChannelsList(AudioDeviceID d, bool passthru)
if ((list = (bool *)malloc((CHANNELS_MAX+1) * sizeof(bool))) == NULL)
return NULL;

bzero(list, (CHANNELS_MAX+1) * sizeof(bool));
memset(list, 0, (CHANNELS_MAX+1) * sizeof(bool));

streams = StreamsList(mDeviceID);
if (!streams)
Expand Down Expand Up @@ -861,7 +861,7 @@ bool *CoreAudioData::ChannelsList(AudioDeviceID d, bool passthru)
}
}
free(formats);
}
}
}

if (!founddigital)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/audiooutputjack.cpp
Expand Up @@ -393,7 +393,7 @@ int AudioOutputJACK::JackCallback(jack_nframes_t nframes)
if (bytes_needed > bytes_read)
{
// play silence on buffer underrun
bzero(aubuf + bytes_read, bytes_needed - bytes_read);
memset(aubuf + bytes_read, 0, bytes_needed - bytes_read);
if (!pauseaudio)
VBERROR(QString("Having to insert silence because GetAudioData "
"hasn't returned enough data. Wanted: %1 Got: %2")
Expand Down

0 comments on commit 57328b4

Please sign in to comment.