View | Details | Raw Unified
Collapse All | Expand All

(-) mjpegtools-1.8.0/lavtools/lav_io.c (-19 / +35 lines)
 Lines 540-554    Link Here 
int lav_write_audio(lav_file_t *lav_file, uint8_t *buff, long samps)
int lav_write_audio(lav_file_t *lav_file, uint8_t *buff, long samps)
{
{
   int res;
   int res = -1;
#ifdef HAVE_LIBQUICKTIME
#ifdef HAVE_LIBQUICKTIME
   int i, j;
   int i, j;
   int16_t *qt_audio = (int16_t *)buff, **qt_audion;
   int16_t *buff16 = (int16_t *)buff, **qt_audion;
   int channels = lav_audio_channels(lav_file);
   int channels = lav_audio_channels(lav_file);
   int bits = lav_audio_bits(lav_file);
   qt_audion = malloc(channels * sizeof (int16_t **));
   for (i = 0; i < channels; i++)
	qt_audion[i] = (int16_t *)malloc(samps * lav_file->bps);
#endif
#endif
   video_format = lav_file->format; internal_error = 0; /* for error messages */
   video_format = lav_file->format; internal_error = 0; /* for error messages */
 Lines 557-580    Link Here 
   {
   {
      case 'a':
      case 'a':
      case 'A':
      case 'A':
         res = AVI_write_audio( lav_file->avi_fd, buff, samps*lav_file->bps);
         res = AVI_write_audio(lav_file->avi_fd, buff, samps*lav_file->bps);
         break;
         break;
#ifdef HAVE_LIBQUICKTIME
#ifdef HAVE_LIBQUICKTIME
      case 'q':
      case 'q':
	/* Deinterleave the audio into the two channels. */
	 if (bits != 16 || channels > 1)
	for (i = 0; i < samps; i++)
	 {
	    {
	    /* Deinterleave the audio into the two channels and/or convert
	    for (j = 0; j < channels; j++)
	     * bits per sample to the required format.
		qt_audion[j][i] = qt_audio[(channels*i) + j];
	     */
	    }
	    qt_audion = malloc(channels * sizeof(*qt_audion));
	res = lqt_encode_audio_track(lav_file->qt_fd, qt_audion, NULL,samps,0);
	    for (i = 0; i < channels; i++)
	for (j = 0; j < channels; j++)
	      qt_audion[i] = malloc(samps * sizeof(**qt_audion));
	    free(qt_audion[j]);
	free(qt_audion);
	    if (bits == 16)
        break;
	      for (i = 0; i < samps; i++)
		for (j = 0; j < channels; j++)
		  qt_audion[j][i] = buff16[channels * i + j];
	    else 
	      if (bits == 8)
		for (i = 0; i < samps; i++)
		  for (j = 0; j < channels; j++)
		    qt_audion[j][i] = ((int16_t)(buff[channels * i + j]) << 8) ^ 0x8000;
	    if (bits == 8 || bits == 16)
	      res = lqt_encode_audio_track(lav_file->qt_fd, qt_audion, NULL, samps, 0);
	    for (i = 0; i < channels; i++)
	      free(qt_audion[i]);
	    free(qt_audion);
	  } else {
	    qt_audion = &buff16;
	    res = lqt_encode_audio_track(lav_file->qt_fd, qt_audion, NULL, samps, 0);
	  }
	  break;
#endif
#endif
      default:
      default:
         res = -1;
         break;
   }
   }
   return res;
   return res;