in this case, frames has a very specific meaning, which will be detailed once i finish writing the code
545248
function toWebM(frames, outputAsArray){
		var info = checkFrames(frames);

		//max duration by cluster in milliseconds
		var CLUSTER_MAX_DURATION = 30000;

		var EBML = [
			{
				"id": 0x1a45dfa3, // EBML
				"data": [
					{
						"data": 1,
						"id": 0x4286 // EBMLVersion
					},
					{
						"data": 1,
						"id": 0x42f7 // EBMLReadVersion
					},
					{
						"data": 4,
						"id": 0x42f2 // EBMLMaxIDLength
					},
					{
						"data": 8,
						"id": 0x42f3 // EBMLMaxSizeLength
					},
					{
						"data": "webm",
						"id": 0x4282 // DocType
					},
					{
						"data": 2,
						"id": 0x4287 // DocTypeVersion
					},
					{
						"data": 2,
						"id": 0x4285 // DocTypeReadVersion
					}
				]
			},
			{
				"id": 0x18538067, // Segment
				"data": [
					{
						"id": 0x1549a966, // Info
						"data": [
							{
								"data": 1e6, //do things in millisecs (num of nanosecs for duration scale)
								"id": 0x2ad7b1 // TimecodeScale
							},
							{
								"data": "whammy",
								"id": 0x4d80 // MuxingApp
							},
							{
								"data": "whammy",
								"id": 0x5741 // WritingApp
							},
							{
								"data": doubleToString(info.duration),
								"id": 0x4489 // Duration
							}
						]
					},
					{
						"id": 0x1654ae6b, // Tracks
						"data": [
							{
								"id": 0xae, // TrackEntry
								"data": [
									{
										"data": 1,
										"id": 0xd7 // TrackNumber
									},
									{
										"data": 1,
										"id": 0x73c5 // TrackUID
									},
									{
										"data": 0,
										"id": 0x9c // FlagLacing
									},
									{
										"data": "und",
										"id": 0x22b59c // Language
									},
									{
										"data": "V_VP8",
										"id": 0x86 // CodecID
									},
									{
										"data": "VP8",
										"id": 0x258688 // CodecName
									},
									{
										"data": 1,
										"id": 0x83 // TrackType
									},
									{
										"id": 0xe0,  // Video
										"data": [
											{
												"data": info.width,
												"id": 0xb0 // PixelWidth
											},
											{
												"data": info.height,
												"id": 0xba // PixelHeight
											}
										]
									}
								]
							}
						]
					},
					{
						"id": 0x1c53bb6b, // Cues
						"data": [
							//cue insertion point
						]
					}

					//cluster insertion point
				]
			}
		 ];


		var segment = EBML[1];
		var cues = segment.data[2];

		//Generate clusters (max duration)
		var frameNumber = 0;
		var clusterTimecode = 0;
		while(frameNumber < frames.length){

			var cuePoint = {
					"id": 0xbb, // CuePoint
					"data": [
						{
							"data": Math.round(clusterTimecode),
							"id": 0xb3 // CueTime
						},
						{
							"id": 0xb7, // CueTrackPositions
							"data": [
								{
									"data": 1,
									"id": 0xf7 // CueTrack
								},
								{
									"data": 0, // to be filled in when we know it
									"size": 8,
									"id": 0xf1 // CueClusterPosition
								}
							]
						}
					]
				};

			cues.data.push(cuePoint);

			var clusterFrames = [];
			var clusterDuration = 0;
			do {
				clusterFrames.push(frames[frameNumber]);
				clusterDuration += frames[frameNumber].duration;
				frameNumber++;
			}while(frameNumber < frames.length && clusterDuration < CLUSTER_MAX_DURATION);

			var clusterCounter = 0;
			var cluster = {
					"id": 0x1f43b675, // Cluster
					"data": [
						{
							"data": Math.round(clusterTimecode),
							"id": 0xe7 // Timecode
						}
					].concat(clusterFrames.map(function(webp){
						var block = makeSimpleBlock({
							discardable: 0,
							frame: webp.data.slice(4),
							invisible: 0,
							keyframe: 1,
							lacing: 0,
							trackNum: 1,
							timecode: Math.round(clusterCounter)
						});
						clusterCounter += webp.duration;
						return {
							data: block,
							id: 0xa3
						};
					}))
				}

			//Add cluster to segment
			segment.data.push(cluster);
			clusterTimecode += clusterDuration;
		}

		//First pass to compute cluster positions
		var position = 0;
		for(var i = 0; i < segment.data.length; i++){
			if (i >= 3) {
				cues.data[i-3].data[1].data[1].data = position;
			}
			var data = generateEBML([segment.data[i]], outputAsArray);
			position += data.size || data.byteLength || data.length;
			if (i != 2) { // not cues
				//Save results to avoid having to encode everything twice
				segment.data[i] = data;
			}
		}

		return generateEBML(EBML, outputAsArray)
	}
