summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad_acm.c2
-rw-r--r--libmpcodecs/ad_ffmpeg.c2
-rw-r--r--libmpcodecs/ad_mpc.c3
-rw-r--r--libmpcodecs/vd_ffmpeg.c14
-rw-r--r--libmpcodecs/vd_qtvideo.c2
-rw-r--r--libmpcodecs/vd_realvid.c4
-rw-r--r--libmpcodecs/ve_lavc.c21
-rw-r--r--libmpcodecs/ve_libdv.c4
-rw-r--r--libmpcodecs/ve_nuv.c4
-rw-r--r--libmpcodecs/ve_x264.c9
-rw-r--r--libmpcodecs/ve_xvid4.c4
11 files changed, 30 insertions, 39 deletions
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;