Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_executable (spdif-decoder
spdif-loop.c
)

SET(FFMPEG /home/sebastian/software/ffmpeg-2.6.1)
SET(FFMPEG ${CMAKE_CURRENT_SOURCE_DIR}/../ffmpeg-4.3.1)

target_include_directories (spdif-decoder
PUBLIC ${FFMPEG}
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ digital surround signal (Dolby Digital), such as an Xbox 360 S or TV, via
your PC to your 5.1 (analog) stereo. Like a digital receiver/decoder,
just in software.

FFMPEG is licenced under the GNU Lesser General Public License version 2.1 and so is
this piece of software.

Requirements
------------
- libasound2-dev
- libao-dev
- cmake
- ffmpeg from Source https://www.ffmpeg.org/download.html (tested with 2.6.2)
- ffmpeg from Source https://www.ffmpeg.org/download.html (tested with 4.3.1)

Build ffmpeg shared library with a minimal set for alsa and AC3 support
-----
Expand All @@ -21,7 +23,7 @@ Build ffmpeg shared library with a minimal set for alsa and AC3 support

Build spdif-decoder
-----
Prepare CMakeLists.txt - set FFMPEG Var with Path to ffmpeg
Prepare CMakeLists.txt - set FFMPEG Var with Path to ffmpeg (if not in ../ffmpeg-4.3.1)

cmake .
make
Expand All @@ -45,11 +47,7 @@ I had to use `amixer` to set the capture source to SPIF. In this case
amixer -c Device set 'PCM Capture Source' 'IEC958 In' # set input


Contact
-------

Sebastian Morgenstern <[email protected]>

Thanks to
-------
Sebastian Morgenstern <[email protected]>
Simon Schubert <[email protected]>
23 changes: 10 additions & 13 deletions myspdifdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@
#include <libavformat/spdif.h>
#include "myspdif.h"
#include <libavcodec/ac3.h>
#include <libavcodec/aacadtsdec.h>
#include "libavcodec/adts_parser.h"
#include "libavutil/bswap.h"

static int spdif_get_offset_and_codec(AVFormatContext *s,
enum IEC61937DataType data_type,
const uint8_t *buf, int *offset,
const char *buf, int *offset,
enum AVCodecID *codec)
{
AACADTSHeaderInfo aac_hdr;
GetBitContext gbc;
uint32_t samples;
uint8_t frames;
int ret;

switch (data_type & 0xff) {
case IEC61937_AC3:
Expand All @@ -57,13 +59,13 @@ static int spdif_get_offset_and_codec(AVFormatContext *s,
*codec = AV_CODEC_ID_MP3;
break;
case IEC61937_MPEG2_AAC:
init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8);
if (avpriv_aac_parse_header(&gbc, &aac_hdr) < 0) {
ret = av_adts_header_parse(buf, &samples, &frames);
if (ret < 0) {
if (s) /* be silent during a probe */
av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n");
return AVERROR_INVALIDDATA;
return ret;
}
*offset = aac_hdr.samples << 2;
*offset = samples << 2;
*codec = AV_CODEC_ID_AAC;
break;
case IEC61937_MPEG2_LAYER1_LSF:
Expand Down Expand Up @@ -91,11 +93,6 @@ static int spdif_get_offset_and_codec(AVFormatContext *s,
*codec = AV_CODEC_ID_DTS;
break;
default:
if (s) { /* be silent during a probe */

//avpriv_request_sample(s, "Data type 0x%04x in IEC 61937",
// data_type);
}
return AVERROR_PATCHWELCOME;
}
return 0;
Expand Down
Loading