Search Results

Search found 1082 results on 44 pages for 'frames'.

Page 5/44 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Understanding PTS and DTS in video frames

    - by theateist
    I had fps issues when transcoding from avi to mp4(x264). Eventually the problem was in PTS and DTS values, so lines 12-15 where added before av_interleaved_write_frame function: 1. AVFormatContext* outContainer = NULL; 2. avformat_alloc_output_context2(&outContainer, NULL, "mp4", "c:\\test.mp4"; 3. AVCodec *encoder = avcodec_find_encoder(AV_CODEC_ID_H264); 4. AVStream *outStream = avformat_new_stream(outContainer, encoder); 5. // outStream->codec initiation 6. // ... 7. avformat_write_header(outContainer, NULL); 8. // reading and decoding packet 9. // ... 10. avcodec_encode_video2(outStream->codec, &encodedPacket, decodedFrame, &got_frame) 11. 12. if (encodedPacket.pts != AV_NOPTS_VALUE) 13. encodedPacket.pts = av_rescale_q(encodedPacket.pts, outStream->codec->time_base, outStream->time_base); 14. if (encodedPacket.dts != AV_NOPTS_VALUE) 15. encodedPacket.dts = av_rescale_q(encodedPacket.dts, outStream->codec->time_base, outStream->time_base); 16. 17. av_interleaved_write_frame(outContainer, &encodedPacket) After reading many posts I still do not understand: outStream->codec->time_base = 1/25 and outStream->time_base = 1/12800. The 1st one was set by me but I cannot figure out why and who set 12800? I noticed that before line (7) outStream->time_base = 1/90000 and right after it it changes to 1/12800, why? When I transcode from avi to avi, meaning changing the line (2) to avformat_alloc_output_context2(&outContainer, NULL, "avi", "c:\\test.avi"; , so before and after line (7) outStream->time_base remains always 1/25 and not like in mp4 case, why? What is the difference between time_base of outStream->codec and outStream? To calc the pts av_rescale_q does: takes 2 time_base, multiplies their fractions in cross and then compute the pts. Why it does this in this way? As I debugged, the encodedPacket.pts has value incremental by 1, so why changing it if it does has value? At the beginning the dts value is -2 and after each rescaling it still has negative number, but despite this the video played correctly! Shouldn't it be positive?

    Read the article

  • Screen scrape a web page that uses javaScript and frames

    - by Mello
    Hi, I want to scrape data from www.marktplaats.nl . I want to analyze the scraped description, price, date and views in Excel/Access. I tried to scrape data with Ruby (nokogiri, scrapi) but nothing worked. (on other sites it worked well) The main problem is that for example selectorgadget and the add-on firebug (Firefox) don’t find any css I can use to scrape the page. On other sites I can extract the css with selectorgadget or firebug and use it with nokogiri or scrapi. Due to lack of experience it is difficult to identify the problem and therefore searching for a solution isn’t easy. Can you tell me where to start solving this problem and where I maybe can find more info about a similar scraping process? Thanks in advance!

    Read the article

  • target="_top" emulation using JavaScript

    - by abovesun
    Suppose we have frameset of with 2 frames, one frame is kind a tiny horizontal header and second is kind of "content" frame with 3rd-party html page inside. When user clicks on some link inside "content" frame, the whole page (frameset) should be reloaded with this link, the same behavior if "content" frame has "target=_top" attribute. How to do this using JS?

    Read the article

  • Grab VLC frames through HTTP protocol

    - by tzador
    Hello, Is there any way to access a movie plaing in VLC through HTTP in jpeg/png format. You see, what I want, is to have a movie playing in my local VLC player, and access currently playing frame through something like http://localhost:9999/current.jpg Is there sucha way, or maybe someother tool can provide it? Thanx a lot in advance

    Read the article

  • EmulateIE7 and FRAMES Question

    - by JJ
    I don't want to have to add the EmulateIE7 meta tag for every page if I dont have to. My default.htm is a FRAMESET page so can I just add the meta tag to my default FRAMESET page and my site stay in IE=EmulateIE7 mode for each new page that loads in the frameset? Thanks

    Read the article

  • R: manipulating data.frames containing strings and booleans.

    - by Mike Dewar
    Hello. I have a data.frame in R; it's called p. Each element in the data.frame is either True or False. My variable p has, say, m rows and n columns. For every row there is strictly only one TRUE element. It also has column names, which are strings. What I would like to do is the following: For every row in p I see a TRUE I would like to replace with the name of the corresponding column I would then like to collapse the data.frame, which now contains FALSEs and column names, to a single vector, which will have m elements. I would like to do this in an R-thonic manner, so as to continue my enlightenment in R and contribute to a world without for-loops. I can do step 1 using the following for loop: for (i in seq(length(colnames(p)))) { p[p[,i]==TRUE,i]=colnames(p)[i] } but theres's no beauty here and I have totally subscribed to this for-loops-in-R-are-probably-wrong mentality. Maybe wrong is too strong but they're certainly not great. I don't really know how to do step 2. I kind of hoped that the sum of a string and FALSE would return the string but it doesn't. I kind of hoped I could use an OR operator of some kind but can't quite figure that out (Python responds to False or 'bob' with 'bob'). Hence, yet again, I appeal to you beautiful Rstats people for help!

    Read the article

  • Web-Cam Video frames to System.Drawing.Bitmap

    - by Hooch
    Hello. I'm using AForge.NET framework to process some data from webcam. My Image processor is working. class WebProc { public void Process(System.Drawing.Bitmap image) { .... } } I know how to send image from HDD. I was thinking about something like that: private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { while(!backgroundWorker1.CancellationPending) { Bitmap Frame GetVidoFrameSomeWay(); WebProc.Process(Frame); } } Can you help me with those questions? How to get frame from webcam? How to list all available webcam for user to chose from? How to open Webcam setting window? Is there a way to set frame size to 640x480 o user size?

    Read the article

  • How to make floating frames with wx.aui.AuiManager be proper windows

    - by jhaukur
    Hello all I'm using wxPython. I'm trying to figure out how I can change the behavior of the wx.aui.AuiManager so that when a window is dragged to become floating, it will become a proper window with Minimize and Maximize buttons and shown in the Taskbar. Apparently there is some subclassing done of the standard window to remove those exact features but I'm not having any luck in getting them back.

    Read the article

  • How to step frames in a movie recorded by iPhone

    - by aron
    Is there a way to have my iPhone program step frame by frame through a movie recorded by the iPhone? What I want to do is have the user record a quicktime movie, then be able to step through the movie frame by frame. Alternately, I suppose if there was a way to extract every single frame from the movie to a jpg, then I could easily step through the pictures. Anyone know of a way to do this??? I suppose the third option (which might not get past Apple's store) is to capture the movie the way the old jailbroken apps did, which is somehow capture the pictures directly from the camera view???? Any help appreciated. Thanks in advance!!!!

    Read the article

  • Blob ID matching over multiple frames in C++ (image analysis)

    - by pollux
    Dear reader, I'm working on a blob matching and tracking library in C++. Currently I'm using openCV to detect blobs and try to match blobs in a new frame by checking the position, velocity and size of the blob. This works quite okay and I'm receiving a high blob match rate (95% or higher). Sometimes blobs fall out of the image or new blobs appear. Now I need to give matched blobs the same ID as they had before. I'm wondering if there are typical or commonly used techniques for doing this. Or even some keywords I can use to google on. Thanks

    Read the article

  • How to refresh a frame .net

    - by Geetha
    Hi All, I am using two frames to display pages. The page url is given in codebehind. But it is not reflecting. If i click f5 its grtting reflected. Needs: How to refresh a frame after setting the src value in the code behind. code: topFrame.Attributes["src"] = "MainPage.aspx"; Geetha.

    Read the article

  • actionscript 3 website load movieclips (frames) from library

    - by steve
    Here is my current code that doesn't function: import flash.display.*; import fl.transitions.*; import flash.events.MouseEvent; stop(); var contentBox:MovieClip = new MovieClip(); contentBox.width = 400; contentBox.height = 500; contentBox.x = 400; contentBox.y = 0; var closeBtn:close_btn = new close_btn(); closeBtn.x = 850; closeBtn.y = 15; var bagLink:MovieClip = new bag_link_mc(); bagLink.x = 900; bagLink.y = 0; menu_bag_button.addEventListener(MouseEvent.CLICK, bagClick); function bagClick(event:MouseEvent):void{ if(MovieClip(root).currentFrame == 835) { } else { MovieClip(root).addChild (contentBox); MovieClip(root).contentBox.addChild (bagLink); MovieClip(root).contentBox.addChild (closeBtn); MovieClip(root).gotoAndPlay(806); } } closeBtn.addEventListener(MouseEvent.CLICK, closeBag); function closeBag (event:MouseEvent):void{ MovieClip(root).removeChild(contentBox); MovieClip(root).gotoAndPlay(850); } I don't know ActionScript at all, so this may be the complete wrong way of approaching it. The setup is as follows: site loads, there's a big menu in the center (frame 805). When you click on a menu item from there, the whole menu moves to the side, and the right side I want a "contentBox" movieclip, filled with "bagLink" (which is site content) and to have a close button (closeBtn.) It also needs to know that if you click the same link again on the left side that it doesn't reanimate, it just stays (which I achieved with the "if" statement.) Finally, if someone clicks another link, it needs to clear "contentBox" and refill it with whatever movieClip that was clicked. I know this is a lot to ask, but I'm in dire need of help as this is due on Wednesday...

    Read the article

  • PHP_AUTH_USER only known in certain frames

    - by Rob
    Getting very confused by PHP_AUTH_USER. Within my web pages I have .htaccess files in every directory, controlling who can (and cant) see certain folders. In order to further customise the pages I was hoping to use PHP_AUTH_USER within the PHP code, i.e. tailor page contents based on the user. This only seems to work partially. The code snippets below hopefully demonstrate my problems. The main index.php creates a framed page with a menu structure in the top left hand corners, some irrelvant stuff in top right and then the tailor made contents in bottom frame. In top left the user is correctly shown, but in the bottom frame PHP_AUTH_USER doesnt seem to be set anymore (it returns empty and when printing all $HTTP_SERVER_VARS its not listed). Script.php is in a different path, but they all have .htaccess files in them and all other contents is displayed correctly. Why does it not know about PHP_AUTH_USER there? Running version php version 5.2.12 on chrome. index.php <FRAMESET ROWS="35%, *"> <FRAMESET COLS="25%, *"> <FRAME SRC="Menu.php"> <FRAME SRC="Something.php"> </FRAMESET> <FRAME SRC="../OtherPath/Script.php?large=1" name="outputlisting"> </FRAMESET> </FRAMESET> Menu.php <ul> <li>Reporting <ul> <li>Link1 <a href="../OtherPath/Script.php" target="outputlisting">All</a>, <a href="../OtherPath/Script.php?large=1" target="outputlisting">Big</a> </ul> <?php echo 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '<br />'; echo 'User: ' . $_SERVER['PHP_AUTH_USER']; ?> Script.php <?php echo 'User: ' . $_SERVER['PHP_AUTH_USER']; ?>

    Read the article

  • Proper Way to Create Standards-Compliant Webpage Structure

    - by Sakamoto Kazuma
    I have been working through projects involving packages that do all the web design stuff for me for the past few years. I will admit that I have not been able to focus any on actual web design. I was wondering what the standard is these days for website layouts. Are layout-tables looked down upon now? Or are all layouts done with div tags and controlled through CSS? Are frames even used anymore? Note I am not talking about chart-table tables when I say layout tables.

    Read the article

  • How to revert to Eclipse's old behavior when double-clicking on frames or windows, in Juno?

    - by mattquiros
    I find Eclipse Juno very counter-intuitive. In my workspace, I used to just have the package view at the left, my code on the right, and whenever I'm printing something in the console, that's only when the console frame shows up from the bottom right. When you double click on a particular window, it either only goes fullscreen within Eclipse, or back to its original size together with the size of the other frames. In Juno, however, it seems that frames are put on layers on top of each other. When I print something to the console, the output frame only shows up as a small, useless square to my right. When I double-click, it goes full screen. When I double-click again, it occupies the full right frame, hiding my code. I double-click again and it goes full screen, then it double-clicks before it shares the right frame with my code on top of it. Then when I minimize it, it goes to the side. Any way to go back to the good old days of Eclipse? Thanks.

    Read the article

  • Are there any statistics on the number of networks using Ethernet Jumbo frames?

    - by Russell Heilling
    I am often told by Sales Engineers and Product managers that a Layer 2 Ethernet service is not fit for purpose if the maximum supported frame size is in the 1518-1522 range (enough to support standard Ethernet frames or VLAN tagged frames). Or in other words: an MTU of 1500 is not enough (see this blog post for my definition of MTU and a short rant on how the term is often misused) I am never able to get any details from them on: a) What proportion of customers (Enterprise / SMB) require Jumbo frames b) What are typical expectations on frame size for Jumbos on WAN links? 1600, 2000, 9k, etc... I know that in Telco and Data Centre environments Jumbos are pretty common, but I am after some insight as to how common this is within Enterprise and SMB networks.

    Read the article

  • Hyperlink and targetname in wpf

    - by Geetha
    Hi All, I want to display the pages in the frame by using the hyperlink control. but it is not working. Code: <Window x:Class="WPFNavigation.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="400" Width="500"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <StackPanel Grid.Column="0"> <TextBlock> <Hyperlink NavigateUri="ImagePage.xaml">Image</Hyperlink> <LineBreak></LineBreak> <Hyperlink NavigateUri="Layouts.xaml" TargetName="targetFrame">Layouts</Hyperlink> </TextBlock> </StackPanel> <Frame Name="targetFrame" Source="MainPage.xaml" Grid.Column="1"></Frame> </Grid> </Window>

    Read the article

  • IFrame targeting another IFrame

    - by Mitchan Adams
    I have a parent page containing two iframes. One holds navigation links and the other should display the information pertaining to the navigation link clicked in the first iframe. So I need to target the one iframe from within another iframe.Is this possible? If so how does one go about it?

    Read the article

  • Troubleshoot Page Loading Issue (ActiveX control)

    - by Spence
    Apologies for cryptic title, I'm hoping most people will read this BEFORE trying to move it to server fault. I might try and discourage the "too hard basket, move it to server fault anyway" crowd as well :). I have a page which will open cleanly when it's opened in it's own browser window/tab. The exact same URL, when loaded as part of a frame in a page in the same (local intranet) security zone shows the error: Your security settins do not allow websites to use ActiveX controls installed on your computer. This page may not display correctly. Click Here for options. How do I troubleshoot IE to work out which ActiveX control won't load in the frame but does load if the page is opened directly? Please note that I have dropped the security fully AND I've also moved EVERY setting in IE to enable or allow and restarted the browser but I STILL get the same issue. The two sites are on different machines in the same domain. I can't access website source code but I can ask for it to be fixed, so I'd really appreciate some help on this.

    Read the article

  • Conceal packet loss in PCM stream

    - by ZeroDefect
    I am looking to use 'Packet Loss Concealment' to conceal lost PCM frames in an audio stream. Unfortunately, I cannot find a library that is accessible without all the licensing restrictions and code bloat (...up for some suggestions though). I have located some GPL code written by Steve Underwood for the Asterisk project which implements PLC. There are several limitations; although, as Steve suggests in his code, his algorithm can be applied to different streams with a bit of work. Currently, the code works with 8kHz 16-bit signed mono streams. Variations of the code can be found through a simple search of Google Code Search. My hope is that I can adapt the code to work with other streams. Initially, the goal is to adjust the algorithm for 8+ kHz, 16-bit signed, multichannel audio (all in a C++ environment). Eventually, I'm looking to make the code available under the GPL license in hopes that it could be of benefit to others... Attached is the code below with my efforts. The code includes a main function that will "drop" a number of frames with a given probability. Unfortunately, the code does not quite work as expected. I'm receiving EXC_BAD_ACCESS when running in gdb, but I don't get a trace from gdb when using 'bt' command. Clearly, I'm trampimg on memory some where but not sure exactly where. When I comment out the *amdf_pitch* function, the code runs without crashing... int main (int argc, char *argv[]) { std::ifstream fin("C:\\cc32kHz.pcm"); if(!fin.is_open()) { std::cout << "Failed to open input file" << std::endl; return 1; } std::ofstream fout_repaired("C:\\cc32kHz_repaired.pcm"); if(!fout_repaired.is_open()) { std::cout << "Failed to open output repaired file" << std::endl; return 1; } std::ofstream fout_lossy("C:\\cc32kHz_lossy.pcm"); if(!fout_lossy.is_open()) { std::cout << "Failed to open output repaired file" << std::endl; return 1; } audio::PcmConcealer Concealer; Concealer.Init(1, 16, 32000); //Generate random numbers; srand( time(NULL) ); int value = 0; int probability = 5; while(!fin.eof()) { char arr[2]; fin.read(arr, 2); //Generate's random number; value = rand() % 100 + 1; if(value <= probability) { char blank[2] = {0x00, 0x00}; fout_lossy.write(blank, 2); //Fill in data; Concealer.Fill((int16_t *)blank, 1); fout_repaired.write(blank, 2); } else { //Write data to file; fout_repaired.write(arr, 2); fout_lossy.write(arr, 2); Concealer.Receive((int16_t *)arr, 1); } } fin.close(); fout_repaired.close(); fout_lossy.close(); return 0; } PcmConcealer.hpp /* * Code adapted from Steve Underwood of the Asterisk Project. This code inherits * the same licensing restrictions as the Asterisk Project. */ #ifndef __PCMCONCEALER_HPP__ #define __PCMCONCEALER_HPP__ /** 1. What does it do? The packet loss concealment module provides a suitable synthetic fill-in signal, to minimise the audible effect of lost packets in VoIP applications. It is not tied to any particular codec, and could be used with almost any codec which does not specify its own procedure for packet loss concealment. Where a codec specific concealment procedure exists, the algorithm is usually built around knowledge of the characteristics of the particular codec. It will, therefore, generally give better results for that particular codec than this generic concealer will. 2. How does it work? While good packets are being received, the plc_rx() routine keeps a record of the trailing section of the known speech signal. If a packet is missed, plc_fillin() is called to produce a synthetic replacement for the real speech signal. The average mean difference function (AMDF) is applied to the last known good signal, to determine its effective pitch. Based on this, the last pitch period of signal is saved. Essentially, this cycle of speech will be repeated over and over until the real speech resumes. However, several refinements are needed to obtain smooth pleasant sounding results. - The two ends of the stored cycle of speech will not always fit together smoothly. This can cause roughness, or even clicks, at the joins between cycles. To soften this, the 1/4 pitch period of real speech preceeding the cycle to be repeated is blended with the last 1/4 pitch period of the cycle to be repeated, using an overlap-add (OLA) technique (i.e. in total, the last 5/4 pitch periods of real speech are used). - The start of the synthetic speech will not always fit together smoothly with the tail of real speech passed on before the erasure was identified. Ideally, we would like to modify the last 1/4 pitch period of the real speech, to blend it into the synthetic speech. However, it is too late for that. We could have delayed the real speech a little, but that would require more buffer manipulation, and hurt the efficiency of the no-lost-packets case (which we hope is the dominant case). Instead we use a degenerate form of OLA to modify the start of the synthetic data. The last 1/4 pitch period of real speech is time reversed, and OLA is used to blend it with the first 1/4 pitch period of synthetic speech. The result seems quite acceptable. - As we progress into the erasure, the chances of the synthetic signal being anything like correct steadily fall. Therefore, the volume of the synthesized signal is made to decay linearly, such that after 50ms of missing audio it is reduced to silence. - When real speech resumes, an extra 1/4 pitch period of sythetic speech is blended with the start of the real speech. If the erasure is small, this smoothes the transition. If the erasure is long, and the synthetic signal has faded to zero, the blending softens the start up of the real signal, avoiding a kind of "click" or "pop" effect that might occur with a sudden onset. 3. How do I use it? Before audio is processed, call plc_init() to create an instance of the packet loss concealer. For each received audio packet that is acceptable (i.e. not including those being dropped for being too late) call plc_rx() to record the content of the packet. Note this may modify the packet a little after a period of packet loss, to blend real synthetic data smoothly. When a real packet is not available in time, call plc_fillin() to create a sythetic substitute. That's it! */ /*! Minimum allowed pitch (66 Hz) */ #define PLC_PITCH_MIN(SAMPLE_RATE) ((double)(SAMPLE_RATE) / 66.6) /*! Maximum allowed pitch (200 Hz) */ #define PLC_PITCH_MAX(SAMPLE_RATE) ((SAMPLE_RATE) / 200) /*! Maximum pitch OLA window */ //#define PLC_PITCH_OVERLAP_MAX(SAMPLE_RATE) ((PLC_PITCH_MIN(SAMPLE_RATE)) >> 2) /*! The length over which the AMDF function looks for similarity (20 ms) */ #define CORRELATION_SPAN(SAMPLE_RATE) ((20 * (SAMPLE_RATE)) / 1000) /*! History buffer length. The buffer must also be at leat 1.25 times PLC_PITCH_MIN, but that is much smaller than the buffer needs to be for the pitch assessment. */ //#define PLC_HISTORY_LEN(SAMPLE_RATE) ((CORRELATION_SPAN(SAMPLE_RATE)) + (PLC_PITCH_MIN(SAMPLE_RATE))) namespace audio { typedef struct { /*! Consecutive erased samples */ int missing_samples; /*! Current offset into pitch period */ int pitch_offset; /*! Pitch estimate */ int pitch; /*! Buffer for a cycle of speech */ float *pitchbuf;//[PLC_PITCH_MIN]; /*! History buffer */ short *history;//[PLC_HISTORY_LEN]; /*! Current pointer into the history buffer */ int buf_ptr; } plc_state_t; class PcmConcealer { public: PcmConcealer(); ~PcmConcealer(); void Init(int channels, int bit_depth, int sample_rate); //Process a block of received audio samples. int Receive(short amp[], int frames); //Fill-in a block of missing audio samples. int Fill(short amp[], int frames); void Destroy(); private: int amdf_pitch(int min_pitch, int max_pitch, short amp[], int channel_index, int frames); void save_history(plc_state_t *s, short *buf, int channel_index, int frames); void normalise_history(plc_state_t *s); /** Holds the states of each of the channels **/ std::vector< plc_state_t * > ChannelStates; int plc_pitch_min; int plc_pitch_max; int plc_pitch_overlap_max; int correlation_span; int plc_history_len; int channel_count; int sample_rate; bool Initialized; }; } #endif PcmConcealer.cpp /* * Code adapted from Steve Underwood of the Asterisk Project. This code inherits * the same licensing restrictions as the Asterisk Project. */ #include "audio/PcmConcealer.hpp" /* We do a straight line fade to zero volume in 50ms when we are filling in for missing data. */ #define ATTENUATION_INCREMENT 0.0025 /* Attenuation per sample */ #if !defined(INT16_MAX) #define INT16_MAX (32767) #define INT16_MIN (-32767-1) #endif #ifdef WIN32 inline double rint(double x) { return floor(x + 0.5); } #endif inline short fsaturate(double damp) { if (damp > 32767.0) return INT16_MAX; if (damp < -32768.0) return INT16_MIN; return (short)rint(damp); } namespace audio { PcmConcealer::PcmConcealer() : Initialized(false) { } PcmConcealer::~PcmConcealer() { Destroy(); } void PcmConcealer::Init(int channels, int bit_depth, int sample_rate) { if(Initialized) return; if(channels <= 0 || bit_depth != 16) return; Initialized = true; channel_count = channels; this->sample_rate = sample_rate; ////////////// double min = PLC_PITCH_MIN(sample_rate); int imin = (int)min; double max = PLC_PITCH_MAX(sample_rate); int imax = (int)max; plc_pitch_min = imin; plc_pitch_max = imax; plc_pitch_overlap_max = (plc_pitch_min >> 2); correlation_span = CORRELATION_SPAN(sample_rate); plc_history_len = correlation_span + plc_pitch_min; ////////////// for(int i = 0; i < channel_count; i ++) { plc_state_t *t = new plc_state_t; memset(t, 0, sizeof(plc_state_t)); t->pitchbuf = new float[plc_pitch_min]; t->history = new short[plc_history_len]; ChannelStates.push_back(t); } } void PcmConcealer::Destroy() { if(!Initialized) return; while(ChannelStates.size()) { plc_state_t *s = ChannelStates.at(0); if(s) { if(s->history) delete s->history; if(s->pitchbuf) delete s->pitchbuf; memset(s, 0, sizeof(plc_state_t)); delete s; } ChannelStates.erase(ChannelStates.begin()); } ChannelStates.clear(); Initialized = false; } //Process a block of received audio samples. int PcmConcealer::Receive(short amp[], int frames) { if(!Initialized) return 0; int j = 0; for(int k = 0; k < ChannelStates.size(); k++) { int i; int overlap_len; int pitch_overlap; float old_step; float new_step; float old_weight; float new_weight; float gain; plc_state_t *s = ChannelStates.at(k); if (s->missing_samples) { /* Although we have a real signal, we need to smooth it to fit well with the synthetic signal we used for the previous block */ /* The start of the real data is overlapped with the next 1/4 cycle of the synthetic data. */ pitch_overlap = s->pitch >> 2; if (pitch_overlap > frames) pitch_overlap = frames; gain = 1.0 - s->missing_samples * ATTENUATION_INCREMENT; if (gain < 0.0) gain = 0.0; new_step = 1.0/pitch_overlap; old_step = new_step*gain; new_weight = new_step; old_weight = (1.0 - new_step)*gain; for (i = 0; i < pitch_overlap; i++) { int index = (i * channel_count) + j; amp[index] = fsaturate(old_weight * s->pitchbuf[s->pitch_offset] + new_weight * amp[index]); if (++s->pitch_offset >= s->pitch) s->pitch_offset = 0; new_weight += new_step; old_weight -= old_step; if (old_weight < 0.0) old_weight = 0.0; } s->missing_samples = 0; } save_history(s, amp, j, frames); j++; } return frames; } //Fill-in a block of missing audio samples. int PcmConcealer::Fill(short amp[], int frames) { if(!Initialized) return 0; int j =0; for(int k = 0; k < ChannelStates.size(); k++) { short *tmp = new short[plc_pitch_overlap_max]; int i; int pitch_overlap; float old_step; float new_step; float old_weight; float new_weight; float gain; short *orig_amp; int orig_len; orig_amp = amp; orig_len = frames; plc_state_t *s = ChannelStates.at(k); if (s->missing_samples == 0) { // As the gap in real speech starts we need to assess the last known pitch, //and prepare the synthetic data we will use for fill-in normalise_history(s); s->pitch = amdf_pitch(plc_pitch_min, plc_pitch_max, s->history + plc_history_len - correlation_span - plc_pitch_min, j, correlation_span); // We overlap a 1/4 wavelength pitch_overlap = s->pitch >> 2; // Cook up a single cycle of pitch, using a single of the real signal with 1/4 //cycle OLA'ed to make the ends join up nicely // The first 3/4 of the cycle is a simple copy for (i = 0; i < s->pitch - pitch_overlap; i++) s->pitchbuf[i] = s->history[plc_history_len - s->pitch + i]; // The last 1/4 of the cycle is overlapped with the end of the previous cycle new_step = 1.0/pitch_overlap; new_weight = new_step; for ( ; i < s->pitch; i++) { s->pitchbuf[i] = s->history[plc_history_len - s->pitch + i]*(1.0 - new_weight) + s->history[plc_history_len - 2*s->pitch + i]*new_weight; new_weight += new_step; } // We should now be ready to fill in the gap with repeated, decaying cycles // of what is in pitchbuf // We need to OLA the first 1/4 wavelength of the synthetic data, to smooth // it into the previous real data. To avoid the need to introduce a delay // in the stream, reverse the last 1/4 wavelength, and OLA with that. gain = 1.0; new_step = 1.0/pitch_overlap; old_step = new_step; new_weight = new_step; old_weight = 1.0 - new_step; for (i = 0; i < pitch_overlap; i++) { int index = (i * channel_count) + j; amp[index] = fsaturate(old_weight * s->history[plc_history_len - 1 - i] + new_weight * s->pitchbuf[i]); new_weight += new_step; old_weight -= old_step; if (old_weight < 0.0) old_weight = 0.0; } s->pitch_offset = i; } else { gain = 1.0 - s->missing_samples*ATTENUATION_INCREMENT; i = 0; } for ( ; gain > 0.0 && i < frames; i++) { int index = (i * channel_count) + j; amp[index] = s->pitchbuf[s->pitch_offset]*gain; gain -= ATTENUATION_INCREMENT; if (++s->pitch_offset >= s->pitch) s->pitch_offset = 0; } for ( ; i < frames; i++) { int index = (i * channel_count) + j; amp[i] = 0; } s->missing_samples += orig_len; save_history(s, amp, j, frames); delete [] tmp; j++; } return frames; } void PcmConcealer::save_history(plc_state_t *s, short *buf, int channel_index, int frames) { if (frames >= plc_history_len) { /* Just keep the last part of the new data, starting at the beginning of the buffer */ //memcpy(s->history, buf + len - plc_history_len, sizeof(short)*plc_history_len); int frames_to_copy = plc_history_len; for(int i = 0; i < frames_to_copy; i ++) { int index = (channel_count * (i + frames - plc_history_len)) + channel_index; s->history[i] = buf[index]; } s->buf_ptr = 0; return; } if (s->buf_ptr + frames > plc_history_len) { /* Wraps around - must break into two sections */ //memcpy(s->history + s->buf_ptr, buf, sizeof(short)*(plc_history_len - s->buf_ptr)); short *hist_ptr = s->history + s->buf_ptr; int frames_to_copy = plc_history_len - s->buf_ptr; for(int i = 0; i < frames_to_copy; i ++) { int index = (channel_count * i) + channel_index; hist_ptr[i] = buf[index]; } frames -= (plc_history_len - s->buf_ptr); //memcpy(s->history, buf + (plc_history_len - s->buf_ptr), sizeof(short)*len); frames_to_copy = frames; for(int i = 0; i < frames_to_copy; i ++) { int index = (channel_count * (i + (plc_history_len - s->buf_ptr))) + channel_index; s->history[i] = buf[index]; } s->buf_ptr = frames; return; } /* Can use just one section */ //memcpy(s->history + s->buf_ptr, buf, sizeof(short)*len); short *hist_ptr = s->history + s->buf_ptr; int frames_to_copy = frames; for(int i = 0; i < frames_to_copy; i ++) { int index = (channel_count * i) + channel_index; hist_ptr[i] = buf[index]; } s->buf_ptr += frames; } void PcmConcealer::normalise_history(plc_state_t *s) { short *tmp = new short[plc_history_len]; if (s->buf_ptr == 0) return; memcpy(tmp, s->history, sizeof(short)*s->buf_ptr); memcpy(s->history, s->history + s->buf_ptr, sizeof(short)*(plc_history_len - s->buf_ptr)); memcpy(s->history + plc_history_len - s->buf_ptr, tmp, sizeof(short)*s->buf_ptr); s->buf_ptr = 0; delete [] tmp; } int PcmConcealer::amdf_pitch(int min_pitch, int max_pitch, short amp[], int channel_index, int frames) { int i; int j; int acc; int min_acc; int pitch; pitch = min_pitch; min_acc = INT_MAX; for (i = max_pitch; i <= min_pitch; i++) { acc = 0; for (j = 0; j < frames; j++) { int index1 = (channel_count * (i+j)) + channel_index; int index2 = (channel_count * j) + channel_index; //std::cout << "Index 1: " << index1 << ", Index 2: " << index2 << std::endl; acc += abs(amp[index1] - amp[index2]); } if (acc < min_acc) { min_acc = acc; pitch = i; } } std::cout << "Pitch: " << pitch << std::endl; return pitch; } } P.S. - I must confess that digital audio is not my forte...

    Read the article

  • How to call a JavaScript function from one frame to another in Chrome/Webkit with file protocol

    - by bambax
    I have developed an application that has a list of items in one frame; when one clicks on an item it does something in another frame (loads an image). This used to work fine in all browsers, including Chrome 3; now it still works fine in Firefox but in recent versions of Chrome (I believe since 4) it throws this error: Unsafe JavaScript attempt to access frame with URL (...) from frame with URL (...). Domains, protocols and ports must match. This is obviously a security "feature" but is it possible to get around it? Here is a simple test: index.html: <html> <frameset cols="50%,50%"> <frame src="left.html" name="left"/> <frame src="right.html" name="right"/> </frameset> </html> left.html: <html> <body> <a href="javascript:parent.right.test('hello');">click me</a> </body> </html> right.html: <html> <body> <script> function test(msg) { alert(msg); } </script> </body> </html> The above works in Firefox 3.6 and Chrome 3 but in Chrome 5 it throws the above error... Edit: added the @cols attribute to the frameset element in fact it works in Chrome if and only if the pages are served with the http protocol (and from the same domain) but my problem is when pages are local and served from a file:// protocol. Then it works in Firefox (all versions) and Chrome 3 but not Chrome 5 (I don't have Chrome 4 so I'm not shure about that specific version (and don't know if it's even possible to download a specific Chrome version?) -- but for Chrome 5 I'm very sure it doesn't work).

    Read the article

  • Watin testing of FckEditor

    - by Iyyengar
    I have been working on the integration testing of a webapp using watin. The webapp uses fckeditor as one of the richtext controls. Here is the piece of html of the viewsource of my webapp that includes fckeditor iframe id="ctl00_HeaderMain_txtSafetyNetDescription___Frame" src="/FCKEditor/editor/fckeditor.html?InstanceName=ctl00_HeaderMain_txtSafetyNetDescription&Toolbar=myApp" width="100%" height="200px" frameborder="no" scrolling="no" /iframe By using the watin script ... i am able to get the frame object with the following code. Frame frame = ie.Frame(Find.ById("ctl00_HeaderMain_txtSafetyNetDescription___Frame")) ; Now I want to write some text to the fckeditor. But i am not sure how to write to the fckeditor as it is a frame -- can someone help me on this. Thanks. Iyyengar.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >