mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
Origin commit data
------------------
Branch: master
Commit: 9d4502b7fe
Author: martii <m4rtii@gmx.de>
Date: 2013-06-10 (Mon, 10 Jun 2013)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
126 lines
3.3 KiB
C
126 lines
3.3 KiB
C
/*
|
|
* LinuxDVB Output handling.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
|
|
/* ***************************** */
|
|
/* Includes */
|
|
/* ***************************** */
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/ioctl.h>
|
|
#include <linux/dvb/video.h>
|
|
#include <linux/dvb/audio.h>
|
|
#include <memory.h>
|
|
#include <asm/types.h>
|
|
#include <pthread.h>
|
|
#include <errno.h>
|
|
|
|
#include "common.h"
|
|
#include "output.h"
|
|
#include "debug.h"
|
|
#include "stm_ioctls.h"
|
|
#include "misc.h"
|
|
|
|
/* ***************************** */
|
|
/* Makros/Constants */
|
|
/* ***************************** */
|
|
|
|
/* ***************************** */
|
|
/* Types */
|
|
/* ***************************** */
|
|
|
|
/* ***************************** */
|
|
/* Varaibles */
|
|
/* ***************************** */
|
|
|
|
/* ***************************** */
|
|
/* Prototypes */
|
|
/* ***************************** */
|
|
|
|
/* ***************************** */
|
|
/* MISC Functions */
|
|
/* ***************************** */
|
|
|
|
void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
|
|
{
|
|
unsigned int bit_buf;
|
|
unsigned int bit_left;
|
|
|
|
bit_buf = ld->BitBuffer;
|
|
bit_left = ld->Remaining;
|
|
|
|
#ifdef DEBUG_PUTBITS
|
|
if (ld->debug)
|
|
dprintf("code = %d, length = %d, bit_buf = 0x%x, bit_left = %d\n", code, length, bit_buf, bit_left);
|
|
#endif /* DEBUG_PUTBITS */
|
|
|
|
if (length < bit_left)
|
|
{
|
|
/* fits into current buffer */
|
|
bit_buf = (bit_buf << length) | code;
|
|
bit_left -= length;
|
|
}
|
|
else
|
|
{
|
|
/* doesn't fit */
|
|
bit_buf <<= bit_left;
|
|
bit_buf |= code >> (length - bit_left);
|
|
ld->Ptr[0] = (char)(bit_buf >> 24);
|
|
ld->Ptr[1] = (char)(bit_buf >> 16);
|
|
ld->Ptr[2] = (char)(bit_buf >> 8);
|
|
ld->Ptr[3] = (char)bit_buf;
|
|
ld->Ptr += 4;
|
|
length -= bit_left;
|
|
bit_buf = code & ((1 << length) - 1);
|
|
bit_left = 32 - length;
|
|
bit_buf = code;
|
|
}
|
|
|
|
#ifdef DEBUG_PUTBITS
|
|
if (ld->debug)
|
|
dprintf("bit_left = %d, bit_buf = 0x%x\n", bit_left, bit_buf);
|
|
#endif /* DEBUG_PUTBITS */
|
|
|
|
/* writeback */
|
|
ld->BitBuffer = bit_buf;
|
|
ld->Remaining = bit_left;
|
|
}
|
|
|
|
void FlushBits(BitPacker_t * ld)
|
|
{
|
|
ld->BitBuffer <<= ld->Remaining;
|
|
while (ld->Remaining < 32)
|
|
{
|
|
#ifdef DEBUG_PUTBITS
|
|
if (ld->debug)
|
|
dprintf("flushing 0x%2.2x\n", ld->BitBuffer >> 24);
|
|
#endif /* DEBUG_PUTBITS */
|
|
*ld->Ptr++ = ld->BitBuffer >> 24;
|
|
ld->BitBuffer <<= 8;
|
|
ld->Remaining += 8;
|
|
}
|
|
ld->Remaining = 32;
|
|
ld->BitBuffer = 0;
|
|
}
|