[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8298 - gnuradio/trunk/gr-atsc/src/lib
From: |
eb |
Subject: |
[Commit-gnuradio] r8298 - gnuradio/trunk/gr-atsc/src/lib |
Date: |
Tue, 29 Apr 2008 22:39:03 -0600 (MDT) |
Author: eb
Date: 2008-04-29 22:39:02 -0600 (Tue, 29 Apr 2008)
New Revision: 8298
Modified:
gnuradio/trunk/gr-atsc/src/lib/atsc_depad.cc
gnuradio/trunk/gr-atsc/src/lib/atsc_depad.h
Log:
Fixed completely buggy memcopy that overwrote potentially lots of memory in
atsc_depad.cc. The problem has to do with confusion between input and output
sizes, as well as some very wrong pointer math (Dan Halperin).
Modified: gnuradio/trunk/gr-atsc/src/lib/atsc_depad.cc
===================================================================
--- gnuradio/trunk/gr-atsc/src/lib/atsc_depad.cc 2008-04-30 04:37:34 UTC
(rev 8297)
+++ gnuradio/trunk/gr-atsc/src/lib/atsc_depad.cc 2008-04-30 04:39:02 UTC
(rev 8298)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -28,8 +28,6 @@
#include <gr_io_signature.h>
#include <atsc_types.h>
-static const int INTR = ATSC_MPEG_PKT_LENGTH;
-
atsc_depad_sptr
atsc_make_depad()
{
@@ -38,43 +36,26 @@
atsc_depad::atsc_depad()
: gr_sync_interpolator("atsc_depad",
- gr_make_io_signature(1, 1, sizeof(atsc_mpeg_packet)),
- gr_make_io_signature(1, 1, sizeof(unsigned char)),
- INTR)
+ gr_make_io_signature(1, 1, sizeof(atsc_mpeg_packet)),
+ gr_make_io_signature(1, 1, sizeof(unsigned char)),
+ ATSC_MPEG_PKT_LENGTH)
{
reset();
}
-void
-atsc_depad::forecast (int noutput_items, gr_vector_int &ninput_items_required)
-{
- unsigned ninputs = ninput_items_required.size();
- for (unsigned i = 0; i < ninputs; i++)
- ninput_items_required[i] = noutput_items / ATSC_MPEG_PKT_LENGTH;
-}
-
-
int
atsc_depad::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
const atsc_mpeg_packet *in = (const atsc_mpeg_packet *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
- // size with padding (256)
- unsigned int ATSC_MPEG_PKT = sizeof(atsc_mpeg_packet);
unsigned int i;
- for (i = 0; i < noutput_items/ATSC_MPEG_PKT + 1; i++){
- for (int j = 0; j < ATSC_MPEG_PKT_LENGTH; j++)
- out[i * ATSC_MPEG_PKT_LENGTH + j] = in[i * ATSC_MPEG_PKT].data[j];
-
+ for (i = 0; i < noutput_items/ATSC_MPEG_PKT_LENGTH; i++){
+ memcpy(&out[i * ATSC_MPEG_PKT_LENGTH], in[i].data, ATSC_MPEG_PKT_LENGTH);
}
return i * ATSC_MPEG_PKT_LENGTH;
}
-
-
-
-
Modified: gnuradio/trunk/gr-atsc/src/lib/atsc_depad.h
===================================================================
--- gnuradio/trunk/gr-atsc/src/lib/atsc_depad.h 2008-04-30 04:37:34 UTC (rev
8297)
+++ gnuradio/trunk/gr-atsc/src/lib/atsc_depad.h 2008-04-30 04:39:02 UTC (rev
8298)
@@ -30,8 +30,7 @@
atsc_depad_sptr atsc_make_depad();
/*!
- * \brief depad mpeg ts packets from 256 byte atsc_mpeg_packet
- * to 188 byte char
+ * \brief depad mpeg ts packets from 256 byte atsc_mpeg_packet to 188 byte char
* \ingroup atsc
*
* input: atsc_mpeg_packet; output: unsigned char
@@ -43,7 +42,6 @@
atsc_depad();
public:
- void forecast (int noutput_items, gr_vector_int &ninput_items_required);
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8298 - gnuradio/trunk/gr-atsc/src/lib,
eb <=