home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / LINUX / gopchop-1.1.7.tar.tar / gopchop-1.1.7.tar / gopchop-1.1.7 / src / GroupOfPictures.cpp < prev    next >
C/C++ Source or Header  |  2005-05-02  |  4KB  |  147 lines

  1. /*
  2. #
  3. # Defines a Vector-based (so List can list it) way to track the packet
  4. # bounds associated with a GOP (and retain the GOP header)
  5. #
  6. # $Id: GroupOfPictures.cpp,v 1.11 2005/05/02 04:45:56 keescook Exp $
  7. #
  8. # Copyright (C) 2001-2003 Kees Cook
  9. # kees@outflux.net, http://outflux.net/
  10. # This program is free software; you can redistribute it and/or
  11. # modify it under the terms of the GNU General Public License
  12. # as published by the Free Software Foundation; either version 2
  13. # of the License, or (at your option) any later version.
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU General Public License for more details.
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21. # http://www.gnu.org/copyleft/gpl.html
  22. #
  23. */
  24.  
  25. #include "GOPchop.h"
  26. #include "GroupOfPictures.h"
  27. #include <stdio.h>
  28. #include <string.h>
  29.  
  30. GroupOfPictures::GroupOfPictures(Vector * head):Vector(0, 0)
  31. {
  32.     // FIXME: I'd sure like to use the Vector to store the header info...
  33.     header = head;
  34.  
  35.     packets = new Bounds();
  36.     pictures = new Bounds();
  37.  
  38.     // set up sequence info as "unknown"
  39.     memset(&info,0,sizeof(info));
  40.     contains_sequence_info = false;
  41.     memset(&sequence_head,0,sizeof(sequence_head));
  42. }
  43.  
  44. GroupOfPictures::~GroupOfPictures()
  45. {
  46.     delete header;
  47.     delete packets;
  48.     delete pictures;
  49. }
  50.  
  51. Bounds *GroupOfPictures::getPacketBounds()
  52. {
  53.     return packets;
  54. }
  55.  
  56. Bounds *GroupOfPictures::getPictureBounds()
  57. {
  58.     return pictures;
  59. }
  60.  
  61. Vector *GroupOfPictures::getHeader()
  62. {
  63.     return header;
  64. }
  65.  
  66. bool GroupOfPictures::has_sequence_info()
  67. {
  68.     return contains_sequence_info;
  69. }
  70.  
  71. void GroupOfPictures::get_sequence_info(struct sequence_info * output)
  72. {
  73.     if (!output) return;
  74.  
  75.     *output=info;
  76. }
  77.  
  78. void GroupOfPictures::set_sequence_info(struct sequence_info * input)
  79. {
  80.     if (!input) return;
  81.  
  82.     info=*input;
  83.     contains_sequence_info = true;
  84. }
  85.  
  86. void GroupOfPictures::get_sequence_header(sequence_header * output)
  87. {
  88.     if (!output) return;
  89.  
  90.     *output=sequence_head;
  91. }
  92.  
  93. void GroupOfPictures::set_sequence_header(sequence_header * input)
  94. {
  95.     if (!input) return;
  96.  
  97.     sequence_head=*input;
  98. }
  99.  
  100. char *GroupOfPictures::strTimeCode()
  101. {
  102.     static char buf[32];
  103.  
  104.     snprintf(buf, 31, "%02d:%02d:%02d.%02d", hours, mins, secs, pics);
  105.     buf[31] = '\0';
  106.  
  107.     return buf;
  108. }
  109.  
  110. void GroupOfPictures::updateTimeCode()
  111. {
  112. #if 0
  113.     uint8_t *area;
  114.  
  115.     if (!(area = bytesAvail(head_vector->getStart(), 8)))
  116.     {
  117.         printf("%s", _("GOP header not available?!\n"));
  118.         goto failure;
  119.     }
  120.  
  121.     // calculate GOP information
  122.     /*
  123.        4         5         6        7
  124.        |         |        |         |
  125.        7 65432 107654 3 210765 432107 6 543210
  126.        1 11111 111111 1 111111 111111 1 1
  127.        d hour  min    m sec    pic    c b
  128.        r              a               l roken
  129.        o              r               osed
  130.        p              k
  131.      */
  132.     drop = ((head[4] & 0x80) > 0);
  133.     hour = ((head[4] & 0x7C) >> 2);
  134.     min = ((head[4] & 0x3) << 4) | ((head[5] & 0xF0) >> 4);
  135.     sec = ((head[5] & 0x7) << 3) | ((head[6] & 0xE0) >> 6);
  136.     pictures = ((head[6] & 0x3F) << 1) | ((head[7] & 0x80) >> 7);
  137.     closed = ((head[7] & 0x40) > 0);
  138.     broken = ((head[7] & 0x20) > 0);
  139.  
  140. #endif
  141. }
  142.  
  143. /* vi:set ai ts=4 sw=4 expandtab: */
  144.