~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/mpeg2enc/putbits.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2007-12-18 13:53:04 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218135304-cdqec2lg2bglyz15
Tags: 1:2.4~preview3-0.0ubuntu1
* Upload to Ubuntu. (LP: #163287, LP: #126572)
* debian/changelog: re-added Ubuntu releases.
* debian/control:
  - Require debhelper >= 5.0.51 (for dh_icons) and imagemagick.
  - Build-depend on libsdl1.2-dev instead of libsdl-dev.
  - Build against newer libx264-dev. (LP: #138854)
  - Removed libamrnb-dev, not in Ubuntu yet.
* debian/rules:
  - Install all icon sizes, using convert (upstream installs none).
  - Added missing calls to dh_installmenu, dh_installman, dh_icons and
    dh_desktop.
* debian/menu, debian/avidemux-qt.menu:
  - Corrected package and executable names.
* debian/avidemux-common.install: Install icons.
* debian/avidemux.common.manpages: Install man/avidemux.1.
* debian/links, debian/avidemux-cli.links, debian/avidemux-gtk.links:
  - Link manpages to avidemux.1.gz.
* debian/install, debian/avidemux-qt.install, debian/avidemux-gtk.desktop,
  debian/avidemux-qt.desktop: Install desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* putbits.c, bit-level output                                              */
2
 
 
3
 
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
4
 
 
5
 
/*
6
 
 * Disclaimer of Warranty
7
 
 *
8
 
 * These software programs are available to the user without any license fee or
9
 
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
10
 
 * any and all warranties, whether express, implied, or statuary, including any
11
 
 * implied warranties or merchantability or of fitness for a particular
12
 
 * purpose.  In no event shall the copyright-holder be liable for any
13
 
 * incidental, punitive, or consequential damages of any kind whatsoever
14
 
 * arising from the use of these programs.
15
 
 *
16
 
 * This disclaimer of warranty extends to the user of these programs and user's
17
 
 * customers, employees, agents, transferees, successors, and assigns.
18
 
 *
19
 
 * The MPEG Software Simulation Group does not represent or warrant that the
20
 
 * programs furnished hereunder are free of infringement of any third-party
21
 
 * patents.
22
 
 *
23
 
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
24
 
 * are subject to royalty fees to patent holders.  Many of these patents are
25
 
 * general enough such that they are unavoidable regardless of implementation
26
 
 * design.
27
 
 *
28
 
 */
29
 
/* Modifications and enhancements (C) 2000/2001 Andrew Stevens */
30
 
 
31
 
/* These modifications are free software; you can redistribute it
32
 
 *  and/or modify it under the terms of the GNU General Public License
33
 
 *  as published by the Free Software Foundation; either version 2 of
34
 
 *  the License, or (at your option) any later version.
35
 
 *
36
 
 *  This program is distributed in the hope that it will be useful,
37
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
38
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
39
 
 *  General Public License for more details.
40
 
 *
41
 
 * You should have received a copy of the GNU General Public License
42
 
 * along with this program; if not, write to the Free Software
43
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
44
 
 * 02111-1307, USA.
45
 
 *
46
 
 */
47
 
 
48
 
 
49
 
#include <config.h>
50
 
#include <stdio.h>
51
 
#include "global.h"
52
 
 
53
 
extern void ad_putchar(unsigned int outbfr);
54
 
/* private data */
55
 
static unsigned int outbfr;
56
 
 
57
 
static int outcnt;
58
 
static int64_t bytecnt;
59
 
 
60
 
/* initialize buffer, call once before first putbits or alignbits */
61
 
void initbits(void)
62
 
{
63
 
 
64
 
  outcnt = 8;
65
 
  bytecnt = BITCOUNT_OFFSET/8LL;
66
 
}
67
 
 
68
 
 
69
 
/* write rightmost n (0<=n<=32) bits of val to outfile */
70
 
void putbits(uint32_t val, int n)
71
 
{
72
 
  val = (n == 32) ? val : (val & (~(0xffffffffU << n)));
73
 
  while( n >= outcnt )
74
 
  {
75
 
          outbfr = (outbfr << outcnt ) | (val >> (n-outcnt));
76
 
          ad_putchar(outbfr);
77
 
          n -= outcnt;
78
 
          outcnt = 8;
79
 
          ++bytecnt;
80
 
  }
81
 
  if( n != 0 )
82
 
  {
83
 
          outbfr = (outbfr<<n) | val;
84
 
          outcnt -= n;
85
 
  }
86
 
}
87
 
 
88
 
/* zero bit stuffing to next byte boundary (5.2.3, 6.2.1) */
89
 
void alignbits(void)
90
 
{
91
 
  if (outcnt!=8)
92
 
    putbits(0,outcnt);
93
 
}
94
 
 
95
 
/* return total number of generated bits */
96
 
int64_t bitcount(void)
97
 
{
98
 
  return 8LL*bytecnt + (8-outcnt);
99
 
}