changeset 35410:1c991ec0e6da

Change declaration to use proper type to avoid a ridiculous number of casts.
author reimar
date Wed, 28 Nov 2012 19:43:03 +0000
parents 232b1aacffda
children abece00352ec
files libmpdemux/aviheader.c libmpdemux/aviheader.h libmpdemux/demux_avi.c
diffstat 3 files changed, 26 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/aviheader.c	Wed Nov 28 19:36:55 2012 +0000
+++ b/libmpdemux/aviheader.c	Wed Nov 28 19:43:03 2012 +0000
@@ -394,7 +394,7 @@
       read = stream_read(demuxer->stream,(char*)priv->idx,priv->idx_size<<4);
       priv->idx_size = FFMAX(read, 0) >> 4;
       for (i = 0; i < priv->idx_size; i++) {	// swap index to machine endian
-	AVIINDEXENTRY *entry=(AVIINDEXENTRY*)priv->idx + i;
+	AVIINDEXENTRY *entry=priv->idx + i;
 	le2me_AVIINDEXENTRY(entry);
 	/*
 	 * We (ab)use the upper word for bits 32-47 of the offset, so
@@ -551,7 +551,7 @@
 	stream_reset (demuxer->stream);
 
 	// find out the video stream id. I have seen files with 01db.
-	for (idx = &((AVIINDEXENTRY *)priv->idx)[0], i=0; i<priv->idx_size; i++, idx++){
+	for (idx = priv->idx, i=0; i<priv->idx_size; i++, idx++){
 	    unsigned char res[2];
 	    if (odml_get_vstream_id(idx->ckid, res)) {
 		db = mmioFOURCC(res[0], res[1], 'd', 'b');
@@ -560,14 +560,14 @@
 	}
 
 	// find first non keyframe
-	for (idx = &((AVIINDEXENTRY *)priv->idx)[0], i=0; i<priv->idx_size; i++, idx++){
+	for (idx = priv->idx, i=0; i<priv->idx_size; i++, idx++){
 	    if (!(idx->dwFlags & AVIIF_KEYFRAME) && idx->ckid == db) break;
 	}
 	if (i<priv->idx_size && db) {
 	    stream_seek(demuxer->stream, AVI_IDX_OFFSET(idx));
 	    id = stream_read_dword_le(demuxer->stream);
 	    if (id && id != db) // index fcc and real fcc differ? fix it.
-		for (idx = &((AVIINDEXENTRY *)priv->idx)[0], i=0; i<priv->idx_size; i++, idx++){
+		for (idx = priv->idx, i=0; i<priv->idx_size; i++, idx++){
 		    if (!(idx->dwFlags & AVIIF_KEYFRAME) && idx->ckid == db)
 			idx->ckid = id;
 	    }
@@ -616,7 +616,7 @@
   }
 
   for (i=0; i<priv->idx_size;i++) {
-    AVIINDEXENTRY *idx=&((AVIINDEXENTRY *)priv->idx)[i];
+    AVIINDEXENTRY *idx=priv->idx + i;
     fread(idx, sizeof(AVIINDEXENTRY), 1, fp);
     if (feof(fp)) {
       mp_msg(MSGT_HEADER,MSGL_ERR, MSGTR_MPDEMUX_AVIHDR_PrematureEOF, index_file_load);
@@ -661,7 +661,7 @@
       priv->idx=realloc(priv->idx,priv->idx_size*sizeof(AVIINDEXENTRY));
       if(!priv->idx){idx_pos=0; break;} // error!
     }
-    idx=&((AVIINDEXENTRY *)priv->idx)[idx_pos++];
+    idx=priv->idx + idx_pos++;
     idx->ckid=id;
     idx->dwFlags=AVIIF_KEYFRAME; // FIXME
     idx->dwFlags|=(demuxer->filepos>>16)&0xffff0000U;
@@ -727,7 +727,7 @@
     fwrite("MPIDX1", 6, 1, fp);
     fwrite(&priv->idx_size, sizeof(priv->idx_size), 1, fp);
     for (i=0; i<priv->idx_size; i++) {
-      AVIINDEXENTRY *idx = &((AVIINDEXENTRY *)priv->idx)[i];
+      AVIINDEXENTRY *idx = priv->idx + i;
       fwrite(idx, sizeof(AVIINDEXENTRY), 1, fp);
     }
     fclose(fp);
--- a/libmpdemux/aviheader.h	Wed Nov 28 19:36:55 2012 +0000
+++ b/libmpdemux/aviheader.h	Wed Nov 28 19:43:03 2012 +0000
@@ -345,7 +345,7 @@
 
 typedef struct {
   // index stuff:
-  void* idx;
+  AVIINDEXENTRY *idx;
   int idx_size;
   off_t idx_pos;
   off_t idx_pos_a;
--- a/libmpdemux/demux_avi.c	Wed Nov 28 19:36:55 2012 +0000
+++ b/libmpdemux/demux_avi.c	Wed Nov 28 19:43:03 2012 +0000
@@ -243,7 +243,7 @@
   if(priv->idx_size>0 && priv->idx_pos<priv->idx_size){
     off_t pos;
 
-    AVIINDEXENTRY *idx=&((AVIINDEXENTRY *)priv->idx)[priv->idx_pos++];
+    AVIINDEXENTRY *idx = priv->idx + priv->idx_pos++;
 
     if(idx->dwFlags&AVIIF_LIST){
       if (!valid_stream_id(idx->ckid))
@@ -334,7 +334,7 @@
 
   if(priv->idx_size>0 && idx_pos<priv->idx_size){
     off_t pos;
-    AVIINDEXENTRY *idx=&((AVIINDEXENTRY *)priv->idx)[idx_pos];
+    AVIINDEXENTRY *idx = priv->idx + idx_pos;
 
     if(idx->dwFlags&AVIIF_LIST){
       if (!valid_stream_id(idx->ckid))
@@ -480,17 +480,17 @@
   if(priv->idx_size>1){
     // decide index format:
 #if 1
-    if((AVI_IDX_OFFSET(&((AVIINDEXENTRY *)priv->idx)[0])<demuxer->movi_start ||
-        AVI_IDX_OFFSET(&((AVIINDEXENTRY *)priv->idx)[1])<demuxer->movi_start )&& !priv->isodml)
+    if((AVI_IDX_OFFSET(priv->idx + 0)<demuxer->movi_start ||
+        AVI_IDX_OFFSET(priv->idx + 1)<demuxer->movi_start )&& !priv->isodml)
       priv->idx_offset=demuxer->movi_start-4;
 #else
-    if(AVI_IDX_OFFSET(&((AVIINDEXENTRY *)priv->idx)[0])<demuxer->movi_start)
+    if(AVI_IDX_OFFSET(priv->idx)<demuxer->movi_start)
       priv->idx_offset=demuxer->movi_start-4;
 #endif
     mp_msg(MSGT_DEMUX,MSGL_V,"AVI index offset: 0x%X (movi=0x%X idx0=0x%X idx1=0x%X)\n",
 	    (int)priv->idx_offset,(int)demuxer->movi_start,
-	    (int)((AVIINDEXENTRY *)priv->idx)[0].dwChunkOffset,
-	    (int)((AVIINDEXENTRY *)priv->idx)[1].dwChunkOffset);
+	    (int)priv->idx[0].dwChunkOffset,
+	    (int)priv->idx[1].dwChunkOffset);
   }
 
   if(priv->idx_size>0){
@@ -499,7 +499,7 @@
       off_t a_pos=-1;
       off_t v_pos=-1;
       for(i=0;i<priv->idx_size;i++){
-        AVIINDEXENTRY* idx=&((AVIINDEXENTRY *)priv->idx)[i];
+        AVIINDEXENTRY *idx = priv->idx + i;
         demux_stream_t* ds=demux_avi_select_stream(demuxer,idx->ckid);
         off_t pos = priv->idx_offset + AVI_IDX_OFFSET(idx);
         if(a_pos==-1 && ds==demuxer->audio){
@@ -643,18 +643,18 @@
       if(rel_seek_frames>0){
         // seek forward
         while(video_chunk_pos<priv->idx_size-1){
-          int id=((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].ckid;
+          int id=priv->idx[video_chunk_pos].ckid;
           if(avi_stream_id(id)==d_video->id){  // video frame
-            if((--rel_seek_frames)<0 && ((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break;
+            if((--rel_seek_frames)<0 && priv->idx[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break;
           }
           ++video_chunk_pos;
         }
       } else {
         // seek backward
         while(video_chunk_pos>0){
-          int id=((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].ckid;
+          int id=priv->idx[video_chunk_pos].ckid;
           if(avi_stream_id(id)==d_video->id){  // video frame
-            if((++rel_seek_frames)>0 && ((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break;
+            if((++rel_seek_frames)>0 && priv->idx[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break;
           }
           --video_chunk_pos;
         }
@@ -664,7 +664,7 @@
       // re-calc video pts:
       d_video->pack_no=0;
       for(i=0;i<video_chunk_pos;i++){
-          int id=((AVIINDEXENTRY *)priv->idx)[i].ckid;
+          int id=priv->idx[i].ckid;
           if(avi_stream_id(id)==d_video->id) ++d_video->pack_no;
       }
       priv->video_pack_no=
@@ -696,9 +696,9 @@
 
         // find audio chunk pos:
           for(i=0;i<chunk_max;i++){
-            int id=((AVIINDEXENTRY *)priv->idx)[i].ckid;
+            int id=priv->idx[i].ckid;
             if(avi_stream_id(id)==d_audio->id){
-                len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength;
+                len=priv->idx[i].dwChunkLength;
                 if(d_audio->dpos<=curr_audio_pos && curr_audio_pos<(d_audio->dpos+len)){
                   break;
                 }
@@ -722,9 +722,9 @@
 
         // find audio chunk pos:
           for(i=0;i<priv->idx_size && chunks>0;i++){
-            int id=((AVIINDEXENTRY *)priv->idx)[i].ckid;
+            int id=priv->idx[i].ckid;
             if(avi_stream_id(id)==d_audio->id){
-                len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength;
+                len=priv->idx[i].dwChunkLength;
 		if(i>chunk_max){
 		  skip_audio_bytes+=len;
 		} else {
@@ -754,7 +754,7 @@
 	  if(audio_chunk_pos<video_chunk_pos){
             // calc priv->skip_video_frames & adjust video pts counter:
 	    for(i=audio_chunk_pos;i<video_chunk_pos;i++){
-              int id=((AVIINDEXENTRY *)priv->idx)[i].ckid;
+              int id=priv->idx[i].ckid;
               if(avi_stream_id(id)==d_video->id) ++priv->skip_video_frames;
             }
             // requires for correct audio pts calculation (demuxer):