1333343
def render_summary(self, app, include_title=True):
        """"""
        title = ''
        frames = []
        classes = ['traceback']
        if not self.frames:
            classes.append('noframe-traceback')

        if include_title:
            if self.is_syntax_error:
                title = text_('Syntax Error')
            else:
                title = text_('Traceback <small>(most recent call last)'
                              '</small>')

        for frame in self.frames:
            txt = frame.info
            if not txt:
                txt = text_(' title="%s"' % escape(frame.info))
            if not txt:
                txt = text_('')
            frames.append(
                text_('<li%s>%s') % (txt, frame.render()))

        if self.is_syntax_error:
            description_wrapper = text_('<pre class=syntaxerror>%s</pre>')
        else:
            description_wrapper = text_('<blockquote>%s</blockquote>')
        vars = {
            'classes': text_(' '.join(classes)),
            'title': title and text_('<h3 class="traceback">%s</h3>'
                                     % title) or text_(''),
            'frames': text_('\n'.join(frames)),
            'description': description_wrapper % escape(self.exception),
        }
        return render('exception_summary.jinja2', app, vars)
608499
def generate(frame)
      bytes  = Buffer.new
      length = 0

      frame[:flags] ||= []
      frame[:stream] ||= 0

      case frame[:type]
      when :data
        bytes << frame[:payload]
        length += frame[:payload].bytesize

      when :headers
        if frame[:weight] || frame[:stream_dependency] || !frame[:exclusive].nil?
          unless frame[:weight] && frame[:stream_dependency] && !frame[:exclusive].nil?
            fail CompressionError, "Must specify all of priority parameters for #{frame[:type]}"
          end
          frame[:flags] += [:priority] unless frame[:flags].include? :priority
        end

        if frame[:flags].include? :priority
          bytes << [(frame[:exclusive] ? EBIT : 0) | (frame[:stream_dependency] & RBIT)].pack(UINT32)
          bytes << [frame[:weight] - 1].pack(UINT8)
          length += 5
        end

        bytes << frame[:payload]
        length += frame[:payload].bytesize

      when :priority
        unless frame[:weight] && frame[:stream_dependency] && !frame[:exclusive].nil?
          fail CompressionError, "Must specify all of priority parameters for #{frame[:type]}"
        end
        bytes << [(frame[:exclusive] ? EBIT : 0) | (frame[:stream_dependency] & RBIT)].pack(UINT32)
        bytes << [frame[:weight] - 1].pack(UINT8)
        length += 5

      when :rst_stream
        bytes << pack_error(frame[:error])
        length += 4

      when :settings
        if (frame[:stream]).nonzero?
          fail CompressionError, "Invalid stream ID (#{frame[:stream]})"
        end

        frame[:payload].each do |(k, v)|
          if k.is_a? Integer
            DEFINED_SETTINGS.value?(k) || next
          else
            k = DEFINED_SETTINGS[k]

            fail CompressionError, "Unknown settings ID for #{k}" if k.nil?
          end

          bytes << [k].pack(UINT16)
          bytes << [v].pack(UINT32)
          length += 6
        end

      when :push_promise
        bytes << [frame[:promise_stream] & RBIT].pack(UINT32)
        bytes << frame[:payload]
        length += 4 + frame[:payload].bytesize

      when :ping
        if frame[:payload].bytesize != 8
          fail CompressionError, "Invalid payload size (#{frame[:payload].size} != 8 bytes)"
        end
        bytes << frame[:payload]
        length += 8

      when :goaway
        bytes << [frame[:last_stream] & RBIT].pack(UINT32)
        bytes << pack_error(frame[:error])
        length += 8

        if frame[:payload]
          bytes << frame[:payload]
          length += frame[:payload].bytesize
        end

      when :window_update
        bytes << [frame[:increment] & RBIT].pack(UINT32)
        length += 4

      when :continuation
        bytes << frame[:payload]
        length += frame[:payload].bytesize

      when :altsvc
        bytes << [frame[:max_age], frame[:port]].pack(UINT32 + UINT16)
        length += 6
        if frame[:proto]
          fail CompressionError, 'Proto too long' if frame[:proto].bytesize > 255
          bytes << [frame[:proto].bytesize].pack(UINT8)
          bytes << frame[:proto].force_encoding(Encoding::BINARY)
          length += 1 + frame[:proto].bytesize
        else
          bytes << [0].pack(UINT8)
          length += 1
        end
        if frame[:host]
          fail CompressionError, 'Host too long' if frame[:host].bytesize > 255
          bytes << [frame[:host].bytesize].pack(UINT8)
          bytes << frame[:host].force_encoding(Encoding::BINARY)
          length += 1 + frame[:host].bytesize
        else
          bytes << [0].pack(UINT8)
          length += 1
        end
        if frame[:origin]
          bytes << frame[:origin]
          length += frame[:origin].bytesize
        end
      end

      # Process padding.
      #  frame[:padding] gives number of extra octets to be added.
      # - http://tools.ietf.org/html/draft-ietf-httpbis-http2-16#section-6.1
      if frame[:padding]
        unless FRAME_TYPES_WITH_PADDING.include?(frame[:type])
          fail CompressionError, "Invalid padding flag for #{frame[:type]}"
        end

        padlen = frame[:padding]

        if padlen <= 0 || padlen > 256 || padlen + length > @max_frame_size
          fail CompressionError, "Invalid padding #{padlen}"
        end

        length += padlen
        bytes.prepend([padlen -= 1].pack(UINT8))
        frame[:flags] << :padded

        # Padding:  Padding octets that contain no application semantic value.
        # Padding octets MUST be set to zero when sending and ignored when
        # receiving.
        bytes << "\0" * padlen
      end

      frame[:length] = length
      bytes.prepend(common_header(frame))
    end
