Skip to content

Commit

Permalink
Ffmpeg update to grab the dvb subtitle code.
Browse files Browse the repository at this point in the history
Daniel, please review the mpegts.c changes.


git-svn-id: http://svn.mythtv.org/svn/trunk@6861 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
Isaac Richards committed Jul 19, 2005
1 parent 2963075 commit aaa9372
Show file tree
Hide file tree
Showing 80 changed files with 1,410 additions and 1,148 deletions.
2 changes: 2 additions & 0 deletions mythtv/libs/libavcodec/8bps.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
dlen = be2me_16(*(unsigned short *)(lp+row*2));
/* Decode a row of this plane */
while(dlen > 0) {
if(dp + 1 >= buf+buf_size) return -1;
if ((count = *dp++) <= 127) {
count++;
dlen -= count + 1;
if (pixptr + count * px_inc > pixptr_end)
break;
if(dp + count > buf+buf_size) return -1;
while(count--) {
*pixptr = *dp++;
pixptr += px_inc;
Expand Down
82 changes: 82 additions & 0 deletions mythtv/libs/libavcodec/adpcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ static const int swf_index_tables[4][16] = {
/*5*/ { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
};

static const int yamaha_indexscale[] = {
230, 230, 230, 230, 307, 409, 512, 614,
230, 230, 230, 230, 307, 409, 512, 614
};

static const int yamaha_difflookup[] = {
1, 3, 5, 7, 9, 11, 13, 15,
-1, -3, -5, -7, -9, -11, -13, -15
};

/* end of tables */

typedef struct ADPCMChannelStatus {
Expand Down Expand Up @@ -168,6 +178,10 @@ static int adpcm_encode_init(AVCodecContext *avctx)
/* and we have 7 bytes per channel overhead */
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_YAMAHA:
avctx->frame_size = BLKSIZE * avctx->channels;
avctx->block_align = BLKSIZE;
break;
default:
return -1;
break;
Expand Down Expand Up @@ -260,6 +274,31 @@ static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, shor
return nibble;
}

static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c, short sample)
{
int i1 = 0, j1;

if(!c->step) {
c->predictor = 0;
c->step = 127;
}
j1 = sample - c->predictor;

j1 = (j1 * 8) / c->step;
i1 = abs(j1) / 2;
if (i1 > 7)
i1 = 7;
if (j1 < 0)
i1 += 8;

c->predictor = c->predictor + ((c->step * yamaha_difflookup[i1]) / 8);
CLAMP_TO_SHORT(c->predictor);
c->step = (c->step * yamaha_indexscale[i1]) >> 8;
c->step = clip(c->step, 127, 24567);

return i1;
}

static int adpcm_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, void *data)
{
Expand Down Expand Up @@ -362,6 +401,18 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
*dst++ = nibble;
}
break;
case CODEC_ID_ADPCM_YAMAHA:
n = avctx->frame_size / 2;
for (; n>0; n--) {
for(i = 0; i < avctx->channels; i++) {
int nibble;
nibble = adpcm_yamaha_compress_sample(&c->status[i], samples[i]);
nibble |= adpcm_yamaha_compress_sample(&c->status[i], samples[i+avctx->channels]) << 4;
*dst++ = nibble;
}
samples += 2 * avctx->channels;
}
break;
default:
return -1;
}
Expand Down Expand Up @@ -463,6 +514,20 @@ static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
return (short)predictor;
}

static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
{
if(!c->step) {
c->predictor = 0;
c->step = 127;
}

c->predictor += (c->step * yamaha_difflookup[nibble]) / 8;
CLAMP_TO_SHORT(c->predictor);
c->step = (c->step * yamaha_indexscale[nibble]) >> 8;
c->step = clip(c->step, 127, 24567);
return c->predictor;
}

static void xa_decode(short *out, const unsigned char *in,
ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
{
Expand Down Expand Up @@ -978,6 +1043,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx,

break;
}
case CODEC_ID_ADPCM_YAMAHA:
while (src < buf + buf_size) {
if (st) {
*samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
src[0] & 0x0F);
*samples++ = adpcm_yamaha_expand_nibble(&c->status[1],
(src[0] >> 4) & 0x0F);
} else {
*samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
src[0] & 0x0F);
*samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F);
}
src++;
}
break;
default:
return -1;
}
Expand Down Expand Up @@ -1035,5 +1116,6 @@ ADPCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
ADPCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
ADPCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
ADPCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
ADPCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);

#undef ADPCM_CODEC
5 changes: 4 additions & 1 deletion mythtv/libs/libavcodec/allcodecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,14 @@ PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);

