diff --git a/mythtv/libs/libavcodec/8bps.c b/mythtv/libs/libavcodec/8bps.c index 3898ac5dd35..4d5a64e5d9e 100644 --- a/mythtv/libs/libavcodec/8bps.c +++ b/mythtv/libs/libavcodec/8bps.c @@ -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; diff --git a/mythtv/libs/libavcodec/adpcm.c b/mythtv/libs/libavcodec/adpcm.c index 0c44121d595..3c67242f41b 100644 --- a/mythtv/libs/libavcodec/adpcm.c +++ b/mythtv/libs/libavcodec/adpcm.c @@ -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 { @@ -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; @@ -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) { @@ -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; } @@ -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) { @@ -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; } @@ -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 diff --git a/mythtv/libs/libavcodec/allcodecs.c b/mythtv/libs/libavcodec/allcodecs.c index 1878d3f1f0e..07f25ea662a 100644 --- a/mythtv/libs/libavcodec/allcodecs.c +++ b/mythtv/libs/libavcodec/allcodecs.c @@ -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); @@ -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); } diff --git a/mythtv/libs/libavcodec/avcodec.h b/mythtv/libs/libavcodec/avcodec.h index af12ef37f99..cbeaa7d0813 100644 --- a/mythtv/libs/libavcodec/avcodec.h +++ b/mythtv/libs/libavcodec/avcodec.h @@ -16,8 +16,9 @@ extern "C" { #include /* 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 @@ -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, @@ -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; @@ -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 */ @@ -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; @@ -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; @@ -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 @@ -2110,6 +2149,7 @@ extern AVCodec dts_decoder; /* subtitles */ extern AVCodec dvdsub_decoder; extern AVCodec dvbsub_encoder; +extern AVCodec dvbsub_decoder; /* resample.c */ @@ -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); diff --git a/mythtv/libs/libavcodec/cinepak.c b/mythtv/libs/libavcodec/cinepak.c index 3c560fdc5f3..3b00a1605d3 100644 --- a/mythtv/libs/libavcodec/cinepak.c +++ b/mythtv/libs/libavcodec/cinepak.c @@ -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; diff --git a/mythtv/libs/libavcodec/dvbsub.c b/mythtv/libs/libavcodec/dvbsub.c index 9b52848d984..8efe8b2f981 100644 --- a/mythtv/libs/libavcodec/dvbsub.c +++ b/mythtv/libs/libavcodec/dvbsub.c @@ -225,18 +225,9 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s, q = outbuf; page_id = 1; - region_id = 0; - clut_id = 0; - object_id = 0; - if (h->nb_colors <= 4) { - /* 2 bpp, some decoders do not support it correctly */ - bpp_index = 0; - } else if (h->nb_colors <= 16) { - /* 4 bpp, standard encoding */ - bpp_index = 1; - } else { + + if (h->num_rects == 0 || h->rects == NULL) return -1; - } *q++ = 0x00; /* subtitle_stream_id */ @@ -254,108 +245,153 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s, page_state = 2; /* mode change */ /* page_version = 0 + page_state */ *q++ = s->object_version | (page_state << 2) | 3; - *q++ = region_id; - *q++ = 0xff; /* reserved */ - putbe16(&q, 0); /* left pos */ - putbe16(&q, 0); /* top pos */ + + for (region_id = 0; region_id < h->num_rects; region_id++) { + *q++ = region_id; + *q++ = 0xff; /* reserved */ + putbe16(&q, h->rects[region_id].x); /* left pos */ + putbe16(&q, h->rects[region_id].y); /* top pos */ + } putbe16(&pseg_len, q - pseg_len - 2); if (!s->hide_state) { - /* CLUT segment */ + for (clut_id = 0; clut_id < h->num_rects; clut_id++) { + + /* CLUT segment */ + + if (h->rects[clut_id].nb_colors <= 4) { + /* 2 bpp, some decoders do not support it correctly */ + bpp_index = 0; + } else if (h->rects[clut_id].nb_colors <= 16) { + /* 4 bpp, standard encoding */ + bpp_index = 1; + } else { + return -1; + } + + *q++ = 0x0f; /* sync byte */ + *q++ = 0x12; /* CLUT definition segment */ + putbe16(&q, page_id); + pseg_len = q; + q += 2; /* segment length */ + *q++ = clut_id; + *q++ = (0 << 4) | 0xf; /* version = 0 */ + + for(i = 0; i < h->rects[clut_id].nb_colors; i++) { + *q++ = i; /* clut_entry_id */ + *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1; /* 2 bits/pixel full range */ + { + int a, r, g, b; + a = (h->rects[clut_id].rgba_palette[i] >> 24) & 0xff; + r = (h->rects[clut_id].rgba_palette[i] >> 16) & 0xff; + g = (h->rects[clut_id].rgba_palette[i] >> 8) & 0xff; + b = (h->rects[clut_id].rgba_palette[i] >> 0) & 0xff; + + *q++ = RGB_TO_Y_CCIR(r, g, b); + *q++ = RGB_TO_V_CCIR(r, g, b, 0); + *q++ = RGB_TO_U_CCIR(r, g, b, 0); + *q++ = 255 - a; + } + } + + putbe16(&pseg_len, q - pseg_len - 2); + } + } + + for (region_id = 0; region_id < h->num_rects; region_id++) { + + /* region composition segment */ - *q++ = 0x0f; /* sync byte */ - *q++ = 0x12; /* CLUT definition segment */ + if (h->rects[region_id].nb_colors <= 4) { + /* 2 bpp, some decoders do not support it correctly */ + bpp_index = 0; + } else if (h->rects[region_id].nb_colors <= 16) { + /* 4 bpp, standard encoding */ + bpp_index = 1; + } else { + return -1; + } + + *q++ = 0x0f; /* sync_byte */ + *q++ = 0x11; /* segment_type */ putbe16(&q, page_id); pseg_len = q; q += 2; /* segment length */ - *q++ = clut_id; - *q++ = (0 << 4) | 0xf; /* version = 0 */ - - for(i = 0; i < h->nb_colors; i++) { - *q++ = i; /* clut_entry_id */ - *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1; /* 2 bits/pixel full range */ - { - int a, r, g, b; - a = (h->rgba_palette[i] >> 24) & 0xff; - r = (h->rgba_palette[i] >> 16) & 0xff; - g = (h->rgba_palette[i] >> 8) & 0xff; - b = (h->rgba_palette[i] >> 0) & 0xff; - - *q++ = RGB_TO_Y_CCIR(r, g, b); - *q++ = RGB_TO_V_CCIR(r, g, b, 0); - *q++ = RGB_TO_U_CCIR(r, g, b, 0); - *q++ = 255 - a; - } + *q++ = region_id; + *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */ + putbe16(&q, h->rects[region_id].w); /* region width */ + putbe16(&q, h->rects[region_id].h); /* region height */ + *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03; + *q++ = region_id; /* clut_id == region_id */ + *q++ = 0; /* 8 bit fill colors */ + *q++ = 0x03; /* 4 bit and 2 bit fill colors */ + + if (!s->hide_state) { + putbe16(&q, region_id); /* object_id == region_id */ + *q++ = (0 << 6) | (0 << 4); + *q++ = 0; + *q++ = 0xf0; + *q++ = 0; } putbe16(&pseg_len, q - pseg_len - 2); } - /* region composition segment */ - - *q++ = 0x0f; /* sync_byte */ - *q++ = 0x11; /* segment_type */ - putbe16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - *q++ = region_id; - *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */ - putbe16(&q, 720); /* region width */ - putbe16(&q, 576); /* region height */ - *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03; - *q++ = clut_id; - *q++ = 0; /* 8 bit fill colors */ - *q++ = 0x03; /* 4 bit and 2 bit fill colors */ - - if (!s->hide_state) { - putbe16(&q, object_id); - *q++ = (0 << 6) | (0 << 4) | ((h->x >> 8) & 0xf); - *q++ = h->x; - *q++ = 0xf0 | ((h->y >> 8) & 0xf); - *q++ = h->y; - } - - putbe16(&pseg_len, q - pseg_len - 2); if (!s->hide_state) { - /* Object Data segment */ + for (object_id = 0; object_id < h->num_rects; object_id++) { + /* Object Data segment */ + + if (h->rects[region_id].nb_colors <= 4) { + /* 2 bpp, some decoders do not support it correctly */ + bpp_index = 0; + } else if (h->rects[region_id].nb_colors <= 16) { + /* 4 bpp, standard encoding */ + bpp_index = 1; + } else { + return -1; + } - *q++ = 0x0f; /* sync byte */ - *q++ = 0x13; - putbe16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - - putbe16(&q, object_id); - *q++ = (s->object_version << 4) | (0 << 2) | (0 << 1) | 1; /* version = 0, - onject_coding_method, - non_modifying_color_flag */ - { - uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr; - void (*dvb_encode_rle)(uint8_t **pq, - const uint8_t *bitmap, int linesize, - int w, int h); - ptop_field_len = q; - q += 2; - pbottom_field_len = q; - q += 2; - - if (bpp_index == 0) - dvb_encode_rle = dvb_encode_rle2; - else - dvb_encode_rle = dvb_encode_rle4; - - top_ptr = q; - dvb_encode_rle(&q, h->bitmap, h->w * 2, h->w, h->h >> 1); - bottom_ptr = q; - dvb_encode_rle(&q, h->bitmap + h->w, h->w * 2, h->w, h->h >> 1); - - putbe16(&ptop_field_len, bottom_ptr - top_ptr); - putbe16(&pbottom_field_len, q - bottom_ptr); - } + *q++ = 0x0f; /* sync byte */ + *q++ = 0x13; + putbe16(&q, page_id); + pseg_len = q; + q += 2; /* segment length */ - putbe16(&pseg_len, q - pseg_len - 2); + putbe16(&q, object_id); + *q++ = (s->object_version << 4) | (0 << 2) | (0 << 1) | 1; /* version = 0, + onject_coding_method, + non_modifying_color_flag */ + { + uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr; + void (*dvb_encode_rle)(uint8_t **pq, + const uint8_t *bitmap, int linesize, + int w, int h); + ptop_field_len = q; + q += 2; + pbottom_field_len = q; + q += 2; + + if (bpp_index == 0) + dvb_encode_rle = dvb_encode_rle2; + else + dvb_encode_rle = dvb_encode_rle4; + + top_ptr = q; + dvb_encode_rle(&q, h->rects[object_id].bitmap, h->rects[object_id].w * 2, + h->rects[object_id].w, h->rects[object_id].h >> 1); + bottom_ptr = q; + dvb_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w, + h->rects[object_id].w * 2, h->rects[object_id].w, + h->rects[object_id].h >> 1); + + putbe16(&ptop_field_len, bottom_ptr - top_ptr); + putbe16(&pbottom_field_len, q - bottom_ptr); + } + + putbe16(&pseg_len, q - pseg_len - 2); + } } /* end of display set segment */ diff --git a/mythtv/libs/libavcodec/dvdsub.c b/mythtv/libs/libavcodec/dvdsub.c index af5d9aca029..3300d0d6296 100644 --- a/mythtv/libs/libavcodec/dvdsub.c +++ b/mythtv/libs/libavcodec/dvdsub.c @@ -132,11 +132,12 @@ static int decode_dvd_subtitles(AVSubtitle *sub_header, int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos; uint8_t palette[4], alpha[4]; int date; + int i; if (buf_size < 4) return -1; - sub_header->bitmap = NULL; - sub_header->rgba_palette = NULL; + sub_header->rects = NULL; + sub_header->num_rects = 0; sub_header->start_display_time = 0; sub_header->end_display_time = 0; @@ -230,30 +231,39 @@ static int decode_dvd_subtitles(AVSubtitle *sub_header, if (h < 0) h = 0; if (w > 0 && h > 0) { - av_freep(&sub_header->bitmap); - av_freep(&sub_header->rgba_palette); + if (sub_header->rects != NULL) { + for (i = 0; i < sub_header->num_rects; i++) { + av_free(sub_header->rects[i].bitmap); + av_free(sub_header->rects[i].rgba_palette); + } + av_freep(&sub_header->rects); + sub_header->num_rects = 0; + } + bitmap = av_malloc(w * h); - sub_header->rgba_palette = av_malloc(4 * 4); + sub_header->rects = av_mallocz(sizeof(AVSubtitleRect)); + sub_header->num_rects = 1; + sub_header->rects[0].rgba_palette = av_malloc(4 * 4); decode_rle(bitmap, w * 2, w, h / 2, buf, offset1 * 2, buf_size); decode_rle(bitmap + w, w * 2, w, h / 2, buf, offset2 * 2, buf_size); - guess_palette(sub_header->rgba_palette, + guess_palette(sub_header->rects[0].rgba_palette, palette, alpha, 0xffff00); - sub_header->x = x1; - sub_header->y = y1; - sub_header->w = w; - sub_header->h = h; - sub_header->nb_colors = 4; - sub_header->linesize = w; - sub_header->bitmap = bitmap; + sub_header->rects[0].x = x1; + sub_header->rects[0].y = y1; + sub_header->rects[0].w = w; + sub_header->rects[0].h = h; + sub_header->rects[0].nb_colors = 4; + sub_header->rects[0].linesize = w; + sub_header->rects[0].bitmap = bitmap; } } if (next_cmd_pos == cmd_pos) break; cmd_pos = next_cmd_pos; } - if (sub_header->bitmap) + if (sub_header->num_rects > 0) return 0; fail: return -1; @@ -278,34 +288,34 @@ static int find_smallest_bouding_rectangle(AVSubtitle *s) int y1, y2, x1, x2, y, w, h, i; uint8_t *bitmap; - if (s->w <= 0 || s->h <= 0) + if (s->num_rects == 0 || s->rects == NULL || s->rects[0].w <= 0 || s->rects[0].h <= 0) return 0; memset(transp_color, 0, 256); - for(i = 0; i < s->nb_colors; i++) { - if ((s->rgba_palette[i] >> 24) == 0) + for(i = 0; i < s->rects[0].nb_colors; i++) { + if ((s->rects[0].rgba_palette[i] >> 24) == 0) transp_color[i] = 1; } y1 = 0; - while (y1 < s->h && is_transp(s->bitmap + y1 * s->linesize, 1, s->w, - transp_color)) + while (y1 < s->rects[0].h && is_transp(s->rects[0].bitmap + y1 * s->rects[0].linesize, + 1, s->rects[0].w, transp_color)) y1++; - if (y1 == s->h) { - av_freep(&s->bitmap); - s->w = s->h = 0; + if (y1 == s->rects[0].h) { + av_freep(&s->rects[0].bitmap); + s->rects[0].w = s->rects[0].h = 0; return 0; } - y2 = s->h - 1; - while (y2 > 0 && is_transp(s->bitmap + y2 * s->linesize, 1, s->w, - transp_color)) + y2 = s->rects[0].h - 1; + while (y2 > 0 && is_transp(s->rects[0].bitmap + y2 * s->rects[0].linesize, 1, + s->rects[0].w, transp_color)) y2--; x1 = 0; - while (x1 < (s->w - 1) && is_transp(s->bitmap + x1, s->linesize, s->h, - transp_color)) + while (x1 < (s->rects[0].w - 1) && is_transp(s->rects[0].bitmap + x1, s->rects[0].linesize, + s->rects[0].h, transp_color)) x1++; - x2 = s->w - 1; - while (x2 > 0 && is_transp(s->bitmap + x2, s->linesize, s->h, + x2 = s->rects[0].w - 1; + while (x2 > 0 && is_transp(s->rects[0].bitmap + x2, s->rects[0].linesize, s->rects[0].h, transp_color)) x2--; w = x2 - x1 + 1; @@ -314,15 +324,15 @@ static int find_smallest_bouding_rectangle(AVSubtitle *s) if (!bitmap) return 1; for(y = 0; y < h; y++) { - memcpy(bitmap + w * y, s->bitmap + x1 + (y1 + y) * s->linesize, w); + memcpy(bitmap + w * y, s->rects[0].bitmap + x1 + (y1 + y) * s->rects[0].linesize, w); } - av_freep(&s->bitmap); - s->bitmap = bitmap; - s->linesize = w; - s->w = w; - s->h = h; - s->x += x1; - s->y += y1; + av_freep(&s->rects[0].bitmap); + s->rects[0].bitmap = bitmap; + s->rects[0].linesize = w; + s->rects[0].w = w; + s->rects[0].h = h; + s->rects[0].x += x1; + s->rects[0].y += y1; return 1; } @@ -379,8 +389,8 @@ static int dvdsub_decode(AVCodecContext *avctx, av_log(NULL, AV_LOG_INFO, "start=%d ms end =%d ms\n", sub->start_display_time, sub->end_display_time); - ppm_save("/tmp/a.ppm", sub->bitmap, - sub->w, sub->h, sub->rgba_palette); + ppm_save("/tmp/a.ppm", sub->rects[0].bitmap, + sub->rects[0].w, sub->rects[0].h, sub->rects[0].rgba_palette); #endif *data_size = 1; diff --git a/mythtv/libs/libavcodec/h261.c b/mythtv/libs/libavcodec/h261.c index f9e148455c1..a823cc39bca 100644 --- a/mythtv/libs/libavcodec/h261.c +++ b/mythtv/libs/libavcodec/h261.c @@ -970,6 +970,10 @@ static int h261_decode_frame(AVCodecContext *avctx, /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return get_consumed_bytes(s, buf_size); if(MPV_frame_start(s, avctx) < 0) return -1; diff --git a/mythtv/libs/libavcodec/h263dec.c b/mythtv/libs/libavcodec/h263dec.c index ba105564f24..b51ce5f0c46 100644 --- a/mythtv/libs/libavcodec/h263dec.c +++ b/mythtv/libs/libavcodec/h263dec.c @@ -673,6 +673,10 @@ uint64_t time= rdtsc(); if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)) return get_consumed_bytes(s, buf_size); /* skip b frames if we are in a hurry */ if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return get_consumed_bytes(s, buf_size); /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); diff --git a/mythtv/libs/libavcodec/h264.c b/mythtv/libs/libavcodec/h264.c index 741c0503c6a..10baf270925 100644 --- a/mythtv/libs/libavcodec/h264.c +++ b/mythtv/libs/libavcodec/h264.c @@ -4349,6 +4349,11 @@ static int decode_slice_header(H264Context *h){ h->slice_beta_offset = get_se_golomb(&s->gb) << 1; } } + if( s->avctx->skip_loop_filter >= AVDISCARD_ALL + ||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && h->slice_type != I_TYPE) + ||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && h->slice_type == B_TYPE) + ||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0)) + h->deblocking_filter= 0; #if 0 //FMO if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5) @@ -7245,7 +7250,8 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ buf_index += consumed; - if( s->hurry_up == 1 && h->nal_ref_idc == 0 ) + if( (s->hurry_up == 1 && h->nal_ref_idc == 0) + ||(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0)) continue; switch(h->nal_unit_type){ @@ -7261,7 +7267,11 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n"); break; } - if(h->redundant_pic_count==0 && s->hurry_up < 5 ) + if(h->redundant_pic_count==0 && s->hurry_up < 5 + && (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc) + && (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE) + && (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE) + && avctx->skip_frame < AVDISCARD_ALL) decode_slice(h); break; case NAL_DPA: @@ -7282,7 +7292,12 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ init_get_bits(&h->inter_gb, ptr, bit_length); h->inter_gb_ptr= &h->inter_gb; - if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning && s->hurry_up < 5 ) + if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning + && s->hurry_up < 5 + && (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc) + && (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE) + && (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE) + && avctx->skip_frame < AVDISCARD_ALL) decode_slice(h); break; case NAL_SEI: diff --git a/mythtv/libs/libavcodec/imgconvert.c b/mythtv/libs/libavcodec/imgconvert.c index 1ba723a957b..afb66fa85a6 100644 --- a/mythtv/libs/libavcodec/imgconvert.c +++ b/mythtv/libs/libavcodec/imgconvert.c @@ -576,6 +576,8 @@ static void img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height) { + if((!dst) || (!src)) + return; for(;height > 0; height--) { memcpy(dst, src, width); dst += dst_wrap; diff --git a/mythtv/libs/libavcodec/indeo2.c b/mythtv/libs/libavcodec/indeo2.c index 25561ec2d7d..5063117ca0a 100644 --- a/mythtv/libs/libavcodec/indeo2.c +++ b/mythtv/libs/libavcodec/indeo2.c @@ -118,11 +118,11 @@ static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_ c -= 0x7F; out += c * 2; } else { /* add two deltas from table */ - t = dst[out] + (table[c * 2] - 128); + t = dst[out] + (((table[c * 2] - 128)*3) >> 2); t= clip_uint8(t); dst[out] = t; out++; - t = dst[out] + (table[(c * 2) + 1] - 128); + t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); t= clip_uint8(t); dst[out] = t; out++; diff --git a/mythtv/libs/libavcodec/libavcodec.pro b/mythtv/libs/libavcodec/libavcodec.pro index e6a0d14415d..2dbc5a2c7fe 100644 --- a/mythtv/libs/libavcodec/libavcodec.pro +++ b/mythtv/libs/libavcodec/libavcodec.pro @@ -31,7 +31,7 @@ SOURCES += mpeg12.c mpegaudiodec.c pcm.c simple_idct.c ratecontrol.c adpcm.c SOURCES += eval.c error_resilience.c fft.c mdct.c raw.c golomb.c cabac.c SOURCES += dpcm.c adx.c rational.c faandct.c parser.c g726.c vp3dsp.c integer.c SOURCES += h264idct.c rangecoder.c pnm.c h263.c msmpeg4.c h263dec.c dvdsub.c -SOURCES += dvbsub.c +SOURCES += dvbsub.c dvbsubdec.c inc.path = $${PREFIX}/include/mythtv/ffmpeg/ inc.files = avcodec.h rational.h common.h i386/mmx.h diff --git a/mythtv/libs/libavcodec/mjpeg.c b/mythtv/libs/libavcodec/mjpeg.c index 4c2b4793bf3..7aaf1e73ad4 100644 --- a/mythtv/libs/libavcodec/mjpeg.c +++ b/mythtv/libs/libavcodec/mjpeg.c @@ -896,11 +896,8 @@ static int mjpeg_decode_init(AVCodecContext *avctx) s->idct_put= s2.dsp.idct_put; s->mpeg_enc_ctx_allocated = 0; - s->buffer_size = 102400; /* smaller buffer should be enough, - but photojpg files could ahive bigger sizes */ - s->buffer = av_malloc(s->buffer_size); - if (!s->buffer) - return -1; + s->buffer_size = 0; + s->buffer = NULL; s->start_code = -1; s->first_picture = 1; s->org_height = avctx->coded_height; @@ -1585,10 +1582,11 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) { int len, id; - /* XXX: verify len field validity */ len = get_bits(&s->gb, 16); if (len < 5) return -1; + if(8*len + get_bits_count(&s->gb) > s->gb.size_in_bits) + return -1; id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16); id = be2me_32(id); @@ -1727,10 +1725,8 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) static int mjpeg_decode_com(MJpegDecodeContext *s) { - /* XXX: verify len field validity */ int len = get_bits(&s->gb, 16); - if (len >= 2 && len < 32768) { - /* XXX: any better upper bound */ + if (len >= 2 && 8*len - 16 + get_bits_count(&s->gb) <= s->gb.size_in_bits) { uint8_t *cbuf = av_malloc(len - 1); if (cbuf) { int i; @@ -1842,7 +1838,7 @@ static int mjpeg_decode_frame(AVCodecContext *avctx, { av_free(s->buffer); s->buffer_size = buf_end-buf_ptr; - s->buffer = av_malloc(s->buffer_size); + s->buffer = av_malloc(s->buffer_size + FF_INPUT_BUFFER_PADDING_SIZE); dprintf("buffer too small, expanding to %d bytes\n", s->buffer_size); } diff --git a/mythtv/libs/libavcodec/mpeg12.c b/mythtv/libs/libavcodec/mpeg12.c index f840edb1a86..806143afdf2 100644 --- a/mythtv/libs/libavcodec/mpeg12.c +++ b/mythtv/libs/libavcodec/mpeg12.c @@ -2230,7 +2230,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { s->full_pel[0] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); - if (f_code == 0) + if (f_code == 0 && avctx->error_resilience >= FF_ER_COMPLIANT) return -1; s->mpeg_f_code[0][0] = f_code; s->mpeg_f_code[0][1] = f_code; @@ -2238,7 +2238,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, if (s->pict_type == B_TYPE) { s->full_pel[1] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); - if (f_code == 0) + if (f_code == 0 && avctx->error_resilience >= FF_ER_COMPLIANT) return -1; s->mpeg_f_code[1][0] = f_code; s->mpeg_f_code[1][1] = f_code; @@ -3118,7 +3118,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, /* find start next code */ start_code = find_start_code(&buf_ptr, buf_end); if (start_code < 0){ - if(s2->pict_type != B_TYPE || avctx->hurry_up==0){ + if(s2->pict_type != B_TYPE || avctx->skip_frame <= AVDISCARD_DEFAULT){ if(avctx->thread_count > 1){ int i; @@ -3169,11 +3169,19 @@ static int mpeg_decode_frame(AVCodecContext *avctx, if (start_code >= SLICE_MIN_START_CODE && start_code <= SLICE_MAX_START_CODE) { int mb_y= start_code - SLICE_MIN_START_CODE; - + + if(s2->last_picture_ptr==NULL){ /* skip b frames if we dont have reference frames */ - if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break; + if(s2->pict_type==B_TYPE) break; + /* skip P frames if we dont have reference frame no valid header */ + if(s2->pict_type==P_TYPE && !s2->first_slice) break; + } /* skip b frames if we are in a hurry */ if(avctx->hurry_up && s2->pict_type==B_TYPE) break; + if( (avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + break; /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) break; diff --git a/mythtv/libs/libavcodec/mpegvideo.c b/mythtv/libs/libavcodec/mpegvideo.c index 48c768b704a..36997a8796a 100644 --- a/mythtv/libs/libavcodec/mpegvideo.c +++ b/mythtv/libs/libavcodec/mpegvideo.c @@ -3776,7 +3776,13 @@ static always_inline void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM bloc } /* skip dequant / idct if we are really late ;) */ - if(s->hurry_up>1) return; + if(s->hurry_up>1) goto skip_idct; + if(s->avctx->skip_idct){ + if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == B_TYPE) + ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != I_TYPE) + || s->avctx->skip_idct >= AVDISCARD_ALL) + goto skip_idct; + } /* add dct residue */ if(s->encoding || !( s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO @@ -3862,6 +3868,7 @@ static always_inline void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM bloc }//gray } } +skip_idct: if(!readable){ s->dsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16); s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift); diff --git a/mythtv/libs/libavcodec/svq1.c b/mythtv/libs/libavcodec/svq1.c index 068dd51d37e..e59f1c731b8 100644 --- a/mythtv/libs/libavcodec/svq1.c +++ b/mythtv/libs/libavcodec/svq1.c @@ -748,6 +748,10 @@ static int svq1_decode_frame(AVCodecContext *avctx, if(s->pict_type==B_TYPE && s->last_picture_ptr==NULL) return buf_size; if(avctx->hurry_up && s->pict_type==B_TYPE) return buf_size; + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return buf_size; if(MPV_frame_start(s, avctx) < 0) return -1; diff --git a/mythtv/libs/libavcodec/svq3.c b/mythtv/libs/libavcodec/svq3.c index 547679bf1c5..f0f995acfa9 100644 --- a/mythtv/libs/libavcodec/svq3.c +++ b/mythtv/libs/libavcodec/svq3.c @@ -896,6 +896,10 @@ static int svq3_decode_frame (AVCodecContext *avctx, if (avctx->hurry_up && s->pict_type == B_TYPE) return 0; /* skip everything if we are in a hurry >= 5 */ if (avctx->hurry_up >= 5) return 0; + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return 0; if (s->next_p_frame_damaged) { if (s->pict_type == B_TYPE) diff --git a/mythtv/libs/libavcodec/utils.c b/mythtv/libs/libavcodec/utils.c index 5bd0012a477..0a0971fc3e9 100644 --- a/mythtv/libs/libavcodec/utils.c +++ b/mythtv/libs/libavcodec/utils.c @@ -642,9 +642,12 @@ int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, int ret; *frame_size_ptr= 0; - ret = avctx->codec->decode(avctx, samples, frame_size_ptr, - buf, buf_size); - avctx->frame_number++; + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ + ret = avctx->codec->decode(avctx, samples, frame_size_ptr, + buf, buf_size); + avctx->frame_number++; + }else + ret= 0; return ret; } diff --git a/mythtv/libs/libavcodec/x264.c b/mythtv/libs/libavcodec/x264.c index 0e850f5739a..df5df9810a6 100644 --- a/mythtv/libs/libavcodec/x264.c +++ b/mythtv/libs/libavcodec/x264.c @@ -19,6 +19,7 @@ #include "avcodec.h" #include +#include typedef struct X264Context { x264_param_t params; diff --git a/mythtv/libs/libavformat/4xm.c b/mythtv/libs/libavformat/4xm.c index 7c0f78e6b9b..d4a80364692 100644 --- a/mythtv/libs/libavformat/4xm.c +++ b/mythtv/libs/libavformat/4xm.c @@ -166,11 +166,11 @@ static int fourxm_read_header(AVFormatContext *s, fourxm->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_4XM; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = fourxm->width; - st->codec.height = fourxm->height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_4XM; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = fourxm->width; + st->codec->height = fourxm->height; } else if (fourcc_tag == strk_TAG) { /* check that there is enough data */ @@ -205,20 +205,20 @@ static int fourxm_read_header(AVFormatContext *s, fourxm->tracks[current_track].stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = 1; - st->codec.channels = fourxm->tracks[current_track].channels; - st->codec.sample_rate = fourxm->tracks[current_track].sample_rate; - st->codec.bits_per_sample = fourxm->tracks[current_track].bits; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = 1; + st->codec->channels = fourxm->tracks[current_track].channels; + st->codec->sample_rate = fourxm->tracks[current_track].sample_rate; + st->codec->bits_per_sample = fourxm->tracks[current_track].bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; if (fourxm->tracks[current_track].adpcm) - st->codec.codec_id = CODEC_ID_ADPCM_4XM; - else if (st->codec.bits_per_sample == 8) - st->codec.codec_id = CODEC_ID_PCM_U8; + st->codec->codec_id = CODEC_ID_ADPCM_4XM; + else if (st->codec->bits_per_sample == 8) + st->codec->codec_id = CODEC_ID_PCM_U8; else - st->codec.codec_id = CODEC_ID_PCM_S16LE; + st->codec->codec_id = CODEC_ID_PCM_S16LE; } } diff --git a/mythtv/libs/libavformat/allformats.c b/mythtv/libs/libavformat/allformats.c index 27e2d46f65b..7f79d019ab1 100644 --- a/mythtv/libs/libavformat/allformats.c +++ b/mythtv/libs/libavformat/allformats.c @@ -51,15 +51,16 @@ void av_register_all(void) #endif //CONFIG_ENCODERS avidec_init(); ff_wav_init(); + ff_mmf_init(); swf_init(); au_init(); #ifdef CONFIG_ENCODERS - //gif_init(); + gif_init(); #endif //CONFIG_ENCODERS mov_init(); #ifdef CONFIG_ENCODERS movenc_init(); - //jpeg_init(); + jpeg_init(); #endif //CONFIG_ENCODERS ff_dv_init(); fourxm_init(); @@ -89,7 +90,7 @@ void av_register_all(void) ffm_init(); #if defined(CONFIG_VIDEO4LINUX) || defined(CONFIG_BKTR) - //video_grab_init(); +// video_grab_init(); #endif #if defined(CONFIG_AUDIO_OSS) || defined(CONFIG_AUDIO_BEOS) audio_init(); @@ -124,14 +125,14 @@ void av_register_all(void) #endif av_register_image_format(&jpeg_image_format); #endif -// av_register_image_format(&gif_image_format); + av_register_image_format(&gif_image_format); // av_register_image_format(&sgi_image_format); heap corruption, dont enable #endif //CONFIG_ENCODERS /* file protocols */ register_protocol(&file_protocol); register_protocol(&pipe_protocol); -#if 0 //CONFIG_NETWORK +#ifdef CONFIG_NETWORK rtsp_init(); rtp_init(); register_protocol(&udp_protocol); diff --git a/mythtv/libs/libavformat/amr.c b/mythtv/libs/libavformat/amr.c index 64c387b5eed..cbe8695330e 100644 --- a/mythtv/libs/libavformat/amr.c +++ b/mythtv/libs/libavformat/amr.c @@ -31,7 +31,7 @@ static const unsigned char AMRWB_header [] = "#!AMR-WB\n"; static int amr_write_header(AVFormatContext *s) { ByteIOContext *pb = &s->pb; - AVCodecContext *enc = &s->streams[0]->codec; + AVCodecContext *enc = s->streams[0]->codec; s->priv_data = NULL; @@ -100,11 +100,11 @@ static int amr_read_header(AVFormatContext *s, return AVERROR_NOMEM; } - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = MKTAG('s', 'a', 'w', 'b'); - st->codec.codec_id = CODEC_ID_AMR_WB; - st->codec.channels = 1; - st->codec.sample_rate = 16000; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b'); + st->codec->codec_id = CODEC_ID_AMR_WB; + st->codec->channels = 1; + st->codec->sample_rate = 16000; } else { @@ -114,11 +114,11 @@ static int amr_read_header(AVFormatContext *s, return AVERROR_NOMEM; } - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = MKTAG('s', 'a', 'm', 'r'); - st->codec.codec_id = CODEC_ID_AMR_NB; - st->codec.channels = 1; - st->codec.sample_rate = 8000; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r'); + st->codec->codec_id = CODEC_ID_AMR_NB; + st->codec->channels = 1; + st->codec->sample_rate = 8000; } return 0; @@ -129,7 +129,7 @@ static int amr_read_header(AVFormatContext *s, static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecContext *enc = &s->streams[0]->codec; + AVCodecContext *enc = s->streams[0]->codec; if (enc->codec_id == CODEC_ID_AMR_NB) { diff --git a/mythtv/libs/libavformat/asf-enc.c b/mythtv/libs/libavformat/asf-enc.c index 4e2fd35072f..a6b3f032e15 100644 --- a/mythtv/libs/libavformat/asf-enc.c +++ b/mythtv/libs/libavformat/asf-enc.c @@ -289,7 +289,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data bit_rate = 0; for(n=0;nnb_streams;n++) { - enc = &s->streams[n]->codec; + enc = s->streams[n]->codec; av_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */ @@ -353,7 +353,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data int er_spr_len = 0; // ASFStream *stream = &asf->streams[n]; - enc = &s->streams[n]->codec; + enc = s->streams[n]->codec; asf->streams[n].num = n + 1; asf->streams[n].seq = 0; @@ -437,7 +437,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data for(n=0;nnb_streams;n++) { AVCodec *p; - enc = &s->streams[n]->codec; + enc = s->streams[n]->codec; p = avcodec_find_encoder(enc->codec_id); put_le16(pb, asf->streams[n].num); @@ -730,7 +730,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt) int64_t packet_st,pts; int start_sec,i; - codec = &s->streams[pkt->stream_index]->codec; + codec = s->streams[pkt->stream_index]->codec; stream = &asf->streams[pkt->stream_index]; //XXX /FIXME use duration from AVPacket (quick hack by) diff --git a/mythtv/libs/libavformat/asf.c b/mythtv/libs/libavformat/asf.c index c52b1da7dcc..12d2a5ed323 100644 --- a/mythtv/libs/libavformat/asf.c +++ b/mythtv/libs/libavformat/asf.c @@ -216,9 +216,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) asf->asfid2avid[st->id] = s->nb_streams - 1; get_le32(pb); - st->codec.codec_type = type; + st->codec->codec_type = type; if (type == CODEC_TYPE_AUDIO) { - get_wav_header(pb, &st->codec, type_specific_size); + get_wav_header(pb, st->codec, type_specific_size); st->need_parsing = 1; /* We have to init the frame size at some point .... */ pos2 = url_ftell(pb); @@ -237,9 +237,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1)) asf_st->ds_span = 0; // disable descrambling } - switch (st->codec.codec_id) { + switch (st->codec->codec_id) { case CODEC_ID_MP3: - st->codec.frame_size = MPA_FRAME_SIZE; + st->codec->frame_size = MPA_FRAME_SIZE; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: @@ -249,11 +249,11 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) case CODEC_ID_PCM_U8: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: - st->codec.frame_size = 1; + st->codec->frame_size = 1; break; default: /* This is probably wrong, but it prevents a crash later */ - st->codec.frame_size = 1; + st->codec->frame_size = 1; break; } } else { @@ -262,38 +262,38 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) get_byte(pb); size = get_le16(pb); /* size */ sizeX= get_le32(pb); /* size */ - st->codec.width = get_le32(pb); - st->codec.height = get_le32(pb); + st->codec->width = get_le32(pb); + st->codec->height = get_le32(pb); /* not available for asf */ get_le16(pb); /* panes */ - st->codec.bits_per_sample = get_le16(pb); /* depth */ + st->codec->bits_per_sample = get_le16(pb); /* depth */ tag1 = get_le32(pb); url_fskip(pb, 20); // av_log(NULL, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX); size= sizeX; if (size > 40) { - st->codec.extradata_size = size - 40; - st->codec.extradata = av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size = size - 40; + st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + get_buffer(pb, st->codec->extradata, st->codec->extradata_size); } /* Extract palette from extradata if bpp <= 8 */ /* This code assumes that extradata contains only palette */ /* This is true for all paletted codecs implemented in ffmpeg */ - if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { - st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); + if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) { + st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #ifdef WORDS_BIGENDIAN - for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++) - st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]); + for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) + st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]); #else - memcpy(st->codec.palctrl->palette, st->codec.extradata, - FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); + memcpy(st->codec->palctrl->palette, st->codec->extradata, + FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif - st->codec.palctrl->palette_changed = 1; + st->codec->palctrl->palette_changed = 1; } - st->codec.codec_tag = tag1; - st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); + st->codec->codec_tag = tag1; + st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1); if(tag1 == MKTAG('D', 'V', 'R', ' ')) st->need_parsing = 1; } @@ -398,7 +398,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) AVStream *st = s->streams[i]; if (st) { av_free(st->priv_data); - av_free(st->codec.extradata); + av_free(st->codec->extradata); } av_free(st); } @@ -608,8 +608,8 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt) asf_st->packet_pos= asf->packet_pos; //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY, -//s->streams[asf->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size); - if (s->streams[asf->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO) +//s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size); + if (s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO) asf->packet_key_frame = 1; if (asf->packet_key_frame) asf_st->pkt.flags |= PKT_FLAG_KEY; @@ -666,8 +666,8 @@ static int asf_read_close(AVFormatContext *s) for(i=0;inb_streams;i++) { AVStream *st = s->streams[i]; av_free(st->priv_data); - av_free(st->codec.extradata); - av_free(st->codec.palctrl); + av_free(st->codec->extradata); + av_free(st->codec->palctrl); } return 0; } diff --git a/mythtv/libs/libavformat/au.c b/mythtv/libs/libavformat/au.c index 984180ab4b1..1777747a924 100644 --- a/mythtv/libs/libavformat/au.c +++ b/mythtv/libs/libavformat/au.c @@ -63,7 +63,7 @@ static int au_write_header(AVFormatContext *s) s->priv_data = NULL; /* format header */ - if (put_au_header(pb, &s->streams[0]->codec) < 0) { + if (put_au_header(pb, s->streams[0]->codec) < 0) { return -1; } @@ -143,11 +143,11 @@ static int au_read_header(AVFormatContext *s, st = av_new_stream(s, 0); if (!st) return -1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = id; - st->codec.codec_id = codec; - st->codec.channels = channels; - st->codec.sample_rate = rate; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = id; + st->codec->codec_id = codec; + st->codec->channels = channels; + st->codec->sample_rate = rate; av_set_pts_info(st, 64, 1, rate); return 0; } diff --git a/mythtv/libs/libavformat/audio.c b/mythtv/libs/libavformat/audio.c index ec7e4365ae7..054ced2266e 100644 --- a/mythtv/libs/libavformat/audio.c +++ b/mythtv/libs/libavformat/audio.c @@ -162,8 +162,8 @@ static int audio_write_header(AVFormatContext *s1) int ret; st = s1->streams[0]; - s->sample_rate = st->codec.sample_rate; - s->channels = st->codec.channels; + s->sample_rate = st->codec->sample_rate; + s->channels = st->codec->channels; ret = audio_open(s, 1, NULL); if (ret < 0) { return AVERROR_IO; @@ -234,10 +234,10 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) } /* take real parameters */ - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = s->codec_id; - st->codec.sample_rate = s->sample_rate; - st->codec.channels = s->channels; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = s->codec_id; + st->codec->sample_rate = s->sample_rate; + st->codec->channels = s->channels; av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */ return 0; diff --git a/mythtv/libs/libavformat/avformat.h b/mythtv/libs/libavformat/avformat.h index ad6192d3443..6509394a47b 100644 --- a/mythtv/libs/libavformat/avformat.h +++ b/mythtv/libs/libavformat/avformat.h @@ -5,7 +5,7 @@ extern "C" { #endif -#define LIBAVFORMAT_BUILD 4628 +#define LIBAVFORMAT_BUILD 4629 #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT #define LIBAVFORMAT_VERSION FFMPEG_VERSION @@ -213,19 +213,10 @@ typedef struct AVIndexEntry { int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */ } AVIndexEntry; -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_BIDIR = 16, ///< discard all bidirectional frames - AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes - AVDISCARD_ALL = 48, ///< discard all -}; - typedef struct AVStream { int index; /* stream index in AVFormatContext */ int id; /* format specific stream id */ - AVCodecContext codec; /* codec context */ + AVCodecContext *codec; /* codec context */ /** * real base frame rate of the stream. * for example if the timebase is 1/90000 and all frames have either @@ -478,6 +469,9 @@ int amr_init(void); /* wav.c */ int ff_wav_init(void); +/* mmf.c */ +int ff_mmf_init(void); + /* raw.c */ int pcm_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags); @@ -550,9 +544,9 @@ int ea_init(void); /* nsvdec.c */ int nsvdec_init(void); -//#include "rtp.h" +#include "rtp.h" -//#include "rtsp.h" +#include "rtsp.h" /* yuv4mpeg.c */ extern AVOutputFormat yuv4mpegpipe_oformat; diff --git a/mythtv/libs/libavformat/avidec.c b/mythtv/libs/libavformat/avidec.c index ab99f223df4..fe3f626ff56 100644 --- a/mythtv/libs/libavformat/avidec.c +++ b/mythtv/libs/libavformat/avidec.c @@ -178,7 +178,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; ast = s->streams[0]->priv_data; - av_freep(&s->streams[0]->codec.extradata); + av_freep(&s->streams[0]->codec->extradata); av_freep(&s->streams[0]); s->nb_streams = 0; avi->dv_demux = dv_init_demux(s); @@ -199,7 +199,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) } st = s->streams[stream_index]; ast = st->priv_data; - st->codec.stream_codec_tag= handler; + st->codec->stream_codec_tag= handler; get_le32(pb); /* flags */ get_le16(pb); /* priority */ @@ -259,10 +259,10 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) switch(codec_type) { case CODEC_TYPE_VIDEO: get_le32(pb); /* size */ - st->codec.width = get_le32(pb); - st->codec.height = get_le32(pb); + st->codec->width = get_le32(pb); + st->codec->height = get_le32(pb); get_le16(pb); /* panes */ - st->codec.bits_per_sample= get_le16(pb); /* depth */ + st->codec->bits_per_sample= get_le16(pb); /* depth */ tag1 = get_le32(pb); get_le32(pb); /* ImageSize */ get_le32(pb); /* XPelsPerMeter */ @@ -271,41 +271,41 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) get_le32(pb); /* ClrImportant */ if(size > 10*4 && size<(1<<30)){ - st->codec.extradata_size= size - 10*4; - st->codec.extradata= av_malloc(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size= size - 10*4; + st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + get_buffer(pb, st->codec->extradata, st->codec->extradata_size); } - if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly + if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly get_byte(pb); /* Extract palette from extradata if bpp <= 8 */ /* This code assumes that extradata contains only palette */ /* This is true for all paletted codecs implemented in ffmpeg */ - if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { - st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); + if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) { + st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #ifdef WORDS_BIGENDIAN - for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++) - st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]); + for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) + st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]); #else - memcpy(st->codec.palctrl->palette, st->codec.extradata, - FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); + memcpy(st->codec->palctrl->palette, st->codec->extradata, + FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif - st->codec.palctrl->palette_changed = 1; + st->codec->palctrl->palette_changed = 1; } #ifdef DEBUG print_tag("video", tag1, 0); #endif - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_tag = tag1; - st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); - if (st->codec.codec_id == CODEC_ID_XAN_WC4) + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_tag = tag1; + st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1); + if (st->codec->codec_id == CODEC_ID_XAN_WC4) xan_video = 1; // url_fskip(pb, size - 5 * 4); break; case CODEC_TYPE_AUDIO: - get_wav_header(pb, &st->codec, size); + get_wav_header(pb, st->codec, size); if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */ url_fskip(pb, 1); /* special case time: To support Xan DPCM, hardcode @@ -314,12 +314,12 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) /* force parsing as several audio frames can be in one packet */ if (xan_video) - st->codec.codec_id = CODEC_ID_XAN_DPCM; + st->codec->codec_id = CODEC_ID_XAN_DPCM; break; default: - st->codec.codec_type = CODEC_TYPE_DATA; - st->codec.codec_id= CODEC_ID_NONE; - st->codec.codec_tag= 0; + st->codec->codec_type = CODEC_TYPE_DATA; + st->codec->codec_id= CODEC_ID_NONE; + st->codec->codec_tag= 0; url_fskip(pb, size); break; } @@ -337,7 +337,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) if (stream_index != s->nb_streams - 1) { fail: for(i=0;inb_streams;i++) { - av_freep(&s->streams[i]->codec.extradata); + av_freep(&s->streams[i]->codec->extradata); av_freep(&s->streams[i]); } return -1; @@ -440,7 +440,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) //av_log(NULL, AV_LOG_DEBUG, "dts:%Ld offset:%d %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, n, size); pkt->stream_index = avi->stream_index; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { if(st->index_entries){ AVIndexEntry *e; int index; @@ -580,9 +580,9 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) g = get_byte(pb); b = get_byte(pb); get_byte(pb); - st->codec.palctrl->palette[k] = b + (g << 8) + (r << 16); + st->codec->palctrl->palette[k] = b + (g << 8) + (r << 16); } - st->codec.palctrl->palette_changed = 1; + st->codec->palctrl->palette_changed = 1; goto resync; } @@ -787,8 +787,8 @@ static int avi_read_close(AVFormatContext *s) AVStream *st = s->streams[i]; AVIStream *ast = st->priv_data; av_free(ast); - av_free(st->codec.extradata); - av_free(st->codec.palctrl); + av_free(st->codec->extradata); + av_free(st->codec->palctrl); } if (avi->dv_demux) diff --git a/mythtv/libs/libavformat/avienc.c b/mythtv/libs/libavformat/avienc.c index a035f85de6d..698bce559f0 100644 --- a/mythtv/libs/libavformat/avienc.c +++ b/mythtv/libs/libavformat/avienc.c @@ -338,7 +338,7 @@ static int avi_write_header(AVFormatContext *s) video_enc = NULL; for(n=0;nnb_streams;n++) { - stream = &s->streams[n]->codec; + stream = s->streams[n]->codec; bitrate += stream->bit_rate; if (stream->codec_type == CODEC_TYPE_VIDEO) video_enc = stream; @@ -376,7 +376,7 @@ static int avi_write_header(AVFormatContext *s) list2 = start_tag(pb, "LIST"); put_tag(pb, "strl"); - stream = &s->streams[i]->codec; + stream = s->streams[i]->codec; /* FourCC should really be set by the codec itself */ if (! stream->codec_tag) { @@ -504,7 +504,7 @@ static int avi_write_ix(AVFormatContext *s) for (i=0;inb_streams;i++) { offset_t ix, pos; - avi_stream2fourcc(&tag[0], i, s->streams[i]->codec.codec_type); + avi_stream2fourcc(&tag[0], i, s->streams[i]->codec->codec_type); ix_tag[3] = '0' + i; /* Writing AVI OpenDML leaf index chunk */ @@ -576,7 +576,7 @@ static int avi_write_idx1(AVFormatContext *s) } if (!empty) { avi_stream2fourcc(&tag[0], stream_id, - s->streams[stream_id]->codec.codec_type); + s->streams[stream_id]->codec->codec_type); put_tag(pb, &tag[0]); put_le32(pb, ie->flags); put_le32(pb, ie->pos); @@ -591,7 +591,7 @@ static int avi_write_idx1(AVFormatContext *s) nb_frames = 0; for(n=0;nnb_streams;n++) { if (avi->frames_hdr_strm[n] != 0) { - stream = &s->streams[n]->codec; + stream = s->streams[n]->codec; url_fseek(pb, avi->frames_hdr_strm[n], SEEK_SET); ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale); if (au_ssize == 0) { @@ -618,7 +618,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) unsigned char tag[5]; unsigned int flags=0; const int stream_index= pkt->stream_index; - AVCodecContext *enc= &s->streams[stream_index]->codec; + AVCodecContext *enc= s->streams[stream_index]->codec; int size= pkt->size; // av_log(s, AV_LOG_DEBUG, "%lld %d %d\n", pkt->dts, avi->packet_count[stream_index], stream_index); @@ -705,7 +705,7 @@ static int avi_write_trailer(AVFormatContext *s) url_fskip(pb, 16); for (n=nb_frames=0;nnb_streams;n++) { - AVCodecContext *stream = &s->streams[n]->codec; + AVCodecContext *stream = s->streams[n]->codec; if (stream->codec_type == CODEC_TYPE_VIDEO) { if (nb_frames < stream->frame_number) nb_frames = stream->frame_number; diff --git a/mythtv/libs/libavformat/dv.c b/mythtv/libs/libavformat/dv.c index ff5f4bedb08..744c71746d5 100644 --- a/mythtv/libs/libavformat/dv.c +++ b/mythtv/libs/libavformat/dv.c @@ -560,8 +560,8 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) if (!c->ast[i]) break; av_set_pts_info(c->ast[i], 64, 1, 30000); - c->ast[i]->codec.codec_type = CODEC_TYPE_AUDIO; - c->ast[i]->codec.codec_id = CODEC_ID_PCM_S16LE; + c->ast[i]->codec->codec_type = CODEC_TYPE_AUDIO; + c->ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; av_init_packet(&c->audio_pkt[i]); c->audio_pkt[i].size = 0; @@ -569,9 +569,9 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) c->audio_pkt[i].stream_index = c->ast[i]->index; c->audio_pkt[i].flags |= PKT_FLAG_KEY; } - c->ast[i]->codec.sample_rate = dv_audio_frequency[freq]; - c->ast[i]->codec.channels = 2; - c->ast[i]->codec.bit_rate = 2 * dv_audio_frequency[freq] * 16; + c->ast[i]->codec->sample_rate = dv_audio_frequency[freq]; + c->ast[i]->codec->channels = 2; + c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16; c->ast[i]->start_time = 0; } c->ach = i; @@ -589,7 +589,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) sys = dv_frame_profile(frame); if (sys) { - avctx = &c->vst->codec; + avctx = c->vst->codec; av_set_pts_info(c->vst, 64, sys->frame_rate_base, sys->frame_rate); avctx->time_base= (AVRational){sys->frame_rate_base, sys->frame_rate}; @@ -628,10 +628,10 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st, c->has_video = 0; } - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { /* FIXME: we have to have more sensible approach than this one */ if (c->has_video) - av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames); + av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames); dv_inject_video(c, data, *frame); c->has_video = 1; @@ -642,7 +642,7 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st, reqasize = 4 * dv_audio_frame_size(c->sys, c->frames); fsize = fifo_size(&c->audio_data, c->audio_data.rptr); - if (st->codec.codec_type == CODEC_TYPE_AUDIO || (c->has_video && fsize >= reqasize)) { + if (st->codec->codec_type == CODEC_TYPE_AUDIO || (c->has_video && fsize >= reqasize)) { if (fsize + data_size >= reqasize && !c->has_audio) { if (fsize >= reqasize) { fifo_read(&c->audio_data, &pcm[0], reqasize, &c->audio_data.rptr); @@ -658,7 +658,7 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st, /* FIXME: we have to have more sensible approach than this one */ if (fifo_size(&c->audio_data, c->audio_data.rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) - av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames); + av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames); fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr); } @@ -682,7 +682,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s) /* We have to sort out where audio and where video stream is */ for (i=0; inb_streams; i++) { - switch (s->streams[i]->codec.codec_type) { + switch (s->streams[i]->codec->codec_type) { case CODEC_TYPE_VIDEO: vst = s->streams[i]; break; @@ -695,13 +695,13 @@ DVMuxContext* dv_init_mux(AVFormatContext* s) } /* Some checks -- DV format is very picky about its incoming streams */ - if (!vst || vst->codec.codec_id != CODEC_ID_DVVIDEO) + if (!vst || vst->codec->codec_id != CODEC_ID_DVVIDEO) goto bail_out; - if (ast && (ast->codec.codec_id != CODEC_ID_PCM_S16LE || - ast->codec.sample_rate != 48000 || - ast->codec.channels != 2)) + if (ast && (ast->codec->codec_id != CODEC_ID_PCM_S16LE || + ast->codec->sample_rate != 48000 || + ast->codec->channels != 2)) goto bail_out; - c->sys = dv_codec_profile(&vst->codec); + c->sys = dv_codec_profile(vst->codec); if (!c->sys) goto bail_out; @@ -711,7 +711,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s) c->has_video = 0; c->start_time = (time_t)s->timestamp; c->aspect = 0; /* 4:3 is the default */ - if ((int)(av_q2d(vst->codec.sample_aspect_ratio) * vst->codec.width / vst->codec.height * 10) == 17) /* 16:9 */ + if ((int)(av_q2d(vst->codec->sample_aspect_ratio) * vst->codec->width / vst->codec->height * 10) == 17) /* 16:9 */ c->aspect = 0x07; if (ast && fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) @@ -751,9 +751,9 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s) c->frames = 0; c->abytes = 0; - c->vst->codec.codec_type = CODEC_TYPE_VIDEO; - c->vst->codec.codec_id = CODEC_ID_DVVIDEO; - c->vst->codec.bit_rate = 25000000; + c->vst->codec->codec_type = CODEC_TYPE_VIDEO; + c->vst->codec->codec_id = CODEC_ID_DVVIDEO; + c->vst->codec->bit_rate = 25000000; c->vst->start_time = 0; return c; @@ -790,7 +790,7 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, size = dv_extract_audio_info(c, buf); for (i=0; iach; i++) { c->audio_pkt[i].size = size; - c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec.bit_rate; + c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate; } dv_extract_audio(buf, c->audio_buf[0], c->audio_buf[1]); c->abytes += size; @@ -813,7 +813,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, int64_t timestamp, int flags) { // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) - const DVprofile* sys = dv_codec_profile(&c->vst->codec); + const DVprofile* sys = dv_codec_profile(c->vst->codec); int64_t offset; int64_t size = url_fsize(&s->pb); int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; @@ -886,12 +886,12 @@ static int dv_read_seek(AVFormatContext *s, int stream_index, RawDVContext *r = s->priv_data; DVDemuxContext *c = r->dv_demux; int64_t offset= dv_frame_offset(s, c, timestamp, flags); - const DVprofile* sys = dv_codec_profile(&c->vst->codec); + const DVprofile* sys = dv_codec_profile(c->vst->codec); c->frames= offset / sys->frame_size; if (c->ach) c->abytes= av_rescale(c->frames, - c->ast[0]->codec.bit_rate * (int64_t)sys->frame_rate_base, + c->ast[0]->codec->bit_rate * (int64_t)sys->frame_rate_base, 8*sys->frame_rate); dv_flush_audio_packets(c); diff --git a/mythtv/libs/libavformat/electronicarts.c b/mythtv/libs/libavformat/electronicarts.c index 2d8bdadb573..7101652dc04 100644 --- a/mythtv/libs/libavformat/electronicarts.c +++ b/mythtv/libs/libavformat/electronicarts.c @@ -188,9 +188,9 @@ static int ea_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); ea->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_EA_MJPEG; - st->codec.codec_tag = 0; /* no fourcc */ + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_EA_MJPEG; + st->codec->codec_tag = 0; /* no fourcc */ #endif /* initialize the audio decoder stream */ @@ -198,15 +198,15 @@ static int ea_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, EA_SAMPLE_RATE); - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ADPCM_EA; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = ea->num_channels; - st->codec.sample_rate = EA_SAMPLE_RATE; - st->codec.bits_per_sample = EA_BITS_PER_SAMPLE; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample / 4; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ADPCM_EA; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = ea->num_channels; + st->codec->sample_rate = EA_SAMPLE_RATE; + st->codec->bits_per_sample = EA_BITS_PER_SAMPLE; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample / 4; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; ea->audio_stream_index = st->index; ea->audio_frame_counter = 0; diff --git a/mythtv/libs/libavformat/ffm.c b/mythtv/libs/libavformat/ffm.c index 6fb069ace2c..55a4f634174 100644 --- a/mythtv/libs/libavformat/ffm.c +++ b/mythtv/libs/libavformat/ffm.c @@ -141,7 +141,7 @@ static int ffm_write_header(AVFormatContext *s) bit_rate = 0; for(i=0;inb_streams;i++) { st = s->streams[i]; - bit_rate += st->codec.bit_rate; + bit_rate += st->codec->bit_rate; } put_be32(pb, bit_rate); @@ -154,7 +154,7 @@ static int ffm_write_header(AVFormatContext *s) av_set_pts_info(st, 64, 1, 1000000); st->priv_data = fst; - codec = &st->codec; + codec = st->codec; /* generic info */ put_be32(pb, codec->codec_id); put_byte(pb, codec->codec_type); @@ -247,10 +247,10 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt) int size= pkt->size; //XXX/FIXME use duration from pkt - if (st->codec.codec_type == CODEC_TYPE_AUDIO) { - duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0); + if (st->codec->codec_type == CODEC_TYPE_AUDIO) { + duration = ((float)st->codec->frame_size / st->codec->sample_rate * 1000000.0); } else { - duration = (1000000.0 * st->codec.time_base.num / (float)st->codec.time_base.den); + duration = (1000000.0 * st->codec->time_base.num / (float)st->codec->time_base.den); } pts = fst->pts; @@ -485,10 +485,10 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) st->priv_data = fst; - codec = &st->codec; + codec = st->codec; /* generic info */ - st->codec.codec_id = get_be32(pb); - st->codec.codec_type = get_byte(pb); /* codec_type */ + st->codec->codec_id = get_be32(pb); + st->codec->codec_type = get_byte(pb); /* codec_type */ codec->bit_rate = get_be32(pb); st->quality = get_be32(pb); codec->flags = get_be32(pb); diff --git a/mythtv/libs/libavformat/flic.c b/mythtv/libs/libavformat/flic.c index 3fa27335db8..d53168dc98d 100644 --- a/mythtv/libs/libavformat/flic.c +++ b/mythtv/libs/libavformat/flic.c @@ -86,19 +86,19 @@ static int flic_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; flic->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_FLIC; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = LE_16(&header[0x08]); - st->codec.height = LE_16(&header[0x0A]); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_FLIC; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = LE_16(&header[0x08]); + st->codec->height = LE_16(&header[0x0A]); - if (!st->codec.width || !st->codec.height) + if (!st->codec->width || !st->codec->height) return AVERROR_INVALIDDATA; /* send over the whole 128-byte FLIC header */ - st->codec.extradata_size = FLIC_HEADER_SIZE; - st->codec.extradata = av_malloc(FLIC_HEADER_SIZE); - memcpy(st->codec.extradata, header, FLIC_HEADER_SIZE); + st->codec->extradata_size = FLIC_HEADER_SIZE; + st->codec->extradata = av_malloc(FLIC_HEADER_SIZE); + memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE); av_set_pts_info(st, 33, 1, 90000); @@ -113,10 +113,10 @@ static int flic_read_header(AVFormatContext *s, url_fseek(pb, 12, SEEK_SET); /* send over abbreviated FLIC header chunk */ - av_free(st->codec.extradata); - st->codec.extradata_size = 12; - st->codec.extradata = av_malloc(12); - memcpy(st->codec.extradata, header, 12); + av_free(st->codec->extradata); + st->codec->extradata_size = 12; + st->codec->extradata = av_malloc(12); + memcpy(st->codec->extradata, header, 12); } else if (magic_number == FLIC_FILE_MAGIC_1) { /* diff --git a/mythtv/libs/libavformat/flvdec.c b/mythtv/libs/libavformat/flvdec.c index 187a692ea93..b309c5b55f9 100644 --- a/mythtv/libs/libavformat/flvdec.c +++ b/mythtv/libs/libavformat/flvdec.c @@ -102,7 +102,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_NOMEM; av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ - st->codec.time_base= (AVRational){1,1000}; + st->codec->time_base= (AVRational){1,1000}; } // av_log(NULL, AV_LOG_DEBUG, "%d %X %d \n", is_audio, flags, st->discard); if( (st->discard >= AVDISCARD_NONKEY && !((flags >> 4)==1 || is_audio)) @@ -116,34 +116,34 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) } if(is_audio){ - if(st->codec.sample_rate == 0){ - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.channels = (flags&1)+1; + if(st->codec->sample_rate == 0){ + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->channels = (flags&1)+1; if((flags >> 4) == 5) - st->codec.sample_rate= 8000; + st->codec->sample_rate= 8000; else - st->codec.sample_rate = (44100<<((flags>>2)&3))>>3; + st->codec->sample_rate = (44100<<((flags>>2)&3))>>3; switch(flags >> 4){/* 0: uncompressed 1: ADPCM 2: mp3 5: Nellymoser 8kHz mono 6: Nellymoser*/ - case 0: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16BE; - else st->codec.codec_id = CODEC_ID_PCM_S8; break; - case 1: st->codec.codec_id = CODEC_ID_ADPCM_SWF; break; - case 2: st->codec.codec_id = CODEC_ID_MP3; break; + case 0: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16BE; + else st->codec->codec_id = CODEC_ID_PCM_S8; break; + case 1: st->codec->codec_id = CODEC_ID_ADPCM_SWF; break; + case 2: st->codec->codec_id = CODEC_ID_MP3; break; // this is not listed at FLV but at SWF, strange... - case 3: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16LE; - else st->codec.codec_id = CODEC_ID_PCM_S8; break; + case 3: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16LE; + else st->codec->codec_id = CODEC_ID_PCM_S8; break; default: av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n", flags >> 4); - st->codec.codec_tag= (flags >> 4); + st->codec->codec_tag= (flags >> 4); } - st->codec.bits_per_sample = (flags & 2) ? 16 : 8; + st->codec->bits_per_sample = (flags & 2) ? 16 : 8; } }else{ - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; switch(flags & 0xF){ - case 2: st->codec.codec_id = CODEC_ID_FLV1; break; + case 2: st->codec->codec_id = CODEC_ID_FLV1; break; default: av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flags & 0xf); - st->codec.codec_tag= flags & 0xF; + st->codec->codec_tag= flags & 0xF; } } diff --git a/mythtv/libs/libavformat/flvenc.c b/mythtv/libs/libavformat/flvenc.c index 29b94598da0..5f3f4c5af75 100644 --- a/mythtv/libs/libavformat/flvenc.c +++ b/mythtv/libs/libavformat/flvenc.c @@ -97,7 +97,7 @@ static int flv_write_header(AVFormatContext *s) put_be32(pb,0); for(i=0; inb_streams; i++){ - AVCodecContext *enc = &s->streams[i]->codec; + AVCodecContext *enc = s->streams[i]->codec; av_set_pts_info(s->streams[i], 24, 1, 1000); /* 24 bit pts in ms */ if(enc->codec_tag == 5){ put_byte(pb,8); // message type @@ -134,7 +134,7 @@ static int flv_write_trailer(AVFormatContext *s) static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) { ByteIOContext *pb = &s->pb; - AVCodecContext *enc = &s->streams[pkt->stream_index]->codec; + AVCodecContext *enc = s->streams[pkt->stream_index]->codec; FLVContext *flv = s->priv_data; int size= pkt->size; int flags; diff --git a/mythtv/libs/libavformat/framehook.c b/mythtv/libs/libavformat/framehook.c index ee390e4d991..18be8a753e6 100644 --- a/mythtv/libs/libavformat/framehook.c +++ b/mythtv/libs/libavformat/framehook.c @@ -49,7 +49,7 @@ int frame_hook_add(int argc, char *argv[]) loaded = dlopen(argv[0], RTLD_NOW); if (!loaded) { - fprintf(stderr, "%s\n", dlerror()); + av_log(NULL, AV_LOG_ERROR, "%s\n", dlerror()); return -1; } @@ -63,18 +63,18 @@ int frame_hook_add(int argc, char *argv[]) fhe->Release = dlsym(loaded, "Release"); /* Optional */ if (!fhe->Process) { - fprintf(stderr, "Failed to find Process entrypoint in %s\n", argv[0]); + av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]); return -1; } if (!fhe->Configure && argc > 1) { - fprintf(stderr, "Failed to find Configure entrypoint in %s\n", argv[0]); + av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]); return -1; } if (argc > 1 || fhe->Configure) { if (fhe->Configure(&fhe->ctx, argc, argv)) { - fprintf(stderr, "Failed to Configure %s\n", argv[0]); + av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]); return -1; } } @@ -86,7 +86,7 @@ int frame_hook_add(int argc, char *argv[]) return 0; #else - fprintf(stderr, "Video hooking not compiled into this version\n"); + av_log(NULL, AV_LOG_ERROR, "Video hooking not compiled into this version\n"); return 1; #endif } diff --git a/mythtv/libs/libavformat/gif.c b/mythtv/libs/libavformat/gif.c index 1248139d79e..be5b7b973dd 100644 --- a/mythtv/libs/libavformat/gif.c +++ b/mythtv/libs/libavformat/gif.c @@ -327,7 +327,7 @@ static int gif_write_header(AVFormatContext *s) video_enc = NULL; for(i=0;inb_streams;i++) { - enc = &s->streams[i]->codec; + enc = s->streams[i]->codec; if (enc->codec_type != CODEC_TYPE_AUDIO) video_enc = enc; } @@ -388,7 +388,7 @@ static int gif_write_video(AVFormatContext *s, static int gif_write_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecContext *codec = &s->streams[pkt->stream_index]->codec; + AVCodecContext *codec = s->streams[pkt->stream_index]->codec; if (codec->codec_type == CODEC_TYPE_AUDIO) return 0; /* just ignore audio */ else diff --git a/mythtv/libs/libavformat/gifdec.c b/mythtv/libs/libavformat/gifdec.c index 90c6fc68e29..429a30cee53 100644 --- a/mythtv/libs/libavformat/gifdec.c +++ b/mythtv/libs/libavformat/gifdec.c @@ -555,14 +555,14 @@ static int gif_read_header(AVFormatContext * s1, if (!st) return -1; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.time_base.den = 5; - st->codec.time_base.num = 1; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->time_base.den = 5; + st->codec->time_base.num = 1; /* XXX: check if screen size is always valid */ - st->codec.width = s->screen_width; - st->codec.height = s->screen_height; - st->codec.pix_fmt = PIX_FMT_RGB24; + st->codec->width = s->screen_width; + st->codec->height = s->screen_height; + st->codec->pix_fmt = PIX_FMT_RGB24; return 0; } diff --git a/mythtv/libs/libavformat/grab.c b/mythtv/libs/libavformat/grab.c index e7c4262565b..d72211c13af 100644 --- a/mythtv/libs/libavformat/grab.c +++ b/mythtv/libs/libavformat/grab.c @@ -109,11 +109,11 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) } desired_palette = -1; - if (st->codec.pix_fmt == PIX_FMT_YUV420P) { + if (st->codec->pix_fmt == PIX_FMT_YUV420P) { desired_palette = VIDEO_PALETTE_YUV420P; - } else if (st->codec.pix_fmt == PIX_FMT_YUV422) { + } else if (st->codec->pix_fmt == PIX_FMT_YUV422) { desired_palette = VIDEO_PALETTE_YUV422; - } else if (st->codec.pix_fmt == PIX_FMT_BGR24) { + } else if (st->codec->pix_fmt == PIX_FMT_BGR24) { desired_palette = VIDEO_PALETTE_RGB24; } @@ -245,15 +245,15 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) switch(s->frame_format) { case VIDEO_PALETTE_YUV420P: frame_size = (width * height * 3) / 2; - st->codec.pix_fmt = PIX_FMT_YUV420P; + st->codec->pix_fmt = PIX_FMT_YUV420P; break; case VIDEO_PALETTE_YUV422: frame_size = width * height * 2; - st->codec.pix_fmt = PIX_FMT_YUV422; + st->codec->pix_fmt = PIX_FMT_YUV422; break; case VIDEO_PALETTE_RGB24: frame_size = width * height * 3; - st->codec.pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */ + st->codec->pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */ break; default: goto fail; @@ -261,12 +261,12 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->fd = video_fd; s->frame_size = frame_size; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.width = width; - st->codec.height = height; - st->codec.time_base.den = frame_rate; - st->codec.time_base.num = frame_rate_base; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->width = width; + st->codec->height = height; + st->codec->time_base.den = frame_rate; + st->codec->time_base.num = frame_rate_base; return 0; fail: diff --git a/mythtv/libs/libavformat/idcin.c b/mythtv/libs/libavformat/idcin.c index aecc1098ddc..ce56d2a8a57 100644 --- a/mythtv/libs/libavformat/idcin.c +++ b/mythtv/libs/libavformat/idcin.c @@ -156,20 +156,20 @@ static int idcin_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); idcin->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_IDCIN; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = width; - st->codec.height = height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_IDCIN; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = width; + st->codec->height = height; /* load up the Huffman tables into extradata */ - st->codec.extradata_size = HUFFMAN_TABLE_SIZE; - st->codec.extradata = av_malloc(HUFFMAN_TABLE_SIZE); - if (get_buffer(pb, st->codec.extradata, HUFFMAN_TABLE_SIZE) != + st->codec->extradata_size = HUFFMAN_TABLE_SIZE; + st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE); + if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) != HUFFMAN_TABLE_SIZE) return AVERROR_IO; /* save a reference in order to transport the palette */ - st->codec.palctrl = &idcin->palctrl; + st->codec->palctrl = &idcin->palctrl; /* if sample rate is 0, assume no audio */ if (sample_rate) { @@ -179,17 +179,17 @@ static int idcin_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); idcin->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = 1; - st->codec.channels = channels; - st->codec.sample_rate = sample_rate; - st->codec.bits_per_sample = bytes_per_sample * 8; - st->codec.bit_rate = sample_rate * bytes_per_sample * 8 * channels; - st->codec.block_align = bytes_per_sample * channels; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = 1; + st->codec->channels = channels; + st->codec->sample_rate = sample_rate; + st->codec->bits_per_sample = bytes_per_sample * 8; + st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels; + st->codec->block_align = bytes_per_sample * channels; if (bytes_per_sample == 1) - st->codec.codec_id = CODEC_ID_PCM_U8; + st->codec->codec_id = CODEC_ID_PCM_U8; else - st->codec.codec_id = CODEC_ID_PCM_S16LE; + st->codec->codec_id = CODEC_ID_PCM_S16LE; if (sample_rate % 14 != 0) { idcin->audio_chunk_size1 = (sample_rate / 14) * diff --git a/mythtv/libs/libavformat/idroq.c b/mythtv/libs/libavformat/idroq.c index add882eef3d..62536b0b6ba 100644 --- a/mythtv/libs/libavformat/idroq.c +++ b/mythtv/libs/libavformat/idroq.c @@ -145,11 +145,11 @@ static int roq_read_header(AVFormatContext *s, /* set the pts reference (1 pts = 1/90000) */ av_set_pts_info(st, 33, 1, 90000); roq->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_ROQ; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = roq->width; - st->codec.height = roq->height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_ROQ; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = roq->width; + st->codec->height = roq->height; if (roq->audio_channels) { st = av_new_stream(s, 0); @@ -157,15 +157,15 @@ static int roq_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); roq->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ROQ_DPCM; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = roq->audio_channels; - st->codec.sample_rate = RoQ_AUDIO_SAMPLE_RATE; - st->codec.bits_per_sample = 16; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ROQ_DPCM; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = roq->audio_channels; + st->codec->sample_rate = RoQ_AUDIO_SAMPLE_RATE; + st->codec->bits_per_sample = 16; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; } return 0; diff --git a/mythtv/libs/libavformat/img.c b/mythtv/libs/libavformat/img.c index c30d455d8a5..b30e78eb140 100644 --- a/mythtv/libs/libavformat/img.c +++ b/mythtv/libs/libavformat/img.c @@ -134,9 +134,9 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->is_pipe = 1; if (!ap || !ap->time_base.num) { - st->codec.time_base= (AVRational){1,25}; + st->codec->time_base= (AVRational){1,25}; } else { - st->codec.time_base= ap->time_base; + st->codec->time_base= ap->time_base; } if (!s->is_pipe) { @@ -166,11 +166,11 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) url_fseek(f, 0, SEEK_SET); } - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.width = s->width; - st->codec.height = s->height; - st->codec.pix_fmt = s->pix_fmt; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->width = s->width; + st->codec->height = s->height; + st->codec->pix_fmt = s->pix_fmt; s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15)); return 0; @@ -232,7 +232,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) } else { /* XXX: computing this pts is not necessary as it is done in the generic code too */ - pkt->pts = av_rescale((int64_t)s->img_count * s1->streams[0]->codec.time_base.num, s1->streams[0]->time_base.den, s1->streams[0]->codec.time_base.den) / s1->streams[0]->time_base.num; + pkt->pts = av_rescale((int64_t)s->img_count * s1->streams[0]->codec->time_base.num, s1->streams[0]->time_base.den, s1->streams[0]->codec->time_base.den) / s1->streams[0]->time_base.num; s->img_count++; s->img_number++; return 0; @@ -276,7 +276,7 @@ static int img_set_parameters(AVFormatContext *s, AVFormatParameters *ap) return -1; img->img_fmt = img_fmt; img->pix_fmt = i; - st->codec.pix_fmt = img->pix_fmt; + st->codec->pix_fmt = img->pix_fmt; return 0; } @@ -306,8 +306,8 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt) char filename[1024]; AVImageInfo info; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + height = st->codec->height; picture = (AVPicture *)pkt->data; @@ -323,7 +323,7 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt) } info.width = width; info.height = height; - info.pix_fmt = st->codec.pix_fmt; + info.pix_fmt = st->codec->pix_fmt; info.interleaved = 0; /* FIXME: there should be a way to set it right */ info.pict = *picture; ret = av_write_image(pb, img->img_fmt, &info); diff --git a/mythtv/libs/libavformat/img2.c b/mythtv/libs/libavformat/img2.c index 2214a1e9e56..dfc8404f450 100644 --- a/mythtv/libs/libavformat/img2.c +++ b/mythtv/libs/libavformat/img2.c @@ -193,8 +193,8 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) } if(ap && ap->width && ap->height){ - st->codec.width = ap->width; - st->codec.height= ap->height; + st->codec->width = ap->width; + st->codec->height= ap->height; } if (!s->is_pipe) { @@ -209,17 +209,17 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) } if(ap->video_codec_id){ - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = ap->video_codec_id; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = ap->video_codec_id; }else if(ap->audio_codec_id){ - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = ap->audio_codec_id; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = ap->audio_codec_id; }else{ - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = av_str2id(img_tags, s->path); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = av_str2id(img_tags, s->path); } - if(st->codec.codec_type == CODEC_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE) - st->codec.pix_fmt = ap->pix_fmt; + if(st->codec->codec_type == CODEC_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE) + st->codec->pix_fmt = ap->pix_fmt; return 0; } @@ -231,7 +231,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) int i; int size[3]={0}, ret[3]={0}; ByteIOContext f1[3], *f[3]= {&f1[0], &f1[1], &f1[2]}; - AVCodecContext *codec= &s1->streams[0]->codec; + AVCodecContext *codec= s1->streams[0]->codec; if (!s->is_pipe) { /* loop over input */ @@ -314,7 +314,7 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt) VideoData *img = s->priv_data; ByteIOContext pb1[3], *pb[3]= {&pb1[0], &pb1[1], &pb1[2]}; char filename[1024]; - AVCodecContext *codec= &s->streams[ pkt->stream_index ]->codec; + AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec; int i; if (!img->is_pipe) { diff --git a/mythtv/libs/libavformat/ipmovie.c b/mythtv/libs/libavformat/ipmovie.c index f2f0e9e2c17..c62a007473c 100644 --- a/mythtv/libs/libavformat/ipmovie.c +++ b/mythtv/libs/libavformat/ipmovie.c @@ -554,14 +554,14 @@ static int ipmovie_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); ipmovie->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_INTERPLAY_VIDEO; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = ipmovie->video_width; - st->codec.height = ipmovie->video_height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = ipmovie->video_width; + st->codec->height = ipmovie->video_height; /* palette considerations */ - st->codec.palctrl = &ipmovie->palette_control; + st->codec->palctrl = &ipmovie->palette_control; if (ipmovie->audio_type) { st = av_new_stream(s, 0); @@ -569,17 +569,17 @@ static int ipmovie_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); ipmovie->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = ipmovie->audio_type; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = ipmovie->audio_channels; - st->codec.sample_rate = ipmovie->audio_sample_rate; - st->codec.bits_per_sample = ipmovie->audio_bits; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - if (st->codec.codec_id == CODEC_ID_INTERPLAY_DPCM) - st->codec.bit_rate /= 2; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = ipmovie->audio_type; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = ipmovie->audio_channels; + st->codec->sample_rate = ipmovie->audio_sample_rate; + st->codec->bits_per_sample = ipmovie->audio_bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM) + st->codec->bit_rate /= 2; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; } return 0; diff --git a/mythtv/libs/libavformat/libavformat.pro b/mythtv/libs/libavformat/libavformat.pro index cfc0cc0a35a..dcf4235a9d7 100644 --- a/mythtv/libs/libavformat/libavformat.pro +++ b/mythtv/libs/libavformat/libavformat.pro @@ -27,10 +27,10 @@ SOURCES += mpjpeg.c nut.c os_support.c rm.c psxstr.c raw.c flic.c audio.c SOURCES += segafilm.c swf.c utils.c wav.c wc3movie.c westwood.c yuv4mpeg.c SOURCES += sierravmd.c asf-enc.c matroska.c img2.c electronicarts.c sol.c SOURCES += nsvdec.c ogg2.c oggparsevorbis.c oggparsetheora.c oggparseflac.c +SOURCES += mmf.c gif.c gifdec.c jpeg.c png.c pnm.c sgi.c yuv.c # not using: barpainet.* beosaudio.cpp, dv1394.*, dc1394.c, framehook.* -# not using: gif.c gifdec.c grab.c http.c jpeg.c png.c pnm.c rtp.* -# not using: rtpproto.c rtsp* sgi.c tcp.c udp.c yuv.c +# not using: grab.c contains( AMR_NB, yes ) { SOURCES += amr.c @@ -46,6 +46,10 @@ contains( CONFIG_VORBIS, yes ) { SOURCES += ogg.c } +contains( CONFIG_NETWORK, yes ) { + SOURCES += rtp.c rtpproto.c rtsp.c udp.c tcp.c http.c +} + inc.path = $${PREFIX}/include/mythtv/ffmpeg/ inc.files = avformat.h avio.h diff --git a/mythtv/libs/libavformat/matroska.c b/mythtv/libs/libavformat/matroska.c index 0cb1efc6361..0661151487c 100644 --- a/mythtv/libs/libavformat/matroska.c +++ b/mythtv/libs/libavformat/matroska.c @@ -2273,46 +2273,46 @@ matroska_read_header (AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ - st->codec.codec_id = codec_id; + st->codec->codec_id = codec_id; if(extradata){ - st->codec.extradata = extradata; - st->codec.extradata_size = extradata_size; + st->codec->extradata = extradata; + st->codec->extradata_size = extradata_size; } else if(track->codec_priv && track->codec_priv_size > 0){ - st->codec.extradata = av_malloc(track->codec_priv_size); - if(st->codec.extradata == NULL) + st->codec->extradata = av_malloc(track->codec_priv_size); + if(st->codec->extradata == NULL) return AVERROR_NOMEM; - st->codec.extradata_size = track->codec_priv_size; - memcpy(st->codec.extradata, track->codec_priv, + st->codec->extradata_size = track->codec_priv_size; + memcpy(st->codec->extradata, track->codec_priv, track->codec_priv_size); } if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_tag = videotrack->fourcc; - st->codec.width = videotrack->pixel_width; - st->codec.height = videotrack->pixel_height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_tag = videotrack->fourcc; + st->codec->width = videotrack->pixel_width; + st->codec->height = videotrack->pixel_height; if (videotrack->display_width == 0) - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->pixel_width; else - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->display_width; if (videotrack->display_height == 0) - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->pixel_height; else - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->display_height; } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.sample_rate = audiotrack->samplerate; - st->codec.channels = audiotrack->channels; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->sample_rate = audiotrack->samplerate; + st->codec->channels = audiotrack->channels; } /* What do we do with private data? E.g. for Vorbis. */ @@ -2700,7 +2700,7 @@ matroska_read_close (AVFormatContext *s) } for (n = 0; n < s->nb_streams; n++) { - av_free(s->streams[n]->codec.extradata); + av_free(s->streams[n]->codec->extradata); } memset(matroska, 0, sizeof(MatroskaDemuxContext)); diff --git a/mythtv/libs/libavformat/mov.c b/mythtv/libs/libavformat/mov.c index cac2c084d18..544db9b2397 100644 --- a/mythtv/libs/libavformat/mov.c +++ b/mythtv/libs/libavformat/mov.c @@ -481,16 +481,16 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) /* helps parsing the string hereafter... */ c->mp4 = 0; if(type == MKTAG('v', 'i', 'd', 'e')) - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; else if(type == MKTAG('s', 'o', 'u', 'n')) - st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = CODEC_TYPE_AUDIO; } else if(ctype == 0) { /* MP4 */ /* helps parsing the string hereafter... */ c->mp4 = 1; if(type == MKTAG('v', 'i', 'd', 'e')) - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; else if(type == MKTAG('s', 'o', 'u', 'n')) - st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = CODEC_TYPE_AUDIO; } get_be32(pb); /* component manufacture */ get_be32(pb); /* component flags */ @@ -591,10 +591,10 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) #ifdef DEBUG av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len); #endif - st->codec.extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); - if (st->codec.extradata) { - get_buffer(pb, st->codec.extradata, len); - st->codec.extradata_size = len; + st->codec->extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); + if (st->codec->extradata) { + get_buffer(pb, st->codec->extradata, len); + st->codec->extradata_size = len; } } } @@ -703,14 +703,14 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) // currently SVQ3 decoder expect full STSD header - so let's fake it // this should be fixed and just SMI header should be passed - av_free(st->codec.extradata); - st->codec.extradata_size = 0x5a + atom.size; - st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - - if (st->codec.extradata) { - strcpy(st->codec.extradata, "SVQ3"); // fake - get_buffer(pb, st->codec.extradata + 0x5a, atom.size); - //av_log(NULL, AV_LOG_DEBUG, "Reading SMI %Ld %s\n", atom.size, (char*)st->codec.extradata + 0x5a); + av_free(st->codec->extradata); + st->codec->extradata_size = 0x5a + atom.size; + st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + + if (st->codec->extradata) { + strcpy(st->codec->extradata, "SVQ3"); // fake + get_buffer(pb, st->codec->extradata + 0x5a, atom.size); + //av_log(NULL, AV_LOG_DEBUG, "Reading SMI %Ld %s\n", atom.size, (char*)st->codec->extradata + 0x5a); } else url_fskip(pb, atom.size); @@ -724,13 +724,13 @@ static int mov_read_avcC(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) if((uint64_t)atom.size > (1<<30)) return -1; - av_free(st->codec.extradata); + av_free(st->codec->extradata); - st->codec.extradata_size = atom.size; - st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata_size = atom.size; + st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - if (st->codec.extradata) { - get_buffer(pb, st->codec.extradata, atom.size); + if (st->codec->extradata) { + get_buffer(pb, st->codec->extradata, atom.size); } else url_fskip(pb, atom.size); @@ -829,7 +829,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) AVCodec *codec; codec = avcodec_find_decoder(id); if (codec) - st->codec.codec_type = codec->type; + st->codec->codec_type = codec->type; } #ifdef DEBUG av_log(NULL, AV_LOG_DEBUG, "size=%d 4CC= %c%c%c%c codec_type=%d\n", @@ -838,23 +838,23 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff, - st->codec.codec_type); + st->codec->codec_type); #endif - st->codec.codec_tag = format; - if(st->codec.codec_type==CODEC_TYPE_VIDEO) { + st->codec->codec_tag = format; + if(st->codec->codec_type==CODEC_TYPE_VIDEO) { MOV_atom_t a = { 0, 0, 0 }; - st->codec.codec_id = id; + st->codec->codec_id = id; get_be16(pb); /* version */ get_be16(pb); /* revision level */ get_be32(pb); /* vendor */ get_be32(pb); /* temporal quality */ get_be32(pb); /* spacial quality */ - if(st->codec.codec_id == CODEC_ID_MPEG4){ //FIXME this is silly + if(st->codec->codec_id == CODEC_ID_MPEG4){ //FIXME this is silly get_be16(pb); get_be16(pb); }else{ - st->codec.width = get_be16(pb); /* width */ - st->codec.height = get_be16(pb); /* height */ + st->codec->width = get_be16(pb); /* width */ + st->codec->height = get_be16(pb); /* height */ } get_be32(pb); /* horiz resolution */ get_be32(pb); /* vert resolution */ @@ -865,16 +865,16 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) #endif get_buffer(pb, codec_name, 32); /* codec name, pascal string (FIXME: true for mp4?) */ if (codec_name[0] <= 31) { - memcpy(st->codec.codec_name, &codec_name[1],codec_name[0]); - st->codec.codec_name[codec_name[0]] = 0; + memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]); + st->codec->codec_name[codec_name[0]] = 0; } - st->codec.bits_per_sample = get_be16(pb); /* depth */ - st->codec.color_table_id = get_be16(pb); /* colortable id */ + st->codec->bits_per_sample = get_be16(pb); /* depth */ + st->codec->color_table_id = get_be16(pb); /* colortable id */ /* These are set in mov_read_stts and might already be set! - st->codec.time_base.den = 25; - st->codec.time_base.num = 1; + st->codec->time_base.den = 25; + st->codec->time_base.num = 1; */ size -= (16+8*4+2+32+2*2); #if 0 @@ -948,8 +948,8 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) #else /* figure out the palette situation */ - color_depth = st->codec.bits_per_sample & 0x1F; - color_greyscale = st->codec.bits_per_sample & 0x20; + color_depth = st->codec->bits_per_sample & 0x1F; + color_greyscale = st->codec->bits_per_sample & 0x20; /* if the depth is 2, 4, or 8 bpp, file is palettized */ if ((color_depth == 2) || (color_depth == 4) || @@ -970,7 +970,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) color_index = 0; } - } else if (st->codec.color_table_id & 0x08) { + } else if (st->codec->color_table_id & 0x08) { /* if flag bit 3 is set, use the default palette */ color_count = 1 << color_depth; @@ -1012,17 +1012,17 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) } } - st->codec.palctrl = &c->palette_control; - st->codec.palctrl->palette_changed = 1; + st->codec->palctrl = &c->palette_control; + st->codec->palctrl->palette_changed = 1; } else - st->codec.palctrl = NULL; + st->codec->palctrl = NULL; a.size = size; mov_read_default(c, pb, a); #endif } else { - st->codec.codec_id = codec_get_id(mov_audio_tags, format); - if(st->codec.codec_id==CODEC_ID_AMR_NB || st->codec.codec_id==CODEC_ID_AMR_WB) //from TS26.244 + st->codec->codec_id = codec_get_id(mov_audio_tags, format); + if(st->codec->codec_id==CODEC_ID_AMR_NB || st->codec->codec_id==CODEC_ID_AMR_WB) //from TS26.244 { #ifdef DEBUG av_log(NULL, AV_LOG_DEBUG, "AMR-NB or AMR-WB audio identified!!\n"); @@ -1045,21 +1045,21 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) get_byte(pb); //frames_per_sample st->duration = AV_NOPTS_VALUE;//Not possible to get from this info, must count number of AMR frames - if(st->codec.codec_id==CODEC_ID_AMR_NB) + if(st->codec->codec_id==CODEC_ID_AMR_NB) { - st->codec.sample_rate=8000; - st->codec.channels=1; + st->codec->sample_rate=8000; + st->codec->channels=1; } else //AMR-WB { - st->codec.sample_rate=16000; - st->codec.channels=1; + st->codec->sample_rate=16000; + st->codec->channels=1; } - st->codec.bits_per_sample=16; - st->codec.bit_rate=0; /*It is not possible to tell this before we have + st->codec->bits_per_sample=16; + st->codec->bit_rate=0; /*It is not possible to tell this before we have an audio frame and even then every frame can be different*/ } - else if( st->codec.codec_tag == MKTAG( 'm', 'p', '4', 's' )) + else if( st->codec->codec_tag == MKTAG( 'm', 'p', '4', 's' )) { //This is some stuff for the hint track, lets ignore it! //Do some mp4 auto detect. @@ -1067,7 +1067,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) size-=(16); url_fskip(pb, size); /* The mp4s atom also contians a esds atom that we can skip*/ } - else if( st->codec.codec_tag == MKTAG( 'm', 'p', '4', 'a' )) + else if( st->codec->codec_tag == MKTAG( 'm', 'p', '4', 'a' )) { MOV_atom_t a; int mp4_version; @@ -1076,10 +1076,10 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) mp4_version=get_be16(pb);/*version*/ get_be16(pb); /*revesion*/ get_be32(pb); - st->codec.channels = get_be16(pb); /* channels */ - st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ + st->codec->channels = get_be16(pb); /* channels */ + st->codec->bits_per_sample = get_be16(pb); /* bits per sample */ get_be32(pb); - st->codec.sample_rate = get_be16(pb); /* sample rate, not always correct */ + st->codec->sample_rate = get_be16(pb); /* sample rate, not always correct */ get_be16(pb); c->mp4=1; @@ -1096,35 +1096,35 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) mov_read_default(c, pb, a); /* Get correct sample rate from extradata */ - if(st->codec.extradata_size) { + if(st->codec->extradata_size) { const int samplerate_table[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0 }; - unsigned char *px = st->codec.extradata; + unsigned char *px = st->codec->extradata; // 5 bits objectTypeIndex, 4 bits sampleRateIndex, 4 bits channels int samplerate_index = ((px[0] & 7) << 1) + ((px[1] >> 7) & 1); - st->codec.sample_rate = samplerate_table[samplerate_index]; - st->codec.channels = (px[1] >> 3) & 15; + st->codec->sample_rate = samplerate_table[samplerate_index]; + st->codec->channels = (px[1] >> 3) & 15; } } - else if( st->codec.codec_tag == MKTAG( 'a', 'l', 'a', 'c' )) + else if( st->codec->codec_tag == MKTAG( 'a', 'l', 'a', 'c' )) { /* Handle alac audio tag + special extradata */ get_be32(pb); /* version */ get_be32(pb); - st->codec.channels = get_be16(pb); /* channels */ - st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ + st->codec->channels = get_be16(pb); /* channels */ + st->codec->bits_per_sample = get_be16(pb); /* bits per sample */ get_be32(pb); - st->codec.sample_rate = get_be16(pb); + st->codec->sample_rate = get_be16(pb); get_be16(pb); /* fetch the 36-byte extradata needed for alac decoding */ - st->codec.extradata_size = 36; - st->codec.extradata = (uint8_t*) - av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size = 36; + st->codec->extradata = (uint8_t*) + av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + get_buffer(pb, st->codec->extradata, st->codec->extradata_size); } else if(size>=(16+20)) {//16 bytes read, reading atleast 20 more @@ -1136,23 +1136,23 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) get_be16(pb); /* revision level */ get_be32(pb); /* vendor */ - st->codec.channels = get_be16(pb); /* channel count */ - st->codec.bits_per_sample = get_be16(pb); /* sample size */ + st->codec->channels = get_be16(pb); /* channel count */ + st->codec->bits_per_sample = get_be16(pb); /* sample size */ /* handle specific s8 codec */ get_be16(pb); /* compression id = 0*/ get_be16(pb); /* packet size = 0 */ - st->codec.sample_rate = ((get_be32(pb) >> 16)); - //av_log(NULL, AV_LOG_DEBUG, "CODECID %d %d %.4s\n", st->codec.codec_id, CODEC_ID_PCM_S16BE, (char*)&format); + st->codec->sample_rate = ((get_be32(pb) >> 16)); + //av_log(NULL, AV_LOG_DEBUG, "CODECID %d %d %.4s\n", st->codec->codec_id, CODEC_ID_PCM_S16BE, (char*)&format); - switch (st->codec.codec_id) { + switch (st->codec->codec_id) { case CODEC_ID_PCM_S16BE: - if (st->codec.bits_per_sample == 8) - st->codec.codec_id = CODEC_ID_PCM_S8; + if (st->codec->bits_per_sample == 8) + st->codec->codec_id = CODEC_ID_PCM_S8; /* fall */ case CODEC_ID_PCM_U8: - st->codec.bit_rate = st->codec.sample_rate * 8; + st->codec->bit_rate = st->codec->sample_rate * 8; break; default: ; @@ -1348,8 +1348,8 @@ av_log(NULL, AV_LOG_DEBUG, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, } av_set_pts_info(st, 64, 1, c->streams[c->fc->nb_streams-1]->time_scale); -// st->codec.time_base.num = 1; -// st->codec.time_base.den = c->streams[c->fc->nb_streams-1]->time_scale; +// st->codec->time_base.num = 1; +// st->codec->time_base.den = c->streams[c->fc->nb_streams-1]->time_scale; st->nb_frames= total_sample_count; if(duration) st->duration= duration; @@ -1400,7 +1400,7 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) sc->sample_to_chunk_index = -1; st->priv_data = sc; - st->codec.codec_type = CODEC_TYPE_MOV_OTHER; + st->codec->codec_type = CODEC_TYPE_MOV_OTHER; st->start_time = 0; /* XXX: check */ c->streams[c->fc->nb_streams-1] = sc; @@ -1443,8 +1443,8 @@ static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) url_fskip(pb, 36); /* display matrix */ /* those are fixed-point */ - /*st->codec.width =*/ get_be32(pb) >> 16; /* track width */ - /*st->codec.height =*/ get_be32(pb) >> 16; /* track height */ + /*st->codec->width =*/ get_be32(pb) >> 16; /* track width */ + /*st->codec->height =*/ get_be32(pb) >> 16; /* track height */ return 0; } @@ -1755,7 +1755,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) #if 1 for(i=0; inb_streams;) { - if(s->streams[i]->codec.codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */ + if(s->streams[i]->codec->codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */ av_free(s->streams[i]); for(j=i+1; jnb_streams; j++) s->streams[j-1] = s->streams[j]; @@ -1894,7 +1894,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) { // I can't figure out why for PCM audio sample_size is always 1 // (it should actually be channels*bits_per_second/8) but it is. - AVCodecContext* cod = &s->streams[sc->ffindex]->codec; + AVCodecContext* cod = s->streams[sc->ffindex]->codec; if (sc->sample_size == 1 && (cod->codec_id == CODEC_ID_PCM_S16BE || cod->codec_id == CODEC_ID_PCM_S16LE)) foundsize=(sc->sample_to_chunk[i].count*cod->channels*cod->bits_per_sample)/8; else diff --git a/mythtv/libs/libavformat/movenc.c b/mythtv/libs/libavformat/movenc.c index 6d8ac364a35..912fa4b21cd 100644 --- a/mythtv/libs/libavformat/movenc.c +++ b/mythtv/libs/libavformat/movenc.c @@ -267,6 +267,7 @@ static const CodecTag codec_movaudio_tags[] = { { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') }, { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, + { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') }, { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') }, { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') }, @@ -1255,11 +1256,11 @@ int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s) static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) { - int AudioRate = s->streams[1]->codec.sample_rate; - int FrameRate = ((s->streams[0]->codec.time_base.den) * (0x10000))/ (s->streams[0]->codec.time_base.num); + int AudioRate = s->streams[1]->codec->sample_rate; + int FrameRate = ((s->streams[0]->codec->time_base.den) * (0x10000))/ (s->streams[0]->codec->time_base.num); //printf("audiorate = %d\n",AudioRate); - //printf("framerate = %d / %d = 0x%x\n",s->streams[0]->codec.time_base.den,s->streams[0]->codec.time_base.num,FrameRate); + //printf("framerate = %d / %d = 0x%x\n",s->streams[0]->codec->time_base.den,s->streams[0]->codec->time_base.num,FrameRate); put_be32(pb, 0x94 ); /* size */ put_tag(pb, "uuid"); @@ -1301,8 +1302,8 @@ static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) put_be32(pb, 0xc0 ); put_be32(pb, FrameRate); // was 0xefc29 put_be32(pb, FrameRate ); // was 0xefc29 - put_be16(pb, s->streams[0]->codec.width); - put_be16(pb, s->streams[0]->codec.height); + put_be16(pb, s->streams[0]->codec->width); + put_be16(pb, s->streams[0]->codec->height); put_be32(pb, 0x010001 ); } @@ -1313,7 +1314,7 @@ static int mov_write_header(AVFormatContext *s) int i; for(i=0; inb_streams; i++){ - AVCodecContext *c= &s->streams[i]->codec; + AVCodecContext *c= s->streams[i]->codec; if (c->codec_type == CODEC_TYPE_VIDEO){ if (!codec_get_tag(codec_movvideo_tags, c->codec_id)){ @@ -1366,7 +1367,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVContext *mov = s->priv_data; ByteIOContext *pb = &s->pb; - AVCodecContext *enc = &s->streams[pkt->stream_index]->codec; + AVCodecContext *enc = s->streams[pkt->stream_index]->codec; MOVTrack* trk = &mov->tracks[pkt->stream_index]; int cl, id; unsigned int samplesInChunk = 0; diff --git a/mythtv/libs/libavformat/mp3.c b/mythtv/libs/libavformat/mp3.c index ddc27dea6f8..f45f852d58a 100644 --- a/mythtv/libs/libavformat/mp3.c +++ b/mythtv/libs/libavformat/mp3.c @@ -251,8 +251,8 @@ static int mp3_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_MP3; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_MP3; st->need_parsing = 1; /* try to get the TAG */ @@ -350,7 +350,7 @@ AVInputFormat mp3_iformat = { mp3_read_header, mp3_read_packet, mp3_read_close, - .extensions = "mp2,mp3", /* XXX: use probe */ + .extensions = "mp2,mp3,m2a", /* XXX: use probe */ }; #ifdef CONFIG_ENCODERS @@ -359,9 +359,9 @@ AVOutputFormat mp2_oformat = { "MPEG audio layer 2", "audio/x-mpeg", #ifdef CONFIG_MP3LAME - "mp2", + "mp2,m2a", #else - "mp2,mp3", + "mp2,mp3,m2a", #endif 0, CODEC_ID_MP2, diff --git a/mythtv/libs/libavformat/mpeg.c b/mythtv/libs/libavformat/mpeg.c index 7057a8f8554..b21ba38b2cc 100644 --- a/mythtv/libs/libavformat/mpeg.c +++ b/mythtv/libs/libavformat/mpeg.c @@ -360,26 +360,26 @@ static int mpeg_mux_init(AVFormatContext *ctx) av_set_pts_info(st, 64, 1, 90000); - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: - if (st->codec.codec_id == CODEC_ID_AC3) { + if (st->codec->codec_id == CODEC_ID_AC3) { stream->id = ac3_id++; - } else if (st->codec.codec_id == CODEC_ID_DTS) { + } else if (st->codec->codec_id == CODEC_ID_DTS) { stream->id = dts_id++; - } else if (st->codec.codec_id == CODEC_ID_PCM_S16BE) { + } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) { stream->id = lpcm_id++; for(j = 0; j < 4; j++) { - if (lpcm_freq_tab[j] == st->codec.sample_rate) + if (lpcm_freq_tab[j] == st->codec->sample_rate) break; } if (j == 4) goto fail; - if (st->codec.channels > 8) + if (st->codec->channels > 8) return -1; stream->lpcm_header[0] = 0x0c; - stream->lpcm_header[1] = (st->codec.channels - 1) | (j << 4); + stream->lpcm_header[1] = (st->codec->channels - 1) | (j << 4); stream->lpcm_header[2] = 0x80; - stream->lpcm_align = st->codec.channels * 2; + stream->lpcm_align = st->codec->channels * 2; } else { stream->id = mpa_id++; } @@ -391,8 +391,8 @@ static int mpeg_mux_init(AVFormatContext *ctx) break; case CODEC_TYPE_VIDEO: stream->id = mpv_id++; - if (st->codec.rc_buffer_size) - stream->max_buffer_size = 6*1024 + st->codec.rc_buffer_size/8; + if (st->codec->rc_buffer_size) + stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8; else stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default #if 0 @@ -422,10 +422,10 @@ static int mpeg_mux_init(AVFormatContext *ctx) st = ctx->streams[i]; stream = (StreamInfo*) st->priv_data; - if(st->codec.rc_max_rate || stream->id==VIDEO_ID) - codec_rate= st->codec.rc_max_rate; + if(st->codec->rc_max_rate || stream->id==VIDEO_ID) + codec_rate= st->codec->rc_max_rate; else - codec_rate= st->codec.bit_rate; + codec_rate= st->codec->bit_rate; if(!codec_rate) codec_rate= (1<<21)*8*50/ctx->nb_streams; @@ -1073,7 +1073,7 @@ static int output_packet(AVFormatContext *ctx, int flush){ /* for subtitle, a single PES packet must be generated, so we flush after every single subtitle packet */ if(s->packet_size > avail_data && !flush - && st->codec.codec_type != CODEC_TYPE_SUBTITLE) + && st->codec->codec_type != CODEC_TYPE_SUBTITLE) return 0; if(avail_data==0) continue; @@ -1183,7 +1183,7 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt) int64_t pts, dts; PacketDesc *pkt_desc; const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE); - const int is_iframe = st->codec.codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY); + const int is_iframe = st->codec->codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY); pts= pkt->pts; dts= pkt->dts; @@ -1283,7 +1283,7 @@ static int mpegps_probe(AVProbeData *p) code == PROGRAM_STREAM_MAP || code == PRIVATE_STREAM_1 || code == PADDING_STREAM || - code >= 0x100 && code <= 0x1b0) // An out of place packet + code >= 0x100 && code <= 0x1b0) return AVPROBE_SCORE_MAX - 2; else return 0; @@ -1635,8 +1635,8 @@ static int mpegps_read_packet(AVFormatContext *s, st = av_new_stream(s, startcode); if (!st) goto skip; - st->codec.codec_type = type; - st->codec.codec_id = codec_id; + st->codec->codec_type = type; + st->codec->codec_id = codec_id; if (codec_id != CODEC_ID_PCM_S16BE) st->need_parsing = 1; @@ -1660,9 +1660,9 @@ static int mpegps_read_packet(AVFormatContext *s, get_byte(&s->pb); /* dynamic range control (0x80 = off) */ len -= 3; freq = (b1 >> 4) & 3; - st->codec.sample_rate = lpcm_freq_tab[freq]; - st->codec.channels = 1 + (b1 & 7); - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * 2; + st->codec->sample_rate = lpcm_freq_tab[freq]; + st->codec->channels = 1 + (b1 & 7); + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * 2; } av_new_packet(pkt, len); get_buffer(&s->pb, pkt->data, pkt->size); diff --git a/mythtv/libs/libavformat/mpegts.c b/mythtv/libs/libavformat/mpegts.c index 703aa337498..25c8c652a34 100644 --- a/mythtv/libs/libavformat/mpegts.c +++ b/mythtv/libs/libavformat/mpegts.c @@ -30,7 +30,10 @@ synchronisation is lost */ #define MAX_RESYNC_SIZE 4096 -static int add_pes_stream(MpegTSContext *ts, int pid, int stream_type); +typedef struct PESContext PESContext; + +static PESContext* add_pes_stream(MpegTSContext *ts, int pid, int stream_type); +static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code); enum MpegTSFilterType { MPEGTS_PES, @@ -392,8 +395,13 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len) { MpegTSContext *ts = opaque; SectionHeader h1, *h = &h1; - const uint8_t *p, *p_end; - int program_info_length, pcr_pid, pid, stream_type, desc_length; + PESContext *pes; + AVStream *st; + const uint8_t *p, *p_end, *desc_list_end, *desc_end; + int program_info_length, pcr_pid, pid, stream_type; + int desc_list_len, desc_len, desc_tag; + int comp_page, anc_page; + char language[4]; int changes = 0; #ifdef DEBUG_SI @@ -433,18 +441,57 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len) ts->pmt_pids_old[i]=0; for(i=0;;) { + language[0] = 0; + st = 0; stream_type = get8(&p, p_end); if (stream_type < 0) break; pid = get16(&p, p_end) & 0x1fff; if (pid < 0) break; - desc_length = get16(&p, p_end) & 0xfff; - if (desc_length < 0) + desc_list_len = get16(&p, p_end) & 0xfff; + if (desc_list_len < 0) + break; + desc_list_end = p + desc_list_len; + if (desc_list_end > p_end) break; - p += desc_length; - if (p > p_end) - return; + for(;;) { + desc_tag = get8(&p, desc_list_end); + if (desc_tag < 0) + break; + desc_len = get8(&p, desc_list_end); + desc_end = p + desc_len; + if (desc_end > desc_list_end) + break; +#ifdef DEBUG_SI + printf("tag: 0x%02x len=%d\n", desc_tag, desc_len); +#endif + switch(desc_tag) { + case DVB_SUBT_DESCID: + if (stream_type == STREAM_TYPE_PRIVATE_DATA) + stream_type = STREAM_TYPE_SUBTITLE_DVB; + + language[0] = get8(&p, desc_end); + language[1] = get8(&p, desc_end); + language[2] = get8(&p, desc_end); + language[3] = 0; + get8(&p, desc_end); + comp_page = get16(&p, desc_end); + anc_page = get16(&p, desc_end); + + break; + case 0x0a: /* ISO 639 language descriptor */ + language[0] = get8(&p, desc_end); + language[1] = get8(&p, desc_end); + language[2] = get8(&p, desc_end); + language[3] = 0; + break; + default: + break; + } + p = desc_end; + } + p = desc_list_end; #ifdef DEBUG_SI av_log(NULL, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n", stream_type, pid); @@ -461,9 +508,12 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len) case STREAM_TYPE_AUDIO_AAC: case STREAM_TYPE_AUDIO_AC3: case STREAM_TYPE_AUDIO_DTS: + case STREAM_TYPE_SUBTITLE_DVB: if (!pmtInList(ts->pmt_pids_old, pid)) { printf("adding pes stream at pid 0x%x with type %i\n", pid, stream_type); - add_pes_stream(ts, pid, stream_type); + pes = add_pes_stream(ts, pid, stream_type); + if (pes) + st = new_pes_av_stream(pes, 0); changes = 1; } ts->pmt_pids[i]=pid; i++; @@ -472,6 +522,18 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len) /* we ignore the other streams */ break; } + + if (st) { + if (language[0] != 0) { + st->language[0] = language[0]; + st->language[1] = language[1]; + st->language[2] = language[2]; + st->language[3] = language[3]; + } + if (stream_type == STREAM_TYPE_SUBTITLE_DVB) { + st->codec->sub_id = (anc_page << 16) | comp_page; + } + } } /* clear existing streams and filters not in new pmt */ @@ -719,7 +781,7 @@ enum MpegTSState { #define PES_START_SIZE 9 #define MAX_PES_HEADER_SIZE (9 + 255) -typedef struct PESContext { +struct PESContext { int pid; int stream_type; MpegTSContext *ts; @@ -733,7 +795,7 @@ typedef struct PESContext { int64_t pts, dts; uint8_t header[MAX_PES_HEADER_SIZE]; int64_t startpos; -} PESContext; +}; static int64_t get_pts(const uint8_t *p) { @@ -783,6 +845,10 @@ static void init_stream(AVStream *st, int stream_type, int code) codec_type = CODEC_TYPE_AUDIO; codec_id = CODEC_ID_DTS; break; + case STREAM_TYPE_SUBTITLE_DVB: + codec_type = CODEC_TYPE_SUBTITLE; + codec_id = CODEC_ID_DVB_SUBTITLE; + break; default: if (code >= 0x1c0 && code <= 0x1df) { codec_type = CODEC_TYPE_AUDIO; @@ -796,22 +862,22 @@ static void init_stream(AVStream *st, int stream_type, int code) } break; } - st->codec.codec_type = codec_type; - st->codec.codec_id = codec_id; + st->codec->codec_type = codec_type; + st->codec->codec_id = codec_id; av_set_pts_info(st, 33, 1, 90000); } -static int create_stream(PESContext *pes, int code) +static AVStream *new_pes_av_stream(PESContext *pes, uint32_t code) { CHECKED_ALLOCZ(pes->st, sizeof(AVStream)); - avcodec_get_context_defaults(&pes->st->codec); // sets codec defaults + pes->st->codec = avcodec_alloc_context(); init_stream(pes->st, pes->stream_type, code); // sets codec type and id pes->st->priv_data = pes; pes->st->need_parsing = 1; pes->st = av_add_stream(pes->stream, pes->st, pes->pid); fail: //for the CHECKED_ALLOCZ macro - return (pes->st)? 0 : -1; + return pes->st; } @@ -855,7 +921,7 @@ static void mpegts_push_data(void *opaque, (code >= 0x1e0 && code <= 0x1ef) || (code == 0x1bd))) goto skip; - if (!pes->st && -1==create_stream(pes, code)) { + if (!pes->st && 0 == new_pes_av_stream(pes, code)) { av_log(NULL, AV_LOG_ERROR, "Error: create_stream() failed in mpegts_push_data"); goto skip; } @@ -938,7 +1004,7 @@ static void mpegts_push_data(void *opaque, } } -static int add_pes_stream(MpegTSContext *ts, int pid, int stream_type) +static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int stream_type) { MpegTSFilter *tss = ts->pids[pid]; PESContext *pes = 0; @@ -946,7 +1012,7 @@ static int add_pes_stream(MpegTSContext *ts, int pid, int stream_type) if (tss->type == MPEGTS_PES) pes = (PESContext*) tss->u.pes_filter.opaque; if (pes && (pes->stream_type == stream_type)) { - return 0; // if it's the same stream type, just return ok + return pes; // if it's the same stream type, just return ok } // otherwise, kill it, and start a new stream mpegts_close_filter(ts, tss); @@ -955,7 +1021,7 @@ static int add_pes_stream(MpegTSContext *ts, int pid, int stream_type) /* create a PES context */ if (!(pes=av_mallocz(sizeof(PESContext)))) { av_log(NULL, AV_LOG_ERROR, "Error: av_mallocz() failed in add_pes_stream"); - return -1; + return 0; } pes->ts = ts; pes->stream = ts->stream; @@ -965,18 +1031,10 @@ static int add_pes_stream(MpegTSContext *ts, int pid, int stream_type) if (!tss) { av_free(pes); av_log(NULL, AV_LOG_ERROR, "Error: unable to open mpegts PES filter in add_pes_stream"); - return -1; - } - if (!pes->st && -1==create_stream(pes, -1)) { - av_log(NULL, AV_LOG_ERROR, "Error: create_stream() failed in add_pes_stream"); - return -1; + return 0; } - assert(pes->stream_type==stream_type); - assert(pes->st->codec.codec_type); - assert(pes->st->codec.codec_id); - - return 0; + return pes; } /* handle one TS packet */ @@ -996,7 +1054,10 @@ static void handle_packet(MpegTSContext *ts, const uint8_t *packet, int64_t posi is_start = packet[1] & 0x40; tss = ts->pids[pid]; if (ts->auto_guess && tss == NULL && is_start) { - add_pes_stream(ts, pid, 0); + PESContext *pes = add_pes_stream(ts, pid, 0); + if (pes) + new_pes_av_stream(pes, 0); + tss = ts->pids[pid]; } if (!tss) @@ -1281,9 +1342,9 @@ static int mpegts_read_header(AVFormatContext *s, av_log(NULL, AV_LOG_ERROR, "mpegts_read_header: av_new_stream() failed\n"); goto fail; } - av_set_pts_info(st, 33, 1, 90000); - st->codec.codec_type = CODEC_TYPE_DATA; - st->codec.codec_id = CODEC_ID_MPEG2TS; + av_set_pts_info(st, 33, 1, 27000000); + st->codec->codec_type = CODEC_TYPE_DATA; + st->codec->codec_id = CODEC_ID_MPEG2TS; /* we iterate until we find two PCRs to estimate the bitrate */ pcr_pid = -1; @@ -1314,7 +1375,7 @@ static int mpegts_read_header(AVFormatContext *s, ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr; - st->codec.bit_rate = s->bit_rate; + st->codec->bit_rate = s->bit_rate; st->start_time = ts->cur_pcr; #if 0 printf("start=%0.3f pcr=%0.3f incr=%d\n", diff --git a/mythtv/libs/libavformat/mpegts.h b/mythtv/libs/libavformat/mpegts.h index 5dfa7b20ccf..848ecdb27af 100644 --- a/mythtv/libs/libavformat/mpegts.h +++ b/mythtv/libs/libavformat/mpegts.h @@ -31,6 +31,9 @@ #define PMT_TID 0x02 #define SDT_TID 0x42 +/* descriptor ids */ +#define DVB_SUBT_DESCID 0x59 + #define STREAM_TYPE_VIDEO_MPEG1 0x01 #define STREAM_TYPE_VIDEO_MPEG2 0x02 #define STREAM_TYPE_AUDIO_MPEG1 0x03 @@ -44,6 +47,8 @@ #define STREAM_TYPE_AUDIO_AC3 0x81 #define STREAM_TYPE_AUDIO_DTS 0x8a +#define STREAM_TYPE_SUBTITLE_DVB 0x100 + unsigned int mpegts_crc32(const uint8_t *data, int len); extern AVOutputFormat mpegts_mux; diff --git a/mythtv/libs/libavformat/mpegtsenc.c b/mythtv/libs/libavformat/mpegtsenc.c index 1463abea78e..4fe8f3e15c9 100644 --- a/mythtv/libs/libavformat/mpegtsenc.c +++ b/mythtv/libs/libavformat/mpegtsenc.c @@ -262,7 +262,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) for(i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MpegTSWriteStream *ts_st = st->priv_data; - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG2VIDEO: stream_type = STREAM_TYPE_VIDEO_MPEG2; @@ -293,7 +293,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) q += 2; /* patched after */ /* write optional descriptors here */ - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: if (strlen(st->language) == 3) { *q++ = 0x0a; /* ISO 639 language descriptor */ @@ -452,10 +452,10 @@ static int mpegts_write_header(AVFormatContext *s) ts_st->pid = DEFAULT_START_PID + i; ts_st->payload_pts = AV_NOPTS_VALUE; /* update PCR pid by using the first video stream */ - if (st->codec.codec_type == CODEC_TYPE_VIDEO && + if (st->codec->codec_type == CODEC_TYPE_VIDEO && service->pcr_pid == 0x1fff) service->pcr_pid = ts_st->pid; - total_bit_rate += st->codec.bit_rate; + total_bit_rate += st->codec->bit_rate; } /* if no video stream, use the first stream as PCR */ @@ -570,15 +570,15 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, *q++ = 0x00; *q++ = 0x01; private_code = 0; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { *q++ = 0xe0; - } else if (st->codec.codec_type == CODEC_TYPE_AUDIO && - (st->codec.codec_id == CODEC_ID_MP2 || - st->codec.codec_id == CODEC_ID_MP3)) { + } else if (st->codec->codec_type == CODEC_TYPE_AUDIO && + (st->codec->codec_id == CODEC_ID_MP2 || + st->codec->codec_id == CODEC_ID_MP3)) { *q++ = 0xc0; } else { *q++ = 0xbd; - if (st->codec.codec_type == CODEC_TYPE_SUBTITLE) { + if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) { private_code = 0x20; } } @@ -593,7 +593,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, *q++ = len; val = 0x80; /* data alignment indicator is required for subtitle data */ - if (st->codec.codec_type == CODEC_TYPE_SUBTITLE) + if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) val |= 0x04; *q++ = val; if (pts != AV_NOPTS_VALUE) { @@ -660,7 +660,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) MpegTSWriteStream *ts_st = st->priv_data; int len, max_payload_size; - if (st->codec.codec_type == CODEC_TYPE_SUBTITLE) { + if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) { /* for subtitle, a single PES packet must be generated */ mpegts_write_pes(s, st, buf, size, pkt->pts); return 0; diff --git a/mythtv/libs/libavformat/mpjpeg.c b/mythtv/libs/libavformat/mpjpeg.c index da61c0726a8..db854bac5dd 100644 --- a/mythtv/libs/libavformat/mpjpeg.c +++ b/mythtv/libs/libavformat/mpjpeg.c @@ -65,44 +65,9 @@ static AVOutputFormat mpjpeg_format = { mpjpeg_write_trailer, }; - -/*************************************/ -/* single frame JPEG */ - -static int single_jpeg_write_header(AVFormatContext *s) -{ - return 0; -} - -static int single_jpeg_write_packet(AVFormatContext *s, AVPacket *pkt) -{ - put_buffer(&s->pb, pkt->data, pkt->size); - put_flush_packet(&s->pb); - return 1; /* no more data can be sent */ -} - -static int single_jpeg_write_trailer(AVFormatContext *s) -{ - return 0; -} - -static AVOutputFormat single_jpeg_format = { - "singlejpeg", - "single JPEG image", - "image/jpeg", - NULL, /* note: no extension to favorize jpeg multiple images match */ - 0, - CODEC_ID_NONE, - CODEC_ID_MJPEG, - single_jpeg_write_header, - single_jpeg_write_packet, - single_jpeg_write_trailer, -}; - int jpeg_init(void) { av_register_output_format(&mpjpeg_format); - av_register_output_format(&single_jpeg_format); return 0; } #endif //CONFIG_ENCODERS diff --git a/mythtv/libs/libavformat/nsvdec.c b/mythtv/libs/libavformat/nsvdec.c index 5834c3fc967..37659a9ac5c 100644 --- a/mythtv/libs/libavformat/nsvdec.c +++ b/mythtv/libs/libavformat/nsvdec.c @@ -439,12 +439,12 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) if (!nst) goto fail; st->priv_data = nst; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_tag = vtag; - st->codec.codec_id = codec_get_id(nsv_codec_video_tags, vtag); - st->codec.width = vwidth; - st->codec.height = vheight; - st->codec.bits_per_sample = 24; /* depth XXX */ + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_tag = vtag; + st->codec->codec_id = codec_get_id(nsv_codec_video_tags, vtag); + st->codec->width = vwidth; + st->codec->height = vheight; + st->codec->bits_per_sample = 24; /* depth XXX */ av_set_pts_info(st, 64, framerate.den, framerate.num); st->start_time = 0; @@ -460,17 +460,17 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) if (!nst) goto fail; st->priv_data = nst; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = atag; - st->codec.codec_id = codec_get_id(nsv_codec_audio_tags, atag); + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = atag; + st->codec->codec_id = codec_get_id(nsv_codec_audio_tags, atag); st->start_time = 0; // st->duration = nsv->duration; //FIXME st->need_parsing = 1; /* for PCM we will read a chunk later and put correct info */ /* XXX:FIXME */ - //st->codec.channels = 2; //XXX:channels; - //st->codec.sample_rate = 1000; - //av_set_pts_info(st, 64, 1, st->codec.sample_rate); + //st->codec->channels = 2; //XXX:channels; + //st->codec->sample_rate = 1000; + //av_set_pts_info(st, 64, 1, st->codec->sample_rate); #endif } @@ -606,7 +606,7 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header) pkt = &nsv->ahead[NSV_ST_AUDIO]; /* read raw audio specific header on the first audio chunk... */ /* on ALL audio chunks ?? seems so! */ - if (asize && st[NSV_ST_AUDIO]->codec.codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) { + if (asize && st[NSV_ST_AUDIO]->codec->codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) { uint8_t bps; uint8_t channels; uint16_t samplerate; @@ -622,13 +622,13 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header) } bps /= channels; // ??? if (bps == 8) - st[NSV_ST_AUDIO]->codec.codec_id = CODEC_ID_PCM_U8; + st[NSV_ST_AUDIO]->codec->codec_id = CODEC_ID_PCM_U8; samplerate /= 4;/* UGH ??? XXX */ channels = 1; - st[NSV_ST_AUDIO]->codec.channels = channels; - st[NSV_ST_AUDIO]->codec.sample_rate = samplerate; + st[NSV_ST_AUDIO]->codec->channels = channels; + st[NSV_ST_AUDIO]->codec->sample_rate = samplerate; av_set_pts_info(st[NSV_ST_AUDIO], 64, 1, - st[NSV_ST_AUDIO]->codec.sample_rate); + st[NSV_ST_AUDIO]->codec->sample_rate); PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %ld\n", bps, channels, samplerate)); } } @@ -704,8 +704,8 @@ static int nsv_read_close(AVFormatContext *s) av_free(ast->index_entries); av_free(ast); } - av_free(st->codec.extradata); - av_free(st->codec.palctrl); + av_free(st->codec->extradata); + av_free(st->codec->palctrl); } #endif diff --git a/mythtv/libs/libavformat/nut.c b/mythtv/libs/libavformat/nut.c index fe3b6df1044..cd46d55d751 100644 --- a/mythtv/libs/libavformat/nut.c +++ b/mythtv/libs/libavformat/nut.c @@ -155,7 +155,7 @@ static void build_frame_code(AVFormatContext *s){ for(stream_id= 0; stream_idnb_streams; stream_id++){ int start2= start + (end-start)*stream_id / s->nb_streams; int end2 = start + (end-start)*(stream_id+1) / s->nb_streams; - AVCodecContext *codec = &s->streams[stream_id]->codec; + AVCodecContext *codec = s->streams[stream_id]->codec; int is_audio= codec->codec_type == CODEC_TYPE_AUDIO; int intra_only= /*codec->intra_only || */is_audio; int pred_count; @@ -579,7 +579,7 @@ static int nut_write_header(AVFormatContext *s) { int nom, denom, ssize; - codec = &s->streams[i]->codec; + codec = s->streams[i]->codec; put_be64(bc, STREAM_STARTCODE); put_packetheader(nut, bc, 120 + codec->extradata_size, 1); @@ -674,7 +674,7 @@ static int nut_write_header(AVFormatContext *s) put_str(bc, s->copyright); } /* encoder */ - if(!(s->streams[0]->codec.flags & CODEC_FLAG_BITEXACT)){ + if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)){ put_v(bc, 13); /* type */ put_str(bc, LIBAVFORMAT_IDENT); } @@ -707,7 +707,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) int size= pkt->size; int stream_index= pkt->stream_index; - enc = &s->streams[stream_index]->codec; + enc = s->streams[stream_index]->codec; key_frame = !!(pkt->flags & PKT_FLAG_KEY); frame_type=0; @@ -949,27 +949,27 @@ static int decode_stream_header(NUTContext *nut){ class = get_v(bc); tmp = get_vb(bc); - st->codec.codec_tag= tmp; + st->codec->codec_tag= tmp; switch(class) { case 0: - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = codec_get_bmp_id(tmp); - if (st->codec.codec_id == CODEC_ID_NONE) + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = codec_get_bmp_id(tmp); + if (st->codec->codec_id == CODEC_ID_NONE) av_log(s, AV_LOG_ERROR, "Unknown codec?!\n"); break; case 1: case 32: //compatibility - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = codec_get_wav_id(tmp); - if (st->codec.codec_id == CODEC_ID_NONE) + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = codec_get_wav_id(tmp); + if (st->codec->codec_id == CODEC_ID_NONE) av_log(s, AV_LOG_ERROR, "Unknown codec?!\n"); break; case 2: -// st->codec.codec_type = CODEC_TYPE_TEXT; +// st->codec->codec_type = CODEC_TYPE_TEXT; // break; case 3: - st->codec.codec_type = CODEC_TYPE_DATA; + st->codec->codec_type = CODEC_TYPE_DATA; break; default: av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class); @@ -980,33 +980,33 @@ static int decode_stream_header(NUTContext *nut){ nom = get_v(bc); denom = get_v(bc); nut->stream[stream_id].msb_timestamp_shift = get_v(bc); - st->codec.has_b_frames= + st->codec->has_b_frames= nut->stream[stream_id].decode_delay= get_v(bc); get_byte(bc); /* flags */ /* codec specific data headers */ while(get_v(bc) != 0){ - st->codec.extradata_size= get_v(bc); - if((unsigned)st->codec.extradata_size > (1<<30)) + st->codec->extradata_size= get_v(bc); + if((unsigned)st->codec->extradata_size > (1<<30)) return -1; - st->codec.extradata= av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(bc, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + get_buffer(bc, st->codec->extradata, st->codec->extradata_size); // url_fskip(bc, get_v(bc)); } - if (st->codec.codec_type == CODEC_TYPE_VIDEO) /* VIDEO */ + if (st->codec->codec_type == CODEC_TYPE_VIDEO) /* VIDEO */ { - st->codec.width = get_v(bc); - st->codec.height = get_v(bc); - st->codec.sample_aspect_ratio.num= get_v(bc); - st->codec.sample_aspect_ratio.den= get_v(bc); + st->codec->width = get_v(bc); + st->codec->height = get_v(bc); + st->codec->sample_aspect_ratio.num= get_v(bc); + st->codec->sample_aspect_ratio.den= get_v(bc); get_v(bc); /* csp type */ } - if (st->codec.codec_type == CODEC_TYPE_AUDIO) /* AUDIO */ + if (st->codec->codec_type == CODEC_TYPE_AUDIO) /* AUDIO */ { - st->codec.sample_rate = get_v(bc); + st->codec->sample_rate = get_v(bc); get_v(bc); // samplerate_den - st->codec.channels = get_v(bc); + st->codec->channels = get_v(bc); } if(check_checksum(bc)){ av_log(s, AV_LOG_ERROR, "Stream header %d checksum mismatch\n", stream_id); @@ -1407,7 +1407,7 @@ static int nut_read_close(AVFormatContext *s) int i; for(i=0;inb_streams;i++) { - av_freep(&s->streams[i]->codec.extradata); + av_freep(&s->streams[i]->codec->extradata); } av_freep(&nut->stream); diff --git a/mythtv/libs/libavformat/ogg.c b/mythtv/libs/libavformat/ogg.c index ab47d029a5e..b2767a22d53 100644 --- a/mythtv/libs/libavformat/ogg.c +++ b/mythtv/libs/libavformat/ogg.c @@ -39,7 +39,7 @@ static int ogg_write_header(AVFormatContext *avfcontext) ogg_stream_init(&context->os, 31415); for(n = 0 ; n < avfcontext->nb_streams ; n++) { - AVCodecContext *codec = &avfcontext->streams[n]->codec; + AVCodecContext *codec = avfcontext->streams[n]->codec; uint8_t *p= codec->extradata; av_set_pts_info(avfcontext->streams[n], 60, 1, AV_TIME_BASE); @@ -65,7 +65,7 @@ static int ogg_write_header(AVFormatContext *avfcontext) static int ogg_write_packet(AVFormatContext *avfcontext, AVPacket *pkt) { OggContext *context = avfcontext->priv_data ; - AVCodecContext *avctx= &avfcontext->streams[pkt->stream_index]->codec; + AVCodecContext *avctx= avfcontext->streams[pkt->stream_index]->codec; ogg_packet *op= &context->op; ogg_page og ; int64_t pts; diff --git a/mythtv/libs/libavformat/ogg2.c b/mythtv/libs/libavformat/ogg2.c index aee6d589094..b32e27d3aba 100644 --- a/mythtv/libs/libavformat/ogg2.c +++ b/mythtv/libs/libavformat/ogg2.c @@ -430,7 +430,7 @@ ogg_gptopts (AVFormatContext * s, int i, uint64_t gp) ogg_t *ogg = s->priv_data; ogg_stream_t *os = ogg->streams + i; AVStream *st = s->streams[i]; - AVCodecContext *codec = &st->codec; + AVCodecContext *codec = st->codec; uint64_t pts = AV_NOPTS_VALUE; if(os->codec->gptopts){ @@ -537,7 +537,7 @@ ogg_read_close (AVFormatContext * s) for (i = 0; i < ogg->nstreams; i++){ av_free (ogg->streams[i].buf); av_free (ogg->streams[i].private); - av_freep (&s->streams[i]->codec.extradata); + av_freep (&s->streams[i]->codec->extradata); } av_free (ogg->streams); return 0; diff --git a/mythtv/libs/libavformat/oggparseflac.c b/mythtv/libs/libavformat/oggparseflac.c index 9ad362830d5..dc80065cfd5 100644 --- a/mythtv/libs/libavformat/oggparseflac.c +++ b/mythtv/libs/libavformat/oggparseflac.c @@ -52,17 +52,17 @@ flac_header (AVFormatContext * s, int idx) skip_bits(&gb, 16*2+24*2); - st->codec.sample_rate = get_bits_long(&gb, 20); - st->codec.channels = get_bits(&gb, 3) + 1; + st->codec->sample_rate = get_bits_long(&gb, 20); + st->codec->channels = get_bits(&gb, 3) + 1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_FLAC; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_FLAC; - st->codec.extradata = + st->codec->extradata = av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); - memcpy (st->codec.extradata, os->buf + os->pstart + 5 + 4 + 4 + 4, + memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4, FLAC_STREAMINFO_SIZE); - st->codec.extradata_size = FLAC_STREAMINFO_SIZE; + st->codec->extradata_size = FLAC_STREAMINFO_SIZE; } else if (mdt == 4) { vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4); } diff --git a/mythtv/libs/libavformat/oggparsetheora.c b/mythtv/libs/libavformat/oggparsetheora.c index 89278225709..299eb4e506f 100644 --- a/mythtv/libs/libavformat/oggparsetheora.c +++ b/mythtv/libs/libavformat/oggparsetheora.c @@ -40,7 +40,7 @@ theora_header (AVFormatContext * s, int idx) ogg_stream_t *os = ogg->streams + idx; AVStream *st = s->streams[idx]; theora_params_t *thp = os->private; - int cds = st->codec.extradata_size + os->psize + 2; + int cds = st->codec->extradata_size + os->psize + 2; uint8_t *cdp; if(!(os->buf[os->pstart] & 0x80)) @@ -62,33 +62,33 @@ theora_header (AVFormatContext * s, int idx) return -1; skip_bits(&gb, 8); /* revision */ - st->codec.width = get_bits(&gb, 16) << 4; - st->codec.height = get_bits(&gb, 16) << 4; + st->codec->width = get_bits(&gb, 16) << 4; + st->codec->height = get_bits(&gb, 16) << 4; skip_bits(&gb, 64); - st->codec.time_base.den = get_bits(&gb, 32); - st->codec.time_base.num = get_bits(&gb, 32); + st->codec->time_base.den = get_bits(&gb, 32); + st->codec->time_base.num = get_bits(&gb, 32); - st->codec.sample_aspect_ratio.num = get_bits(&gb, 24); - st->codec.sample_aspect_ratio.den = get_bits(&gb, 24); + st->codec->sample_aspect_ratio.num = get_bits(&gb, 24); + st->codec->sample_aspect_ratio.den = get_bits(&gb, 24); skip_bits(&gb, 38); thp->gpshift = get_bits(&gb, 5); thp->gpmask = (1 << thp->gpshift) - 1; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_THEORA; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_THEORA; } else if (os->buf[os->pstart] == 0x83) { vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); } - st->codec.extradata = av_realloc (st->codec.extradata, cds); - cdp = st->codec.extradata + st->codec.extradata_size; + st->codec->extradata = av_realloc (st->codec->extradata, cds); + cdp = st->codec->extradata + st->codec->extradata_size; *cdp++ = os->psize >> 8; *cdp++ = os->psize & 0xff; memcpy (cdp, os->buf + os->pstart, os->psize); - st->codec.extradata_size = cds; + st->codec->extradata_size = cds; return 1; } @@ -103,8 +103,8 @@ theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp) uint64_t iframe = gp >> thp->gpshift; uint64_t pframe = gp & thp->gpmask; - return (iframe + pframe) * AV_TIME_BASE * st->codec.time_base.num / - st->codec.time_base.den; + return (iframe + pframe) * AV_TIME_BASE * st->codec->time_base.num / + st->codec->time_base.den; } ogg_codec_t theora_codec = { diff --git a/mythtv/libs/libavformat/oggparsevorbis.c b/mythtv/libs/libavformat/oggparsevorbis.c index 877b1a9a8a6..f9f53fd5524 100644 --- a/mythtv/libs/libavformat/oggparsevorbis.c +++ b/mythtv/libs/libavformat/oggparsevorbis.c @@ -178,19 +178,19 @@ vorbis_header (AVFormatContext * s, int idx) memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize); if (os->buf[os->pstart] == 1) { uint8_t *p = os->buf + os->pstart + 11; //skip up to the audio channels - st->codec.channels = *p++; - st->codec.sample_rate = le2me_32 (unaligned32 (p)); + st->codec->channels = *p++; + st->codec->sample_rate = le2me_32 (unaligned32 (p)); p += 8; //skip maximum and and nominal bitrate - st->codec.bit_rate = le2me_32 (unaligned32 (p)); //Minimum bitrate + st->codec->bit_rate = le2me_32 (unaligned32 (p)); //Minimum bitrate - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_VORBIS; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_VORBIS; } else if (os->buf[os->pstart] == 3) { vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); } else { - st->codec.extradata_size = - fixup_vorbis_headers(s, priv, &st->codec.extradata); + st->codec->extradata_size = + fixup_vorbis_headers(s, priv, &st->codec->extradata); } return os->seq < 3; diff --git a/mythtv/libs/libavformat/psxstr.c b/mythtv/libs/libavformat/psxstr.c index c8c3b2915ad..51afe1b5afe 100644 --- a/mythtv/libs/libavformat/psxstr.c +++ b/mythtv/libs/libavformat/psxstr.c @@ -182,11 +182,11 @@ static int str_read_header(AVFormatContext *s, str->channels[channel].video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_MDEC; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = str->channels[channel].width; - st->codec.height = str->channels[channel].height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_MDEC; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = str->channels[channel].width; + st->codec->height = str->channels[channel].height; } break; @@ -212,13 +212,13 @@ static int str_read_header(AVFormatContext *s, str->channels[channel].audio_stream_index = st->index; fmt = sector[0x13]; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ADPCM_XA; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.channels = (fmt&1)?2:1; - st->codec.sample_rate = (fmt&4)?18900:37800; - // st->codec.bit_rate = 0; //FIXME; - st->codec.block_align = 128; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ADPCM_XA; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->channels = (fmt&1)?2:1; + st->codec->sample_rate = (fmt&4)?18900:37800; + // st->codec->bit_rate = 0; //FIXME; + st->codec->block_align = 128; } break; diff --git a/mythtv/libs/libavformat/raw.c b/mythtv/libs/libavformat/raw.c index a9e3a90f42b..b1a5762f79a 100644 --- a/mythtv/libs/libavformat/raw.c +++ b/mythtv/libs/libavformat/raw.c @@ -50,25 +50,25 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap) if (ap) { id = s->iformat->value; if (id == CODEC_ID_RAWVIDEO) { - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; } else { - st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = CODEC_TYPE_AUDIO; } - st->codec.codec_id = id; + st->codec->codec_id = id; - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: - st->codec.sample_rate = ap->sample_rate; - st->codec.channels = ap->channels; - av_set_pts_info(st, 64, 1, st->codec.sample_rate); + st->codec->sample_rate = ap->sample_rate; + st->codec->channels = ap->channels; + av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; case CODEC_TYPE_VIDEO: av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); - st->codec.width = ap->width; - st->codec.height = ap->height; - st->codec.pix_fmt = ap->pix_fmt; - if(st->codec.pix_fmt == PIX_FMT_NONE) - st->codec.pix_fmt= PIX_FMT_YUV420P; + st->codec->width = ap->width; + st->codec->height = ap->height; + st->codec->pix_fmt = ap->pix_fmt; + if(st->codec->pix_fmt == PIX_FMT_NONE) + st->codec->pix_fmt= PIX_FMT_YUV420P; break; default: return -1; @@ -133,24 +133,24 @@ int pcm_read_seek(AVFormatContext *s, int64_t pos; st = s->streams[0]; - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: - block_align = 2 * st->codec.channels; - byte_rate = block_align * st->codec.sample_rate; + block_align = 2 * st->codec->channels; + byte_rate = block_align * st->codec->sample_rate; break; case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ALAW: - block_align = st->codec.channels; - byte_rate = block_align * st->codec.sample_rate; + block_align = st->codec->channels; + byte_rate = block_align * st->codec->sample_rate; break; default: - block_align = st->codec.block_align; - byte_rate = st->codec.bit_rate / 8; + block_align = st->codec->block_align; + byte_rate = st->codec->bit_rate / 8; break; } @@ -180,8 +180,8 @@ static int ac3_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_AC3; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_AC3; st->need_parsing = 1; /* the parameters will be extracted from the compressed bitstream */ return 0; @@ -195,8 +195,8 @@ static int shorten_read_header(AVFormatContext *s, st = av_new_stream(s, 0); if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_SHORTEN; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_SHORTEN; st->need_parsing = 1; /* the parameters will be extracted from the compressed bitstream */ return 0; @@ -212,8 +212,8 @@ static int dts_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_DTS; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_DTS; st->need_parsing = 1; /* the parameters will be extracted from the compressed bitstream */ return 0; @@ -229,17 +229,17 @@ static int video_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = s->iformat->value; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = s->iformat->value; st->need_parsing = 1; /* for mjpeg, specify frame rate */ /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/ if (ap && ap->time_base.num) { av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); - } else if ( st->codec.codec_id == CODEC_ID_MJPEG || - st->codec.codec_id == CODEC_ID_MPEG4 || - st->codec.codec_id == CODEC_ID_H264) { + } else if ( st->codec->codec_id == CODEC_ID_MJPEG || + st->codec->codec_id == CODEC_ID_MPEG4 || + st->codec->codec_id == CODEC_ID_H264) { av_set_pts_info(st, 64, 1, 25); } @@ -479,7 +479,7 @@ AVOutputFormat mpeg1video_oformat = { "mpeg1video", "MPEG video", "video/x-mpeg", - "mpg,mpeg", + "mpg,mpeg,m1v", 0, 0, CODEC_ID_MPEG1VIDEO, @@ -609,10 +609,10 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) int packet_size, ret, width, height; AVStream *st = s->streams[0]; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + height = st->codec->height; - packet_size = avpicture_get_size(st->codec.pix_fmt, width, height); + packet_size = avpicture_get_size(st->codec->pix_fmt, width, height); if (packet_size < 0) return -1; diff --git a/mythtv/libs/libavformat/rm.c b/mythtv/libs/libavformat/rm.c index f0fe17974b8..4568f4f1d2f 100644 --- a/mythtv/libs/libavformat/rm.c +++ b/mythtv/libs/libavformat/rm.c @@ -298,7 +298,7 @@ static int rm_write_header(AVFormatContext *s) for(n=0;nnb_streams;n++) { s->streams[n]->id = n; - codec = &s->streams[n]->codec; + codec = s->streams[n]->codec; stream = &rm->streams[n]; memset(stream, 0, sizeof(StreamInfo)); stream->num = n; @@ -399,7 +399,7 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int static int rm_write_packet(AVFormatContext *s, AVPacket *pkt) { - if (s->streams[pkt->stream_index]->codec.codec_type == + if (s->streams[pkt->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO) return rm_write_audio(s, pkt->data, pkt->size, pkt->flags); else @@ -495,10 +495,10 @@ static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, get_str8(pb, s->comment, sizeof(s->comment)); get_byte(pb); get_str8(pb, buf, sizeof(buf)); - st->codec.sample_rate = 8000; - st->codec.channels = 1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_RA_144; + st->codec->sample_rate = 8000; + st->codec->channels = 1; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_RA_144; } else { int flavor, sub_packet_h, coded_framesize; /* old version (4) */ @@ -512,30 +512,30 @@ static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, get_be32(pb); /* ??? */ get_be32(pb); /* ??? */ sub_packet_h= get_be16(pb); /* 1 */ - st->codec.block_align= get_be16(pb); /* frame size */ + st->codec->block_align= get_be16(pb); /* frame size */ get_be16(pb); /* sub packet size */ get_be16(pb); /* ??? */ - st->codec.sample_rate = get_be16(pb); + st->codec->sample_rate = get_be16(pb); get_be32(pb); - st->codec.channels = get_be16(pb); + st->codec->channels = get_be16(pb); get_str8(pb, buf, sizeof(buf)); /* desc */ get_str8(pb, buf, sizeof(buf)); /* desc */ - st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = CODEC_TYPE_AUDIO; if (!strcmp(buf, "dnet")) { - st->codec.codec_id = CODEC_ID_AC3; + st->codec->codec_id = CODEC_ID_AC3; } else if (!strcmp(buf, "28_8")) { - st->codec.codec_id = CODEC_ID_RA_288; - st->codec.extradata_size= 10; - st->codec.extradata= av_mallocz(st->codec.extradata_size); + st->codec->codec_id = CODEC_ID_RA_288; + st->codec->extradata_size= 10; + st->codec->extradata= av_mallocz(st->codec->extradata_size); /* this is completly braindead and broken, the idiot who added this codec and endianness specific reordering to mplayer and libavcodec/ra288.c should be drowned in a see of cola */ //FIXME pass the unpermutated extradata - ((uint16_t*)st->codec.extradata)[1]= sub_packet_h; - ((uint16_t*)st->codec.extradata)[2]= flavor; - ((uint16_t*)st->codec.extradata)[3]= coded_framesize; + ((uint16_t*)st->codec->extradata)[1]= sub_packet_h; + ((uint16_t*)st->codec->extradata)[2]= flavor; + ((uint16_t*)st->codec->extradata)[3]= coded_framesize; } else { - st->codec.codec_id = CODEC_ID_NONE; - pstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name), + st->codec->codec_id = CODEC_ID_NONE; + pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name), buf); } if (read_all) { @@ -635,7 +635,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; st->id = get_be16(pb); get_be32(pb); /* max bit rate */ - st->codec.bit_rate = get_be32(pb); /* bit rate */ + st->codec->bit_rate = get_be32(pb); /* bit rate */ get_be32(pb); /* max packet size */ get_be32(pb); /* avg packet size */ start_time = get_be32(pb); /* start time */ @@ -647,7 +647,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) get_str8(pb, buf, sizeof(buf)); /* mimetype */ codec_data_size = get_be32(pb); codec_pos = url_ftell(pb); - st->codec.codec_type = CODEC_TYPE_DATA; + st->codec->codec_type = CODEC_TYPE_DATA; av_set_pts_info(st, 64, 1, 1000); v = get_be32(pb); @@ -658,43 +658,43 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) int fps, fps2; if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { fail1: - av_log(&st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); + av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); goto skip; } - st->codec.codec_tag = get_le32(pb); -// av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec.codec_tag, MKTAG('R', 'V', '2', '0')); - if ( st->codec.codec_tag != MKTAG('R', 'V', '1', '0') - && st->codec.codec_tag != MKTAG('R', 'V', '2', '0') - && st->codec.codec_tag != MKTAG('R', 'V', '3', '0') - && st->codec.codec_tag != MKTAG('R', 'V', '4', '0')) + st->codec->codec_tag = get_le32(pb); +// av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); + if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0') + && st->codec->codec_tag != MKTAG('R', 'V', '2', '0') + && st->codec->codec_tag != MKTAG('R', 'V', '3', '0') + && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) goto fail1; - st->codec.width = get_be16(pb); - st->codec.height = get_be16(pb); - st->codec.time_base.num= 1; + st->codec->width = get_be16(pb); + st->codec->height = get_be16(pb); + st->codec->time_base.num= 1; fps= get_be16(pb); - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; get_be32(pb); fps2= get_be16(pb); get_be16(pb); - st->codec.extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); - st->codec.extradata= av_malloc(st->codec.extradata_size); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); + st->codec->extradata= av_malloc(st->codec->extradata_size); + get_buffer(pb, st->codec->extradata, st->codec->extradata_size); // av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); - st->codec.time_base.den = fps * st->codec.time_base.num; + st->codec->time_base.den = fps * st->codec->time_base.num; /* modification of h263 codec version (!) */ #ifdef WORDS_BIGENDIAN - h263_hack_version = ((uint32_t*)st->codec.extradata)[1]; + h263_hack_version = ((uint32_t*)st->codec->extradata)[1]; #else - h263_hack_version = bswap_32(((uint32_t*)st->codec.extradata)[1]); + h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]); #endif - st->codec.sub_id = h263_hack_version; + st->codec->sub_id = h263_hack_version; switch((h263_hack_version>>28)){ - case 1: st->codec.codec_id = CODEC_ID_RV10; break; - case 2: st->codec.codec_id = CODEC_ID_RV20; break; - case 3: st->codec.codec_id = CODEC_ID_RV30; break; - case 4: st->codec.codec_id = CODEC_ID_RV40; break; + case 1: st->codec->codec_id = CODEC_ID_RV10; break; + case 2: st->codec->codec_id = CODEC_ID_RV20; break; + case 3: st->codec->codec_id = CODEC_ID_RV30; break; + case 4: st->codec->codec_id = CODEC_ID_RV40; break; default: goto fail1; } } @@ -827,7 +827,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_IO; st = s->streams[i]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { int h, pic_num, len2, pos; h= get_byte(pb); len--; @@ -862,8 +862,8 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) pkt->stream_index = i; #if 0 - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - if(st->codec.codec_id == CODEC_ID_RV20){ + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { + if(st->codec->codec_id == CODEC_ID_RV20){ int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1); av_log(NULL, AV_LOG_DEBUG, "%d %Ld %d\n", timestamp, timestamp*512LL/25, seq); @@ -882,7 +882,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) } /* for AC3, needs to swap bytes */ - if (st->codec.codec_id == CODEC_ID_AC3) { + if (st->codec->codec_id == CODEC_ID_AC3) { ptr = pkt->data; for(j=0;jstreams[stream_index2]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { h= get_byte(&s->pb); len--; if(!(h & 0x40)){ seq = get_byte(&s->pb); len--; diff --git a/mythtv/libs/libavformat/rtp.c b/mythtv/libs/libavformat/rtp.c index 63236f00c65..fff10e00433 100644 --- a/mythtv/libs/libavformat/rtp.c +++ b/mythtv/libs/libavformat/rtp.c @@ -290,7 +290,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_t return NULL; } } else { - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG2VIDEO: case CODEC_ID_MP2: @@ -307,7 +307,6 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_t static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf) { - AVCodecContext codec; int au_headers_length, au_header_size, i; GetBitContext getbitcontext; rtp_payload_data_t *infos; @@ -317,8 +316,6 @@ static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf) if (infos == NULL) return -1; - codec = s->st->codec; - /* decode the first 2 bytes where are stored the AUHeader sections length in bits */ au_headers_length = BE_16(buf); @@ -407,7 +404,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, return -1; #if defined(DEBUG) || 1 if (seq != ((s->seq + 1) & 0xffff)) { - av_log(&s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n", + av_log(s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n", payload_type, seq, ((s->seq + 1) & 0xffff)); } #endif @@ -428,7 +425,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, return 1; } } else { - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MP2: /* better than nothing: skip mpeg audio RTP header */ if (len <= 4) @@ -462,7 +459,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, break; } - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MP2: case CODEC_ID_MPEG1VIDEO: if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) { @@ -529,7 +526,7 @@ static int rtp_write_header(AVFormatContext *s1) return -1; st = s1->streams[0]; - payload_type = rtp_get_payload_type(&st->codec); + payload_type = rtp_get_payload_type(st->codec); if (payload_type < 0) payload_type = RTP_PT_PRIVATE; /* private payload type */ s->payload_type = payload_type; @@ -544,7 +541,7 @@ static int rtp_write_header(AVFormatContext *s1) return AVERROR_IO; s->max_payload_size = max_packet_size - 12; - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MP2: case CODEC_ID_MP3: s->buf_ptr = s->buf + 4; @@ -663,7 +660,7 @@ static void rtp_send_mpegaudio(AVFormatContext *s1, s->buf_ptr = s->buf + 4; /* 90 KHz time stamp */ s->timestamp = s->base_timestamp + - (s->cur_timestamp * 90000LL) / st->codec.sample_rate; + (s->cur_timestamp * 90000LL) / st->codec->sample_rate; } } @@ -697,7 +694,7 @@ static void rtp_send_mpegaudio(AVFormatContext *s1, memcpy(s->buf_ptr, buf1, size); s->buf_ptr += size; } - s->cur_timestamp += st->codec.frame_size; + s->cur_timestamp += st->codec->frame_size; } /* NOTE: a single frame must be passed with sequence header if @@ -715,7 +712,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1, while (size > 0) { /* XXX: more correct headers */ h = 0; - if (st->codec.sub_id == 2) + if (st->codec->sub_id == 2) h |= 1 << 26; /* mpeg 2 indicator */ q = s->buf; *q++ = h >> 24; @@ -723,7 +720,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1, *q++ = h >> 8; *q++ = h; - if (st->codec.sub_id == 2) { + if (st->codec->sub_id == 2) { h = 0; *q++ = h >> 24; *q++ = h >> 16; @@ -740,7 +737,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1, /* 90 KHz time stamp */ s->timestamp = s->base_timestamp + - av_rescale((int64_t)s->cur_timestamp * st->codec.time_base.num, 90000, st->codec.time_base.den); //FIXME pass timestamps + av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps rtp_send_data(s1, s->buf, q - s->buf); buf1 += len; @@ -765,7 +762,7 @@ static void rtp_send_raw(AVFormatContext *s1, /* 90 KHz time stamp */ s->timestamp = s->base_timestamp + - av_rescale((int64_t)s->cur_timestamp * st->codec.time_base.num, 90000, st->codec.time_base.den); //FIXME pass timestamps + av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps rtp_send_data(s1, buf1, len); buf1 += len; @@ -824,18 +821,18 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) s->first_packet = 0; } - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_S8: - rtp_send_samples(s1, buf1, size, 1 * st->codec.channels); + rtp_send_samples(s1, buf1, size, 1 * st->codec->channels); break; case CODEC_ID_PCM_U16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16LE: - rtp_send_samples(s1, buf1, size, 2 * st->codec.channels); + rtp_send_samples(s1, buf1, size, 2 * st->codec->channels); break; case CODEC_ID_MP2: case CODEC_ID_MP3: diff --git a/mythtv/libs/libavformat/rtsp.c b/mythtv/libs/libavformat/rtsp.c index 67c23aa4bc4..789266e9c01 100644 --- a/mythtv/libs/libavformat/rtsp.c +++ b/mythtv/libs/libavformat/rtsp.c @@ -282,7 +282,7 @@ static void sdp_parse_fmtp(AVStream *st, const char *p) int i; RTSPStream *rtsp_st = st->priv_data; - AVCodecContext *codec = &st->codec; + AVCodecContext *codec = st->codec; rtp_payload_data_t *rtp_payload_data = &rtsp_st->rtp_payload_data; /* loop on each attribute */ @@ -405,10 +405,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, return; st->priv_data = rtsp_st; rtsp_st->stream_index = st->index; - st->codec.codec_type = codec_type; + st->codec->codec_type = codec_type; if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) { /* if standard payload type, we can find the codec right now */ - rtp_get_codec_info(&st->codec, rtsp_st->sdp_payload_type); + rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type); } } /* put a default control url */ @@ -438,7 +438,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, st = s->streams[i]; rtsp_st = st->priv_data; if (rtsp_st->sdp_payload_type == payload_type) { - sdp_parse_rtpmap(&st->codec, payload_type, p); + sdp_parse_rtpmap(st->codec, payload_type, p); } } } else if (strstart(p, "fmtp:", &p)) { diff --git a/mythtv/libs/libavformat/segafilm.c b/mythtv/libs/libavformat/segafilm.c index d2954881ed9..7727462e218 100644 --- a/mythtv/libs/libavformat/segafilm.c +++ b/mythtv/libs/libavformat/segafilm.c @@ -140,11 +140,11 @@ static int film_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; film->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = film->video_type; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = BE_32(&scratch[16]); - st->codec.height = BE_32(&scratch[12]); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = film->video_type; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = BE_32(&scratch[16]); + st->codec->height = BE_32(&scratch[12]); } if (film->audio_type) { @@ -152,16 +152,16 @@ static int film_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; film->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = film->audio_type; - st->codec.codec_tag = 1; - st->codec.channels = film->audio_channels; - st->codec.bits_per_sample = film->audio_bits; - st->codec.sample_rate = film->audio_samplerate; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = st->codec.channels * - st->codec.bits_per_sample / 8; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = film->audio_type; + st->codec->codec_tag = 1; + st->codec->channels = film->audio_channels; + st->codec->bits_per_sample = film->audio_bits; + st->codec->sample_rate = film->audio_samplerate; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = st->codec->channels * + st->codec->bits_per_sample / 8; } /* load the sample table */ diff --git a/mythtv/libs/libavformat/sierravmd.c b/mythtv/libs/libavformat/sierravmd.c index 152b4fb8f71..5f6005bca41 100644 --- a/mythtv/libs/libavformat/sierravmd.c +++ b/mythtv/libs/libavformat/sierravmd.c @@ -131,14 +131,14 @@ static int vmd_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); vmd->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_VMDVIDEO; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = LE_16(&vmd->vmd_header[12]); - st->codec.height = LE_16(&vmd->vmd_header[14]); - st->codec.extradata_size = VMD_HEADER_SIZE; - st->codec.extradata = av_malloc(VMD_HEADER_SIZE); - memcpy(st->codec.extradata, vmd->vmd_header, VMD_HEADER_SIZE); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_VMDVIDEO; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = LE_16(&vmd->vmd_header[12]); + st->codec->height = LE_16(&vmd->vmd_header[14]); + st->codec->extradata_size = VMD_HEADER_SIZE; + st->codec->extradata = av_malloc(VMD_HEADER_SIZE); + memcpy(st->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE); /* if sample rate is 0, assume no audio */ vmd->sample_rate = LE_16(&vmd->vmd_header[804]); @@ -148,29 +148,29 @@ static int vmd_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); vmd->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_VMDAUDIO; - st->codec.codec_tag = 0; /* no codec tag */ - st->codec.channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1; - st->codec.sample_rate = vmd->sample_rate; - st->codec.block_align = vmd->audio_block_align = + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_VMDAUDIO; + st->codec->codec_tag = 0; /* no codec tag */ + st->codec->channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1; + st->codec->sample_rate = vmd->sample_rate; + st->codec->block_align = vmd->audio_block_align = LE_16(&vmd->vmd_header[806]); - if (st->codec.block_align & 0x8000) { - st->codec.bits_per_sample = 16; - st->codec.block_align = -(st->codec.block_align - 0x10000); + if (st->codec->block_align & 0x8000) { + st->codec->bits_per_sample = 16; + st->codec->block_align = -(st->codec->block_align - 0x10000); } else - st->codec.bits_per_sample = 16; -// st->codec.bits_per_sample = 8; - st->codec.bit_rate = st->codec.sample_rate * - st->codec.bits_per_sample * st->codec.channels; + st->codec->bits_per_sample = 16; +// st->codec->bits_per_sample = 8; + st->codec->bit_rate = st->codec->sample_rate * + st->codec->bits_per_sample * st->codec->channels; /* for calculating pts */ - vmd->audio_frame_divisor = st->codec.bits_per_sample / 8 / - st->codec.channels; + vmd->audio_frame_divisor = st->codec->bits_per_sample / 8 / + st->codec->channels; video_pts_inc = 90000; - video_pts_inc *= st->codec.block_align; - video_pts_inc /= st->codec.sample_rate; + video_pts_inc *= st->codec->block_align; + video_pts_inc /= st->codec->sample_rate; } else { /* if no audio, assume 10 frames/second */ video_pts_inc = 90000 / 10; @@ -290,7 +290,7 @@ static int vmd_read_packet(AVFormatContext *s, pkt->data, pkt->size, vmd->audio_block_align); } -printf (" dispatching %s frame with %d bytes and pts %lld (%0.1f sec)\n", +av_log(NULL, AV_LOG_INFO, " dispatching %s frame with %d bytes and pts %lld (%0.1f sec)\n", (frame->frame_record[0] == 0x02) ? "video" : "audio", frame->frame_size + BYTES_PER_FRAME_RECORD, pkt->pts, (float)(pkt->pts / 90000.0)); diff --git a/mythtv/libs/libavformat/sol.c b/mythtv/libs/libavformat/sol.c index eed1b38f320..70dab2ac128 100644 --- a/mythtv/libs/libavformat/sol.c +++ b/mythtv/libs/libavformat/sol.c @@ -113,11 +113,11 @@ static int sol_read_header(AVFormatContext *s, st = av_new_stream(s, 0); if (!st) return -1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = id; - st->codec.codec_id = codec; - st->codec.channels = channels; - st->codec.sample_rate = rate; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = id; + st->codec->codec_id = codec; + st->codec->channels = channels; + st->codec->sample_rate = rate; av_set_pts_info(st, 64, 1, rate); return 0; } diff --git a/mythtv/libs/libavformat/swf.c b/mythtv/libs/libavformat/swf.c index c8988bf5f75..923a4f99348 100644 --- a/mythtv/libs/libavformat/swf.c +++ b/mythtv/libs/libavformat/swf.c @@ -324,7 +324,7 @@ static int swf_write_header(AVFormatContext *s) video_enc = NULL; audio_enc = NULL; for(i=0;inb_streams;i++) { - enc = &s->streams[i]->codec; + enc = s->streams[i]->codec; if (enc->codec_type == CODEC_TYPE_AUDIO) audio_enc = enc; else { @@ -652,7 +652,7 @@ static int swf_write_audio(AVFormatContext *s, static int swf_write_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecContext *codec = &s->streams[pkt->stream_index]->codec; + AVCodecContext *codec = s->streams[pkt->stream_index]->codec; if (codec->codec_type == CODEC_TYPE_AUDIO) return swf_write_audio(s, codec, pkt->data, pkt->size); else @@ -668,7 +668,7 @@ static int swf_write_trailer(AVFormatContext *s) video_enc = NULL; for(i=0;inb_streams;i++) { - enc = &s->streams[i]->codec; + enc = s->streams[i]->codec; if (enc->codec_type == CODEC_TYPE_VIDEO) video_enc = enc; } @@ -775,8 +775,8 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) if (tag < 0) { if ( ast || vst ) { if ( vst && ast ) { - vst->codec.time_base.den = ast->codec.sample_rate / swf->samples_per_frame; - vst->codec.time_base.num = 1; + vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame; + vst->codec->time_base.num = 1; } break; } @@ -794,11 +794,11 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) vst = av_new_stream(s, 0); av_set_pts_info(vst, 24, 1, 1000); /* 24 bit pts in ms */ - vst->codec.codec_type = CODEC_TYPE_VIDEO; - vst->codec.codec_id = CODEC_ID_FLV1; + vst->codec->codec_type = CODEC_TYPE_VIDEO; + vst->codec->codec_id = CODEC_ID_FLV1; if ( swf->samples_per_frame ) { - vst->codec.time_base.den = 1000. / swf->ms_per_frame; - vst->codec.time_base.num = 1; + vst->codec->time_base.den = 1000. / swf->ms_per_frame; + vst->codec->time_base.num = 1; } } } else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) { @@ -819,26 +819,26 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) return -ENOMEM; if (v & 0x01) - ast->codec.channels = 2; + ast->codec->channels = 2; else - ast->codec.channels = 1; + ast->codec->channels = 1; switch((v>> 2) & 0x03) { case 1: - ast->codec.sample_rate = 11025; + ast->codec->sample_rate = 11025; break; case 2: - ast->codec.sample_rate = 22050; + ast->codec->sample_rate = 22050; break; case 3: - ast->codec.sample_rate = 44100; + ast->codec->sample_rate = 44100; break; default: av_free(ast); return AVERROR_IO; } - ast->codec.codec_type = CODEC_TYPE_AUDIO; - ast->codec.codec_id = CODEC_ID_MP3; + ast->codec->codec_type = CODEC_TYPE_AUDIO; + ast->codec->codec_id = CODEC_ID_MP3; } } else { url_fskip(pb, len); diff --git a/mythtv/libs/libavformat/udp.c b/mythtv/libs/libavformat/udp.c index 8b5fc32a2c3..50aa14bfaf0 100644 --- a/mythtv/libs/libavformat/udp.c +++ b/mythtv/libs/libavformat/udp.c @@ -133,7 +133,7 @@ struct addrinfo* udp_ipv6_resolve_host(const char *hostname, int port, int type, hints.ai_family = family; hints.ai_flags = flags; if ((error = getaddrinfo(node, service, &hints, &res))) { - fprintf(stderr, "udp_ipv6_resolve_host: %s\n", gai_strerror(error)); + av_log(NULL, AV_LOG_ERROR, "udp_ipv6_resolve_host: %s\n", gai_strerror(error)); } } return res; diff --git a/mythtv/libs/libavformat/utils.c b/mythtv/libs/libavformat/utils.c index 6dcdc2d185b..8bbfa299ead 100644 --- a/mythtv/libs/libavformat/utils.c +++ b/mythtv/libs/libavformat/utils.c @@ -754,14 +754,14 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, *pnum = 0; *pden = 0; - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_VIDEO: if(st->time_base.num*1000LL > st->time_base.den){ *pnum = st->time_base.num; *pden = st->time_base.den; - }else if(st->codec.time_base.num*1000LL > st->codec.time_base.den){ - *pnum = st->codec.time_base.num; - *pden = st->codec.time_base.den; + }else if(st->codec->time_base.num*1000LL > st->codec->time_base.den){ + *pnum = st->codec->time_base.num; + *pden = st->codec->time_base.den; if (pc && pc->repeat_pict) { *pden *= 2; *pnum = (*pnum) * (2 + pc->repeat_pict); @@ -769,11 +769,11 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, } break; case CODEC_TYPE_AUDIO: - frame_size = get_audio_frame_size(&st->codec, pkt->size); + frame_size = get_audio_frame_size(st->codec, pkt->size); if (frame_size < 0) break; *pnum = frame_size; - *pden = st->codec.sample_rate; + *pden = st->codec->sample_rate; break; default: break; @@ -828,16 +828,16 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, } } - if(is_intra_only(&st->codec)) + if(is_intra_only(st->codec)) pkt->flags |= PKT_FLAG_KEY; /* do we have a video B frame ? */ presentation_delayed = 0; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { /* XXX: need has_b_frame, but cannot get it if the codec is not initialized */ - if (( st->codec.codec_id == CODEC_ID_H264 - || st->codec.has_b_frames) && + if (( st->codec->codec_id == CODEC_ID_H264 + || st->codec->has_b_frames) && pc && pc->pict_type != FF_B_TYPE) presentation_delayed = 1; /* this may be redundant, but it shouldnt hurt */ @@ -906,7 +906,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if (pc) { pkt->flags = 0; /* key frame computation */ - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_VIDEO: if (pc->pict_type == FF_I_TYPE) pkt->flags |= PKT_FLAG_KEY; @@ -952,7 +952,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) st->cur_frame_startpos = s->cur_pkt.pos; st->got_frame = 1; } - len = av_parser_parse(st->parser, &st->codec, &pkt->data, &pkt->size, + len = av_parser_parse(st->parser, st->codec, &pkt->data, &pkt->size, s->cur_ptr, s->cur_len, s->cur_pkt.pts, s->cur_pkt.dts); s->cur_pkt.pts = AV_NOPTS_VALUE; @@ -992,7 +992,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->parser && st->need_parsing) { - av_parser_parse(st->parser, &st->codec, + av_parser_parse(st->parser, st->codec, &pkt->data, &pkt->size, NULL, 0, AV_NOPTS_VALUE, AV_NOPTS_VALUE); @@ -1013,13 +1013,13 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) s->cur_ptr = s->cur_pkt.data; s->cur_len = s->cur_pkt.size; if (st->need_parsing && !st->parser) { - st->parser = av_parser_init(st->codec.codec_id); + st->parser = av_parser_init(st->codec->codec_id); if (!st->parser) { /* no parser available : just output the raw packets */ st->need_parsing = 0; av_log(s, AV_LOG_ERROR, "Parser not found for Codec Id: %d !\n", - st->codec.codec_id); + st->codec->codec_id); } } } @@ -1092,7 +1092,7 @@ int av_find_default_stream_index(AVFormatContext *s) return -1; for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { return i; } } @@ -1302,7 +1302,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts AVInputFormat *avif= s->iformat; int64_t pos_min, pos_max, pos, pos_limit; int64_t ts_min, ts_max, ts; - int64_t start_pos; + int64_t start_pos, filesize; int index, no_change; AVStream *st; @@ -1359,7 +1359,8 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts if(ts_max == AV_NOPTS_VALUE){ int step= 1024; - pos_max = url_fsize(&s->pb) - 1; + filesize = url_fsize(&s->pb); + pos_max = filesize - 1; do{ pos_max -= step; ts_max = avif->read_timestamp(s, stream_index, &pos_max, pos_max + step); @@ -1375,6 +1376,8 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts break; ts_max= tmp_ts; pos_max= tmp_pos; + if(tmp_pos >= filesize) + break; } pos_limit= pos_max; } @@ -1639,7 +1642,7 @@ static void av_estimate_timings_from_bit_rate(AVFormatContext *ic) bit_rate = 0; for(i=0;inb_streams;i++) { st = ic->streams[i]; - bit_rate += st->codec.bit_rate; + bit_rate += st->codec->bit_rate; } ic->bit_rate = bit_rate; } @@ -1848,26 +1851,26 @@ static int try_decode_frame(AVStream *st, const uint8_t *data, int size) int got_picture, ret=0; AVFrame picture; - if(!st->codec.codec){ - codec = avcodec_find_decoder(st->codec.codec_id); + if(!st->codec->codec){ + codec = avcodec_find_decoder(st->codec->codec_id); if (!codec) return -1; - ret = avcodec_open(&st->codec, codec); + ret = avcodec_open(st->codec, codec); if (ret < 0) return ret; } - if(!has_codec_parameters(&st->codec)){ - switch(st->codec.codec_type) { + if(!has_codec_parameters(st->codec)){ + switch(st->codec->codec_type) { case CODEC_TYPE_VIDEO: - ret = avcodec_decode_video(&st->codec, &picture, + ret = avcodec_decode_video(st->codec, &picture, &got_picture, (uint8_t *)data, size); break; case CODEC_TYPE_AUDIO: samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); if (!samples) goto fail; - ret = avcodec_decode_audio(&st->codec, samples, + ret = avcodec_decode_audio(st->codec, samples, &got_picture, (uint8_t *)data, size); av_free(samples); break; @@ -1908,15 +1911,15 @@ int av_find_stream_info(AVFormatContext *ic) for(i=0;inb_streams;i++) { st = ic->streams[i]; - if(st->codec.codec_type == CODEC_TYPE_VIDEO){ + if(st->codec->codec_type == CODEC_TYPE_VIDEO){ /* if(!st->time_base.num) st->time_base= */ - if(!st->codec.time_base.num) - st->codec.time_base= st->time_base; + if(!st->codec->time_base.num) + st->codec->time_base= st->time_base; } //only for the split stuff if (!st->parser) { - st->parser = av_parser_init(st->codec.codec_id); + st->parser = av_parser_init(st->codec->codec_id); } } @@ -1932,13 +1935,13 @@ int av_find_stream_info(AVFormatContext *ic) /* check if one codec still needs to be handled */ for(i=0;inb_streams;i++) { st = ic->streams[i]; - if (!has_codec_parameters(&st->codec)) + if (!has_codec_parameters(st->codec)) break; /* variable fps and no guess at the real fps */ - if( st->codec.time_base.den >= 1000LL*st->codec.time_base.num - && duration_count[i]<20 && st->codec.codec_type == CODEC_TYPE_VIDEO) + if( st->codec->time_base.den >= 1000LL*st->codec->time_base.num + && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO) break; - if(st->parser && st->parser->parser->split && !st->codec.extradata) + if(st->parser && st->parser->parser->split && !st->codec->extradata) break; } @@ -1967,7 +1970,7 @@ int av_find_stream_info(AVFormatContext *ic) ret = -1; /* we could not have all the codec parameters before EOF */ for(i=0;inb_streams;i++) { st = ic->streams[i]; - if (!has_codec_parameters(&st->codec)) + if (!has_codec_parameters(st->codec)) break; } if (i == ic->nb_streams) @@ -2020,12 +2023,12 @@ int av_find_stream_info(AVFormatContext *ic) } last_dts[pkt->stream_index]= pkt->dts; } - if(st->parser && st->parser->parser->split && !st->codec.extradata){ - int i= st->parser->parser->split(&st->codec, pkt->data, pkt->size); + if(st->parser && st->parser->parser->split && !st->codec->extradata){ + int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); if(i){ - st->codec.extradata_size= i; - st->codec.extradata= av_malloc(st->codec.extradata_size); - memcpy(st->codec.extradata, pkt->data, st->codec.extradata_size); + st->codec->extradata_size= i; + st->codec->extradata= av_malloc(st->codec->extradata_size); + memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size); } } @@ -2033,21 +2036,21 @@ int av_find_stream_info(AVFormatContext *ic) decompress the frame. We try to avoid that in most cases as it takes longer and uses more memory. For MPEG4, we need to decompress for Quicktime. */ - if (!has_codec_parameters(&st->codec) /*&& - (st->codec.codec_id == CODEC_ID_FLV1 || - st->codec.codec_id == CODEC_ID_H264 || - st->codec.codec_id == CODEC_ID_H263 || - st->codec.codec_id == CODEC_ID_H261 || - st->codec.codec_id == CODEC_ID_VORBIS || - st->codec.codec_id == CODEC_ID_MJPEG || - st->codec.codec_id == CODEC_ID_PNG || - st->codec.codec_id == CODEC_ID_PAM || - st->codec.codec_id == CODEC_ID_PGM || - st->codec.codec_id == CODEC_ID_PGMYUV || - st->codec.codec_id == CODEC_ID_PBM || - st->codec.codec_id == CODEC_ID_PPM || - st->codec.codec_id == CODEC_ID_SHORTEN || - (st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/) + if (!has_codec_parameters(st->codec) /*&& + (st->codec->codec_id == CODEC_ID_FLV1 || + st->codec->codec_id == CODEC_ID_H264 || + st->codec->codec_id == CODEC_ID_H263 || + st->codec->codec_id == CODEC_ID_H261 || + st->codec->codec_id == CODEC_ID_VORBIS || + st->codec->codec_id == CODEC_ID_MJPEG || + st->codec->codec_id == CODEC_ID_PNG || + st->codec->codec_id == CODEC_ID_PAM || + st->codec->codec_id == CODEC_ID_PGM || + st->codec->codec_id == CODEC_ID_PGMYUV || + st->codec->codec_id == CODEC_ID_PBM || + st->codec->codec_id == CODEC_ID_PPM || + st->codec->codec_id == CODEC_ID_SHORTEN || + (st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/) try_decode_frame(st, pkt->data, pkt->size); if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= MAX_STREAM_DURATION) { @@ -2059,16 +2062,16 @@ int av_find_stream_info(AVFormatContext *ic) // close codecs which where opened in try_decode_frame() for(i=0;inb_streams;i++) { st = ic->streams[i]; - if(st->codec.codec) - avcodec_close(&st->codec); + if(st->codec->codec) + avcodec_close(st->codec); } for(i=0;inb_streams;i++) { st = ic->streams[i]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - if(st->codec.codec_id == CODEC_ID_RAWVIDEO && !st->codec.codec_tag && !st->codec.bits_per_sample) - st->codec.codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec.pix_fmt); + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { + if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_sample) + st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); - if(duration_count[i] && st->codec.time_base.num*1000LL <= st->codec.time_base.den && + if(duration_count[i] && st->codec->time_base.num*1000LL <= st->codec->time_base.den && st->time_base.num*duration_sum[i]/duration_count[i]*1000LL > st->time_base.den){ AVRational fps1; int64_t num, den; @@ -2086,16 +2089,16 @@ int av_find_stream_info(AVFormatContext *ic) /* set real frame rate info */ /* compute the real frame rate for telecine */ - if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO || - st->codec.codec_id == CODEC_ID_MPEG2VIDEO || - st->codec.codec_id == CODEC_ID_MPEG2VIDEO_XVMC || - st->codec.codec_id == CODEC_ID_MPEG2VIDEO_XVMC_VLD) && - st->codec.sub_id == 2) { + if ((st->codec->codec_id == CODEC_ID_MPEG1VIDEO || + st->codec->codec_id == CODEC_ID_MPEG2VIDEO || + st->codec->codec_id == CODEC_ID_MPEG2VIDEO_XVMC || + st->codec->codec_id == CODEC_ID_MPEG2VIDEO_XVMC_VLD) && + st->codec->sub_id == 2) { if (st->codec_info_nb_frames >= 20) { float coded_frame_rate, est_frame_rate; est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) / (double)st->codec_info_duration ; - coded_frame_rate = 1.0/av_q2d(st->codec.time_base); + coded_frame_rate = 1.0/av_q2d(st->codec->time_base); #if 0 printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n", coded_frame_rate, est_frame_rate); @@ -2111,8 +2114,8 @@ int av_find_stream_info(AVFormatContext *ic) } /* if no real frame rate, use the codec one */ if (!st->r_frame_rate.num){ - st->r_frame_rate.num = st->codec.time_base.den; - st->r_frame_rate.den = st->codec.time_base.num; + st->r_frame_rate.num = st->codec->time_base.den; + st->r_frame_rate.den = st->codec->time_base.num; } } } @@ -2122,7 +2125,7 @@ int av_find_stream_info(AVFormatContext *ic) /* correct DTS for b frame streams with no timestamps */ for(i=0;inb_streams;i++) { st = ic->streams[i]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { if(b-frames){ ppktl = &ic->packet_buffer; while(ppkt1){ @@ -2193,6 +2196,7 @@ void av_close_input_file(AVFormatContext *s) av_parser_close(st->parser); } av_free(st->index_entries); + av_free(st->codec); av_free(st); } flush_packet_queue(s); @@ -2221,7 +2225,7 @@ AVStream *av_new_stream(AVFormatContext *s, int id) { AVStream *st = av_mallocz(sizeof(AVStream)); if (st) { - avcodec_get_context_defaults(&st->codec); + st->codec = avcodec_alloc_context(); AVStream *stream = av_add_stream(s, st, id); if (!stream) av_free(st); @@ -2252,7 +2256,7 @@ AVStream *av_add_stream(AVFormatContext *s, AVStream *st, int id) if (s->iformat) { /* no default bitrate if decoding */ - st->codec.bit_rate = 0; + st->codec->bit_rate = 0; } st->index = s->nb_streams; st->id = id; @@ -2333,14 +2337,14 @@ int av_write_header(AVFormatContext *s) for(i=0;inb_streams;i++) { st = s->streams[i]; - switch (st->codec.codec_type) { + switch (st->codec->codec_type) { case CODEC_TYPE_AUDIO: av_frac_init(&st->pts, 0, 0, - (int64_t)st->time_base.num * st->codec.sample_rate); + (int64_t)st->time_base.num * st->codec->sample_rate); break; case CODEC_TYPE_VIDEO: av_frac_init(&st->pts, 0, 0, - (int64_t)st->time_base.num * st->codec.time_base.den); + (int64_t)st->time_base.num * st->codec->time_base.den); break; default: break; @@ -2351,7 +2355,7 @@ int av_write_header(AVFormatContext *s) //FIXME merge with compute_pkt_fields static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){ - int b_frames = FFMAX(st->codec.has_b_frames, st->codec.max_b_frames); + int b_frames = FFMAX(st->codec->has_b_frames, st->codec->max_b_frames); int num, den, frame_size; // av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts:%lld dts:%lld cur_dts:%lld b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, b_frames, pkt->size, pkt->stream_index); @@ -2403,9 +2407,9 @@ static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){ st->pts.val= pkt->dts; /* update pts */ - switch (st->codec.codec_type) { + switch (st->codec->codec_type) { case CODEC_TYPE_AUDIO: - frame_size = get_audio_frame_size(&st->codec, pkt->size); + frame_size = get_audio_frame_size(st->codec, pkt->size); /* HACK/FIXME, we skip the initial 0-size packets as they are most likely equal to the encoder delay, but it would be better if we had the real timestamps from the encoder */ @@ -2414,7 +2418,7 @@ static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){ } break; case CODEC_TYPE_VIDEO: - av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec.time_base.num); + av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num); break; default: break; @@ -2551,7 +2555,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ AVStream *st= s->streams[ pkt->stream_index]; //FIXME/XXX/HACK drop zero sized packets - if(st->codec.codec_type == CODEC_TYPE_AUDIO && pkt->size==0) + if(st->codec->codec_type == CODEC_TYPE_AUDIO && pkt->size==0) return 0; //av_log(NULL, AV_LOG_DEBUG, "av_interleaved_write_frame %d %Ld %Ld\n", pkt->size, pkt->dts, pkt->pts); @@ -2668,7 +2672,7 @@ void dump_format(AVFormatContext *ic, } for(i=0;inb_streams;i++) { AVStream *st = ic->streams[i]; - avcodec_string(buf, sizeof(buf), &st->codec, is_output); + avcodec_string(buf, sizeof(buf), st->codec, is_output); av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i); /* the pid is an important information, so we display it */ /* XXX: add a generic system */ @@ -2679,6 +2683,9 @@ void dump_format(AVFormatContext *ic, if (flags & AVFMT_SHOW_IDS) { av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); } + if (strlen(st->language) > 0) { + av_log(NULL, AV_LOG_INFO, "(%s)", st->language); + } av_log(NULL, AV_LOG_INFO, ": %s\n", buf); } } diff --git a/mythtv/libs/libavformat/wav.c b/mythtv/libs/libavformat/wav.c index d1f1bc65c96..6557c0a962b 100644 --- a/mythtv/libs/libavformat/wav.c +++ b/mythtv/libs/libavformat/wav.c @@ -29,6 +29,7 @@ const CodecTag codec_wav_tags[] = { { CODEC_ID_PCM_MULAW, 0x07 }, { CODEC_ID_ADPCM_MS, 0x02 }, { CODEC_ID_ADPCM_IMA_WAV, 0x11 }, + { CODEC_ID_ADPCM_YAMAHA, 0x20 }, { CODEC_ID_ADPCM_G726, 0x45 }, { CODEC_ID_ADPCM_IMA_DK4, 0x61 }, /* rogue format number */ { CODEC_ID_ADPCM_IMA_DK3, 0x62 }, /* rogue format number */ @@ -65,7 +66,7 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc) bps = 8; } else if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) { bps = 0; - } else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV || enc->codec_id == CODEC_ID_ADPCM_MS || enc->codec_id == CODEC_ID_ADPCM_G726) { // + } else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV || enc->codec_id == CODEC_ID_ADPCM_MS || enc->codec_id == CODEC_ID_ADPCM_G726 || enc->codec_id == CODEC_ID_ADPCM_YAMAHA) { // bps = 4; } else { bps = 16; @@ -198,13 +199,13 @@ static int wav_write_header(AVFormatContext *s) /* format header */ fmt = start_tag(pb, "fmt "); - if (put_wav_header(pb, &s->streams[0]->codec) < 0) { + if (put_wav_header(pb, s->streams[0]->codec) < 0) { av_free(wav); return -1; } end_tag(pb, fmt); - av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec.sample_rate); + av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); /* data header */ wav->data = start_tag(pb, "data"); @@ -304,10 +305,10 @@ static int wav_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - get_wav_header(pb, &st->codec, size); + get_wav_header(pb, st->codec, size); st->need_parsing = 1; - av_set_pts_info(st, 64, 1, st->codec.sample_rate); + av_set_pts_info(st, 64, 1, st->codec->sample_rate); size = find_tag(pb, MKTAG('d', 'a', 't', 'a')); if (size < 0) @@ -328,10 +329,10 @@ static int wav_read_packet(AVFormatContext *s, st = s->streams[0]; size = MAX_SIZE; - if (st->codec.block_align > 1) { - if (size < st->codec.block_align) - size = st->codec.block_align; - size = (size / st->codec.block_align) * st->codec.block_align; + if (st->codec->block_align > 1) { + if (size < st->codec->block_align) + size = st->codec->block_align; + size = (size / st->codec->block_align) * st->codec->block_align; } if (av_new_packet(pkt, size)) return AVERROR_IO; @@ -357,7 +358,7 @@ static int wav_read_seek(AVFormatContext *s, AVStream *st; st = s->streams[0]; - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MP2: case CODEC_ID_MP3: case CODEC_ID_AC3: diff --git a/mythtv/libs/libavformat/wc3movie.c b/mythtv/libs/libavformat/wc3movie.c index 30417fef156..23c13324b45 100644 --- a/mythtv/libs/libavformat/wc3movie.c +++ b/mythtv/libs/libavformat/wc3movie.c @@ -239,29 +239,29 @@ static int wc3_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); wc3->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_XAN_WC3; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = wc3->width; - st->codec.height = wc3->height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_XAN_WC3; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = wc3->width; + st->codec->height = wc3->height; /* palette considerations */ - st->codec.palctrl = &wc3->palette_control; + st->codec->palctrl = &wc3->palette_control; st = av_new_stream(s, 0); if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); wc3->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_PCM_S16LE; - st->codec.codec_tag = 1; - st->codec.channels = WC3_AUDIO_CHANNELS; - st->codec.bits_per_sample = WC3_AUDIO_BITS; - st->codec.sample_rate = WC3_SAMPLE_RATE; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_PCM_S16LE; + st->codec->codec_tag = 1; + st->codec->channels = WC3_AUDIO_CHANNELS; + st->codec->bits_per_sample = WC3_AUDIO_BITS; + st->codec->sample_rate = WC3_SAMPLE_RATE; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS; return 0; } diff --git a/mythtv/libs/libavformat/westwood.c b/mythtv/libs/libavformat/westwood.c index 22150e2a641..1d3e325e4fd 100644 --- a/mythtv/libs/libavformat/westwood.c +++ b/mythtv/libs/libavformat/westwood.c @@ -136,15 +136,15 @@ static int wsaud_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, wsaud->audio_samplerate); - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = wsaud->audio_type; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = wsaud->audio_channels; - st->codec.sample_rate = wsaud->audio_samplerate; - st->codec.bits_per_sample = wsaud->audio_bits; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample / 4; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = wsaud->audio_type; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = wsaud->audio_channels; + st->codec->sample_rate = wsaud->audio_samplerate; + st->codec->bits_per_sample = wsaud->audio_bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample / 4; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; wsaud->audio_stream_index = st->index; wsaud->audio_frame_counter = 0; @@ -222,24 +222,24 @@ static int wsvqa_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); wsvqa->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_WS_VQA; - st->codec.codec_tag = 0; /* no fourcc */ + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_WS_VQA; + st->codec->codec_tag = 0; /* no fourcc */ /* skip to the start of the VQA header */ url_fseek(pb, 20, SEEK_SET); /* the VQA header needs to go to the decoder */ - st->codec.extradata_size = VQA_HEADER_SIZE; - st->codec.extradata = av_malloc(VQA_HEADER_SIZE); - header = (unsigned char *)st->codec.extradata; - if (get_buffer(pb, st->codec.extradata, VQA_HEADER_SIZE) != + st->codec->extradata_size = VQA_HEADER_SIZE; + st->codec->extradata = av_malloc(VQA_HEADER_SIZE); + header = (unsigned char *)st->codec->extradata; + if (get_buffer(pb, st->codec->extradata, VQA_HEADER_SIZE) != VQA_HEADER_SIZE) { - av_free(st->codec.extradata); + av_free(st->codec->extradata); return AVERROR_IO; } - st->codec.width = LE_16(&header[6]); - st->codec.height = LE_16(&header[8]); + st->codec->width = LE_16(&header[6]); + st->codec->height = LE_16(&header[8]); /* initialize the audio decoder stream is sample rate is non-zero */ if (LE_16(&header[24])) { @@ -247,19 +247,19 @@ static int wsvqa_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ADPCM_IMA_WS; - st->codec.codec_tag = 0; /* no tag */ - st->codec.sample_rate = LE_16(&header[24]); - st->codec.channels = header[26]; - st->codec.bits_per_sample = 16; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample / 4; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS; + st->codec->codec_tag = 0; /* no tag */ + st->codec->sample_rate = LE_16(&header[24]); + st->codec->channels = header[26]; + st->codec->bits_per_sample = 16; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample / 4; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; wsvqa->audio_stream_index = st->index; - wsvqa->audio_samplerate = st->codec.sample_rate; - wsvqa->audio_channels = st->codec.channels; + wsvqa->audio_samplerate = st->codec->sample_rate; + wsvqa->audio_channels = st->codec->channels; wsvqa->audio_frame_counter = 0; } @@ -267,7 +267,7 @@ static int wsvqa_read_header(AVFormatContext *s, * FINF has been skipped and the file will be ready to be demuxed */ do { if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) { - av_free(st->codec.extradata); + av_free(st->codec->extradata); return AVERROR_IO; } chunk_tag = BE_32(&scratch[0]); diff --git a/mythtv/libs/libavformat/yuv4mpeg.c b/mythtv/libs/libavformat/yuv4mpeg.c index 74519fa1b66..1f38fe86890 100644 --- a/mythtv/libs/libavformat/yuv4mpeg.c +++ b/mythtv/libs/libavformat/yuv4mpeg.c @@ -33,22 +33,22 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) char *colorspace = ""; st = s->streams[0]; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + height = st->codec->height; - av_reduce(&raten, &rated, st->codec.time_base.den, st->codec.time_base.num, (1UL<<31)-1); + av_reduce(&raten, &rated, st->codec->time_base.den, st->codec->time_base.num, (1UL<<31)-1); - aspectn = st->codec.sample_aspect_ratio.num; - aspectd = st->codec.sample_aspect_ratio.den; + aspectn = st->codec->sample_aspect_ratio.num; + aspectd = st->codec->sample_aspect_ratio.den; if ( aspectn == 0 && aspectd == 1 ) aspectd = 0; // 0:0 means unknown inter = 'p'; /* progressive is the default */ - if (st->codec.coded_frame && st->codec.coded_frame->interlaced_frame) { - inter = st->codec.coded_frame->top_field_first ? 't' : 'b'; + if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) { + inter = st->codec->coded_frame->top_field_first ? 't' : 'b'; } - switch(st->codec.pix_fmt) { + switch(st->codec->pix_fmt) { case PIX_FMT_GRAY8: colorspace = " Cmono"; break; @@ -56,7 +56,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) colorspace = " C411 XYSCSS=411"; break; case PIX_FMT_YUV420P: - colorspace = (st->codec.codec_id == CODEC_ID_DVVIDEO)?" C420paldv XYSCSS=420PALDV":" C420mpeg2 XYSCSS=420MPEG2"; + colorspace = (st->codec->codec_id == CODEC_ID_DVVIDEO)?" C420paldv XYSCSS=420PALDV":" C420mpeg2 XYSCSS=420MPEG2"; break; case PIX_FMT_YUV422P: colorspace = " C422 XYSCSS=422"; @@ -109,8 +109,8 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) m = snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC); put_buffer(pb, buf1, strlen(buf1)); - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + height = st->codec->height; ptr = picture->data[0]; for(i=0;ilinesize[0]; } - if (st->codec.pix_fmt != PIX_FMT_GRAY8){ + if (st->codec->pix_fmt != PIX_FMT_GRAY8){ // Adjust for smaller Cb and Cr planes - avcodec_get_chroma_sub_sample(st->codec.pix_fmt, &h_chroma_shift, &v_chroma_shift); + avcodec_get_chroma_sub_sample(st->codec->pix_fmt, &h_chroma_shift, &v_chroma_shift); width >>= h_chroma_shift; height >>= v_chroma_shift; @@ -146,13 +146,13 @@ static int yuv4_write_header(AVFormatContext *s) if (s->nb_streams != 1) return AVERROR_IO; - if (s->streams[0]->codec.pix_fmt == PIX_FMT_YUV411P) { + if (s->streams[0]->codec->pix_fmt == PIX_FMT_YUV411P) { av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\n"); } - else if ((s->streams[0]->codec.pix_fmt != PIX_FMT_YUV420P) && - (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV422P) && - (s->streams[0]->codec.pix_fmt != PIX_FMT_GRAY8) && - (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV444P)) { + else if ((s->streams[0]->codec->pix_fmt != PIX_FMT_YUV420P) && + (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV422P) && + (s->streams[0]->codec->pix_fmt != PIX_FMT_GRAY8) && + (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV444P)) { av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\n"); return AVERROR_IO; } @@ -320,14 +320,14 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) st = av_new_stream(s, 0); st = s->streams[0]; - st->codec.width = width; - st->codec.height = height; + st->codec->width = width; + st->codec->height = height; av_reduce(&raten, &rated, raten, rated, (1UL<<31)-1); av_set_pts_info(st, 64, rated, raten); - st->codec.pix_fmt = pix_fmt; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.sample_aspect_ratio= (AVRational){aspectn, aspectd}; + st->codec->pix_fmt = pix_fmt; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->sample_aspect_ratio= (AVRational){aspectn, aspectd}; return 0; } @@ -349,10 +349,10 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) if (i == MAX_FRAME_HEADER) return -1; if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return -1; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + height = st->codec->height; - packet_size = avpicture_get_size(st->codec.pix_fmt, width, height); + packet_size = avpicture_get_size(st->codec->pix_fmt, width, height); if (packet_size < 0) return -1; diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp index eadfb3ab308..a1002de70e5 100644 --- a/mythtv/libs/libmythtv/avformatdecoder.cpp +++ b/mythtv/libs/libmythtv/avformatdecoder.cpp @@ -198,8 +198,8 @@ void AvFormatDecoder::CloseContext() for (int i = 0; i < ic->nb_streams; i++) { AVStream *st = ic->streams[i]; - if (st->codec.codec) - avcodec_close(&st->codec); + if (st->codec->codec) + avcodec_close(st->codec); } ic->iformat->flags |= AVFMT_NOFILE; @@ -239,7 +239,7 @@ bool AvFormatDecoder::DoFastForward(long long desiredFrame, bool doflush) for (i = 0; i < ic->nb_streams; i++) { AVStream *st1 = ic->streams[i]; - if (st1 && st1->codec.codec_type == CODEC_TYPE_VIDEO) + if (st1 && st1->codec->codec_type == CODEC_TYPE_VIDEO) { st = st1; break; @@ -249,7 +249,7 @@ bool AvFormatDecoder::DoFastForward(long long desiredFrame, bool doflush) return false; int64_t frameseekadjust = 0; - AVCodecContext *context = &(st->codec); + AVCodecContext *context = st->codec; if (context->codec_id == CODEC_ID_MPEG1VIDEO || context->codec_id == CODEC_ID_MPEG2VIDEO || @@ -319,7 +319,7 @@ void AvFormatDecoder::SeekReset(long long, int skipFrames, bool doflush) VERBOSE(VB_PLAYBACK, "AvFormatDecoder::SeekReset() flushing"); for (int i = 0; i < ic->nb_streams; i++) { - AVCodecContext *enc = &ic->streams[i]->codec; + AVCodecContext *enc = ic->streams[i]->codec; if (enc->codec) avcodec_flush_buffers(enc); } @@ -369,11 +369,11 @@ void AvFormatDecoder::Reset(bool reset_video_data, bool seek_reset) /// NOTE: As of the 12th of May, 2005 VLD is defined whenever libXVMCW /// exits, so the following hack will no longer work. #ifdef USING_XVMC_VLD - if (st->codec.codec_type == CODEC_TYPE_AUDIO) + if (st->codec->codec_type == CODEC_TYPE_AUDIO) #endif { - if (st->codec.codec) - avcodec_close(&st->codec); + if (st->codec->codec) + avcodec_close(st->codec); av_remove_stream(ic, st->id); } } @@ -790,7 +790,7 @@ int AvFormatDecoder::ScanStreams(bool novideo) for (int i = 0; i < ic->nb_streams; i++) { - AVCodecContext *enc = &ic->streams[i]->codec; + AVCodecContext *enc = ic->streams[i]->codec; VERBOSE(VB_PLAYBACK, QString("AVFD: Opening Stream #%1: codec id %2"). arg(i).arg(enc->codec_id)); @@ -930,7 +930,7 @@ bool AvFormatDecoder::CheckVideoParams(int width, int height) for (int i = 0; i < ic->nb_streams; i++) { - AVCodecContext *enc = &ic->streams[i]->codec; + AVCodecContext *enc = ic->streams[i]->codec; switch (enc->codec_type) { case CODEC_TYPE_VIDEO: @@ -992,7 +992,7 @@ void AvFormatDecoder::CheckAudioParams(int freq, int channels, bool safe) " %2hz to %3 channels %4hz").arg(audio_channels) .arg(audio_sampling_rate).arg(channels).arg(freq)); - AVCodecContext *enc = &ic->streams[wantedAudioStream]->codec; + AVCodecContext *enc = ic->streams[wantedAudioStream]->codec; AVCodec *codec = enc->codec; if (codec) avcodec_close(enc); @@ -1244,7 +1244,7 @@ void AvFormatDecoder::HandleGopStart(AVPacket *pkt) void AvFormatDecoder::MpegPreProcessPkt(AVStream *stream, AVPacket *pkt) { - AVCodecContext *context = &(stream->codec); + AVCodecContext *context = stream->codec; unsigned char *bufptr = pkt->data; //unsigned char *bufend = pkt->data + pkt->size; unsigned int state = 0xFFFFFFFF, v = 0; @@ -1401,7 +1401,7 @@ void AvFormatDecoder::incCurrentAudioTrack() currentAudioTrack = tempTrackNo; wantedAudioStream = audioStreams[currentAudioTrack]; - AVCodecContext *e = &ic->streams[wantedAudioStream]->codec; + AVCodecContext *e = ic->streams[wantedAudioStream]->codec; SetupAudioStream(); CheckAudioParams(e->sample_rate, e->channels, true); } @@ -1419,7 +1419,7 @@ void AvFormatDecoder::decCurrentAudioTrack() currentAudioTrack = tempTrackNo; wantedAudioStream = audioStreams[currentAudioTrack]; - AVCodecContext *e = &ic->streams[wantedAudioStream]->codec; + AVCodecContext *e = ic->streams[wantedAudioStream]->codec; SetupAudioStream(); CheckAudioParams(e->sample_rate, e->channels, true); } @@ -1438,7 +1438,7 @@ bool AvFormatDecoder::setCurrentAudioTrack(int trackNo) wantedAudioStream = audioStreams[currentAudioTrack]; - AVCodecContext *e = &ic->streams[wantedAudioStream]->codec; + AVCodecContext *e = ic->streams[wantedAudioStream]->codec; SetupAudioStream(); CheckAudioParams(e->sample_rate, e->channels, true); return true; @@ -1475,7 +1475,7 @@ bool AvFormatDecoder::autoSelectAudioTrack() for (track = 0; track <= maxTracks; track++) { int tempStream = audioStreams[track]; - AVCodecContext *e = &ic->streams[tempStream]->codec; + AVCodecContext *e = ic->streams[tempStream]->codec; if (e->channels > minChannels) { @@ -1513,7 +1513,7 @@ bool AvFormatDecoder::autoSelectAudioTrack() currentAudioTrack = selectedTrack; wantedAudioStream = audioStreams[currentAudioTrack]; - AVCodecContext *e = &ic->streams[wantedAudioStream]->codec; + AVCodecContext *e = ic->streams[wantedAudioStream]->codec; if (e->codec_id == CODEC_ID_AC3) { VERBOSE(VB_AUDIO, @@ -1546,9 +1546,9 @@ void AvFormatDecoder::SetupAudioStream(void) VERBOSE(VB_AUDIO, QString("Initializing audio parms from audio track #%1.") .arg(currentAudioTrack)); - m_parent->SetEffDsp(curstream->codec.sample_rate * 100); + m_parent->SetEffDsp(curstream->codec->sample_rate * 100); - do_ac3_passthru = curstream->codec.codec_id == CODEC_ID_AC3 && + do_ac3_passthru = curstream->codec->codec_id == CODEC_ID_AC3 && !transcoding && gContext->GetNumSetting("AC3PassThru", false); } @@ -1634,7 +1634,7 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) pts = (long long)(av_q2d(curstream->time_base) * pkt->dts * 1000); if (storevideoframes && - curstream->codec.codec_type == CODEC_TYPE_VIDEO) + curstream->codec->codec_type == CODEC_TYPE_VIDEO) { av_dup_packet(pkt); storedPackets.append(pkt); @@ -1642,13 +1642,13 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) continue; } - if (len > 0 && curstream->codec.codec_type == CODEC_TYPE_VIDEO) + if (len > 0 && curstream->codec->codec_type == CODEC_TYPE_VIDEO) { framesRead++; if (exitafterdecoded) gotvideo = 1; - AVCodecContext *context = &(curstream->codec); + AVCodecContext *context = curstream->codec; if (context->codec_id == CODEC_ID_MPEG1VIDEO || context->codec_id == CODEC_ID_MPEG2VIDEO || @@ -1675,7 +1675,7 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) } } - if (!curstream->codec.codec) + if (!curstream->codec->codec) { VERBOSE(VB_PLAYBACK, QString("No codec for stream index %1").arg(pkt->stream_index)); av_free_packet(pkt); @@ -1687,7 +1687,7 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) while (!have_err && len > 0) { - switch (curstream->codec.codec_type) + switch (curstream->codec->codec_type) { case CODEC_TYPE_AUDIO: { @@ -1721,7 +1721,7 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) } else { - ret = avcodec_decode_audio(&curstream->codec, + ret = avcodec_decode_audio(curstream->codec, audioSamples, &data_size, ptr, len); } @@ -1733,14 +1733,15 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) continue; if (!do_ac3_passthru) - CheckAudioParams(curstream->codec.sample_rate, - curstream->codec.channels, false); + CheckAudioParams(curstream->codec->sample_rate, + curstream->codec->channels, false); long long temppts = lastapts; // calc for next frame lastapts += (long long)((double)(data_size * 1000) / - (curstream->codec.channels * 2) / curstream->codec.sample_rate); + (curstream->codec->channels * 2) / + curstream->codec->sample_rate); m_parent->AddAudioData((char *)audioSamples, data_size, temppts); @@ -1756,7 +1757,7 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) continue; } - AVCodecContext *context = &(curstream->codec); + AVCodecContext *context = curstream->codec; AVFrame mpa_pic; int gotpicture = 0; @@ -1852,7 +1853,7 @@ bool AvFormatDecoder::GetFrame(int onlyvideo) break; } default: - cerr << "error decoding - " << curstream->codec.codec_type + cerr << "error decoding - " << curstream->codec->codec_type << endl; have_err = true; break; diff --git a/mythtv/libs/libmythtv/mpegrecorder.cpp b/mythtv/libs/libmythtv/mpegrecorder.cpp index 81f8ffb2fe7..5651166d829 100644 --- a/mythtv/libs/libmythtv/mpegrecorder.cpp +++ b/mythtv/libs/libmythtv/mpegrecorder.cpp @@ -615,7 +615,7 @@ void MpegRecorder::ProcessData(unsigned char *buffer, int len) } AVStream *curstream = ic->streams[pkt.stream_index]; - if (pkt.size > 0 && curstream->codec.codec_type == CODEC_TYPE_VIDEO) + if (pkt.size > 0 && curstream->codec->codec_type == CODEC_TYPE_VIDEO) { if (PacketHasHeader(pkt.data, pkt.size, PICTURE_START)) { diff --git a/mythtv/programs/mythtranscode/mpeg2trans.cpp b/mythtv/programs/mythtranscode/mpeg2trans.cpp index e0e9c675e3a..297d3e0b939 100644 --- a/mythtv/programs/mythtranscode/mpeg2trans.cpp +++ b/mythtv/programs/mythtranscode/mpeg2trans.cpp @@ -269,7 +269,7 @@ void MPEG2trans::write_muxed_frame(AVStream *stream, AVPacket *pkt, int advance, int64_t bufpts = buf->getPTS() - buf->getDelta(); audioout_st->pts.val = INT2PTS(bufpts, audioout_st); // long long orig = PTS2INT(audioout_st->pts, audioout_st); - audioout_st->codec.coded_frame= &avframe; + audioout_st->codec->coded_frame= &avframe; if (av_write_frame(outputContext, buf->getPkt()) != 0) { VERBOSE(VB_IMPORTANT, "Error while writing audio frame"); @@ -286,7 +286,7 @@ void MPEG2trans::write_muxed_frame(AVStream *stream, AVPacket *pkt, int advance, int64_t bufpts = buf->getPTS() - buf->getDelta(); videoout_st->pts.val = INT2PTS(bufpts, videoout_st); // int64_t oldpts = PTS2INT(videoout_st->pts, videoout_st); - videoout_st->codec.coded_frame= &avframe; + videoout_st->codec->coded_frame= &avframe; if (av_write_frame(outputContext, buf->getPkt()) != 0) { VERBOSE(VB_IMPORTANT, "Error while writing video frame"); @@ -695,13 +695,13 @@ int MPEG2trans::DoTranscode(QString inputFilename, QString outputFilename) } for (i = 0; i < inputContext->nb_streams; i++) { - AVCodecContext *enc = &inputContext->streams[i]->codec; + AVCodecContext *enc = inputContext->streams[i]->codec; VERBOSE(VB_GENERAL, QString("Stream: %1 Type: %2") .arg(i).arg(enc->codec_type)); switch(enc->codec_type) { case CODEC_TYPE_AUDIO: if (!use_ac3 && - (inputContext->streams[i])->codec.codec_id == CODEC_ID_AC3) { + (inputContext->streams[i])->codec->codec_id == CODEC_ID_AC3) { use_ac3 = 1; audioin_index = i; } else if (audioin_index == -1) @@ -931,8 +931,8 @@ void MPEG2trans::init_audioout_stream(void) { AVCodecContext *c; - c = &audioout_st->codec; - c->codec_id = (inputContext->streams[audioin_index])->codec.codec_id; + c = audioout_st->codec; + c->codec_id = (inputContext->streams[audioin_index])->codec->codec_id; c->codec_type = CODEC_TYPE_AUDIO; /* put sample parameters */ @@ -948,8 +948,8 @@ void MPEG2trans::init_videoout_stream() { AVCodecContext *c; - c = &videoout_st->codec; - c->codec_id = (inputContext->streams[videoin_index])->codec.codec_id; + c = videoout_st->codec; + c->codec_id = (inputContext->streams[videoin_index])->codec->codec_id; c->codec_type = CODEC_TYPE_VIDEO; /* put sample parameters */ @@ -994,7 +994,7 @@ int MPEG2trans::BuildKeyframeIndex(QString filename, QMap for (i = 0; i < inputContext->nb_streams; i++) { - AVCodecContext *enc = &inputContext->streams[i]->codec; + AVCodecContext *enc = inputContext->streams[i]->codec; if (enc->codec_type == CODEC_TYPE_VIDEO) { videoin_index = i;