Example #1
0
int ZimFields(TagTable *image)
{
  ImVfb *vfb;
  TagEntryQValue(TagTableQDirect(image,"image vfb", 0), &vfb);
  return  ImVfbQFields(vfb);
}
Example #2
0
TagTable *ParamImSeqNextImageFromParam(ParamImSeq *self)
{
  const char *str;
  char *ext;
  TagTable  *nextImage = NULL, *unusedImage;
  int mpegSkipNum;
  
  if (self->mpeg)
	{
	  if (MpegDecoderMoreFrames(self->mpeg))
		{
		  nextImage = MpegDecoderNextImage(self->mpeg);
		  if (self->skipFields)
			{
			  sprintf(self->currentImageFilename, "%s%.06db",MpegDecoderCurrentFilename(self->mpeg),MpegDecoderBitstreamFrameNum(self->mpeg));
			}
		  else
			{
			  sprintf(self->currentImageFilename, "%s%.06d",MpegDecoderCurrentFilename(self->mpeg),MpegDecoderBitstreamFrameNum(self->mpeg));
			}
		  if (self->mpegSkipNum > 1)
			{  // skip the required number of images so we're primed for the next pass
			  mpegSkipNum = self->mpegSkipNum -1;
			  while (mpegSkipNum--)
				{
				  unusedImage = MpegDecoderNextImage(self->mpeg);
				  ZimFree(unusedImage);
				}
			}
		  
		  return nextImage;
		}
	  else
		{
		  MpegDecoderFree(self->mpeg);
		  self->mpeg = NULL;
		}
	}
  if (ParamMoreFrames(self->param) == YES)
	{
	  str =  ParamGetNextImageFilename(self->param);
	}
  else
	{
	  return NULL;
	}
  if ((str == NULL) || (str[0] == '\0'))
	{
	  return NULL;
	}
  else
	{
	  strcpy(self->currentImageFilename, str);
	}
  if( (ext = strstr(self->currentImageFilename , ".mpg")) || (ext = strstr(self->currentImageFilename, ".m2v")))
	{
	  char *margv[] = 
		{
		  "mpegstream", "-b", NULL, "-r", "-o6", "-v0", NULL, NULL
		};
	  int margc = 6;
	  char *fn;	  
	  char *frameNum;

	  self->mpegFirstFrame = 0;
	  self->mpegLastFrame = 999999;
	  self->mpegSkipNum = 1;
	  if (ext[4] != '\0')
		{
		  ParamGetCurrentRange(self->param, &self->mpegFirstFrame, &self->mpegLastFrame, &self->mpegSkipNum ,YES);
		  if (self->mpegLastFrame ==999999)  //we didn't have a range
		  {
		  	self->mpegLastFrame = atoi(&ext[4]);  //use the number by itself, only one frame
		  }
		}

	  fn = strdup(self->currentImageFilename);
	  frameNum = strrchr(fn, '.')+4;
	  *frameNum = '\0';//remove frame number so mpeg object can open the file
	  margv[2] = fn;
	  
	  if (! self->skipFields)  //specify frame flag
	  {
	  	margv[margc++] = "-f";
	  }
	  
	  self->mpeg = MpegDecoderNew(margc, margv, self->mpegFirstFrame, self->mpegLastFrame);
	  return ParamImSeqNextImage(self);/*in case it's an empty mpg...*/
	}
  else
	{
	  char *secondFilename,firstFilename[MAXPATHLEN+1];
	  TagTable *image1tt ;
	  ImVfb *img, *image1;
	  int fields;
	  
	  if (!(secondFilename= strchr(self->currentImageFilename,'\n')))
		{  //one filename, no compositing
			nextImage = ZimImageTagTableFromFile(self->currentImageFilename, "");
		}
	  else
		{
		  strncpy(firstFilename,self->currentImageFilename,secondFilename-self->currentImageFilename);
		  firstFilename[secondFilename-self->currentImageFilename]='\0';
		  secondFilename++;//point past the \n
		  image1tt = ZimImageTagTableFromFile(firstFilename, "");
		  nextImage = ZimImageTagTableFromFile(secondFilename, "");//result will be in here
		  TagEntryQValue(TagTableQDirect(image1tt, "image vfb", 0), &image1);
		  TagEntryQValue(TagTableQDirect(nextImage, "image vfb", 0), &img);		  
		  
		//image is the composite of those two
		  fields = IMRED | IMGREEN | IMBLUE;
		  if (ImVfbQFields(img) && IMVFBALPHA)
			{
			  fields |= IMALPHA;
			}
		  
		  ImVfbComp(image1, 0, 0, ImVfbQWidth(img), ImVfbQHeight(img), fields, IMCOMPOVER, img, 0, 0);
		  //free image1tt, it's not needed any more
		  ZimFree(image1tt);
		}
	}
  
  return nextImage;
}