# HG changeset patch # User reimar # Date 1162125855 0 # Node ID e8d37db54bf5363bc4efef7a8d305e40f5a39bb4 # Parent 0b563edd9b3a65b84a0389c35d51198db1dc44d4 realloc subtitle buffers since subcp_recode might have decreased their size. diff -r 0b563edd9b3a -r e8d37db54bf5 libmpdemux/demux_ogg.c --- a/libmpdemux/demux_ogg.c Sun Oct 29 12:32:12 2006 +0000 +++ b/libmpdemux/demux_ogg.c Sun Oct 29 12:44:15 2006 +0000 @@ -225,14 +225,6 @@ return (ret); } -void demux_ogg_init_sub (void) { - int lcv; - if(!ogg_sub.text[0]) // not yet allocated - for (lcv = 0; lcv < SUB_MAX_TEXT; lcv++) { - ogg_sub.text[lcv] = malloc(OGG_SUB_MAX_LINE); - } -} - void demux_ogg_add_sub (ogg_stream_t* os,ogg_packet* pack) { int lcv; int line_pos = 0; @@ -263,11 +255,15 @@ pts = (float)pack->granulepos/(float)os->samplerate; clear_sub = 1.0 + pts + (float)duration/1000.0; } + ogg_sub.text[0] = realloc(ogg_sub.text[0], OGG_SUB_MAX_LINE); while (1) { int c = packet[lcv++]; if(c=='\n' || c==0 || line_pos >= OGG_SUB_MAX_LINE-1){ ogg_sub.text[ogg_sub.lines][line_pos] = 0; // close sub - if(line_pos) ogg_sub.lines++; + if(line_pos) { + ogg_sub.lines++; + ogg_sub.text[ogg_sub.lines] = realloc(ogg_sub.text[ogg_sub.lines], OGG_SUB_MAX_LINE); + } if(!c || ogg_sub.lines>=SUB_MAX_TEXT) break; // EOL or TooMany line_pos = 0; } @@ -1155,7 +1151,6 @@ ogg_d->text_ids[ogg_d->n_text - 1] = ogg_d->num_sub; ogg_d->text_langs = (char **)realloc(ogg_d->text_langs, sizeof(char *) * ogg_d->n_text); ogg_d->text_langs[ogg_d->n_text - 1] = NULL; - demux_ogg_init_sub(); //// Unknown header type } else mp_msg(MSGT_DEMUX,MSGL_ERR,"Ogg stream %d has a header marker but is of an unknown type\n",ogg_d->num_sub);