Advertisement
Guest User

Untitled

a guest
Sep 7th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. static int load_textfile(AVFilterContext *ctx)
  2. {
  3.     DrawTextContext *s = ctx->priv;
  4.     int err;
  5.     uint8_t *textbuf;
  6.     uint8_t *tmp;
  7.     size_t textbuf_size;
  8.  
  9.     if ((err = av_file_map(s->textfile, &textbuf, &textbuf_size, 0, ctx)) < 0) {
  10.         av_log(ctx, AV_LOG_ERROR,
  11.                "The text file '%s' could not be read or is empty\n",
  12.                s->textfile);
  13.         return err;
  14.     }
  15.  
  16.     if (!(tmp = av_realloc(s->text, textbuf_size + 1))) {
  17.         av_file_unmap(textbuf, textbuf_size);
  18.         return AVERROR(ENOMEM);
  19.     }
  20.     s->text = tmp;
  21.     memcpy(s->text, textbuf, textbuf_size);
  22.     s->text[textbuf_size] = 0;
  23.     av_file_unmap(textbuf, textbuf_size);
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement