]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/apiexample.c
do not display par and dar if not available
[ffmpeg] / libavcodec / apiexample.c
index 484c778764fb92d94b8fdf472ed7a3e54917d8d5..793cfaa04072804d7d36072e19a6d10e08befbea 100644 (file)
@@ -32,6 +32,8 @@
 #include <string.h>
 #include <math.h>
 
+#define PI 3.14159265358979323846
+
 #ifdef HAVE_AV_CONFIG_H
 #undef HAVE_AV_CONFIG_H
 #endif
@@ -89,7 +91,7 @@ void audio_encode_example(const char *filename)
 
     /* encode a single tone sound */
     t = 0;
-    tincr = 2 * M_PI * 440.0 / c->sample_rate;
+    tincr = 2 * PI * 440.0 / c->sample_rate;
     for(i=0;i<200;i++) {
         for(j=0;j<frame_size;j++) {
             samples[2*j] = (int)(sin(t) * 10000);
@@ -122,9 +124,6 @@ void audio_decode_example(const char *outfilename, const char *filename)
 
     printf("Audio decoding\n");
 
-    /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
-    memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
     /* find the mpeg audio decoder */
     codec = avcodec_find_decoder(CODEC_ID_MP2);
     if (!codec) {
@@ -226,8 +225,6 @@ void video_encode_example(const char *filename)
         exit(1);
     }
 
-    /* the codec gives us the frame size, in samples */
-
     f = fopen(filename, "wb");
     if (!f) {
         fprintf(stderr, "could not open %s\n", filename);
@@ -339,11 +336,11 @@ void video_decode_example(const char *outfilename, const char *filename)
     picture= avcodec_alloc_frame();
 
     if(codec->capabilities&CODEC_CAP_TRUNCATED)
-        c->flags|= CODEC_FLAG_TRUNCATED; /* we dont send complete frames */
+        c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */
 
-    /* for some codecs, such as msmpeg4 and mpeg4, width and height
-       MUST be initialized there because these info are not available
-       in the bitstream */
+    /* For some codecs, such as msmpeg4 and mpeg4, width and height
+       MUST be initialized there because this information is not
+       available in the bitstream. */
 
     /* open it */
     if (avcodec_open(c, codec) < 0) {
@@ -436,8 +433,7 @@ int main(int argc, char **argv)
     /* must be called before using avcodec lib */
     avcodec_init();
 
-    /* register all the codecs (you can also register only the codec
-       you wish to have smaller code */
+    /* register all the codecs */
     avcodec_register_all();
 
     if (argc <= 1) {