~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/render/renderer-null.cc

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 /*
  2  * renderer-null.cc --
  3  *
  4  *      A null renderer: it acts as a frame sink.
  5  *
  6  *      This object (Renderer/Null in Otcl, NullRenderer in C++) is 
  7  *      interesting for two reasons. The first one is to provide an 
  8  *      easy-to-interface renderer for the simple-video-rx script. 
  9  *      All decoder require having a renderer after them, and interfacing 
 10  *      a video window renderer made the script too complicated for 
 11  *      docent purposes. Secondly, it's a good place to look for in 
 12  *      case you need to create a Renderer object that wants to process 
 13  *      the incoming frames in a different way than displaying them. In 
 14  *      this case you should modify NullRenderer::recv() to add your own 
 15  *      processing
 16  *
 17  * Copyright (c) 2001-2002 The Regents of the University of California.
 18  * All rights reserved.
 19  *
 20  * Redistribution and use in source and binary forms, with or without
 21  * modification, are permitted provided that the following conditions are met:
 22  *
 23  * A. Redistributions of source code must retain the above copyright notice,
 24  *    this list of conditions and the following disclaimer.
 25  * B. Redistributions in binary form must reproduce the above copyright notice,
 26  *    this list of conditions and the following disclaimer in the documentation
 27  *    and/or other materials provided with the distribution.
 28  * C. Neither the names of the copyright holders nor the names of its
 29  *    contributors may be used to endorse or promote products derived from this
 30  *    software without specific prior written permission.
 31  *
 32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
 33  * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 34  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 35  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
 36  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 37  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 38  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 39  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 40  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 41  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 42  * POSSIBILITY OF SUCH DAMAGE.
 43  */
 44 
 45 
 46 #include <stdlib.h>
 47 #include "render/renderer.h"
 48 #include "render/vw.h"
 49 #include "render/rv.h"
 50 
 51 #include "tclcl.h"
 52 #include "codec/module.h"
 53 #include "codec/postdct.h"
 54 
 55 
 56 class NullRenderer : public Renderer {
 57         public:
 58                 inline NullRenderer() {};
 59 //inline NullRenderer() {printf ("NullRenderer::NullRenderer()\n");};
 60                 virtual int command(int argc, const char*const* argv);
 61         protected:
 62                 virtual void recv(Buffer*);
 63                 virtual void recv(Buffer*, int, int);
 64                 virtual void resize(int w, int h);
 65                 virtual void render(const u_char* /*frm*/, int /*off*/,
 66                                 int /*x*/, int /*w*/, int /*h*/) {};
 67                 virtual void push(const u_char* /*frm*/, int /*miny*/,
 68                                 int /*maxy*/, int /*minx*/, int /*maxx*/) {};
 69 };
 70 
 71 
 72 int NullRenderer::command (int argc, const char*const* argv) {
 73         if (argc == 3) {
 74                 if (strcmp(argv[1], "irthresh") == 0) {
 75                         //int irthresh_ = atoi(argv[2]);
 76                         return (TCL_OK);
 77                 }
 78         }
 79         return (Renderer::command(argc, argv));
 80 }
 81 
 82 void NullRenderer::recv (Buffer* bp) {
 83         recv(bp, CODEC_ANY, 0);
 84 }
 85 
 86 void NullRenderer::recv (Buffer* bp, int /* codec */, int /* quality */) {
 87         const VideoFrame* vf = (VideoFrame*)bp;
 88         if (!samesize(vf))
 89                 resize(vf->width_, vf->height_);
 90         //YuvFrame* p = (YuvFrame*)vf;
 91 
 92         // we could want to print something about the frame
 93         //printf ("frame with timestamp %i, size %i x %i\n", 
 94         //              p->ts_, p->width_, p->height_);
 95         return;
 96 }
 97 
 98 void NullRenderer::resize (int w, int h) {
 99         // print something about the frame
100         printf ("resizing to %ix%i\n", w, h);
101 
102         width_ = w;
103         height_ = h;
104         return;
105 }
106 
107 
108 static class NullRendererClass : public TclClass {
109 public:
110         NullRendererClass() : TclClass("Renderer/Null") {}
111   TclObject* create(int argc, const char*const* /* argv */) {
112                 if (argc != 4)
113                                 abort();
114                 return (new NullRenderer());
115         }
116 } nullrenderer_class;
117 
118 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.