#undef PCM_CODEC

/* subtitles */
/* subtitles */
register_avcodec(&dvdsub_decoder);
register_avcodec(&dvbsub_encoder);
register_avcodec(&dvbsub_decoder);

/* parsers */
av_register_codec_parser(&mpegvideo_parser);
Expand All @@ -578,5 +580,6 @@ PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
av_register_codec_parser(&ac3_parser);
#endif
av_register_codec_parser(&dvdsub_parser);
av_register_codec_parser(&dvbsub_parser);
}

55 changes: 48 additions & 7 deletions mythtv/libs/libavcodec/avcodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ extern "C" {
#include <sys/types.h> /* size_t */

#define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1"
#define LIBAVCODEC_BUILD 4757
#define FFMPEG_VERSION "CVS"
#define LIBAVCODEC_BUILD 4758


#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION
Expand Down Expand Up @@ -137,6 +138,7 @@ enum CodecID {
CODEC_ID_ADPCM_G726,
CODEC_ID_ADPCM_CT,
CODEC_ID_ADPCM_SWF,
CODEC_ID_ADPCM_YAMAHA,

/* AMR */
CODEC_ID_AMR_NB= 0x12000,
Expand Down Expand Up @@ -285,6 +287,16 @@ enum AVRounding {
AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
};

enum AVDiscard{
//we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames)
AVDISCARD_NONE =-16, ///< discard nothing
AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
AVDISCARD_NONREF = 8, ///< discard all non reference
AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
AVDISCARD_ALL = 48, ///< discard all
};

typedef struct RcOverride{
int start_frame;
int end_frame;
Expand Down Expand Up @@ -859,6 +871,7 @@ typedef struct AVCodecContext {

/**
* hurry up amount.
* deprecated in favor of skip_idct and skip_frame
* - encoding: unused
* - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
*/
Expand Down Expand Up @@ -1809,13 +1822,33 @@ typedef struct AVCodecContext {
*/
int me_penalty_compensation;

/**
*
* - encoding: unused
* - decoding: set by user.
*/
enum AVDiscard skip_loop_filter;

/**
*
* - encoding: unused
* - decoding: set by user.
*/
enum AVDiscard skip_idct;

/**
*
* - encoding: unused
* - decoding: set by user.
*/
enum AVDiscard skip_frame;

/**
* XVMC_VLD (VIA CLE266) Hardware MPEG decoding
* - encoding: forbidden
* - decoding: set by decoder
*/
int xvmc_vld_hwslice;

} AVCodecContext;


Expand Down Expand Up @@ -1905,18 +1938,23 @@ typedef struct AVPaletteControl {

} AVPaletteControl;

typedef struct AVSubtitle {
uint16_t format; /* 0 = graphics */
typedef struct AVSubtitleRect {
uint16_t x;
uint16_t y;
uint16_t w;
uint16_t h;
uint16_t nb_colors;
uint32_t start_display_time; /* relative to packet pts, in ms */
uint32_t end_display_time; /* relative to packet pts, in ms */
int linesize;
uint32_t *rgba_palette;
uint8_t *bitmap;
} AVSubtitleRect;

typedef struct AVSubtitle {
uint16_t format; /* 0 = graphics */
uint32_t start_display_time; /* relative to packet pts, in ms */
uint32_t end_display_time; /* relative to packet pts, in ms */
uint32_t num_rects;
AVSubtitleRect *rects;
} AVSubtitle;

extern AVCodec ac3_encoder;
Expand Down Expand Up @@ -2096,6 +2134,7 @@ PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);

#undef PCM_CODEC

Expand All @@ -2110,6 +2149,7 @@ extern AVCodec dts_decoder;
/* subtitles */
extern AVCodec dvdsub_decoder;
extern AVCodec dvbsub_encoder;
extern AVCodec dvbsub_decoder;

/* resample.c */

Expand Down Expand Up @@ -2365,6 +2405,7 @@ extern AVCodecParser pnm_parser;
extern AVCodecParser mpegaudio_parser;
extern AVCodecParser ac3_parser;
extern AVCodecParser dvdsub_parser;
extern AVCodecParser dvbsub_parser;

/* memory */
void *av_malloc(unsigned int size);
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libavcodec/cinepak.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ static int cinepak_decode_strip (CinepakContext *s,
while ((data + 4) <= eod) {
chunk_id = BE_16 (&data[0]);
chunk_size = BE_16 (&data[2]) - 4;
if(chunk_size < 0)
return -1;

data += 4;
chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;

Expand Down
Loading

0 comments on commit aaa9372

Please sign in to comment.