505591
def dump_frames(self, frame):
        
        current_thread = threading.currentThread()
        frames = []
        frame_browser = frame
        
        # Browse the frame chain as far as we can
        _logger.f_debug("dump_frames(), frame analysis:")
        spacer = ""
        while hasattr(frame_browser, 'f_back') and frame_browser.f_back != self.frame_beginning:
            spacer += "="
            _logger.f_debug("%s>frame = %s, frame.f_code = %s, frame.f_back = %s, "
                            "self.frame_beginning = %s",
                            spacer,
                            hex(id(frame_browser)),
                            frame_browser.f_code,
                            hex(id(frame_browser.f_back)),
                            hex(id(self.frame_beginning)))

            # At root frame, globals == locals so we dump only globals
            if hasattr(frame_browser.f_back, 'f_back')\
                    and frame_browser.f_back.f_back != self.frame_beginning:
                locals_vars_list = self.extract_object_properties(frame_browser.f_locals,
                                                                  limit_size=True)
            else:
                locals_vars_list = []
                                
            globals_vars_list = self.extract_object_properties(frame_browser.f_globals,
                                                               limit_size=True)
            # normalize path sent to debugging client
            file_path = self.normalize_path_out(frame_browser.f_code.co_filename)

            frame_name = "%s() [%s]" % (frame_browser.f_code.co_name, current_thread.name,)
            remote_frame = {
                'id': id(frame_browser),
                'name': frame_name,
                'line_number': frame_browser.f_lineno,  # Warning 1 based
                'file_path': file_path,
                'f_locals': locals_vars_list + globals_vars_list,
                'thread': current_thread.ident,
                'thread_name': current_thread.name
            }
            frames.append(remote_frame)
            frame_browser = frame_browser.f_back
        return frames
