diff options
45 files changed, 143 insertions, 173 deletions
diff --git a/TOOLS/vivodump.c b/TOOLS/vivodump.c index 2893fa29a0..5c2e81c23b 100644 --- a/TOOLS/vivodump.c +++ b/TOOLS/vivodump.c @@ -212,8 +212,8 @@ mux->buffer=malloc(mux->buffer_size); mux->h.dwScale=1; mux->h.dwRate=10; -mux->bih=malloc(sizeof(BITMAPINFOHEADER)); -mux->bih->biSize=sizeof(BITMAPINFOHEADER); +mux->bih=malloc(sizeof(*mux->bih)); +mux->bih->biSize=sizeof(*mux->bih); mux->bih->biPlanes=1; mux->bih->biBitCount=24; mux->bih->biCompression=0x6f766976;// 7669766f; diff --git a/libmpcodecs/ad_acm.c b/libmpcodecs/ad_acm.c index 46af4fae7d..1b1184a06a 100644 --- a/libmpcodecs/ad_acm.c +++ b/libmpcodecs/ad_acm.c @@ -71,7 +71,7 @@ static int preinit(sh_audio_t *sh_audio) // priv->handle = NULL; - priv->o_wf = malloc(sizeof(WAVEFORMATEX)); + priv->o_wf = malloc(sizeof(*priv->o_wf)); if (!priv->o_wf) { mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n"); diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 6dd5dcf492..7c398af5b0 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -129,7 +129,7 @@ static int init(sh_audio_t *sh_audio) if (sh_audio->wf && sh_audio->wf->cbSize > 0) { lavc_context->extradata = av_mallocz(sh_audio->wf->cbSize + FF_INPUT_BUFFER_PADDING_SIZE); lavc_context->extradata_size = sh_audio->wf->cbSize; - memcpy(lavc_context->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX), + memcpy(lavc_context->extradata, sh_audio->wf + 1, lavc_context->extradata_size); } diff --git a/libmpcodecs/ad_mpc.c b/libmpcodecs/ad_mpc.c index 33ed911f72..31463abcb7 100644 --- a/libmpcodecs/ad_mpc.c +++ b/libmpcodecs/ad_mpc.c @@ -134,8 +134,7 @@ static int init(sh_audio_t *sh) { mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Missing extradata!\n"); return 0; } - cd->header = (char *)sh->wf; - cd->header = &cd->header[sizeof(WAVEFORMATEX)]; + cd->header = (char *)(sh->wf + 1); cd->header_len = sh->wf->cbSize; cd->sh = sh; cd->pos = 0; diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index 30ee162743..1bb7c2e94b 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -294,10 +294,10 @@ static int init(sh_video_t *sh){ /* AVRn stores huffman table in AVI header */ /* Pegasus MJPEG stores it also in AVI header, but it uses the common MJPG fourcc :( */ - if (!sh->bih || sh->bih->biSize <= sizeof(BITMAPINFOHEADER)) + if (!sh->bih || sh->bih->biSize <= sizeof(*sh->bih)) break; avctx->flags |= CODEC_FLAG_EXTERN_HUFF; - avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER); + avctx->extradata_size = sh->bih->biSize-sizeof(*sh->bih); avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size); @@ -327,7 +327,7 @@ static int init(sh_video_t *sh){ (sh->format == mmioFOURCC('R', 'V', '1', '3')) ? 0x10003001 : 0x10000000; } else { /* has extra slice header (demux_rm or rm->avi streamcopy) */ - avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER); + avctx->extradata_size = sh->bih->biSize-sizeof(*sh->bih); avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size); } @@ -337,9 +337,9 @@ static int init(sh_video_t *sh){ break; default: - if (!sh->bih || sh->bih->biSize <= sizeof(BITMAPINFOHEADER)) + if (!sh->bih || sh->bih->biSize <= sizeof(*sh->bih)) break; - avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER); + avctx->extradata_size = sh->bih->biSize-sizeof(*sh->bih); avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size); break; @@ -348,10 +348,10 @@ static int init(sh_video_t *sh){ if (sh->bih && (sh->bih->biBitCount <= 8)) { avctx->palctrl = calloc(1, sizeof(AVPaletteControl)); avctx->palctrl->palette_changed = 1; - if (sh->bih->biSize-sizeof(BITMAPINFOHEADER)) + if (sh->bih->biSize-sizeof(*sh->bih)) /* Palette size in biSize */ memcpy(avctx->palctrl->palette, sh->bih+1, - FFMIN(sh->bih->biSize-sizeof(BITMAPINFOHEADER), AVPALETTE_SIZE)); + FFMIN(sh->bih->biSize-sizeof(*sh->bih), AVPALETTE_SIZE)); else /* Palette size in biClrUsed */ memcpy(avctx->palctrl->palette, sh->bih+1, diff --git a/libmpcodecs/vd_qtvideo.c b/libmpcodecs/vd_qtvideo.c index b0340e5020..1847291b0b 100644 --- a/libmpcodecs/vd_qtvideo.c +++ b/libmpcodecs/vd_qtvideo.c @@ -98,7 +98,7 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){ // init driver static int init(sh_video_t *sh){ OSErr result = 1; - int extradata_size = sh->bih ? sh->bih->biSize - sizeof(BITMAPINFOHEADER) : 0; + int extradata_size = sh->bih ? sh->bih->biSize - sizeof(*sh->bih) : 0; void *extradata = sh->bih + 1; if (!sh->ImageDesc) diff --git a/libmpcodecs/vd_realvid.c b/libmpcodecs/vd_realvid.c index 04ac9efba7..c0994952ab 100644 --- a/libmpcodecs/vd_realvid.c +++ b/libmpcodecs/vd_realvid.c @@ -282,11 +282,11 @@ static int init(sh_video_t *sh){ int result; // we export codec id and sub-id from demuxer in bitmapinfohdr: unsigned char* extrahdr=(unsigned char*)(sh->bih+1); - unsigned int extrahdr_size = sh->bih->biSize - sizeof(BITMAPINFOHEADER); + unsigned int extrahdr_size = sh->bih->biSize - sizeof(*sh->bih); struct rv_init_t init_data; if(extrahdr_size < 8) { - mp_msg(MSGT_DECVIDEO,MSGL_ERR,"realvideo: extradata too small (%u)\n", sh->bih->biSize - sizeof(BITMAPINFOHEADER)); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"realvideo: extradata too small (%u)\n", extrahdr_size); return 0; } init_data = (struct rv_init_t){11, sh->disp_w, sh->disp_h, 0, 0, AV_RB32(extrahdr), 1, AV_RB32(extrahdr + 4)}; // rv30 diff --git a/libmpcodecs/ve_lavc.c b/libmpcodecs/ve_lavc.c index b36dad73ee..258dbf2cc5 100644 --- a/libmpcodecs/ve_lavc.c +++ b/libmpcodecs/ve_lavc.c @@ -927,8 +927,7 @@ static int vf_open(vf_instance_t *vf, char* args){ vf->control=control; vf->query_format=query_format; vf->put_image=put_image; - vf->priv=malloc(sizeof(struct vf_priv_s)); - memset(vf->priv,0,sizeof(struct vf_priv_s)); + vf->priv=calloc(1, sizeof(struct vf_priv_s)); vf->priv->mux=(muxer_stream_t*)args; /* XXX: hack: some of the MJPEG decoder DLL's needs exported huffman @@ -936,40 +935,34 @@ static int vf_open(vf_instance_t *vf, char* args){ huffman tables into the stream, so no problem */ if (lavc_param_vcodec && !strcasecmp(lavc_param_vcodec, "mjpeg")) { - mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+28); - memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+28); + mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)+28); mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+28; } else if (lavc_param_vcodec && (!strcasecmp(lavc_param_vcodec, "huffyuv") || !strcasecmp(lavc_param_vcodec, "ffvhuff"))) { /* XXX: hack: huffyuv needs to store huffman tables (allthough we dunno the size yet ...) */ - mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+1000); - memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+1000); + mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)+1000); mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+1000; } else if (lavc_param_vcodec && !strcasecmp(lavc_param_vcodec, "asv1")) { - mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+8); - memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+8); + mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)+8); mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+8; } else if (lavc_param_vcodec && !strcasecmp(lavc_param_vcodec, "asv2")) { - mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+8); - memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+8); + mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)+8); mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+8; } else if (lavc_param_vcodec && !strcasecmp(lavc_param_vcodec, "wmv2")) { - mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+4); - memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+4); + mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)+4); mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+4; } else { - mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)); - memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)); + mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)); mux_v->bih->biSize=sizeof(BITMAPINFOHEADER); } mux_v->bih->biWidth=0; diff --git a/libmpcodecs/ve_libdv.c b/libmpcodecs/ve_libdv.c index f1e265398e..99808e34e8 100644 --- a/libmpcodecs/ve_libdv.c +++ b/libmpcodecs/ve_libdv.c @@ -113,8 +113,8 @@ static int vf_open(vf_instance_t *vf, char* args){ vf->priv->enc=dv_encoder_new(0,1,1); // FIXME, parse some options! if(!vf->priv->enc) return 0; - mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)); - mux_v->bih->biSize=sizeof(BITMAPINFOHEADER); + mux_v->bih=calloc(1, sizeof(*mux_v->bih)); + mux_v->bih->biSize=sizeof(*mux_v->bih); mux_v->bih->biWidth=0; mux_v->bih->biHeight=0; mux_v->bih->biCompression=mmioFOURCC('d','v','s','d'); diff --git a/libmpcodecs/ve_nuv.c b/libmpcodecs/ve_nuv.c index 9fe25d4154..807fff5517 100644 --- a/libmpcodecs/ve_nuv.c +++ b/libmpcodecs/ve_nuv.c @@ -225,8 +225,8 @@ static int vf_open(vf_instance_t *vf, char* args){ memcpy(vf->priv, &nuv_priv_dflt,sizeof(struct vf_priv_s)); vf->priv->mux=(muxer_stream_t*)args; - mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER)); - mux_v->bih->biSize=sizeof(BITMAPINFOHEADER); + mux_v->bih=calloc(1, sizeof(*mux_v->bih)); + mux_v->bih->biSize=sizeof(*mux_v->bih); mux_v->bih->biWidth=0; mux_v->bih->biHeight=0; mux_v->bih->biPlanes=1; diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c index c14b71ab55..47a636b3cc 100644 --- a/libmpcodecs/ve_x264.c +++ b/libmpcodecs/ve_x264.c @@ -182,9 +182,9 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, in extradata_size = x264_encoder_headers(mod->x264, &nal, &nnal); - mod->mux->bih= realloc(mod->mux->bih, sizeof(BITMAPINFOHEADER) + extradata_size); + mod->mux->bih= realloc(mod->mux->bih, sizeof(*mod->mux->bih) + extradata_size); memcpy(mod->mux->bih + 1, nal->p_payload, extradata_size); - mod->mux->bih->biSize= sizeof(BITMAPINFOHEADER) + extradata_size; + mod->mux->bih->biSize= sizeof(*mod->mux->bih) + extradata_size; } if (param.i_bframe > 1 && param.i_bframe_pyramid) @@ -290,9 +290,8 @@ static int vf_open(vf_instance_t *vf, char *args) { mod=(h264_module_t*)vf->priv; mod->mux = (muxer_stream_t*)args; - mod->mux->bih = malloc(sizeof(BITMAPINFOHEADER)); - memset(mod->mux->bih, 0, sizeof(BITMAPINFOHEADER)); - mod->mux->bih->biSize = sizeof(BITMAPINFOHEADER); + mod->mux->bih = calloc(1, sizeof(*mod->mux->bih)); + mod->mux->bih->biSize = sizeof(*mod->mux->bih); mod->mux->bih->biPlanes = 1; mod->mux->bih->biBitCount = 24; mod->mux->bih->biCompression = mmioFOURCC('h', '2', '6', '4'); diff --git a/libmpcodecs/ve_xvid4.c b/libmpcodecs/ve_xvid4.c index fc6aa2d23b..778817c25f 100644 --- a/libmpcodecs/ve_xvid4.c +++ b/libmpcodecs/ve_xvid4.c @@ -602,7 +602,7 @@ vf_open(vf_instance_t *vf, char* args) mod->mux = (muxer_stream_t*)args; /* Initialize muxer BITMAP header */ - mod->mux->bih = calloc(1, sizeof(BITMAPINFOHEADER)); + mod->mux->bih = calloc(1, sizeof(*mod->mux->bih)); if(mod->mux->bih == NULL) { mp_msg(MSGT_MENCODER,MSGL_ERR, @@ -610,7 +610,7 @@ vf_open(vf_instance_t *vf, char* args) return BAD; } - mod->mux->bih->biSize = sizeof(BITMAPINFOHEADER); + mod->mux->bih->biSize = sizeof(*mod->mux->bih); mod->mux->bih->biWidth = 0; mod->mux->bih->biHeight = 0; mod->mux->bih->biPlanes = 1; diff --git a/libmpdemux/asfheader.c b/libmpdemux/asfheader.c index b1058ae011..033d065606 100644 --- a/libmpdemux/asfheader.c +++ b/libmpdemux/asfheader.c @@ -344,7 +344,7 @@ static int asf_init_audio_stream(demuxer_t *demuxer,struct asf_priv* asf, sh_aud uint8_t *buffer = *buf; int pos = *ppos; - sh_audio->wf=calloc((streamh->type_size<sizeof(WAVEFORMATEX))?sizeof(WAVEFORMATEX):streamh->type_size,1); + sh_audio->wf=calloc((streamh->type_size<sizeof(*sh_audio->wf))?sizeof(*sh_audio->wf):streamh->type_size,1); memcpy(sh_audio->wf,buffer,streamh->type_size); le2me_WAVEFORMATEX(sh_audio->wf); if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_wave_header(sh_audio->wf,MSGL_V); @@ -493,10 +493,10 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){ len=streamh->type_size-(4+4+1+2); ++video_streams; // sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize); - sh_video->bih=calloc((len<sizeof(BITMAPINFOHEADER))?sizeof(BITMAPINFOHEADER):len,1); + sh_video->bih=calloc((len<sizeof(*sh_video->bih))?sizeof(*sh_video->bih):len,1); memcpy(sh_video->bih,&buffer[4+4+1+2],len); le2me_BITMAPINFOHEADER(sh_video->bih); - if (sh_video->bih->biSize > len && sh_video->bih->biSize > sizeof(BITMAPINFOHEADER)) + if (sh_video->bih->biSize > len && sh_video->bih->biSize > sizeof(*sh_video->bih)) sh_video->bih->biSize = len; if (sh_video->bih->biCompression == mmioFOURCC('D', 'V', 'R', ' ')) { //mp_tmsg(MSGT_DEMUXER, MSGL_WARN, "DVR will probably only work with libavformat, try -demuxer 35 if you have problems\n"); diff --git a/libmpdemux/aviheader.c b/libmpdemux/aviheader.c index 27d1e4a27f..ac3a7f7ae6 100644 --- a/libmpdemux/aviheader.c +++ b/libmpdemux/aviheader.c @@ -265,12 +265,12 @@ while(1){ break; } case ckidSTREAMFORMAT: { // read 'strf' if(last_fccType==streamtypeVIDEO){ - sh_video->bih=calloc(FFMAX(chunksize, sizeof(BITMAPINFOHEADER)), 1); + sh_video->bih=calloc(FFMAX(chunksize, sizeof(*sh_video->bih)), 1); // sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize); - mp_tmsg(MSGT_HEADER,MSGL_V,"Found 'bih', %u bytes of %d\n",chunksize,sizeof(BITMAPINFOHEADER)); + mp_tmsg(MSGT_HEADER,MSGL_V,"Found 'bih', %u bytes of %d\n",chunksize,sizeof(*sh_video->bih)); stream_read(demuxer->stream,(char*) sh_video->bih,chunksize); le2me_BITMAPINFOHEADER(sh_video->bih); // swap to machine endian - if (sh_video->bih->biSize > chunksize && sh_video->bih->biSize > sizeof(BITMAPINFOHEADER)) + if (sh_video->bih->biSize > chunksize && sh_video->bih->biSize > sizeof(*sh_video->bih)) sh_video->bih->biSize = chunksize; // fixup MS-RLE header (seems to be broken for <256 color files) if(sh_video->bih->biCompression<=1 && sh_video->bih->biSize==40) @@ -320,15 +320,15 @@ while(1){ } } else if(last_fccType==streamtypeAUDIO){ - unsigned wf_size = chunksize<sizeof(WAVEFORMATEX)?sizeof(WAVEFORMATEX):chunksize; + unsigned wf_size = chunksize<sizeof(*sh_audio->wf)?sizeof(*sh_audio->wf):chunksize; sh_audio->wf=calloc(wf_size,1); // sh_audio->wf=malloc(chunksize); memset(sh_audio->wf,0,chunksize); - mp_tmsg(MSGT_HEADER,MSGL_V,"Found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX)); + mp_tmsg(MSGT_HEADER,MSGL_V,"Found 'wf', %d bytes of %d\n",chunksize,sizeof(*sh_audio->wf)); stream_read(demuxer->stream,(char*) sh_audio->wf,chunksize); le2me_WAVEFORMATEX(sh_audio->wf); if (sh_audio->wf->cbSize != 0 && - wf_size < sizeof(WAVEFORMATEX)+sh_audio->wf->cbSize) { - sh_audio->wf=realloc(sh_audio->wf, sizeof(WAVEFORMATEX)+sh_audio->wf->cbSize); + wf_size < sizeof(*sh_audio->wf)+sh_audio->wf->cbSize) { + sh_audio->wf=realloc(sh_audio->wf, sizeof(*sh_audio->wf)+sh_audio->wf->cbSize); } sh_audio->format=sh_audio->wf->wFormatTag; if (sh_audio->format == 1 && diff --git a/libmpdemux/aviprint.c b/libmpdemux/aviprint.c index f83bcd3756..e7520a42c5 100644 --- a/libmpdemux/aviprint.c +++ b/libmpdemux/aviprint.c @@ -117,12 +117,12 @@ void print_video_header(BITMAPINFOHEADER *h, int verbose_level){ mp_msg(MSGT_HEADER, verbose_level, " biBitCount %d\n", h->biBitCount); mp_msg(MSGT_HEADER, verbose_level, " biCompression %d='%.4s'\n", h->biCompression, (char *)&h->biCompression); mp_msg(MSGT_HEADER, verbose_level, " biSizeImage %d\n", h->biSizeImage); - if (h->biSize > sizeof(BITMAPINFOHEADER)) + if (h->biSize > sizeof(*h)) { int i; uint8_t* p = (uint8_t*)(h + 1); mp_msg(MSGT_HEADER, verbose_level, "Unknown extra header dump: "); - for (i = 0; i < h->biSize-sizeof(BITMAPINFOHEADER); i++) + for (i = 0; i < h->biSize-sizeof(*h); i++) mp_msg(MSGT_HEADER, verbose_level, "[%x] ", *(p+i)); mp_msg(MSGT_HEADER, verbose_level, "\n"); } diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index 38f1d2afd2..16118a4139 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -333,7 +333,7 @@ static int demux_audio_open(demuxer_t* demuxer) { sh_audio->audio.dwSampleSize= 0; sh_audio->audio.dwScale = mp3_found->mpa_spf; sh_audio->audio.dwRate = mp3_found->mp3_freq; - sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); + sh_audio->wf = malloc(sizeof(*sh_audio->wf)); sh_audio->wf->wFormatTag = sh_audio->format; sh_audio->wf->nChannels = mp3_found->mp3_chans; sh_audio->wf->nSamplesPerSec = mp3_found->mp3_freq; @@ -394,7 +394,7 @@ static int demux_audio_open(demuxer_t* demuxer) { mp_msg(MSGT_DEMUX,MSGL_ERR,"[demux_audio] Bad wav header length: too long (%d)!!!\n",l); l = 16; } - sh_audio->wf = w = malloc(l > sizeof(WAVEFORMATEX) ? l : sizeof(WAVEFORMATEX)); + sh_audio->wf = w = malloc(l > sizeof(*w) ? l : sizeof(*w)); w->wFormatTag = sh_audio->format = stream_read_word_le(s); w->nChannels = sh_audio->channels = stream_read_word_le(s); w->nSamplesPerSec = sh_audio->samplerate = stream_read_dword_le(s); @@ -413,7 +413,7 @@ static int demux_audio_open(demuxer_t* demuxer) { l,w->cbSize); w->cbSize = l; } - stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),w->cbSize); + stream_read(s,(char*)(w + 1),w->cbSize); l -= w->cbSize; if (w->wFormatTag & 0xfffe && w->cbSize >= 22) sh_audio->format = ((WAVEFORMATEXTENSIBLE *)w)->SubFormat; diff --git a/libmpdemux/demux_avs.c b/libmpdemux/demux_avs.c index 33fc01ab0d..e90e36c1a7 100644 --- a/libmpdemux/demux_avs.c +++ b/libmpdemux/demux_avs.c @@ -299,7 +299,7 @@ static demuxer_t* demux_open_avs(demuxer_t* demuxer) sh_video->fps = (double) AVS->video_info->fps_numerator / (double) AVS->video_info->fps_denominator; sh_video->frametime = 1.0 / sh_video->fps; - sh_video->bih = malloc(sizeof(BITMAPINFOHEADER) + (256 * 4)); + sh_video->bih = malloc(sizeof(*sh_video->bih) + (256 * 4)); sh_video->bih->biCompression = sh_video->format; sh_video->bih->biBitCount = avs_bits_per_pixel(AVS->video_info); //sh_video->bih->biPlanes = 2; @@ -332,7 +332,7 @@ static demuxer_t* demux_open_avs(demuxer_t* demuxer) demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; - sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); + sh_audio->wf = malloc(sizeof(*sh_audio->wf)); sh_audio->wf->wFormatTag = sh_audio->format = (AVS->video_info->sample_type == AVS_SAMPLE_FLOAT) ? 0x3 : 0x1; sh_audio->wf->nChannels = sh_audio->channels = AVS->video_info->nchannels; diff --git a/libmpdemux/demux_film.c b/libmpdemux/demux_film.c index e337fe1c14..57d8296d80 100644 --- a/libmpdemux/demux_film.c +++ b/libmpdemux/demux_film.c @@ -325,7 +325,7 @@ static demuxer_t* demux_open_film(demuxer_t* demuxer) demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; - sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); + sh_audio->wf = malloc(sizeof(*sh_audio->wf)); // uncompressed PCM format sh_audio->wf->wFormatTag = 1; @@ -356,7 +356,7 @@ static demuxer_t* demux_open_film(demuxer_t* demuxer) demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; - sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); + sh_audio->wf = malloc(sizeof(*sh_audio->wf)); // uncompressed PCM format sh_audio->wf->wFormatTag = 1; diff --git a/libmpdemux/demux_gif.c b/libmpdemux/demux_gif.c index 0a59bff5d8..d82728ffb6 100644 --- a/libmpdemux/demux_gif.c +++ b/libmpdemux/demux_gif.c @@ -279,7 +279,7 @@ static demuxer_t* demux_open_gif(demuxer_t* demuxer) sh_video->fps = 5.0f; sh_video->frametime = 1.0f / sh_video->fps; - sh_video->bih = malloc(sizeof(BITMAPINFOHEADER) + (256 * 4)); + sh_video->bih = malloc(sizeof(*sh_video->bih) + (256 * 4)); sh_video->bih->biCompression = sh_video->format; sh_video->bih->biWidth = priv->w = (uint16_t)gif->SWidth; sh_video->bih->biHeight = priv->h = (uint16_t)gif->SHeight; diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index af77d6aef3..098ee3786d 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -275,7 +275,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) { break; stream_type = "audio"; priv->astreams[priv->audio_streams] = i; - wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1); + wf= calloc(sizeof(*wf) + codec->extradata_size, 1); // mp4a tag is used for all mp4 files no matter what they actually contain if(codec->codec_tag == MKTAG('m', 'p', '4', 'a')) codec->codec_tag= 0; @@ -351,7 +351,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) { if(!sh_video) break; stream_type = "video"; priv->vstreams[priv->video_streams] = i; - bih=calloc(sizeof(BITMAPINFOHEADER) + codec->extradata_size,1); + bih=calloc(sizeof(*bih) + codec->extradata_size,1); if(codec->codec_id == CODEC_ID_RAWVIDEO) { switch (codec->pix_fmt) { @@ -361,7 +361,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) { } if(!codec->codec_tag) codec->codec_tag= mp_av_codec_get_tag(mp_bmp_taglists, codec->codec_id); - bih->biSize= sizeof(BITMAPINFOHEADER) + codec->extradata_size; + bih->biSize= sizeof(*bih) + codec->extradata_size; bih->biWidth= codec->width; bih->biHeight= codec->height; bih->biBitCount= codec->bits_per_coded_sample; diff --git a/libmpdemux/demux_lmlm4.c b/libmpdemux/demux_lmlm4.c index 7f95e36de0..05cec05282 100644 --- a/libmpdemux/demux_lmlm4.c +++ b/libmpdemux/demux_lmlm4.c @@ -309,8 +309,7 @@ static demuxer_t* demux_open_lmlm4(demuxer_t* demuxer){ sh_video->disp_h = 480; sh_video->format = mmioFOURCC('D','I','V','X'); - sh_video->bih = malloc(sizeof(BITMAPINFOHEADER)); - memset(sh_video->bih, 0, sizeof(BITMAPINFOHEADER)); + sh_video->bih = calloc(1, sizeof(*sh_video->bih)); /* these are false values */ sh_video->bih->biSize = 40; @@ -325,8 +324,7 @@ static demuxer_t* demux_open_lmlm4(demuxer_t* demuxer){ demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; - sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); - memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX)); + sh_audio->wf = calloc(1, sizeof(*sh_audio->wf)); sh_audio->samplerate = 48000; sh_audio->wf->wBitsPerSample = 16; |