FFmpeg
Loading...
Searching...
No Matches
jpegapp.c File Reference
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/error.h"
#include "libavutil/file_open.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavcodec/bsf.h"
#include "libavcodec/bsf_internal.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/mjpeg.h"

Go to the source code of this file.

Data Structures

struct  JPEGAppContext
 

Macros

#define JPEGAPP_MAX_RECORD   (16 * 1024 * 1024)
 Sidecar format (big-endian), one record per encoded JPEG packet:
 
#define OFFSET(x)
 
#define FLAGS   (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_BSF_PARAM)
 

Functions

static int jpeg_app_segment_len (const uint8_t *data, int size)
 
static int jpegapp_validate_payload (const uint8_t *data, int size)
 
static int jpegapp_init (AVBSFContext *ctx)
 
static int jpegapp_read_record (AVBSFContext *ctx, int *out_size)
 
static int jpegapp_filter (AVBSFContext *ctx, AVPacket *out)
 

Variables

static const AVOption jpegapp_options []
 
static const AVClass jpegapp_class
 
static enum AVCodecID jpegapp_codec_ids []
 
const FFBitStreamFilter ff_jpegapp_bsf
 

Macro Definition Documentation

◆ JPEGAPP_MAX_RECORD

#define JPEGAPP_MAX_RECORD   (16 * 1024 * 1024)

Sidecar format (big-endian), one record per encoded JPEG packet:

u32be length u8 payload[length]

Payload is zero or more complete JPEG APP segments (APP0..APP15), each FF En + 16-bit length (length includes those two bytes). A zero length leaves the packet unchanged.

After SOI the payload is inserted. If it starts with APP0 and the two bytes immediately after SOI are an APP0 marker, that segment is dropped so the sidecar can replace it. An APP0 preceded by fill bytes or another segment is retained. An APP1-only payload keeps the encoder APP0: SOI, APP1, APP0, DQT, ...

A sidecar read or validation error stops further record consumption for this filter context. Flushing does not clear that error.

Definition at line 62 of file jpegapp.c.

Referenced by jpegapp_read_record().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 217 of file jpegapp.c.

◆ FLAGS

Definition at line 218 of file jpegapp.c.

Function Documentation

◆ jpeg_app_segment_len()

static int jpeg_app_segment_len ( const uint8_t * data,
int size )
static

Definition at line 73 of file jpegapp.c.

Referenced by jpegapp_filter(), and jpegapp_validate_payload().

◆ jpegapp_validate_payload()

static int jpegapp_validate_payload ( const uint8_t * data,
int size )
static

Definition at line 85 of file jpegapp.c.

Referenced by jpegapp_read_record().

◆ jpegapp_init()

static int jpegapp_init ( AVBSFContext * ctx)
static

Definition at line 98 of file jpegapp.c.

◆ jpegapp_read_record()

static int jpegapp_read_record ( AVBSFContext * ctx,
int * out_size )
static

Definition at line 112 of file jpegapp.c.

Referenced by jpegapp_filter().

◆ jpegapp_filter()

static int jpegapp_filter ( AVBSFContext * ctx,
AVPacket * out )
static

Definition at line 149 of file jpegapp.c.

Variable Documentation

◆ jpegapp_options

const AVOption jpegapp_options[]
static
Initial value:
= {
{ "sidecar", "sidecar of u32be-length + APP-segment records", OFFSET(sidecar),
{ NULL },
}
#define FLAGS
Definition cmdutils.c:596
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_BINARY
Underlying C type is a uint8_t* that is either NULL or points to an array allocated with the av_mallo...
Definition opt.h:285

Definition at line 219 of file jpegapp.c.

◆ jpegapp_class

const AVClass jpegapp_class
static
Initial value:
= {
.class_name = "jpegapp",
.item_name = av_default_item_name,
.option = jpegapp_options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:247
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static const AVOption jpegapp_options[]
Definition jpegapp.c:219

Definition at line 225 of file jpegapp.c.

◆ jpegapp_codec_ids

enum AVCodecID jpegapp_codec_ids[]
static
Initial value:
= {
}
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_MJPEG
Definition codec_id.h:57

Definition at line 232 of file jpegapp.c.

◆ ff_jpegapp_bsf

const FFBitStreamFilter ff_jpegapp_bsf
Initial value:
= {
.p.name = "jpegapp",
.p.codec_ids = jpegapp_codec_ids,
.p.priv_class = &jpegapp_class,
.priv_data_size = sizeof(JPEGAppContext),
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static int jpegapp_init(AVBSFContext *ctx)
Definition jpegapp.c:98
static int jpegapp_filter(AVBSFContext *ctx, AVPacket *out)
Definition jpegapp.c:149
static const AVClass jpegapp_class
Definition jpegapp.c:225
static enum AVCodecID jpegapp_codec_ids[]
Definition jpegapp.c:232
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29

Definition at line 236 of file jpegapp.c.