1189770
private void defineInternalFrames(UIDefaults d) {
        
        // Copied from nimbus
        
        //Initialize InternalFrameTitlePane
        d.put("InternalFrameTitlePane.contentMargins", new InsetsUIResource(0, 0, 0, 0));
        d.put("InternalFrameTitlePane.maxFrameIconSize", new DimensionUIResource(18, 18));

        //Initialize InternalFrame
        d.put("InternalFrame.contentMargins", new InsetsUIResource(1, 6, 6, 6));
        d.put("InternalFrame:InternalFrameTitlePane.contentMargins", new InsetsUIResource(3, 0, 3, 0));
        d.put("InternalFrame:InternalFrameTitlePane.titleAlignment", "CENTER");
        d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.menuButton\".contentMargins", new InsetsUIResource(0, 0, 0, 0));
        d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.iconifyButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9));
        d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.maximizeButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9));
        d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.closeButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9));
        
        // Seaglass starts below
        
        if (PlatformUtils.isMac()) {
            d.put("frameBaseActive", new Color(0xa8a8a8));
        } else {
            d.put("frameBaseActive", new Color(0x96adc4));
        }

        d.put("frameBaseInactive", new Color(0xe0e0e0));

        d.put("frameBorderBase", new Color(0x545454));

        d.put("frameInnerHighlightInactive", new Color(0x55ffffff, true));
        d.put("frameInnerHighlightActive", new Color(0x55ffffff, true));

        d.put("seaGlassTitlePaneButtonEnabledBorder", new Color(0x99000000, true));
        d.put("seaGlassTitlePaneButtonEnabledCorner", new Color(0x26000000, true));
        d.put("seaGlassTitlePaneButtonEnabledInterior", new Color(0x99ffffff, true));

        d.put("seaGlassTitlePaneButtonHoverBorder", new Color(0xe5101010, true));
        d.put("seaGlassTitlePaneButtonHoverCorner", new Color(0x267a7a7a, true));
        d.put("seaGlassTitlePaneButtonHoverInterior", new Color(0xffffff));

        d.put("seaGlassTitlePaneButtonPressedBorder", new Color(0xe50e0e0e, true));
        d.put("seaGlassTitlePaneButtonPressedCorner", new Color(0x876e6e6e, true));
        d.put("seaGlassTitlePaneButtonPressedInterior", new Color(0xe6e6e6));

        String p = "InternalFrame";
        String c = PAINTER_PREFIX + "FrameAndRootPainter";
        
        d.put(p + ".titleFont", new DerivedFont("defaultFont", 1.0f, true, null));

        d.put(p + ".States", "Enabled,WindowFocused");
        d.put(p + ":InternalFrameTitlePane.WindowFocused", new TitlePaneWindowFocusedState());
        d.put(p + ".WindowFocused", new InternalFrameWindowFocusedState());

        d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED));
        d.put(p + "[Enabled+WindowFocused].backgroundPainter",
              new LazyPainter(c,
                              FrameAndRootPainter.Which.BACKGROUND_ENABLED_WINDOWFOCUSED));

        p = "InternalFrameTitlePane";
        d.put(p + ".buttonSpacing", 0);

        p = "InternalFrame:InternalFrameTitlePane";
        d.put(p + "[Enabled].textForeground", d.get("seaGlassDisabledText"));
        d.put(p + "[WindowFocused].textForeground", Color.BLACK);
    }
