/* * Copyright (c) 1999-2003 WIDE Project * All rights reserved. * * Author : Akimichi OGAWA (akimichi@sfc.wide.ad.jp) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code MUST retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form MUST reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * MUST display the following acknowledgement: * This product includes software developed by Akimichi OGAWA. * 4. The name of the author MAY NOT be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include "write.h" #include "ieee1394.h" #include "shm.h" #include "dv.h" /* blocks used for [u_int32_t outbuf] */ #define NBLOCKS 300 #define USE_SILENT_AUDIO 0x00000001 int freebsd4_write_frame_to_ieee1394 __P((struct dvrecv_param *, u_int32_t *, int)); void ieee1394dv_write_loop (struct dvrecv_param *dvrecv_param) { u_char dummy_inst[] = { 17,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,14,15,14,15,15,14,15,14,15, 17,14,15,15,14,15,14,15,14,15,14,15,15,14,15,14,15, 17,14,15,15,14,15,14,15,14,15,14,15,14,15,15,14,15, 17,14,15,14,15,15,14,15,14,15,14,15,14,15,15,14,15, 17,14,15,14,15,14,15,15,14,15,14,15,14,15,14,15,15, 17,14,15,14,15,14,15,15,14,15,14,15,14,15,14,15,14, 18,14,15,14,15,14,15,15,14,15,14,15,14,15,14,15,14, 18,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14, 18,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14, 17,15,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14, 17,15,15,14,15,14,15,14,15,14,15,14,15,15,14,15,14, 17,15,14,15,15,14,15,14,15,14,15,14,15,15,14,15,14, 17,15,14,15,15,14,15,14,15,14,15,14,15,14,15,15,14, 17,15,14,15,15,14,15,14,15,14,15,14,15,14,15,15,14, 17,15,13,16,14,15,15,14,15,14,15,14,15,14,15,15,14, 17,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15, 17,14,15,15,14,15,14,15,14,15,14,15,15,14,15,14,15, 17,14,15,15,14,15,14,15,14,15,14,15,14,15,15,14,15, 17,14,15,14,15,15,14,15,14,15,14,15,14,15,15,14,15, 17,14,15,14,15,15,14,15,14,15,14,15,14,15,15,14,15, 17,14,15,14,15,15,14,15,14,15,14,15,14,15,14,15,15, 17,14,15,14,15,14,15,15,14,15,14,15,14,15,14,15,15, 17,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14, 18,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14, 18,14,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14, 18,14,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14, 17,15,15,14,15,14,15,14,15,14,15,15,14,15,14,15,14, 17,15,14,15,15,14,15,14,15,14,15,14,15,15,14,15,14, 17,15,14,15,15,14,15,14,15,14,15,14,15,14,15,15,14, 17,15,14,15,14,15,15,14,15,14,15,14,15,14,15,15,14, 17,15,14,15,14,15,15,14,15,14,15,14,15,14,15,15,14, 17,15,14,15,14,15,15,14,15,14,15,14,15,14,15,14,15, 17,15,14,15,14,15,14,15,15,14,15,14,15,14,15,14,15 }; u_long silent_audio[DIFSEQ_NUM*9*80/4]; u_long silent_audio_flag = 0; u_long same_audio_count = 0; u_int32_t outbuf[512/4 * NBLOCKS]; u_char seq = 0; u_char dseq, sct, dbn; int i; int ieee1394_pkt_count = 0; int count; int dummy_inst_count = 0; int dummy_inst_interval = 0; /* prepare DV DIF block without any sound */ memset(silent_audio, 0, sizeof(silent_audio)); sct = SCT_AUDIO; for (dseq=0; dseqvideo_framebuf->next->frame_buf->lock == DVFRAME_DATA_READY) { dvrecv_param->video_framebuf = dvrecv_param->video_framebuf->next; dvrecv_param->video_framebuf->frame_buf->lock = DVFRAME_WRITING_IEEE1394; } if (dvrecv_param->audio_framebuf->next->frame_buf->lock == DVFRAME_DATA_READY) { same_audio_count = 0; silent_audio_flag = 0; dvrecv_param->audio_framebuf = dvrecv_param->audio_framebuf->next; dvrecv_param->audio_framebuf->frame_buf->lock = DVFRAME_WRITING_IEEE1394; } else { same_audio_count++; if (same_audio_count > 5) { if (same_audio_count == 6) { printf("MUTE AUDIO\n"); } same_audio_count = 10; silent_audio_flag = USE_SILENT_AUDIO; } } for (dseq=0; dseqvideo_framebuf->frame_buf->dvframe.pkt[dseq][0][0] + (6 + i*16)*80/4, &silent_audio[dseq*9*(80/4) + i*(80/4)], 80); } } else { for (i=0; i<9; i++) { memcpy(&dvrecv_param->video_framebuf->frame_buf->dvframe.pkt[dseq][0][0] + (6 + i*16)*80/4, &dvrecv_param->audio_framebuf->frame_buf->dseq[dseq].dbn[i], 80); } } } for (dseq=0; dseqvideo_framebuf->frame_buf->dvframe.pkt[dseq][0][0] + count*480/4, 480); outbuf[ieee1394_pkt_count*(512/4)] = htonl(488 << 16 | 0x00007fa0); if (dummy_inst_interval >= dummy_inst[dummy_inst_count] - 1) { dummy_inst_interval = 0; ieee1394_pkt_count++; dummy_inst_count++; outbuf[ieee1394_pkt_count*(512/4)] = htonl(8 << 16 | 0x00007fa0); if (dummy_inst_count >= sizeof(dummy_inst)) { dummy_inst_count = 0; } } else { dummy_inst_interval++; } ieee1394_pkt_count++; } /* end of for(count=0; countvideo_framebuf->frame_buf->lock = DVFRAME_READY; dvrecv_param->audio_framebuf->frame_buf->lock = DVFRAME_READY; } }