Attempt to add MJPEG support

This commit is contained in:
samsamsam
2019-02-02 18:53:58 +01:00
committed by Thilo Graf
parent a3e9180edd
commit 32bc62a65b
7 changed files with 157 additions and 1 deletions

View File

@@ -52,6 +52,7 @@ SOURCE_FILES += \
output/writer/mipsel/h265.c \
output/writer/mipsel/h264.c \
output/writer/mipsel/h263.c \
output/writer/mipsel/mjpeg.c \
output/writer/mipsel/mpeg2.c \
output/writer/mipsel/mpeg4.c \
output/writer/mipsel/divx3.c \

View File

@@ -306,7 +306,9 @@ static char *Codec2Encoding(int32_t codec_id, int32_t media_type, uint8_t *extra
case AV_CODEC_ID_MPEG1VIDEO:
return "V_MPEG1";
case AV_CODEC_ID_MPEG2VIDEO:
return "V_MPEG1";
return "V_MPEG2";
case AV_CODEC_ID_MJPEG:
return "V_MJPEG";
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
case AV_CODEC_ID_H263I:

View File

@@ -55,6 +55,7 @@ typedef enum
STREAMTYPE_DIVX5 = 15,
STREAMTYPE_VB6 = 18,
STREAMTYPE_SPARK = 21,
STREAMTYPE_MJPEG = 30,
} video_stream_type_t;

View File

@@ -527,4 +527,22 @@
#define wmv_err(...) log_error(__VA_ARGS__)
#else
#define wmv_err(...)
#endif
/*******************************************
* mjpeg
*******************************************/
#define MJPEG_DEBUG_LEVEL 0
#define MJPEG_SILENT
#if MJPEG_DEBUG_LEVEL
#define mjpeg_printf(...) log_printf(MJPEG_DEBUG_LEVEL, __VA_ARGS__)
#else
#define mjpeg_printf(...)
#endif
#ifndef MJPEG_SILENT
#define mjpeg_err(...) log_error(__VA_ARGS__)
#else
#define mjpeg_err(...)
#endif

View File

@@ -82,6 +82,7 @@ extern Writer_t WriterVideoVP6;
extern Writer_t WriterVideoVP8;
extern Writer_t WriterVideoVP9;
extern Writer_t WriterVideoSPARK;
extern Writer_t WriterVideoMJPEG;
extern Writer_t WriterFramebuffer;
extern Writer_t WriterPipe;

View File

@@ -0,0 +1,132 @@
/*
* linuxdvb output/writer handling.
*
* konfetti 2010 based on linuxdvb.c code from libeplayer2
*
* 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 <sys/uio.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 "stm_ioctls.h"
#include "bcm_ioctls.h"
#include "common.h"
#include "output.h"
#include "debug.h"
#include "misc.h"
#include "pes.h"
#include "writer.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
static bool must_send_header = true;
static uint8_t *private_data = NULL;
static uint32_t private_size = 0;
/* ***************************** */
/* Prototypes */
/* ***************************** */
/* ***************************** */
/* MISC Functions */
/* ***************************** */
static int reset()
{
must_send_header = true;
return 0;
}
static int writeData(void *_call)
{
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
static uint8_t PesHeader[PES_MAX_HEADER_SIZE];
int32_t len = 0;
uint32_t Position = 0;
mjpeg_printf(10, "\n");
if (call == NULL)
{
mjpeg_err("call data is NULL...\n");
return 0;
}
mjpeg_printf(10, "VideoPts %lld\n", call->Pts);
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader(PesHeader, call->len, MPEG_VIDEO_PES_START_CODE, call->Pts, 0);
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
return call->WriteV(call->fd, iov, 2);;
}
/* ***************************** */
/* Writer Definition */
/* ***************************** */
static WriterCaps_t caps =
{
"mjpeg",
eVideo,
"V_MJPEG",
VIDEO_ENCODING_AUTO,
STREAMTYPE_MJPEG,
-1
};
struct Writer_s WriterVideoMJPEG =
{
&reset,
&writeData,
NULL,
&caps
};

View File

@@ -85,6 +85,7 @@ static Writer_t *AvailableWriter[] =
&WriterVideoVP9,
&WriterVideoSPARK,
&WriterVideoWMV,
&WriterVideoMJPEG,
NULL
};