776399
function(){
            
                /*
                 * keyframes:
                 *   : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' {
                 *   ;
                 */
                var tokenStream = this._tokenStream,
                    token,
                    tt,
                    name;            
                    
                tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
                this._readWhitespace();
                name = this._keyframe_name();
                
                this._readWhitespace();
                tokenStream.mustMatch(Tokens.LBRACE);
                    
                this.fire({
                    type:   "startkeyframes",
                    name:   name,
                    line:   name.line,
                    col:    name.col
                });                
                
                this._readWhitespace();
                tt = tokenStream.peek();
                
                //check for key
                while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) {
                    this._keyframe_rule();
                    this._readWhitespace();
                    tt = tokenStream.peek();
                }           
                
                this.fire({
                    type:   "endkeyframes",
                    name:   name,
                    line:   name.line,
                    col:    name.col
                });                      
                    
                this._readWhitespace();
                tokenStream.mustMatch(Tokens.RBRACE);                    
                
            }
92330
def frame_info(self):
        """"""
        if not self._logger.isEnabledFor(logging.DEBUG):
            return ''
        f = sys._getframe(3)
        fname = os.path.split(f.f_code.co_filename)[1]
        return '{}:{}'.format(fname, f.f_lineno)
1359407
private void visitFrame(final Frame f) {
        int i, t;
        int nTop = 0;
        int nLocal = 0;
        int nStack = 0;
        int[] locals = f.inputLocals;
        int[] stacks = f.inputStack;
        // computes the number of locals (ignores TOP types that are just after
        // a LONG or a DOUBLE, and all trailing TOP types)
        for (i = 0; i < locals.length; ++i) {
            t = locals[i];
            if (t == Frame.TOP) {
                ++nTop;
            } else {
                nLocal += nTop + 1;
                nTop = 0;
            }
            if (t == Frame.LONG || t == Frame.DOUBLE) {
                ++i;
            }
        }
        // computes the stack size (ignores TOP types that are just after
        // a LONG or a DOUBLE)
        for (i = 0; i < stacks.length; ++i) {
            t = stacks[i];
            ++nStack;
            if (t == Frame.LONG || t == Frame.DOUBLE) {
                ++i;
            }
        }
        // visits the frame and its content
        startFrame(f.owner.position, nLocal, nStack);
        for (i = 0; nLocal > 0; ++i, --nLocal) {
            t = locals[i];
            frame[frameIndex++] = t;
            if (t == Frame.LONG || t == Frame.DOUBLE) {
                ++i;
            }
        }
        for (i = 0; i < stacks.length; ++i) {
            t = stacks[i];
            frame[frameIndex++] = t;
            if (t == Frame.LONG || t == Frame.DOUBLE) {
                ++i;
            }
        }
        endFrame();
    }
111547
public void writeFrame(byte[] frame) throws IOException {
        lastUsedTime = System.currentTimeMillis();
        out.write(frame);
        out.flush();
    }
791110
function(frame, frameSize) {
    const opcode = encoders.opcode('PROCESS_FRAME');

    const time = new Float64Array(1);
    time[0] = frame.time;

    const data = new Float32Array(frameSize);
    for (let i = 0; i < frameSize; i++)
      data[i] = frame.data[i];

    const metadata = json2Uint16Array(frame.metadata);

    const length = 1 + 4 + (2 * frameSize) + metadata.length;
    const payload = new Uint16Array(length);
    payload.set(opcode, 0);
    payload.set(new Uint16Array(time.buffer), 1);
    payload.set(new Uint16Array(data.buffer), 1 + 4);
    payload.set(metadata, 1 + 4 + (2 * frameSize));

    return payload.buffer;
  }
