vdr2jpeg-0.1.9-ffmpeg.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. diff -urN vdr2jpeg-0.1.9.old/ffm.cpp vdr2jpeg-0.1.9/ffm.cpp
  2. --- vdr2jpeg-0.1.9.old/ffm.cpp 2012-04-21 09:53:26.727892390 +0200
  3. +++ vdr2jpeg-0.1.9/ffm.cpp 2012-04-21 09:57:25.555890271 +0200
  4. @@ -21,6 +21,7 @@
  5. extern "C" {
  6. #include <libavutil/avutil.h>
  7. +#include <libavutil/mathematics.h>
  8. #include <libavcodec/avcodec.h>
  9. #include <libavformat/avformat.h>
  10. #include <libswscale/swscale.h>
  11. @@ -185,7 +186,7 @@
  12. }else
  13. ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
  14. - nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);
  15. + nb_frames= FFMIN(nb_frames, max_frames[AVMEDIA_TYPE_VIDEO] - ost->frame_number);
  16. if (nb_frames <= 0)
  17. return true;
  18. @@ -221,7 +222,7 @@
  19. if(dec->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
  20. pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
  21. if(dec->coded_frame && dec->coded_frame->key_frame)
  22. - pkt.flags |= PKT_FLAG_KEY;
  23. + pkt.flags |= AV_PKT_FLAG_KEY;
  24. av_interleaved_write_frame(s, &pkt);
  25. enc->coded_frame = old_frame;
  26. @@ -245,7 +246,7 @@
  27. big_picture.quality = (int)ist->st->quality;
  28. }else
  29. big_picture.quality = (int)ost->st->quality;
  30. - big_picture.pict_type = 0;
  31. + big_picture.pict_type = (AVPictureType) 0;
  32. // big_picture.pts = AV_NOPTS_VALUE;
  33. big_picture.pts= ost->sync_opts;
  34. // big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->time_base.num, enc->time_base.den);
  35. @@ -268,7 +269,7 @@
  36. pkt.dts != AV_NOPTS_VALUE ? av_rescale(pkt.dts, enc->time_base.den, AV_TIME_BASE*(int64_t)enc->time_base.num) : -1);*/
  37. if(enc->coded_frame && enc->coded_frame->key_frame)
  38. - pkt.flags |= PKT_FLAG_KEY;
  39. + pkt.flags |= AV_PKT_FLAG_KEY;
  40. av_interleaved_write_frame(s, &pkt);
  41. *frame_size = ret;
  42. }
  43. @@ -316,13 +317,17 @@
  44. data_size = 0;
  45. if (ist->decoding_needed) {
  46. switch(ist->st->codec->codec_type) {
  47. - case CODEC_TYPE_VIDEO:
  48. + case AVMEDIA_TYPE_VIDEO:
  49. data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
  50. /* XXX: allocate picture correctly */
  51. avcodec_get_frame_defaults(&picture);
  52. + AVPacket pkt;
  53. + av_init_packet( &pkt );
  54. + pkt.data = ptr;
  55. + pkt.size = len;
  56. - ret = avcodec_decode_video(ist->st->codec,
  57. - &picture, &got_picture, ptr, len);
  58. + ret = avcodec_decode_video2(ist->st->codec,
  59. + &picture, &got_picture, &pkt);
  60. ist->st->quality= picture.quality;
  61. if (ret < 0)
  62. goto fail_decode;
  63. @@ -341,7 +346,7 @@
  64. goto fail_decode;
  65. }
  66. } else {
  67. - if(ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
  68. + if(ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
  69. if (ist->st->codec->time_base.num != 0) {
  70. ist->next_pts += ((int64_t)AV_TIME_BASE *
  71. ist->st->codec->time_base.num) /
  72. @@ -354,16 +359,6 @@
  73. len = 0;
  74. }
  75. - /* frame rate emulation */
  76. - if (ist->st->codec->rate_emu) {
  77. - int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den);
  78. - int64_t now = av_gettime() - ist->start;
  79. - if (pts > now)
  80. - usleep(pts - now);
  81. -
  82. - ist->frame++;
  83. - }
  84. -
  85. #if 0
  86. /* mpeg PTS deordering : if it is a P or I frame, the PTS
  87. is the one of the next displayed one */
  88. @@ -398,7 +393,7 @@
  89. if (ost->encoding_needed) {
  90. switch(ost->st->codec->codec_type) {
  91. - case CODEC_TYPE_VIDEO:
  92. + case AVMEDIA_TYPE_VIDEO:
  93. if(!do_video_out(os, ost, ist, &picture, &frame_size))
  94. return -1;
  95. break;
  96. @@ -415,9 +410,9 @@
  97. avcodec_get_frame_defaults(&avframe);
  98. ost->st->codec->coded_frame= &avframe;
  99. - avframe.key_frame = pkt->flags & PKT_FLAG_KEY;
  100. + avframe.key_frame = pkt->flags & AV_PKT_FLAG_KEY;
  101. - if (ost->st->codec->codec_type == CODEC_TYPE_VIDEO) {
  102. + if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
  103. ost->sync_opts++;
  104. }
  105. @@ -438,7 +433,7 @@
  106. opkt.flags= pkt->flags;
  107. //FIXME remove the following 2 lines they shall be replaced by the bitstream filters
  108. - if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY))
  109. + if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))
  110. opkt.destruct= av_destruct_packet;
  111. av_interleaved_write_frame(os, &opkt);
  112. @@ -459,7 +454,7 @@
  113. AVCodecContext *enc= ost->st->codec;
  114. os = output_files[ost->file_index];
  115. - if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
  116. + if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
  117. continue;
  118. if (ost->encoding_needed) {
  119. @@ -469,10 +464,10 @@
  120. pkt.stream_index= ost->index;
  121. switch(ost->st->codec->codec_type) {
  122. - case CODEC_TYPE_VIDEO:
  123. + case AVMEDIA_TYPE_VIDEO:
  124. ret = avcodec_encode_video(enc, bit_buffer, bit_buffer_size, NULL);
  125. if(enc->coded_frame && enc->coded_frame->key_frame)
  126. - pkt.flags |= PKT_FLAG_KEY;
  127. + pkt.flags |= AV_PKT_FLAG_KEY;
  128. break;
  129. default:
  130. ret=-1;
  131. @@ -547,11 +542,6 @@
  132. ist->index = k;
  133. ist->discard = 1; /* the stream is discarded by default
  134. (changed later) */
  135. -
  136. - if (ist->st->codec->rate_emu) {
  137. - ist->start = av_gettime();
  138. - ist->frame = 0;
  139. - }
  140. }
  141. }
  142. @@ -641,20 +631,20 @@
  143. else
  144. codec->time_base = ist->st->time_base;
  145. switch(codec->codec_type) {
  146. - case CODEC_TYPE_VIDEO:
  147. + case AVMEDIA_TYPE_VIDEO:
  148. codec->pix_fmt = icodec->pix_fmt;
  149. codec->width = icodec->width;
  150. codec->height = icodec->height;
  151. codec->has_b_frames = icodec->has_b_frames;
  152. break;
  153. - case CODEC_TYPE_SUBTITLE:
  154. + case AVMEDIA_TYPE_SUBTITLE:
  155. break;
  156. default:
  157. return false;
  158. }
  159. } else {
  160. switch(codec->codec_type) {
  161. - case CODEC_TYPE_VIDEO:
  162. + case AVMEDIA_TYPE_VIDEO:
  163. ost->video_resample = ((codec->width != icodec->width) ||
  164. (codec->height != icodec->height) ||
  165. (codec->pix_fmt != icodec->pix_fmt));
  166. @@ -686,7 +676,7 @@
  167. return false;
  168. }
  169. }
  170. - if(codec->codec_type == CODEC_TYPE_VIDEO){
  171. + if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
  172. int size= codec->width * codec->height;
  173. bit_buffer_size= FFMAX(bit_buffer_size, 4*size);
  174. }
  175. @@ -738,7 +728,7 @@
  176. ist->file_index, ist->index);
  177. return false;
  178. }
  179. - //if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO)
  180. + //if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
  181. // ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD;
  182. }
  183. }
  184. @@ -786,7 +776,7 @@
  185. ost = ost_table[i];
  186. os = output_files[ost->file_index];
  187. ist = ist_table[ost->source_index];
  188. - if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO)
  189. + if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
  190. opts = ost->sync_opts * av_q2d(ost->st->codec->time_base);
  191. else
  192. opts = ost->st->pts.val * av_q2d(ost->st->time_base);
  193. @@ -924,22 +914,22 @@
  194. void print_error(const char *filename, int err)
  195. {
  196. switch(err) {
  197. - case AVERROR_NUMEXPECTED:
  198. + case AVERROR(EINVAL):
  199. fprintf(stderr, "%s: Incorrect image filename syntax.\n",
  200. filename);
  201. break;
  202. case AVERROR_INVALIDDATA:
  203. fprintf(stderr, "%s: Error while parsing header\n", filename);
  204. break;
  205. - case AVERROR_NOFMT:
  206. + case AVERROR(EILSEQ):
  207. fprintf(stderr, "%s: Unknown format\n", filename);
  208. break;
  209. - case AVERROR_IO:
  210. + case AVERROR(EIO):
  211. fprintf(stderr, "%s: I/O error occured\n"
  212. "Usually that means that input file is truncated and/or corrupted.\n",
  213. filename);
  214. break;
  215. - case AVERROR_NOMEM:
  216. + case AVERROR(ENOMEM):
  217. fprintf(stderr, "%s: memory allocation error occured\n", filename);
  218. break;
  219. default:
  220. @@ -968,9 +958,9 @@
  221. ap->pix_fmt = frame_pix_fmt;
  222. ap->channel = 0;
  223. ap->standard = 0;
  224. - ap->video_codec_id = CODEC_ID_NONE;
  225. + ic->video_codec_id = CODEC_ID_NONE;
  226. if(pgmyuv_compatibility_hack)
  227. - ap->video_codec_id= CODEC_ID_PGMYUV;
  228. + ic->video_codec_id= CODEC_ID_PGMYUV;
  229. /* open the input file with generic libav function */
  230. err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
  231. @@ -999,7 +989,7 @@
  232. AVCodecContext *enc = ic->streams[i]->codec;
  233. enc->thread_count= 1;
  234. switch(enc->codec_type) {
  235. - case CODEC_TYPE_VIDEO:
  236. + case AVMEDIA_TYPE_VIDEO:
  237. frame_height = enc->height;
  238. frame_width = enc->width;
  239. frame_aspect_ratio = av_q2d(enc->sample_aspect_ratio) * enc->width / enc->height;
  240. @@ -1020,13 +1010,12 @@
  241. frame_rate = rfps;
  242. frame_rate_base = rfps_base;
  243. - enc->rate_emu = 0;
  244. break;
  245. - case CODEC_TYPE_DATA:
  246. + case AVMEDIA_TYPE_DATA:
  247. break;
  248. - case CODEC_TYPE_SUBTITLE:
  249. + case AVMEDIA_TYPE_SUBTITLE:
  250. break;
  251. - case CODEC_TYPE_UNKNOWN:
  252. + case AVMEDIA_TYPE_UNKNOWN:
  253. break;
  254. default:
  255. //av_abort();
  256. @@ -1058,12 +1047,12 @@
  257. for(i=0;i<ic->nb_streams;i++) {
  258. AVCodecContext *enc = ic->streams[i]->codec;
  259. switch(enc->codec_type) {
  260. - case CODEC_TYPE_VIDEO:
  261. + case AVMEDIA_TYPE_VIDEO:
  262. has_video = 1;
  263. break;
  264. - case CODEC_TYPE_DATA:
  265. - case CODEC_TYPE_UNKNOWN:
  266. - case CODEC_TYPE_SUBTITLE:
  267. + case AVMEDIA_TYPE_DATA:
  268. + case AVMEDIA_TYPE_UNKNOWN:
  269. + case AVMEDIA_TYPE_SUBTITLE:
  270. break;
  271. default:
  272. //av_abort();
  273. @@ -1086,14 +1075,14 @@
  274. fprintf(stderr, "Could not alloc stream\n");
  275. return false;
  276. }
  277. - avcodec_get_context_defaults2(st->codec, CODEC_TYPE_VIDEO);
  278. + avcodec_get_context_defaults2(st->codec, AVMEDIA_TYPE_VIDEO);
  279. video_enc = st->codec;
  280. {
  281. AVCodec *codec;
  282. - codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO);
  283. + codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO);
  284. video_enc->codec_id = codec_id;
  285. codec = avcodec_find_encoder(codec_id);
  286. @@ -1203,7 +1192,7 @@
  287. oc = avformat_alloc_context();
  288. if (!file_oformat) {
  289. - file_oformat = guess_format(NULL, filename, NULL);
  290. + file_oformat = av_guess_format(NULL, filename, NULL);
  291. if (!file_oformat) {
  292. fprintf(stderr, "Unable for find a suitable output format for '%s'\n",
  293. filename);
  294. @@ -1239,7 +1228,7 @@
  295. /* check filename in case of an image number is expected */
  296. if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
  297. if (!av_filename_number_test(oc->filename)) {
  298. - print_error(oc->filename, AVERROR_NUMEXPECTED);
  299. + print_error(oc->filename, AVERROR(EINVAL));
  300. return false;
  301. }
  302. }