112535
function checkFrames(frames){
		var width = frames[0].width,
			height = frames[0].height,
			duration = frames[0].duration;
		for(var i = 1; i < frames.length; i++){
			if(frames[i].width != width) throw "Frame " + (i + 1) + " has a different width";
			if(frames[i].height != height) throw "Frame " + (i + 1) + " has a different height";
			if(frames[i].duration < 0 || frames[i].duration > 0x7fff) throw "Frame " + (i + 1) + " has a weird duration (must be between 0 and 32767)";
			duration += frames[i].duration;
		}
		return {
			duration: duration,
			width: width,
			height: height
		};
	}
75176
private void encode(byte[] frame, int[] limits) {
    JSType.setCount(frame, limits, indices.length);
    for (int i = 0; i < indices.length; i++)
      JSType.setCount(frame, limits, indices[i]);
    JSType.setCount(frame, limits, varBias);
    JSType.setCount(frame, limits, setCases.length);
    for (int i = 0; i < setCases.length; i++) {
      int[] cases = setCases[i];
      if (cases == null)
        JSType.setCount(frame, limits, -1);
      else {
        JSType.setCount(frame, limits, cases.length);
        for (int j = 0; j < cases.length; j++)
          JSType.setCount(frame, limits, cases[j]);
      }
    }
    JSType.setCount(frame, limits, getCases.length);
    for (int i = 0; i < getCases.length; i++) {
      int[] cases = getCases[i];
      if (cases == null)
        JSType.setCount(frame, limits, -1);
      else {
        JSType.setCount(frame, limits, cases.length);
        for (int j = 0; j < cases.length; j++)
          JSType.setCount(frame, limits, cases[j]);
      }
    }
  }
639255
function getFrameLocation(stackFrame) {
  var frameString = stackFrame.toString()
  var lastParenIndex = frameString.lastIndexOf('(')
  return lastParenIndex === -1 ? frameString : frameString.slice(lastParenIndex + 1, -1)
}
34903
function() {
        var factory = this.viewFactory;

        this._addChildren([
            factory.createFrame(frameConst.L),
            factory.createFrame(frameConst.R)
        ]);
    }
506435
private void getBodyFromFrame() {
        if (dataPayload == null) {
            dataPayload = new ArrayList<byte[]>();
        }
        if (currentFrame.getFrameType() == FrameTypes.DATA) {
            dataPayload.add(((FrameData) currentFrame).getData());
        }
    }
865772
def get_outer_frame_variables():
    
    cur_filename = inspect.getframeinfo(inspect.currentframe()).filename
    outer_frame = next(f
                       for f in inspect.getouterframes(inspect.currentframe())
                       if f.filename != cur_filename)
    variables = {}
    variables.update(outer_frame.frame.f_globals)
    variables.update(outer_frame.frame.f_locals)
    return variables
597836
def render_summary(self, include_title=True, request=None):
        """"""
        title = ''
        frames = []
        classes = ['traceback']
        if not self.frames:
            classes.append('noframe-traceback')

        if include_title:
            if self.is_syntax_error:
                title = text_('Syntax Error')
            else:
                title = text_('Traceback <small>(most recent call last)'
                              '</small>')

        for frame in self.frames:
            frames.append(
                text_('<li%s>%s') % (
                    frame.info and text_(' title="%s"' % escape(frame.info)) or
                    text_(''),
                    frame.render()
                ))

        if self.is_syntax_error:
            description_wrapper = text_('<pre class=syntaxerror>%s</pre>')
        else:
            description_wrapper = text_('<blockquote>%s</blockquote>')

        vars = {
            'classes': text_(' '.join(classes)),
            'title': title and text_('<h3 class="traceback">%s</h3>'
                                     % title) or text_(''),
            'frames': text_('\n'.join(frames)),
            'description': description_wrapper % escape(self.exception),
        }
        app = request.app
        template = app.ps.jinja2.env.get_template('debugtoolbar/exception_summary.html')
        return template.render(app=app, request=request, **vars)